package androidx.window.layout;

import android.content.Context;
import androidx.window.extensions.layout.WindowLayoutComponent;
import e.y;
import java.math.BigInteger;
import java.util.concurrent.locks.ReentrantLock;

/* JADX INFO: loaded from: classes.dex */
public final class j {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final /* synthetic */ j f4481a = new j();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final kd.c f4482b;

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

    static {
        kotlin.jvm.internal.g.a(k.class).c();
        f4482b = kotlin.a.c(new sd.a() { // from class: androidx.window.layout.WindowInfoTracker$Companion$extensionBackend$2
            @Override // sd.a
            public final Object invoke() {
                i iVar;
                WindowLayoutComponent windowLayoutComponentA;
                try {
                    ClassLoader classLoader = k.class.getClassLoader();
                    if (classLoader != null) {
                        y yVar = new y();
                        yVar.f25365a = classLoader;
                        iVar = new i(classLoader, yVar);
                    } else {
                        iVar = null;
                    }
                    if (iVar == null || (windowLayoutComponentA = iVar.a()) == null) {
                        return null;
                    }
                    nb.g.h(classLoader, "loader");
                    y yVar2 = new y();
                    yVar2.f25365a = classLoader;
                    int iA = androidx.window.core.e.a();
                    return iA >= 2 ? new d4.b(windowLayoutComponentA) : iA == 1 ? new androidx.window.layout.adapter.extensions.a(windowLayoutComponentA, yVar2) : new d4.a();
                } catch (Throwable unused) {
                    j jVar = j.f4481a;
                    return null;
                }
            }
        });
        f4483c = b.f4462a;
    }

    public static m a(Context context) {
        nb.g.i(context, "context");
        c4.a aVar = (c4.a) f4482b.getValue();
        if (aVar == null) {
            e4.j jVar = e4.j.f25466c;
            if (e4.j.f25466c == null) {
                ReentrantLock reentrantLock = e4.j.f25467d;
                reentrantLock.lock();
                try {
                    if (e4.j.f25466c == null) {
                        e4.g gVar = null;
                        try {
                            androidx.window.core.k kVarC = e4.e.c();
                            if (kVarC != null) {
                                androidx.window.core.k kVar = androidx.window.core.k.f4435f;
                                nb.g.i(kVar, "other");
                                Object value = kVarC.f4440e.getValue();
                                nb.g.h(value, "<get-bigInteger>(...)");
                                Object value2 = kVar.f4440e.getValue();
                                nb.g.h(value2, "<get-bigInteger>(...)");
                                if (((BigInteger) value).compareTo((BigInteger) value2) >= 0) {
                                    e4.g gVar2 = new e4.g(context);
                                    if (gVar2.i()) {
                                        gVar = gVar2;
                                    }
                                }
                            }
                        } catch (Throwable unused) {
                        }
                        e4.j.f25466c = new e4.j(gVar);
                    }
                } finally {
                    reentrantLock.unlock();
                }
            }
            aVar = e4.j.f25466c;
            nb.g.f(aVar);
        }
        r rVar = r.f4493b;
        m mVar = new m(aVar);
        f4483c.getClass();
        return mVar;
    }
}
