package c.f.l;

import android.graphics.Rect;
import android.os.Build;
import android.util.Log;
import android.view.WindowInsets;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Objects;

/* JADX INFO: compiled from: WindowInsetsCompat.java */
/* JADX INFO: loaded from: classes.dex */
public class b0 {
    private final i a;

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class d {
        private final b0 a;

        d() {
            this(new b0((b0) null));
        }

        b0 a() {
            return this.a;
        }

        void b(c.f.e.b bVar) {
        }

        d(b0 b0Var) {
            this.a = b0Var;
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class g extends f {
        g(b0 b0Var, WindowInsets windowInsets) {
            super(b0Var, windowInsets);
        }

        @Override // c.f.l.b0.i
        b0 a() {
            return b0.l(this.f1454b.consumeDisplayCutout());
        }

        @Override // c.f.l.b0.i
        c.f.l.c d() {
            return c.f.l.c.a(this.f1454b.getDisplayCutout());
        }

        @Override // c.f.l.b0.i
        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (obj instanceof g) {
                return Objects.equals(this.f1454b, ((g) obj).f1454b);
            }
            return false;
        }

        @Override // c.f.l.b0.i
        public int hashCode() {
            return this.f1454b.hashCode();
        }

        g(b0 b0Var, g gVar) {
            super(b0Var, gVar);
        }
    }

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

        h(b0 b0Var, h hVar) {
            super(b0Var, hVar);
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class i {
        final b0 a;

        i(b0 b0Var) {
            this.a = b0Var;
        }

        b0 a() {
            return this.a;
        }

        b0 b() {
            return this.a;
        }

        b0 c() {
            return this.a;
        }

        c.f.l.c d() {
            return null;
        }

        c.f.e.b e() {
            return c.f.e.b.f1373e;
        }

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

        c.f.e.b f() {
            return c.f.e.b.f1373e;
        }

        boolean g() {
            return false;
        }

        boolean h() {
            return false;
        }

        public int hashCode() {
            return c.f.k.b.b(Boolean.valueOf(h()), Boolean.valueOf(g()), f(), e(), d());
        }
    }

    static {
        new a().a().a().b().c();
    }

    private b0(WindowInsets windowInsets) {
        int i2 = Build.VERSION.SDK_INT;
        if (i2 >= 29) {
            this.a = new h(this, windowInsets);
            return;
        }
        if (i2 >= 28) {
            this.a = new g(this, windowInsets);
            return;
        }
        if (i2 >= 21) {
            this.a = new f(this, windowInsets);
        } else if (i2 >= 20) {
            this.a = new e(this, windowInsets);
        } else {
            this.a = new i(this);
        }
    }

    public static b0 l(WindowInsets windowInsets) {
        c.f.k.f.b(windowInsets);
        return new b0(windowInsets);
    }

    public b0 a() {
        return this.a.a();
    }

    public b0 b() {
        return this.a.b();
    }

    public b0 c() {
        return this.a.c();
    }

    public int d() {
        return h().f1376d;
    }

    public int e() {
        return h().a;
    }

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

    public int f() {
        return h().f1375c;
    }

    public int g() {
        return h().f1374b;
    }

    public c.f.e.b h() {
        return this.a.f();
    }

    public int hashCode() {
        i iVar = this.a;
        if (iVar == null) {
            return 0;
        }
        return iVar.hashCode();
    }

    public boolean i() {
        return this.a.g();
    }

    @Deprecated
    public b0 j(int i2, int i3, int i4, int i5) {
        a aVar = new a(this);
        aVar.b(c.f.e.b.a(i2, i3, i4, i5));
        return aVar.a();
    }

    public WindowInsets k() {
        i iVar = this.a;
        if (iVar instanceof e) {
            return ((e) iVar).f1454b;
        }
        return null;
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class b extends d {

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        private static Field f1448c = null;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        private static boolean f1449d = false;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        private static Constructor<WindowInsets> f1450e = null;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        private static boolean f1451f = false;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        private WindowInsets f1452b;

        b() {
            this.f1452b = c();
        }

        private static WindowInsets c() {
            if (!f1449d) {
                try {
                    f1448c = WindowInsets.class.getDeclaredField("CONSUMED");
                } catch (ReflectiveOperationException e2) {
                    Log.i("WindowInsetsCompat", "Could not retrieve WindowInsets.CONSUMED field", e2);
                }
                f1449d = true;
            }
            Field field = f1448c;
            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 (!f1451f) {
                try {
                    f1450e = WindowInsets.class.getConstructor(Rect.class);
                } catch (ReflectiveOperationException e4) {
                    Log.i("WindowInsetsCompat", "Could not retrieve WindowInsets(Rect) constructor", e4);
                }
                f1451f = true;
            }
            Constructor<WindowInsets> constructor = f1450e;
            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.l.b0.d
        b0 a() {
            return b0.l(this.f1452b);
        }

        @Override // c.f.l.b0.d
        void b(c.f.e.b bVar) {
            WindowInsets windowInsets = this.f1452b;
            if (windowInsets != null) {
                this.f1452b = windowInsets.replaceSystemWindowInsets(bVar.a, bVar.f1374b, bVar.f1375c, bVar.f1376d);
            }
        }

        b(b0 b0Var) {
            this.f1452b = b0Var.k();
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class c extends d {

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

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

        @Override // c.f.l.b0.d
        b0 a() {
            return b0.l(this.f1453b.build());
        }

        @Override // c.f.l.b0.d
        void b(c.f.e.b bVar) {
            this.f1453b.setSystemWindowInsets(bVar.b());
        }

        c(b0 b0Var) {
            WindowInsets.Builder builder;
            WindowInsets windowInsetsK = b0Var.k();
            if (windowInsetsK != null) {
                builder = new WindowInsets.Builder(windowInsetsK);
            } else {
                builder = new WindowInsets.Builder();
            }
            this.f1453b = builder;
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class f extends e {

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        private c.f.e.b f1456d;

        f(b0 b0Var, WindowInsets windowInsets) {
            super(b0Var, windowInsets);
            this.f1456d = null;
        }

        @Override // c.f.l.b0.i
        b0 b() {
            return b0.l(this.f1454b.consumeStableInsets());
        }

        @Override // c.f.l.b0.i
        b0 c() {
            return b0.l(this.f1454b.consumeSystemWindowInsets());
        }

        @Override // c.f.l.b0.i
        final c.f.e.b e() {
            if (this.f1456d == null) {
                this.f1456d = c.f.e.b.a(this.f1454b.getStableInsetLeft(), this.f1454b.getStableInsetTop(), this.f1454b.getStableInsetRight(), this.f1454b.getStableInsetBottom());
            }
            return this.f1456d;
        }

        @Override // c.f.l.b0.i
        boolean g() {
            return this.f1454b.isConsumed();
        }

        f(b0 b0Var, f fVar) {
            super(b0Var, fVar);
            this.f1456d = null;
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class e extends i {

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        final WindowInsets f1454b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        private c.f.e.b f1455c;

        e(b0 b0Var, WindowInsets windowInsets) {
            super(b0Var);
            this.f1455c = null;
            this.f1454b = windowInsets;
        }

        @Override // c.f.l.b0.i
        final c.f.e.b f() {
            if (this.f1455c == null) {
                this.f1455c = c.f.e.b.a(this.f1454b.getSystemWindowInsetLeft(), this.f1454b.getSystemWindowInsetTop(), this.f1454b.getSystemWindowInsetRight(), this.f1454b.getSystemWindowInsetBottom());
            }
            return this.f1455c;
        }

        @Override // c.f.l.b0.i
        boolean h() {
            return this.f1454b.isRound();
        }

        e(b0 b0Var, e eVar) {
            this(b0Var, new WindowInsets(eVar.f1454b));
        }
    }

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

        public a() {
            int i2 = Build.VERSION.SDK_INT;
            if (i2 >= 29) {
                this.a = new c();
            } else if (i2 >= 20) {
                this.a = new b();
            } else {
                this.a = new d();
            }
        }

        public b0 a() {
            return this.a.a();
        }

        public a b(c.f.e.b bVar) {
            this.a.b(bVar);
            return this;
        }

        public a(b0 b0Var) {
            int i2 = Build.VERSION.SDK_INT;
            if (i2 >= 29) {
                this.a = new c(b0Var);
            } else if (i2 >= 20) {
                this.a = new b(b0Var);
            } else {
                this.a = new d(b0Var);
            }
        }
    }

    public b0(b0 b0Var) {
        if (b0Var != null) {
            i iVar = b0Var.a;
            if (Build.VERSION.SDK_INT >= 29 && (iVar instanceof h)) {
                this.a = new h(this, (h) iVar);
                return;
            }
            if (Build.VERSION.SDK_INT >= 28 && (iVar instanceof g)) {
                this.a = new g(this, (g) iVar);
                return;
            }
            if (Build.VERSION.SDK_INT >= 21 && (iVar instanceof f)) {
                this.a = new f(this, (f) iVar);
                return;
            } else if (Build.VERSION.SDK_INT >= 20 && (iVar instanceof e)) {
                this.a = new e(this, (e) iVar);
                return;
            } else {
                this.a = new i(this);
                return;
            }
        }
        this.a = new i(this);
    }
}
