package c.f.j;

import android.annotation.SuppressLint;
import android.graphics.Rect;
import android.os.Build;
import android.util.Log;
import android.view.DisplayCutout;
import android.view.View;
import android.view.WindowInsets;
import c.f.j.a0;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Objects;
import java.util.WeakHashMap;

/* JADX INFO: compiled from: WindowInsetsCompat.java */
/* JADX INFO: loaded from: classes.dex */
public class m0 {
    public static final m0 a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final k f1438b;

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    @SuppressLint({"SoonBlockedPrivateApi"})
    public static class a {
        public static Field a;

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

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

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public static boolean f1441d;

        static {
            try {
                Field declaredField = View.class.getDeclaredField("mAttachInfo");
                a = declaredField;
                declaredField.setAccessible(true);
                Class<?> cls = Class.forName("android.view.View$AttachInfo");
                Field declaredField2 = cls.getDeclaredField("mStableInsets");
                f1439b = declaredField2;
                declaredField2.setAccessible(true);
                Field declaredField3 = cls.getDeclaredField("mContentInsets");
                f1440c = declaredField3;
                declaredField3.setAccessible(true);
                f1441d = true;
            } catch (ReflectiveOperationException e2) {
                StringBuilder sbB = d.b.a.a.a.B("Failed to get visible insets from AttachInfo ");
                sbB.append(e2.getMessage());
                Log.w("WindowInsetsCompat", sbB.toString(), e2);
            }
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    public static class d extends c {
        public d() {
        }

        public d(m0 m0Var) {
            super(m0Var);
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    public static class e {
        public final m0 a;

        public e() {
            this(new m0((m0) null));
        }

        public final void a() {
        }

        public m0 b() {
            throw null;
        }

        public void c(c.f.d.b bVar) {
            throw null;
        }

        public void d(c.f.d.b bVar) {
            throw null;
        }

        public e(m0 m0Var) {
            this.a = m0Var;
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    public static class f extends k {

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

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

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public static Class<?> f1451e;

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

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

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

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        public c.f.d.b[] f1455i;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        public c.f.d.b f1456j;

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

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        public c.f.d.b f1458l;

        public f(m0 m0Var, WindowInsets windowInsets) {
            super(m0Var);
            this.f1456j = null;
            this.f1454h = windowInsets;
        }

        @SuppressLint({"PrivateApi"})
        public static void o() {
            try {
                f1450d = View.class.getDeclaredMethod("getViewRootImpl", new Class[0]);
                Class<?> cls = Class.forName("android.view.View$AttachInfo");
                f1451e = cls;
                f1452f = cls.getDeclaredField("mVisibleInsets");
                f1453g = Class.forName("android.view.ViewRootImpl").getDeclaredField("mAttachInfo");
                f1452f.setAccessible(true);
                f1453g.setAccessible(true);
            } catch (ReflectiveOperationException e2) {
                StringBuilder sbB = d.b.a.a.a.B("Failed to get visible insets. (Reflection error). ");
                sbB.append(e2.getMessage());
                Log.e("WindowInsetsCompat", sbB.toString(), e2);
            }
            f1449c = true;
        }

        @Override // c.f.j.m0.k
        public void d(View view) {
            c.f.d.b bVarN = n(view);
            if (bVarN == null) {
                bVarN = c.f.d.b.a;
            }
            p(bVarN);
        }

        @Override // c.f.j.m0.k
        public boolean equals(Object obj) {
            if (super.equals(obj)) {
                return Objects.equals(this.f1458l, ((f) obj).f1458l);
            }
            return false;
        }

        @Override // c.f.j.m0.k
        public final c.f.d.b g() {
            if (this.f1456j == null) {
                this.f1456j = c.f.d.b.a(this.f1454h.getSystemWindowInsetLeft(), this.f1454h.getSystemWindowInsetTop(), this.f1454h.getSystemWindowInsetRight(), this.f1454h.getSystemWindowInsetBottom());
            }
            return this.f1456j;
        }

        @Override // c.f.j.m0.k
        public m0 h(int i2, int i3, int i4, int i5) {
            m0 m0VarG = m0.g(this.f1454h);
            int i6 = Build.VERSION.SDK_INT;
            e dVar = i6 >= 30 ? new d(m0VarG) : i6 >= 29 ? new c(m0VarG) : new b(m0VarG);
            dVar.d(m0.e(g(), i2, i3, i4, i5));
            dVar.c(m0.e(f(), i2, i3, i4, i5));
            return dVar.b();
        }

        @Override // c.f.j.m0.k
        public boolean j() {
            return this.f1454h.isRound();
        }

        @Override // c.f.j.m0.k
        public void k(c.f.d.b[] bVarArr) {
            this.f1455i = bVarArr;
        }

        @Override // c.f.j.m0.k
        public void l(m0 m0Var) {
            this.f1457k = m0Var;
        }

        public final c.f.d.b n(View view) {
            if (Build.VERSION.SDK_INT >= 30) {
                throw new UnsupportedOperationException("getVisibleInsets() should not be called on API >= 30. Use WindowInsets.isVisible() instead.");
            }
            if (!f1449c) {
                o();
            }
            Method method = f1450d;
            if (method != null && f1451e != null && f1452f != 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) f1452f.get(f1453g.get(objInvoke));
                    if (rect != null) {
                        return c.f.d.b.a(rect.left, rect.top, rect.right, rect.bottom);
                    }
                    return null;
                } catch (ReflectiveOperationException e2) {
                    StringBuilder sbB = d.b.a.a.a.B("Failed to get visible insets. (Reflection error). ");
                    sbB.append(e2.getMessage());
                    Log.e("WindowInsetsCompat", sbB.toString(), e2);
                }
            }
            return null;
        }

        public void p(c.f.d.b bVar) {
            this.f1458l = bVar;
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    public static class g extends f {
        public c.f.d.b m;

        public g(m0 m0Var, WindowInsets windowInsets) {
            super(m0Var, windowInsets);
            this.m = null;
        }

        @Override // c.f.j.m0.k
        public m0 b() {
            return m0.g(this.f1454h.consumeStableInsets());
        }

        @Override // c.f.j.m0.k
        public m0 c() {
            return m0.g(this.f1454h.consumeSystemWindowInsets());
        }

        @Override // c.f.j.m0.k
        public final c.f.d.b f() {
            if (this.m == null) {
                this.m = c.f.d.b.a(this.f1454h.getStableInsetLeft(), this.f1454h.getStableInsetTop(), this.f1454h.getStableInsetRight(), this.f1454h.getStableInsetBottom());
            }
            return this.m;
        }

        @Override // c.f.j.m0.k
        public boolean i() {
            return this.f1454h.isConsumed();
        }

        @Override // c.f.j.m0.k
        public void m(c.f.d.b bVar) {
            this.m = bVar;
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    public static class h extends g {
        public h(m0 m0Var, WindowInsets windowInsets) {
            super(m0Var, windowInsets);
        }

        @Override // c.f.j.m0.k
        public m0 a() {
            return m0.g(this.f1454h.consumeDisplayCutout());
        }

        @Override // c.f.j.m0.k
        public c.f.j.i e() {
            DisplayCutout displayCutout = this.f1454h.getDisplayCutout();
            if (displayCutout == null) {
                return null;
            }
            return new c.f.j.i(displayCutout);
        }

        @Override // c.f.j.m0.f, c.f.j.m0.k
        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof h)) {
                return false;
            }
            h hVar = (h) obj;
            return Objects.equals(this.f1454h, hVar.f1454h) && Objects.equals(this.f1458l, hVar.f1458l);
        }

        @Override // c.f.j.m0.k
        public int hashCode() {
            return this.f1454h.hashCode();
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    public static class i extends h {
        public c.f.d.b n;
        public c.f.d.b o;
        public c.f.d.b p;

        public i(m0 m0Var, WindowInsets windowInsets) {
            super(m0Var, windowInsets);
            this.n = null;
            this.o = null;
            this.p = null;
        }

        @Override // c.f.j.m0.f, c.f.j.m0.k
        public m0 h(int i2, int i3, int i4, int i5) {
            return m0.g(this.f1454h.inset(i2, i3, i4, i5));
        }

        @Override // c.f.j.m0.g, c.f.j.m0.k
        public void m(c.f.d.b bVar) {
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    public static class j extends i {
        public static final m0 q = m0.g(WindowInsets.CONSUMED);

        public j(m0 m0Var, WindowInsets windowInsets) {
            super(m0Var, windowInsets);
        }

        @Override // c.f.j.m0.f, c.f.j.m0.k
        public final void d(View view) {
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    public static class k {
        public static final m0 a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public final m0 f1459b;

        static {
            int i2 = Build.VERSION.SDK_INT;
            a = (i2 >= 30 ? new d() : i2 >= 29 ? new c() : new b()).b().f1438b.a().f1438b.b().f1438b.c();
        }

        public k(m0 m0Var) {
            this.f1459b = m0Var;
        }

        public m0 a() {
            return this.f1459b;
        }

        public m0 b() {
            return this.f1459b;
        }

        public m0 c() {
            return this.f1459b;
        }

        public void d(View view) {
        }

        public c.f.j.i e() {
            return null;
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof k)) {
                return false;
            }
            k kVar = (k) obj;
            return j() == kVar.j() && i() == kVar.i() && c.f.i.b.a(g(), kVar.g()) && c.f.i.b.a(f(), kVar.f()) && c.f.i.b.a(e(), kVar.e());
        }

        public c.f.d.b f() {
            return c.f.d.b.a;
        }

        public c.f.d.b g() {
            return c.f.d.b.a;
        }

        public m0 h(int i2, int i3, int i4, int i5) {
            return a;
        }

        public int hashCode() {
            return c.f.i.b.b(Boolean.valueOf(j()), Boolean.valueOf(i()), g(), f(), e());
        }

        public boolean i() {
            return false;
        }

        public boolean j() {
            return false;
        }

        public void k(c.f.d.b[] bVarArr) {
        }

        public void l(m0 m0Var) {
        }

        public void m(c.f.d.b bVar) {
        }
    }

    static {
        if (Build.VERSION.SDK_INT >= 30) {
            a = j.q;
        } else {
            a = k.a;
        }
    }

    public m0(WindowInsets windowInsets) {
        int i2 = Build.VERSION.SDK_INT;
        if (i2 >= 30) {
            this.f1438b = new j(this, windowInsets);
            return;
        }
        if (i2 >= 29) {
            this.f1438b = new i(this, windowInsets);
        } else if (i2 >= 28) {
            this.f1438b = new h(this, windowInsets);
        } else {
            this.f1438b = new g(this, windowInsets);
        }
    }

    public static c.f.d.b e(c.f.d.b bVar, int i2, int i3, int i4, int i5) {
        int iMax = Math.max(0, bVar.f1332b - i2);
        int iMax2 = Math.max(0, bVar.f1333c - i3);
        int iMax3 = Math.max(0, bVar.f1334d - i4);
        int iMax4 = Math.max(0, bVar.f1335e - i5);
        return (iMax == i2 && iMax2 == i3 && iMax3 == i4 && iMax4 == i5) ? bVar : c.f.d.b.a(iMax, iMax2, iMax3, iMax4);
    }

    public static m0 g(WindowInsets windowInsets) {
        return h(windowInsets, null);
    }

    public static m0 h(WindowInsets windowInsets, View view) {
        Objects.requireNonNull(windowInsets);
        m0 m0Var = new m0(windowInsets);
        if (view != null) {
            WeakHashMap<View, i0> weakHashMap = a0.a;
            if (a0.f.b(view)) {
                m0Var.f1438b.l(a0.i.a(view));
                m0Var.f1438b.d(view.getRootView());
            }
        }
        return m0Var;
    }

    @Deprecated
    public int a() {
        return this.f1438b.g().f1335e;
    }

    @Deprecated
    public int b() {
        return this.f1438b.g().f1332b;
    }

    @Deprecated
    public int c() {
        return this.f1438b.g().f1334d;
    }

    @Deprecated
    public int d() {
        return this.f1438b.g().f1333c;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof m0) {
            return c.f.i.b.a(this.f1438b, ((m0) obj).f1438b);
        }
        return false;
    }

    public WindowInsets f() {
        k kVar = this.f1438b;
        if (kVar instanceof f) {
            return ((f) kVar).f1454h;
        }
        return null;
    }

    public int hashCode() {
        k kVar = this.f1438b;
        if (kVar == null) {
            return 0;
        }
        return kVar.hashCode();
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    public static class b extends e {

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public static Field f1442b = null;

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

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public static Constructor<WindowInsets> f1444d = null;

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

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

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        public c.f.d.b f1447g;

        public b() {
            this.f1446f = e();
        }

        public static WindowInsets e() {
            if (!f1443c) {
                try {
                    f1442b = WindowInsets.class.getDeclaredField("CONSUMED");
                } catch (ReflectiveOperationException e2) {
                    Log.i("WindowInsetsCompat", "Could not retrieve WindowInsets.CONSUMED field", e2);
                }
                f1443c = true;
            }
            Field field = f1442b;
            if (field != null) {
                try {
                    WindowInsets windowInsets = (WindowInsets) field.get(null);
                    if (windowInsets != null) {
                        return new WindowInsets(windowInsets);
                    }
                } catch (ReflectiveOperationException e3) {
                    Log.i("WindowInsetsCompat", "Could not get value from WindowInsets.CONSUMED field", e3);
                }
            }
            if (!f1445e) {
                try {
                    f1444d = WindowInsets.class.getConstructor(Rect.class);
                } catch (ReflectiveOperationException e4) {
                    Log.i("WindowInsetsCompat", "Could not retrieve WindowInsets(Rect) constructor", e4);
                }
                f1445e = true;
            }
            Constructor<WindowInsets> constructor = f1444d;
            if (constructor != null) {
                try {
                    return constructor.newInstance(new Rect());
                } catch (ReflectiveOperationException e5) {
                    Log.i("WindowInsetsCompat", "Could not invoke WindowInsets(Rect) constructor", e5);
                }
            }
            return null;
        }

        @Override // c.f.j.m0.e
        public m0 b() {
            a();
            m0 m0VarG = m0.g(this.f1446f);
            m0VarG.f1438b.k(null);
            m0VarG.f1438b.m(this.f1447g);
            return m0VarG;
        }

        @Override // c.f.j.m0.e
        public void c(c.f.d.b bVar) {
            this.f1447g = bVar;
        }

        @Override // c.f.j.m0.e
        public void d(c.f.d.b bVar) {
            WindowInsets windowInsets = this.f1446f;
            if (windowInsets != null) {
                this.f1446f = windowInsets.replaceSystemWindowInsets(bVar.f1332b, bVar.f1333c, bVar.f1334d, bVar.f1335e);
            }
        }

        public b(m0 m0Var) {
            super(m0Var);
            this.f1446f = m0Var.f();
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    public static class c extends e {

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public final WindowInsets.Builder f1448b;

        public c() {
            this.f1448b = new WindowInsets.Builder();
        }

        @Override // c.f.j.m0.e
        public m0 b() {
            a();
            m0 m0VarG = m0.g(this.f1448b.build());
            m0VarG.f1438b.k(null);
            return m0VarG;
        }

        @Override // c.f.j.m0.e
        public void c(c.f.d.b bVar) {
            this.f1448b.setStableInsets(bVar.b());
        }

        @Override // c.f.j.m0.e
        public void d(c.f.d.b bVar) {
            this.f1448b.setSystemWindowInsets(bVar.b());
        }

        public c(m0 m0Var) {
            WindowInsets.Builder builder;
            super(m0Var);
            WindowInsets windowInsetsF = m0Var.f();
            if (windowInsetsF != null) {
                builder = new WindowInsets.Builder(windowInsetsF);
            } else {
                builder = new WindowInsets.Builder();
            }
            this.f1448b = builder;
        }
    }

    public m0(m0 m0Var) {
        this.f1438b = new k(this);
    }
}
