package E2;

import android.graphics.Rect;
import androidx.window.sidecar.SidecarDeviceState;
import androidx.window.sidecar.SidecarDisplayFeature;
import androidx.window.sidecar.SidecarWindowLayoutInfo;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import kotlin.jvm.internal.o;
import x4.y;

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final /* synthetic */ int f1119b = 0;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final z2.i f1120a = z2.i.f26314b;

    public static boolean a(SidecarDisplayFeature sidecarDisplayFeature, SidecarDisplayFeature sidecarDisplayFeature2) {
        if (o.c(sidecarDisplayFeature, sidecarDisplayFeature2)) {
            return true;
        }
        if (sidecarDisplayFeature == null || sidecarDisplayFeature2 == null || sidecarDisplayFeature.getType() != sidecarDisplayFeature2.getType()) {
            return false;
        }
        return o.c(sidecarDisplayFeature.getRect(), sidecarDisplayFeature2.getRect());
    }

    public static boolean b(List list, List list2) {
        if (list == list2) {
            return true;
        }
        if (list.size() == list2.size()) {
            int size = list.size();
            for (int i6 = 0; i6 < size; i6++) {
                if (a((SidecarDisplayFeature) list.get(i6), (SidecarDisplayFeature) list2.get(i6))) {
                }
            }
            return true;
        }
        return false;
    }

    public static final boolean e(SidecarDisplayFeature require) {
        o.h(require, "$this$require");
        return require.getType() == 1 || require.getType() == 2;
    }

    public static final boolean f(SidecarDisplayFeature require) {
        o.h(require, "$this$require");
        return (require.getRect().width() == 0 && require.getRect().height() == 0) ? false : true;
    }

    public static final boolean g(SidecarDisplayFeature require) {
        o.h(require, "$this$require");
        return require.getType() != 1 || require.getRect().width() == 0 || require.getRect().height() == 0;
    }

    public static final boolean h(SidecarDisplayFeature require) {
        o.h(require, "$this$require");
        return require.getRect().left == 0 || require.getRect().top == 0;
    }

    public final B2.l c(SidecarWindowLayoutInfo sidecarWindowLayoutInfo, SidecarDeviceState sidecarDeviceState) {
        if (sidecarWindowLayoutInfo == null) {
            return new B2.l(y.f26065a);
        }
        SidecarDeviceState sidecarDeviceState2 = new SidecarDeviceState();
        e.d(sidecarDeviceState2, e.b(sidecarDeviceState));
        return new B2.l(d(e.c(sidecarWindowLayoutInfo), sidecarDeviceState2));
    }

    public final ArrayList d(List list, SidecarDeviceState sidecarDeviceState) {
        ArrayList arrayList = new ArrayList();
        Iterator it = list.iterator();
        while (it.hasNext()) {
            B2.c cVarI = i((SidecarDisplayFeature) it.next(), sidecarDeviceState);
            if (cVarI != null) {
                arrayList.add(cVarI);
            }
        }
        return arrayList;
    }

    public final B2.c i(SidecarDisplayFeature feature, SidecarDeviceState sidecarDeviceState) {
        B2.b bVar;
        B2.b bVar2;
        o.h(feature, "feature");
        z2.a aVar = z2.a.f26294a;
        z2.i verificationMode = this.f1120a;
        o.h(verificationMode, "verificationMode");
        SidecarDisplayFeature sidecarDisplayFeature = (SidecarDisplayFeature) new z2.h(feature, verificationMode, aVar).n("Type must be either TYPE_FOLD or TYPE_HINGE", new a()).n("Feature bounds must not be 0", new b()).n("TYPE_FOLD must have 0 area", new c()).n("Feature be pinned to either left or top", new d()).d();
        if (sidecarDisplayFeature == null) {
            return null;
        }
        int type = sidecarDisplayFeature.getType();
        if (type == 1) {
            bVar = B2.b.f458j;
        } else {
            if (type != 2) {
                return null;
            }
            bVar = B2.b.f459k;
        }
        int iB = e.b(sidecarDeviceState);
        if (iB == 0 || iB == 1) {
            return null;
        }
        if (iB != 2) {
            bVar2 = B2.b.f456h;
            if (iB != 3 && iB == 4) {
                return null;
            }
        } else {
            bVar2 = B2.b.f457i;
        }
        Rect rect = feature.getRect();
        o.g(rect, "getRect(...)");
        return new B2.c(new z2.b(rect), bVar, bVar2);
    }
}
