package kotlinx.coroutines.internal;

import d2.h1;
import java.util.Iterator;
import java.util.List;

/* JADX INFO: compiled from: MainDispatchers.kt */
/* JADX INFO: loaded from: classes.dex */
public final class t {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private static final boolean f5235b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final h1 f5236c;

    static {
        t tVar = new t();
        f5234a = tVar;
        f5235b = c0.e("kotlinx.coroutines.fast.service.loader", true);
        f5236c = tVar.a();
    }

    private t() {
    }

    private final h1 a() {
        Object next;
        try {
            List<r> listC = f5235b ? i.f5204a.c() : b2.h.d(b2.f.a(s.a()));
            Iterator<T> it = listC.iterator();
            if (it.hasNext()) {
                next = it.next();
                if (it.hasNext()) {
                    int loadPriority = ((r) next).getLoadPriority();
                    do {
                        Object next2 = it.next();
                        int loadPriority2 = ((r) next2).getLoadPriority();
                        if (loadPriority < loadPriority2) {
                            next = next2;
                            loadPriority = loadPriority2;
                        }
                    } while (it.hasNext());
                }
            } else {
                next = null;
            }
            r rVar = (r) next;
            h1 h1VarE = rVar == null ? null : u.e(rVar, listC);
            return h1VarE == null ? u.b(null, null, 3, null) : h1VarE;
        } catch (Throwable th) {
            return u.b(th, null, 2, null);
        }
    }
}
