/*
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, Type, typeCast, markType, getEnumerator, runOn, getBoxIfEnum } from "igniteui-angular-core";
import { WorkItem } from "./WorkItem";
import { Async_ForHelper } from "./Async_ForHelper";
import { Async_ForSliceHelper } from "./Async_ForSliceHelper";
import { WorkItemExtensions } from "./WorkItemExtensions";
import { WorkItem_WorkItemCatch$1 } from "./WorkItem_WorkItemCatch$1";
import { WorkItem_WorkItemSync } from "./WorkItem_WorkItemSync";
import { Async_WhileHelper } from "./Async_WhileHelper";
import { Async_WhileSliceHelper } from "./Async_WhileSliceHelper";
/**
 * @hidden
 */
export class Async extends Base {
    static c(a, b, c, d) {
        return new Async_ForHelper(a, b, c, d).a();
    }
    static f(a, b, c, d) {
        return new Async_ForSliceHelper(a, b, c, d).a();
    }
    static d($t, a, b) {
        return new Async_ForEachHelper$1($t, getEnumerator(a), b).a();
    }
    static e($t, a, b) {
        return new Async_ForEachSliceHelper$1($t, getEnumerator(a), b).a();
    }
    static g(a, b, c = null) {
        if (a) {
            return b();
        }
        if (c != null) {
            return c();
        }
        return null;
    }
    static h(a, b) {
        try {
            return Async.b(a(), b);
        }
        catch (c) {
            b();
            throw c;
        }
    }
    static i($tResult, a, b) {
        try {
            let c = Type.getDefaultValue($tResult);
            return WorkItemExtensions.g($tResult, Async.b(WorkItemExtensions.e($tResult, a(), (d) => c = WorkItemExtensions.m($tResult, d)), b), () => c);
        }
        catch (d) {
            b();
            throw d;
        }
    }
    static j($tException, a, b, c = null) {
        try {
            return Async.b(Async.a($tException, a(), b), c);
        }
        catch (d) {
            try {
                let e = typeCast($tException, d);
                if (e != null) {
                    b(e);
                    return null;
                }
                throw d;
            }
            finally {
                if (c != null) {
                    let f = c;
                    c = null;
                    f();
                }
            }
        }
    }
    static k($tException, $tResult, a, b, c = null) {
        try {
            let d = Type.getDefaultValue($tResult);
            return WorkItemExtensions.g($tResult, Async.b(Async.a($tException, WorkItemExtensions.e($tResult, a(), (e) => d = WorkItemExtensions.m($tResult, e)), b), c), () => d);
        }
        catch (e) {
            try {
                let f = typeCast($tException, e);
                if (f != null) {
                    b(f);
                    return null;
                }
                throw e;
            }
            finally {
                if (c != null) {
                    let g = c;
                    c = null;
                    g();
                }
            }
        }
    }
    static l($tException1, $tException2, a, b, c, d = null) {
        try {
            return Async.b(Async.a($tException2, Async.a($tException1, a(), b), c, true), d);
        }
        catch (e) {
            try {
                let f = typeCast($tException1, e);
                if (f != null) {
                    b(f);
                    return null;
                }
                let g = typeCast($tException2, e);
                if (g != null) {
                    c(g);
                    return null;
                }
                throw e;
            }
            finally {
                if (d != null) {
                    let h = d;
                    d = null;
                    h();
                }
            }
        }
    }
    static m($tException1, $tException2, $tException3, a, b, c, d, e = null) {
        try {
            return Async.b(Async.a($tException3, Async.a($tException2, Async.a($tException1, a(), b), c, true), d, true), e);
        }
        catch (f) {
            try {
                let g = typeCast($tException1, f);
                if (g != null) {
                    b(g);
                    return null;
                }
                let h = typeCast($tException2, f);
                if (h != null) {
                    c(h);
                    return null;
                }
                let i = typeCast($tException3, f);
                if (i != null) {
                    d(i);
                    return null;
                }
                throw f;
            }
            finally {
                if (e != null) {
                    let j = e;
                    e = null;
                    j();
                }
            }
        }
    }
    static a($tException, a, b, c = false) {
        return new WorkItem_WorkItemCatch$1($tException, b, a, c);
    }
    static b(a, b) {
        if (b == null) {
            return a;
        }
        return new WorkItem_WorkItemSync(b, 1, a, false);
    }
    static o($t, a, b) {
        return WorkItemExtensions.f($t, a, (c) => new Async_UsingHelper$1($t, WorkItemExtensions.m($t, c), b).b());
    }
    static n($t, a, b) {
        return new Async_UsingHelper$1($t, a, b).b();
    }
    static p($t, $tResult, a, b) {
        return new Async_UsingHelper$2($t, $tResult, a, b).b();
    }
    static q($t, $tResult, a, b) {
        return WorkItemExtensions.l($t, $tResult, a, (c) => new Async_UsingHelper$2($t, $tResult, WorkItemExtensions.m($t, c), b).b());
    }
    static r(a, b) {
        return new Async_WhileHelper(a, b).a();
    }
    static s(a, b) {
        return new Async_WhileSliceHelper(a, b).a();
    }
}
Async.$t = markType(Async, 'Async');
/**
 * @hidden
 */
export class Async_ForEachHelper$1 extends Base {
    constructor($t, a, b) {
        super();
        this.$t = null;
        this.c = null;
        this.d = null;
        this.e = null;
        this.$t = $t;
        this.$type = this.$type.specialize(this.$t);
        this.c = a;
        this.e = b;
        this.d = runOn(this, this.b);
    }
    a() {
        return Async.h(this.d, () => {
            if (this.c != null) {
                this.c.dispose();
            }
        });
    }
    b() {
        if (this.c.moveNext() == false) {
            return null;
        }
        return WorkItemExtensions.c(this.e(this.c.current), this.d);
    }
}
Async_ForEachHelper$1.$t = markType(Async_ForEachHelper$1, 'Async_ForEachHelper$1');
/**
 * @hidden
 */
export class Async_ForEachSliceHelper$1 extends Base {
    constructor($t, a, b) {
        super();
        this.$t = null;
        this.c = null;
        this.d = null;
        this.e = null;
        this.$t = $t;
        this.$type = this.$type.specialize(this.$t);
        this.c = a;
        this.e = b;
        this.d = runOn(this, this.b);
    }
    a() {
        return Async.h(this.d, () => {
            if (this.c != null) {
                this.c.dispose();
            }
        });
    }
    b() {
        while (this.c.moveNext()) {
            if (this.e(this.c.current) == false) {
                return WorkItem.d(this.d, 2);
            }
        }
        return null;
    }
}
Async_ForEachSliceHelper$1.$t = markType(Async_ForEachSliceHelper$1, 'Async_ForEachSliceHelper$1');
/**
 * @hidden
 */
export class Async_UsingHelper$1 extends Base {
    constructor($t, a, b) {
        super();
        this.$t = null;
        this.a = null;
        this.c = null;
        this.$t = $t;
        this.$type = this.$type.specialize(this.$t);
        this.a = a;
        this.c = b;
    }
    b() {
        return Async.h(() => this.c(this.a), () => {
            if (getBoxIfEnum(this.$t, this.a) != null) {
                this.a.dispose();
            }
        });
    }
}
Async_UsingHelper$1.$t = markType(Async_UsingHelper$1, 'Async_UsingHelper$1');
/**
 * @hidden
 */
export class Async_UsingHelper$2 extends Base {
    constructor($t, $tResult, a, b) {
        super();
        this.$t = null;
        this.$tResult = null;
        this.a = null;
        this.c = null;
        this.$t = $t;
        this.$tResult = $tResult;
        this.$type = this.$type.specialize(this.$t, this.$tResult);
        this.a = a;
        this.c = b;
    }
    b() {
        return Async.i(this.$tResult, () => this.c(this.a), () => {
            if (getBoxIfEnum(this.$t, this.a) != null) {
                this.a.dispose();
            }
        });
    }
}
Async_UsingHelper$2.$t = markType(Async_UsingHelper$2, 'Async_UsingHelper$2');
//# sourceMappingURL=Async_combined.js.map