package o;

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

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public class Al0 extends Hl0 {
    public static boolean i = false;
    public static Method j;
    public static Class k;
    public static Field l;
    public static Field m;
    public final WindowInsets c;
    public LH[] d;
    public LH e;
    public Kl0 f;
    public LH g;
    public int h;

    public Al0(Kl0 kl0, WindowInsets windowInsets) {
        super(kl0);
        this.e = null;
        this.c = windowInsets;
    }

    private static void B() throws ClassNotFoundException, SecurityException {
        try {
            j = View.class.getDeclaredMethod("getViewRootImpl", null);
            Class<?> cls = Class.forName("android.view.View$AttachInfo");
            k = cls;
            l = cls.getDeclaredField("mVisibleInsets");
            m = Class.forName("android.view.ViewRootImpl").getDeclaredField("mAttachInfo");
            l.setAccessible(true);
            m.setAccessible(true);
        } catch (ReflectiveOperationException e) {
            e.getMessage();
        }
        i = true;
    }

    public static boolean C(int i2, int i3) {
        return (i2 & 6) == (i3 & 6);
    }

    private LH w(int i2, boolean z) {
        LH lhA = LH.e;
        for (int i3 = 1; i3 <= 512; i3 <<= 1) {
            if ((i2 & i3) != 0) {
                lhA = LH.a(lhA, x(i3, z));
            }
        }
        return lhA;
    }

    private LH y() {
        Kl0 kl0 = this.f;
        return kl0 != null ? kl0.a.j() : LH.e;
    }

    private LH z(View view) throws IllegalAccessException, ClassNotFoundException, SecurityException, IllegalArgumentException, InvocationTargetException {
        if (Build.VERSION.SDK_INT >= 30) {
            throw new UnsupportedOperationException("getVisibleInsets() should not be called on API >= 30. Use WindowInsets.isVisible() instead.");
        }
        if (!i) {
            B();
        }
        Method method = j;
        if (method != null && k != null && l != null) {
            try {
                Object objInvoke = method.invoke(view, null);
                if (objInvoke != null) {
                    Rect rect = (Rect) l.get(m.get(objInvoke));
                    if (rect != null) {
                        return LH.b(rect.left, rect.top, rect.right, rect.bottom);
                    }
                }
            } catch (ReflectiveOperationException e) {
                e.getMessage();
            }
        }
        return null;
    }

    public boolean A(int i2) {
        if (i2 != 1 && i2 != 2) {
            if (i2 == 4) {
                return false;
            }
            if (i2 != 8 && i2 != 128) {
                return true;
            }
        }
        return !x(i2, false).equals(LH.e);
    }

    @Override // o.Hl0
    public void d(View view) throws IllegalAccessException, ClassNotFoundException, SecurityException, IllegalArgumentException, InvocationTargetException {
        LH lhZ = z(view);
        if (lhZ == null) {
            lhZ = LH.e;
        }
        s(lhZ);
    }

    @Override // o.Hl0
    public void e(Kl0 kl0) {
        kl0.a.t(this.f);
        LH lh = this.g;
        Hl0 hl0 = kl0.a;
        hl0.s(lh);
        hl0.v(this.h);
    }

    @Override // o.Hl0
    public boolean equals(Object obj) {
        if (!super.equals(obj)) {
            return false;
        }
        Al0 al0 = (Al0) obj;
        return Objects.equals(this.g, al0.g) && C(this.h, al0.h);
    }

    @Override // o.Hl0
    public LH g(int i2) {
        return w(i2, false);
    }

    @Override // o.Hl0
    public LH h(int i2) {
        return w(i2, true);
    }

    @Override // o.Hl0
    public final LH l() {
        if (this.e == null) {
            WindowInsets windowInsets = this.c;
            this.e = LH.b(windowInsets.getSystemWindowInsetLeft(), windowInsets.getSystemWindowInsetTop(), windowInsets.getSystemWindowInsetRight(), windowInsets.getSystemWindowInsetBottom());
        }
        return this.e;
    }

    @Override // o.Hl0
    public Kl0 n(int i2, int i3, int i4, int i5) {
        Kl0 kl0G = Kl0.g(null, this.c);
        int i6 = Build.VERSION.SDK_INT;
        AbstractC3124zl0 c3029yl0 = i6 >= 34 ? new C3029yl0(kl0G) : i6 >= 31 ? new C2934xl0(kl0G) : i6 >= 30 ? new C2839wl0(kl0G) : i6 >= 29 ? new C2744vl0(kl0G) : new C2649ul0(kl0G);
        c3029yl0.g(Kl0.e(l(), i2, i3, i4, i5));
        c3029yl0.e(Kl0.e(j(), i2, i3, i4, i5));
        return c3029yl0.b();
    }

    @Override // o.Hl0
    public boolean p() {
        return this.c.isRound();
    }

    @Override // o.Hl0
    public boolean q(int i2) {
        for (int i3 = 1; i3 <= 512; i3 <<= 1) {
            if ((i2 & i3) != 0 && !A(i3)) {
                return false;
            }
        }
        return true;
    }

    @Override // o.Hl0
    public void r(LH[] lhArr) {
        this.d = lhArr;
    }

    @Override // o.Hl0
    public void s(LH lh) {
        this.g = lh;
    }

    @Override // o.Hl0
    public void t(Kl0 kl0) {
        this.f = kl0;
    }

    @Override // o.Hl0
    public void v(int i2) {
        this.h = i2;
    }

    public LH x(int i2, boolean z) {
        LH lhJ;
        int i3;
        LH lh = LH.e;
        if (i2 != 1) {
            if (i2 != 2) {
                if (i2 == 8) {
                    LH[] lhArr = this.d;
                    lhJ = lhArr != null ? lhArr[AbstractC2539te.F(8)] : null;
                    if (lhJ != null) {
                        return lhJ;
                    }
                    LH lhL = l();
                    LH lhY = y();
                    int i4 = lhL.d;
                    if (i4 > lhY.d) {
                        return LH.b(0, 0, 0, i4);
                    }
                    LH lh2 = this.g;
                    if (lh2 != null && !lh2.equals(lh) && (i3 = this.g.d) > lhY.d) {
                        return LH.b(0, 0, 0, i3);
                    }
                } else {
                    if (i2 == 16) {
                        return k();
                    }
                    if (i2 == 32) {
                        return i();
                    }
                    if (i2 == 64) {
                        return m();
                    }
                    if (i2 == 128) {
                        Kl0 kl0 = this.f;
                        C1998ns c1998nsF = kl0 != null ? kl0.a.f() : f();
                        if (c1998nsF != null) {
                            int i5 = Build.VERSION.SDK_INT;
                            return LH.b(i5 >= 28 ? AbstractC0094Dq.i(c1998nsF.a) : 0, i5 >= 28 ? AbstractC0094Dq.k(c1998nsF.a) : 0, i5 >= 28 ? AbstractC0094Dq.j(c1998nsF.a) : 0, i5 >= 28 ? AbstractC0094Dq.h(c1998nsF.a) : 0);
                        }
                    }
                }
            } else {
                if (z) {
                    LH lhY2 = y();
                    LH lhJ2 = j();
                    return LH.b(Math.max(lhY2.a, lhJ2.a), 0, Math.max(lhY2.c, lhJ2.c), Math.max(lhY2.d, lhJ2.d));
                }
                if ((this.h & 2) == 0) {
                    LH lhL2 = l();
                    Kl0 kl02 = this.f;
                    lhJ = kl02 != null ? kl02.a.j() : null;
                    int iMin = lhL2.d;
                    if (lhJ != null) {
                        iMin = Math.min(iMin, lhJ.d);
                    }
                    return LH.b(lhL2.a, 0, lhL2.c, iMin);
                }
            }
        } else {
            if (z) {
                return LH.b(0, Math.max(y().b, l().b), 0, 0);
            }
            if ((this.h & 4) == 0) {
                return LH.b(0, l().b, 0, 0);
            }
        }
        return lh;
    }

    public Al0(Kl0 kl0, Al0 al0) {
        this(kl0, new WindowInsets(al0.c));
    }
}
