package androidx.room;

import android.content.Context;
import android.content.Intent;
import androidx.room.RoomDatabase;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import kotlin.collections.EmptyList;

/* JADX INFO: loaded from: classes.dex */
public final class f0 extends c {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final e f4083c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final n0 f4084d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final List f4085e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final androidx.room.coroutines.c f4086f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public l3.b f4087g;

    public f0(e eVar, n0 n0Var) {
        int i10;
        androidx.room.coroutines.f fVar;
        nb.g.i(eVar, "config");
        this.f4083c = eVar;
        this.f4084d = n0Var;
        List list = eVar.f4064e;
        this.f4085e = list == null ? EmptyList.f29203a : list;
        RoomDatabase.JournalMode journalMode = eVar.f4066g;
        String str = eVar.f4061b;
        k3.b bVar = eVar.f4079t;
        if (bVar == null) {
            l3.f fVar2 = eVar.f4062c;
            if (fVar2 == null) {
                throw new IllegalArgumentException("SQLiteManager was constructed with both null driver and open helper factory!".toString());
            }
            Context context = eVar.f4060a;
            nb.g.i(context, "context");
            l3.d dVar = new l3.d(context);
            dVar.f30104b = str;
            dVar.f30105c = new d0(this, n0Var.getVersion());
            this.f4086f = new androidx.room.driver.b(new androidx.room.driver.c(fVar2.b(dVar.a())));
        } else {
            if (str == null) {
                fVar = new androidx.room.coroutines.f(new b(this, bVar));
            } else {
                b bVar2 = new b(this, bVar);
                nb.g.i(journalMode, "<this>");
                int iOrdinal = journalMode.ordinal();
                if (iOrdinal == 1) {
                    i10 = 1;
                } else {
                    if (iOrdinal != 2) {
                        throw new IllegalStateException(("Can't get max number of reader for journal mode '" + journalMode + '\'').toString());
                    }
                    i10 = 4;
                }
                int iOrdinal2 = journalMode.ordinal();
                if (iOrdinal2 != 1 && iOrdinal2 != 2) {
                    throw new IllegalStateException(("Can't get max number of writers for journal mode '" + journalMode + '\'').toString());
                }
                fVar = new androidx.room.coroutines.f(bVar2, str, i10);
            }
            this.f4086f = fVar;
        }
        boolean z10 = journalMode == RoomDatabase.JournalMode.f3997c;
        l3.g gVarH = h();
        if (gVarH != null) {
            gVarH.setWriteAheadLoggingEnabled(z10);
        }
    }

    public final l3.g h() {
        androidx.room.driver.c cVar;
        androidx.room.coroutines.c cVar2 = this.f4086f;
        androidx.room.driver.b bVar = cVar2 instanceof androidx.room.driver.b ? (androidx.room.driver.b) cVar2 : null;
        if (bVar == null || (cVar = bVar.f4046a) == null) {
            return null;
        }
        return cVar.f4047a;
    }

    public f0(e eVar, h0 h0Var) {
        nb.g.i(eVar, "config");
        this.f4083c = eVar;
        this.f4084d = new c0(-1, "", "");
        List list = eVar.f4064e;
        this.f4085e = list == null ? EmptyList.f29203a : list;
        ArrayList arrayListM1 = kotlin.collections.n.m1(new e0(new b0(this, 0)), list == null ? EmptyList.f29203a : list);
        String str = eVar.f4061b;
        l3.f fVar = eVar.f4062c;
        boolean z10 = eVar.f4065f;
        Intent intent = eVar.f4069j;
        boolean z11 = eVar.f4070k;
        boolean z12 = eVar.f4071l;
        Set set = eVar.f4072m;
        String str2 = eVar.f4073n;
        File file = eVar.f4074o;
        Callable callable = eVar.f4075p;
        boolean z13 = eVar.f4078s;
        k3.b bVar = eVar.f4079t;
        kotlin.coroutines.h hVar = eVar.f4080u;
        Context context = eVar.f4060a;
        nb.g.i(context, "context");
        l0 l0Var = eVar.f4063d;
        nb.g.i(l0Var, "migrationContainer");
        RoomDatabase.JournalMode journalMode = eVar.f4066g;
        nb.g.i(journalMode, "journalMode");
        Executor executor = eVar.f4067h;
        nb.g.i(executor, "queryExecutor");
        Executor executor2 = eVar.f4068i;
        nb.g.i(executor2, "transactionExecutor");
        List list2 = eVar.f4076q;
        nb.g.i(list2, "typeConverters");
        List list3 = eVar.f4077r;
        nb.g.i(list3, "autoMigrationSpecs");
        this.f4086f = new androidx.room.driver.b(new androidx.room.driver.c((l3.g) h0Var.invoke(new e(context, str, fVar, l0Var, arrayListM1, z10, journalMode, executor, executor2, intent, z11, z12, set, str2, file, callable, list2, list3, z13, bVar, hVar))));
        boolean z14 = journalMode == RoomDatabase.JournalMode.f3997c;
        l3.g gVarH = h();
        if (gVarH != null) {
            gVarH.setWriteAheadLoggingEnabled(z14);
        }
    }
}
