package androidx.window.layout.adapter.sidecar;

import android.graphics.Rect;
import androidx.window.core.VerificationMode;
import androidx.window.core.b;
import androidx.window.core.i;
import androidx.window.layout.e;
import androidx.window.layout.h;
import androidx.window.layout.n;
import androidx.window.sidecar.SidecarDeviceState;
import androidx.window.sidecar.SidecarDisplayFeature;
import androidx.window.sidecar.SidecarWindowLayoutInfo;
import e4.c;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import nb.g;
import sd.l;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final VerificationMode f4461a = VerificationMode.f4411a;

    public static boolean a(SidecarDeviceState sidecarDeviceState, SidecarDeviceState sidecarDeviceState2) {
        if (g.c(sidecarDeviceState, sidecarDeviceState2)) {
            return true;
        }
        return (sidecarDeviceState == null || sidecarDeviceState2 == null || c.b(sidecarDeviceState) != c.b(sidecarDeviceState2)) ? false : true;
    }

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

    public static boolean c(List list, List list2) {
        if (list == list2) {
            return true;
        }
        if (list == null || list2 == null || list.size() != list2.size()) {
            return false;
        }
        int size = list.size();
        for (int i10 = 0; i10 < size; i10++) {
            if (!b((SidecarDisplayFeature) list.get(i10), (SidecarDisplayFeature) list2.get(i10))) {
                return false;
            }
        }
        return true;
    }

    public static boolean d(SidecarWindowLayoutInfo sidecarWindowLayoutInfo, SidecarWindowLayoutInfo sidecarWindowLayoutInfo2) {
        if (g.c(sidecarWindowLayoutInfo, sidecarWindowLayoutInfo2)) {
            return true;
        }
        if (sidecarWindowLayoutInfo == null || sidecarWindowLayoutInfo2 == null) {
            return false;
        }
        return c(c.c(sidecarWindowLayoutInfo), c.c(sidecarWindowLayoutInfo2));
    }

    public final n e(SidecarWindowLayoutInfo sidecarWindowLayoutInfo, SidecarDeviceState sidecarDeviceState) {
        g.i(sidecarDeviceState, "state");
        if (sidecarWindowLayoutInfo == null) {
            return new n(hb.a.W());
        }
        SidecarDeviceState sidecarDeviceState2 = new SidecarDeviceState();
        c.d(sidecarDeviceState2, c.b(sidecarDeviceState));
        return new n(f(c.c(sidecarWindowLayoutInfo), sidecarDeviceState2));
    }

    public final ArrayList f(List list, SidecarDeviceState sidecarDeviceState) {
        g.i(list, "sidecarDisplayFeatures");
        ArrayList arrayList = new ArrayList();
        Iterator it = list.iterator();
        while (it.hasNext()) {
            h hVarG = g((SidecarDisplayFeature) it.next(), sidecarDeviceState);
            if (hVarG != null) {
                arrayList.add(hVarG);
            }
        }
        return arrayList;
    }

    /* JADX WARN: Code restructure failed: missing block: B:18:0x0057, code lost:
    
        if (r6 == 4) goto L23;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final h g(SidecarDisplayFeature sidecarDisplayFeature, SidecarDeviceState sidecarDeviceState) {
        androidx.window.layout.g gVar;
        e eVar;
        g.i(sidecarDisplayFeature, "feature");
        int i10 = i.f4430a;
        SidecarDisplayFeature sidecarDisplayFeature2 = (SidecarDisplayFeature) androidx.window.core.h.q(sidecarDisplayFeature, this.f4461a).c("Type must be either TYPE_FOLD or TYPE_HINGE", new l() { // from class: androidx.window.layout.adapter.sidecar.SidecarAdapter$translate$checkedFeature$1
            @Override // sd.l
            /* JADX INFO: renamed from: c, reason: merged with bridge method [inline-methods] */
            public final Boolean invoke(SidecarDisplayFeature sidecarDisplayFeature3) {
                g.i(sidecarDisplayFeature3, "$this$require");
                boolean z10 = true;
                if (sidecarDisplayFeature3.getType() != 1 && sidecarDisplayFeature3.getType() != 2) {
                    z10 = false;
                }
                return Boolean.valueOf(z10);
            }
        }).c("Feature bounds must not be 0", new l() { // from class: androidx.window.layout.adapter.sidecar.SidecarAdapter$translate$checkedFeature$2
            @Override // sd.l
            /* JADX INFO: renamed from: c, reason: merged with bridge method [inline-methods] */
            public final Boolean invoke(SidecarDisplayFeature sidecarDisplayFeature3) {
                g.i(sidecarDisplayFeature3, "$this$require");
                return Boolean.valueOf((sidecarDisplayFeature3.getRect().width() == 0 && sidecarDisplayFeature3.getRect().height() == 0) ? false : true);
            }
        }).c("TYPE_FOLD must have 0 area", new l() { // from class: androidx.window.layout.adapter.sidecar.SidecarAdapter$translate$checkedFeature$3
            @Override // sd.l
            /* JADX INFO: renamed from: c, reason: merged with bridge method [inline-methods] */
            public final Boolean invoke(SidecarDisplayFeature sidecarDisplayFeature3) {
                g.i(sidecarDisplayFeature3, "$this$require");
                boolean z10 = true;
                if (sidecarDisplayFeature3.getType() == 1 && sidecarDisplayFeature3.getRect().width() != 0 && sidecarDisplayFeature3.getRect().height() != 0) {
                    z10 = false;
                }
                return Boolean.valueOf(z10);
            }
        }).c("Feature be pinned to either left or top", new l() { // from class: androidx.window.layout.adapter.sidecar.SidecarAdapter$translate$checkedFeature$4
            @Override // sd.l
            /* JADX INFO: renamed from: c, reason: merged with bridge method [inline-methods] */
            public final Boolean invoke(SidecarDisplayFeature sidecarDisplayFeature3) {
                g.i(sidecarDisplayFeature3, "$this$require");
                return Boolean.valueOf(sidecarDisplayFeature3.getRect().left == 0 || sidecarDisplayFeature3.getRect().top == 0);
            }
        }).a();
        if (sidecarDisplayFeature2 == null) {
            return null;
        }
        int type = sidecarDisplayFeature2.getType();
        if (type == 1) {
            gVar = androidx.window.layout.g.f4472b;
        } else {
            if (type != 2) {
                return null;
            }
            gVar = androidx.window.layout.g.f4473c;
        }
        int iB = c.b(sidecarDeviceState);
        if (iB != 0 && iB != 1) {
            if (iB != 2) {
                eVar = e.f4469b;
                if (iB != 3) {
                }
            } else {
                eVar = e.f4470c;
            }
            Rect rect = sidecarDisplayFeature.getRect();
            g.h(rect, "feature.rect");
            return new h(new b(rect), gVar, eVar);
        }
        return null;
    }
}
