package kotlinx.coroutines.internal;

import com.google.android.gms.measurement.internal.u1;
import java.util.Iterator;
import java.util.List;
import kotlinx.coroutines.i1;

/* JADX INFO: loaded from: classes.dex */
public abstract class n {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final i1 f29483a;

    static {
        String property;
        Object next;
        int i10 = u.f29489a;
        i1 i1VarB = null;
        try {
            property = System.getProperty("kotlinx.coroutines.fast.service.loader");
        } catch (SecurityException unused) {
            property = null;
        }
        if (property != null) {
            Boolean.parseBoolean(property);
        }
        Iterator itA = u1.A();
        nb.g.i(itA, "<this>");
        kotlin.sequences.e mVar = new kotlin.collections.m(itA, 2);
        if (!(mVar instanceof kotlin.sequences.a)) {
            mVar = new kotlin.sequences.a(mVar);
        }
        List listB1 = kotlin.sequences.j.b1(mVar);
        Iterator it = listB1.iterator();
        if (it.hasNext()) {
            next = it.next();
            if (it.hasNext()) {
                int iC = ((m) next).c();
                do {
                    Object next2 = it.next();
                    int iC2 = ((m) next2).c();
                    if (iC < iC2) {
                        next = next2;
                        iC = iC2;
                    }
                } while (it.hasNext());
            }
        } else {
            next = null;
        }
        m mVar2 = (m) next;
        if (mVar2 != null) {
            try {
                i1VarB = mVar2.b(listB1);
            } catch (Throwable unused2) {
                mVar2.a();
            }
            if (i1VarB != null) {
                f29483a = i1VarB;
                return;
            }
        }
        throw new IllegalStateException("Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android' and ensure it has the same version as 'kotlinx-coroutines-core'");
    }
}
