package F1;

import a.AbstractC0872a;
import android.graphics.Rect;
import android.os.Build;
import android.util.Log;
import android.view.View;
import android.view.WindowInsets;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public class b0 extends h0 {

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public static boolean f1422i = false;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public static Method f1423j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public static Class f1424k;
    public static Field l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public static Field f1425m;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final WindowInsets f1426c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public z1.b[] f1427d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public z1.b f1428e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public m0 f1429f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public z1.b f1430g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f1431h;

    public b0(m0 m0Var, WindowInsets windowInsets) {
        super(m0Var);
        this.f1428e = null;
        this.f1426c = windowInsets;
    }

    private static void B() {
        try {
            f1423j = View.class.getDeclaredMethod("getViewRootImpl", new Class[0]);
            Class<?> cls = Class.forName("android.view.View$AttachInfo");
            f1424k = cls;
            l = cls.getDeclaredField("mVisibleInsets");
            f1425m = Class.forName("android.view.ViewRootImpl").getDeclaredField("mAttachInfo");
            l.setAccessible(true);
            f1425m.setAccessible(true);
        } catch (ReflectiveOperationException e6) {
            Log.e("WindowInsetsCompat", "Failed to get visible insets. (Reflection error). " + e6.getMessage(), e6);
        }
        f1422i = true;
    }

    public static boolean C(int i6, int i7) {
        return (i6 & 6) == (i7 & 6);
    }

    private z1.b w(int i6, boolean z6) {
        z1.b bVarA = z1.b.f26268e;
        for (int i7 = 1; i7 <= 512; i7 <<= 1) {
            if ((i6 & i7) != 0) {
                bVarA = z1.b.a(bVarA, x(i7, z6));
            }
        }
        return bVarA;
    }

    private z1.b y() {
        m0 m0Var = this.f1429f;
        return m0Var != null ? m0Var.f1458a.j() : z1.b.f26268e;
    }

    private z1.b z(View view) {
        if (Build.VERSION.SDK_INT >= 30) {
            throw new UnsupportedOperationException("getVisibleInsets() should not be called on API >= 30. Use WindowInsets.isVisible() instead.");
        }
        if (!f1422i) {
            B();
        }
        Method method = f1423j;
        if (method != null && f1424k != null && l != null) {
            try {
                Object objInvoke = method.invoke(view, new Object[0]);
                if (objInvoke == null) {
                    Log.w("WindowInsetsCompat", "Failed to get visible insets. getViewRootImpl() returned null from the provided view. This means that the view is either not attached or the method has been overridden", new NullPointerException());
                    return null;
                }
                Rect rect = (Rect) l.get(f1425m.get(objInvoke));
                if (rect != null) {
                    return z1.b.b(rect.left, rect.top, rect.right, rect.bottom);
                }
            } catch (ReflectiveOperationException e6) {
                Log.e("WindowInsetsCompat", "Failed to get visible insets. (Reflection error). " + e6.getMessage(), e6);
            }
        }
        return null;
    }

    public boolean A(int i6) {
        if (i6 != 1 && i6 != 2) {
            if (i6 == 4) {
                return false;
            }
            if (i6 != 8 && i6 != 128) {
                return true;
            }
        }
        return !x(i6, false).equals(z1.b.f26268e);
    }

    @Override // F1.h0
    public void d(View view) {
        z1.b bVarZ = z(view);
        if (bVarZ == null) {
            bVarZ = z1.b.f26268e;
        }
        s(bVarZ);
    }

    @Override // F1.h0
    public void e(m0 m0Var) {
        m0Var.f1458a.t(this.f1429f);
        z1.b bVar = this.f1430g;
        h0 h0Var = m0Var.f1458a;
        h0Var.s(bVar);
        h0Var.v(this.f1431h);
    }

    @Override // F1.h0
    public boolean equals(Object obj) {
        if (!super.equals(obj)) {
            return false;
        }
        b0 b0Var = (b0) obj;
        return Objects.equals(this.f1430g, b0Var.f1430g) && C(this.f1431h, b0Var.f1431h);
    }

    @Override // F1.h0
    public z1.b g(int i6) {
        return w(i6, false);
    }

    @Override // F1.h0
    public z1.b h(int i6) {
        return w(i6, true);
    }

    @Override // F1.h0
    public final z1.b l() {
        if (this.f1428e == null) {
            WindowInsets windowInsets = this.f1426c;
            this.f1428e = z1.b.b(windowInsets.getSystemWindowInsetLeft(), windowInsets.getSystemWindowInsetTop(), windowInsets.getSystemWindowInsetRight(), windowInsets.getSystemWindowInsetBottom());
        }
        return this.f1428e;
    }

    @Override // F1.h0
    public m0 n(int i6, int i7, int i8, int i9) {
        m0 m0VarC = m0.c(null, this.f1426c);
        int i10 = Build.VERSION.SDK_INT;
        a0 z6 = i10 >= 34 ? new Z(m0VarC) : i10 >= 30 ? new Y(m0VarC) : i10 >= 29 ? new X(m0VarC) : new W(m0VarC);
        z6.g(m0.a(l(), i6, i7, i8, i9));
        z6.e(m0.a(j(), i6, i7, i8, i9));
        return z6.b();
    }

    @Override // F1.h0
    public boolean p() {
        return this.f1426c.isRound();
    }

    @Override // F1.h0
    public boolean q(int i6) {
        for (int i7 = 1; i7 <= 512; i7 <<= 1) {
            if ((i6 & i7) != 0 && !A(i7)) {
                return false;
            }
        }
        return true;
    }

    @Override // F1.h0
    public void r(z1.b[] bVarArr) {
        this.f1427d = bVarArr;
    }

    @Override // F1.h0
    public void s(z1.b bVar) {
        this.f1430g = bVar;
    }

    @Override // F1.h0
    public void t(m0 m0Var) {
        this.f1429f = m0Var;
    }

    @Override // F1.h0
    public void v(int i6) {
        this.f1431h = i6;
    }

    public z1.b x(int i6, boolean z6) {
        z1.b bVarJ;
        int i7;
        z1.b bVar = z1.b.f26268e;
        if (i6 != 1) {
            if (i6 != 2) {
                if (i6 == 8) {
                    z1.b[] bVarArr = this.f1427d;
                    bVarJ = bVarArr != null ? bVarArr[AbstractC0872a.T(8)] : null;
                    if (bVarJ != null) {
                        return bVarJ;
                    }
                    z1.b bVarL = l();
                    z1.b bVarY = y();
                    int i8 = bVarL.f26272d;
                    if (i8 > bVarY.f26272d) {
                        return z1.b.b(0, 0, 0, i8);
                    }
                    z1.b bVar2 = this.f1430g;
                    if (bVar2 != null && !bVar2.equals(bVar) && (i7 = this.f1430g.f26272d) > bVarY.f26272d) {
                        return z1.b.b(0, 0, 0, i7);
                    }
                } else {
                    if (i6 == 16) {
                        return k();
                    }
                    if (i6 == 32) {
                        return i();
                    }
                    if (i6 == 64) {
                        return m();
                    }
                    if (i6 == 128) {
                        m0 m0Var = this.f1429f;
                        C0176e c0176eF = m0Var != null ? m0Var.f1458a.f() : f();
                        if (c0176eF != null) {
                            int i9 = Build.VERSION.SDK_INT;
                            return z1.b.b(i9 >= 28 ? A1.b.i(c0176eF.f1433a) : 0, i9 >= 28 ? A1.b.k(c0176eF.f1433a) : 0, i9 >= 28 ? A1.b.j(c0176eF.f1433a) : 0, i9 >= 28 ? A1.b.h(c0176eF.f1433a) : 0);
                        }
                    }
                }
            } else {
                if (z6) {
                    z1.b bVarY2 = y();
                    z1.b bVarJ2 = j();
                    return z1.b.b(Math.max(bVarY2.f26269a, bVarJ2.f26269a), 0, Math.max(bVarY2.f26271c, bVarJ2.f26271c), Math.max(bVarY2.f26272d, bVarJ2.f26272d));
                }
                if ((this.f1431h & 2) == 0) {
                    z1.b bVarL2 = l();
                    m0 m0Var2 = this.f1429f;
                    bVarJ = m0Var2 != null ? m0Var2.f1458a.j() : null;
                    int iMin = bVarL2.f26272d;
                    if (bVarJ != null) {
                        iMin = Math.min(iMin, bVarJ.f26272d);
                    }
                    return z1.b.b(bVarL2.f26269a, 0, bVarL2.f26271c, iMin);
                }
            }
        } else {
            if (z6) {
                return z1.b.b(0, Math.max(y().f26270b, l().f26270b), 0, 0);
            }
            if ((this.f1431h & 4) == 0) {
                return z1.b.b(0, l().f26270b, 0, 0);
            }
        }
        return bVar;
    }

    public b0(m0 m0Var, b0 b0Var) {
        this(m0Var, new WindowInsets(b0Var.f1426c));
    }
}
