package androidx.coordinatorlayout.widget;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Parcelable;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import androidx.annotation.AttrRes;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.collection.s;
import androidx.core.view.f3;
import androidx.core.view.g1;
import androidx.core.view.h0;
import androidx.core.view.i0;
import androidx.core.view.k0;
import androidx.core.view.s1;
import d0.a;
import d0.b;
import d0.d;
import d0.e;
import d0.g;
import d0.h;
import d0.i;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.WeakHashMap;
import nb.c;
import p0.f;

/* JADX INFO: loaded from: classes.dex */
public class CoordinatorLayout extends ViewGroup implements h0, i0 {
    public static final String W;

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    public static final Class[] f1499a0;

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public static final ThreadLocal f1500b0;

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    public static final g f1501c0;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    public static final f f1502d0;
    public f3 Q;
    public boolean R;
    public Drawable S;
    public ViewGroup.OnHierarchyChangeListener T;
    public c U;
    public final k0 V;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ArrayList f1503a;

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final int[] f1506d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final int[] f1507e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final int[] f1508f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public boolean f1509g;

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public final int[] f1511i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public View f1512j;

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

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public e f1514l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public boolean f1515m;

    @Retention(RetentionPolicy.RUNTIME)
    @Deprecated
    public @interface DefaultBehavior {
        Class<? extends b> value();
    }

    @Retention(RetentionPolicy.SOURCE)
    @RestrictTo({RestrictTo.Scope.f557c})
    public @interface DispatchChangeEvent {
    }

    static {
        Package r02 = CoordinatorLayout.class.getPackage();
        W = r02 != null ? r02.getName() : null;
        f1501c0 = new g(0);
        f1499a0 = new Class[]{Context.class, AttributeSet.class};
        f1500b0 = new ThreadLocal();
        f1502d0 = new f(12);
    }

    public CoordinatorLayout(Context context) {
        this(context, null);
    }

    public static Rect e() {
        Rect rect = (Rect) f1502d0.acquire();
        return rect == null ? new Rect() : rect;
    }

    private int getFullContentHeight() {
        int height = 0;
        for (int i10 = 0; i10 < getChildCount(); i10++) {
            View childAt = getChildAt(i10);
            d dVar = (d) childAt.getLayoutParams();
            height += childAt.getHeight() + ((ViewGroup.MarginLayoutParams) dVar).topMargin + ((ViewGroup.MarginLayoutParams) dVar).bottomMargin;
        }
        return height;
    }

    public static void k(int i10, Rect rect, Rect rect2, d dVar, int i11, int i12) {
        int i13 = dVar.f24886c;
        if (i13 == 0) {
            i13 = 17;
        }
        int absoluteGravity = Gravity.getAbsoluteGravity(i13, i10);
        int i14 = dVar.f24887d;
        if ((i14 & 7) == 0) {
            i14 |= 8388611;
        }
        if ((i14 & 112) == 0) {
            i14 |= 48;
        }
        int absoluteGravity2 = Gravity.getAbsoluteGravity(i14, i10);
        int i15 = absoluteGravity & 7;
        int i16 = absoluteGravity & 112;
        int i17 = absoluteGravity2 & 7;
        int i18 = absoluteGravity2 & 112;
        int iWidth = i17 != 1 ? i17 != 5 ? rect.left : rect.right : rect.left + (rect.width() / 2);
        int iHeight = i18 != 16 ? i18 != 80 ? rect.top : rect.bottom : rect.top + (rect.height() / 2);
        if (i15 == 1) {
            iWidth -= i11 / 2;
        } else if (i15 != 5) {
            iWidth -= i11;
        }
        if (i16 == 16) {
            iHeight -= i12 / 2;
        } else if (i16 != 80) {
            iHeight -= i12;
        }
        rect2.set(iWidth, iHeight, i11 + iWidth, i12 + iHeight);
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static d l(View view) {
        d dVar = (d) view.getLayoutParams();
        if (!dVar.f24885b) {
            if (view instanceof a) {
                b behavior = ((a) view).getBehavior();
                b bVar = dVar.f24884a;
                if (bVar != behavior) {
                    if (bVar != null) {
                        bVar.j();
                    }
                    dVar.f24884a = behavior;
                    dVar.f24885b = true;
                    if (behavior != null) {
                        behavior.g(dVar);
                    }
                }
                dVar.f24885b = true;
            } else {
                DefaultBehavior defaultBehavior = null;
                for (Class<?> superclass = view.getClass(); superclass != null; superclass = superclass.getSuperclass()) {
                    defaultBehavior = (DefaultBehavior) superclass.getAnnotation(DefaultBehavior.class);
                    if (defaultBehavior != null) {
                        break;
                    }
                }
                if (defaultBehavior != null) {
                    try {
                        b bVarNewInstance = defaultBehavior.value().getDeclaredConstructor(new Class[0]).newInstance(new Object[0]);
                        b bVar2 = dVar.f24884a;
                        if (bVar2 != bVarNewInstance) {
                            if (bVar2 != null) {
                                bVar2.j();
                            }
                            dVar.f24884a = bVarNewInstance;
                            dVar.f24885b = true;
                            if (bVarNewInstance != null) {
                                bVarNewInstance.g(dVar);
                            }
                        }
                    } catch (Exception unused) {
                        defaultBehavior.value().getClass();
                    }
                }
                dVar.f24885b = true;
            }
        }
        return dVar;
    }

    public static void v(int i10, View view) {
        d dVar = (d) view.getLayoutParams();
        int i11 = dVar.f24892i;
        if (i11 != i10) {
            WeakHashMap weakHashMap = s1.f1815a;
            view.offsetLeftAndRight(i10 - i11);
            dVar.f24892i = i10;
        }
    }

    public static void w(int i10, View view) {
        d dVar = (d) view.getLayoutParams();
        int i11 = dVar.f24893j;
        if (i11 != i10) {
            WeakHashMap weakHashMap = s1.f1815a;
            view.offsetTopAndBottom(i10 - i11);
            dVar.f24893j = i10;
        }
    }

    @Override // android.view.ViewGroup
    public final boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return (layoutParams instanceof d) && super.checkLayoutParams(layoutParams);
    }

    @Override // android.view.ViewGroup, android.view.View
    public final boolean dispatchKeyEvent(KeyEvent keyEvent) {
        boolean zDispatchKeyEvent = super.dispatchKeyEvent(keyEvent);
        if (zDispatchKeyEvent || keyEvent.getAction() != 0) {
            return zDispatchKeyEvent;
        }
        int keyCode = keyEvent.getKeyCode();
        return keyCode != 19 ? keyCode != 20 ? keyCode != 62 ? keyCode != 92 ? keyCode != 93 ? keyCode != 122 ? keyCode != 123 ? zDispatchKeyEvent : n(getFullContentHeight() - getHeight()) : n(-getFullContentHeight()) : n(getHeight()) : n(-getHeight()) : keyEvent.isShiftPressed() ? n(-getFullContentHeight()) : n(getFullContentHeight() - getHeight()) : keyEvent.isAltPressed() ? n(getHeight()) : n((int) (getHeight() * 0.2f)) : keyEvent.isAltPressed() ? n(-getHeight()) : n(-((int) (getHeight() * 0.2f)));
    }

    @Override // android.view.ViewGroup
    public final boolean drawChild(Canvas canvas, View view, long j10) {
        b bVar = ((d) view.getLayoutParams()).f24884a;
        if (bVar != null) {
            bVar.getClass();
        }
        return super.drawChild(canvas, view, j10);
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void drawableStateChanged() {
        super.drawableStateChanged();
        int[] drawableState = getDrawableState();
        Drawable drawable = this.S;
        if (drawable != null && drawable.isStateful() && drawable.setState(drawableState)) {
            invalidate();
        }
    }

    public final void f(d dVar, Rect rect, int i10, int i11) {
        int width = getWidth();
        int height = getHeight();
        int iMax = Math.max(getPaddingLeft() + ((ViewGroup.MarginLayoutParams) dVar).leftMargin, Math.min(rect.left, ((width - getPaddingRight()) - i10) - ((ViewGroup.MarginLayoutParams) dVar).rightMargin));
        int iMax2 = Math.max(getPaddingTop() + ((ViewGroup.MarginLayoutParams) dVar).topMargin, Math.min(rect.top, ((height - getPaddingBottom()) - i11) - ((ViewGroup.MarginLayoutParams) dVar).bottomMargin));
        rect.set(iMax, iMax2, i10 + iMax, i11 + iMax2);
    }

    public final void g(View view) {
        ArrayList arrayList = (ArrayList) this.f1504b.f24906b.get(view);
        if (arrayList == null || arrayList.isEmpty()) {
            return;
        }
        for (int i10 = 0; i10 < arrayList.size(); i10++) {
            View view2 = (View) arrayList.get(i10);
            b bVar = ((d) view2.getLayoutParams()).f24884a;
            if (bVar != null) {
                bVar.h(this, view2, view);
            }
        }
    }

    @Override // android.view.ViewGroup
    public final ViewGroup.LayoutParams generateDefaultLayoutParams() {
        return new d();
    }

    @Override // android.view.ViewGroup
    public final ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
        return new d(getContext(), attributeSet);
    }

    @VisibleForTesting
    public final List<View> getDependencySortedChildren() {
        t();
        return Collections.unmodifiableList(this.f1503a);
    }

    @RestrictTo({RestrictTo.Scope.f557c})
    public final f3 getLastWindowInsets() {
        return this.Q;
    }

    @Override // android.view.ViewGroup
    public int getNestedScrollAxes() {
        k0 k0Var = this.V;
        return k0Var.f1774b | k0Var.f1773a;
    }

    public Drawable getStatusBarBackground() {
        return this.S;
    }

    @Override // android.view.View
    public int getSuggestedMinimumHeight() {
        return Math.max(super.getSuggestedMinimumHeight(), getPaddingBottom() + getPaddingTop());
    }

    @Override // android.view.View
    public int getSuggestedMinimumWidth() {
        return Math.max(super.getSuggestedMinimumWidth(), getPaddingRight() + getPaddingLeft());
    }

    public final void h(View view, boolean z10, Rect rect) {
        if (view.isLayoutRequested() || view.getVisibility() == 8) {
            rect.setEmpty();
        } else if (z10) {
            j(rect, view);
        } else {
            rect.set(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
        }
    }

    public final List i(View view) {
        s sVar = this.f1504b.f24906b;
        int i10 = sVar.f968c;
        ArrayList arrayList = null;
        for (int i11 = 0; i11 < i10; i11++) {
            ArrayList arrayList2 = (ArrayList) sVar.m(i11);
            if (arrayList2 != null && arrayList2.contains(view)) {
                if (arrayList == null) {
                    arrayList = new ArrayList();
                }
                arrayList.add(sVar.i(i11));
            }
        }
        return arrayList == null ? Collections.emptyList() : arrayList;
    }

    public final void j(Rect rect, View view) {
        ThreadLocal threadLocal = i.f24909a;
        rect.set(0, 0, view.getWidth(), view.getHeight());
        ThreadLocal threadLocal2 = i.f24909a;
        Matrix matrix = (Matrix) threadLocal2.get();
        if (matrix == null) {
            matrix = new Matrix();
            threadLocal2.set(matrix);
        } else {
            matrix.reset();
        }
        i.a(this, view, matrix);
        ThreadLocal threadLocal3 = i.f24910b;
        RectF rectF = (RectF) threadLocal3.get();
        if (rectF == null) {
            rectF = new RectF();
            threadLocal3.set(rectF);
        }
        rectF.set(rect);
        matrix.mapRect(rectF);
        rect.set((int) (rectF.left + 0.5f), (int) (rectF.top + 0.5f), (int) (rectF.right + 0.5f), (int) (rectF.bottom + 0.5f));
    }

    public final boolean m(View view, int i10, int i11) {
        f fVar = f1502d0;
        Rect rectE = e();
        j(rectE, view);
        try {
            return rectE.contains(i10, i11);
        } finally {
            rectE.setEmpty();
            fVar.a(rectE);
        }
    }

    public final boolean n(int i10) {
        View focusedChild = this;
        while (true) {
            if (focusedChild == null) {
                focusedChild = null;
                break;
            }
            if (focusedChild.isFocused()) {
                break;
            }
            focusedChild = focusedChild instanceof ViewGroup ? ((ViewGroup) focusedChild).getFocusedChild() : null;
        }
        onStartNestedScroll(this, focusedChild, 2, 1);
        View view = focusedChild;
        onNestedPreScroll(view, 0, i10, this.f1508f, 1);
        int[] iArr = this.f1508f;
        int i11 = iArr[1];
        iArr[0] = 0;
        iArr[1] = 0;
        onNestedScroll(view, 0, i11, 0, i10, 1, iArr);
        onStopNestedScroll(focusedChild, 1);
        return iArr[1] > 0;
    }

    /* JADX WARN: Removed duplicated region for block: B:34:0x00e8  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void o(int i10) {
        int i11;
        Rect rect;
        int i12;
        ArrayList arrayList;
        boolean zH;
        boolean z10;
        boolean z11;
        int width;
        int i13;
        int i14;
        int i15;
        int height;
        int i16;
        int i17;
        int i18;
        int i19;
        d dVar;
        ArrayList arrayList2;
        int i20;
        Rect rect2;
        int i21;
        View view;
        f fVar;
        d dVar2;
        int i22;
        boolean z12;
        b bVar;
        int layoutDirection = getLayoutDirection();
        ArrayList arrayList3 = this.f1503a;
        int size = arrayList3.size();
        Rect rectE = e();
        Rect rectE2 = e();
        Rect rectE3 = e();
        int i23 = 0;
        while (true) {
            f fVar2 = f1502d0;
            if (i23 >= size) {
                Rect rect3 = rectE3;
                rectE.setEmpty();
                fVar2.a(rectE);
                rectE2.setEmpty();
                fVar2.a(rectE2);
                rect3.setEmpty();
                fVar2.a(rect3);
                return;
            }
            View view2 = (View) arrayList3.get(i23);
            d dVar3 = (d) view2.getLayoutParams();
            if (i10 != 0 || view2.getVisibility() != 8) {
                int i24 = 0;
                while (i24 < i23) {
                    if (dVar3.f24895l == ((View) arrayList3.get(i24))) {
                        d dVar4 = (d) view2.getLayoutParams();
                        if (dVar4.f24894k != null) {
                            Rect rectE4 = e();
                            Rect rectE5 = e();
                            arrayList2 = arrayList3;
                            Rect rectE6 = e();
                            i19 = i24;
                            j(rectE4, dVar4.f24894k);
                            h(view2, false, rectE5);
                            int measuredWidth = view2.getMeasuredWidth();
                            i20 = size;
                            int measuredHeight = view2.getMeasuredHeight();
                            i21 = i23;
                            dVar = dVar3;
                            view = view2;
                            rect2 = rectE3;
                            fVar = fVar2;
                            k(layoutDirection, rectE4, rectE6, dVar4, measuredWidth, measuredHeight);
                            if (rectE6.left == rectE5.left && rectE6.top == rectE5.top) {
                                dVar2 = dVar4;
                                i22 = measuredWidth;
                                z12 = false;
                            } else {
                                dVar2 = dVar4;
                                i22 = measuredWidth;
                                z12 = true;
                            }
                            f(dVar2, rectE6, i22, measuredHeight);
                            int i25 = rectE6.left - rectE5.left;
                            int i26 = rectE6.top - rectE5.top;
                            if (i25 != 0) {
                                WeakHashMap weakHashMap = s1.f1815a;
                                view.offsetLeftAndRight(i25);
                            }
                            if (i26 != 0) {
                                WeakHashMap weakHashMap2 = s1.f1815a;
                                view.offsetTopAndBottom(i26);
                            }
                            if (z12 && (bVar = dVar2.f24884a) != null) {
                                bVar.h(this, view, dVar2.f24894k);
                            }
                            rectE4.setEmpty();
                            fVar.a(rectE4);
                            rectE5.setEmpty();
                            fVar.a(rectE5);
                            rectE6.setEmpty();
                            fVar.a(rectE6);
                        } else {
                            i19 = i24;
                            dVar = dVar3;
                            arrayList2 = arrayList3;
                            i20 = size;
                            rect2 = rectE3;
                            i21 = i23;
                            view = view2;
                            fVar = fVar2;
                        }
                    }
                    i24 = i19 + 1;
                    fVar2 = fVar;
                    view2 = view;
                    arrayList3 = arrayList2;
                    size = i20;
                    i23 = i21;
                    dVar3 = dVar;
                    rectE3 = rect2;
                }
                d dVar5 = dVar3;
                ArrayList arrayList4 = arrayList3;
                int i27 = size;
                Rect rect4 = rectE3;
                i11 = i23;
                View view3 = view2;
                p0.e eVar = fVar2;
                h(view3, true, rectE2);
                if (dVar5.f24890g != 0 && !rectE2.isEmpty()) {
                    int absoluteGravity = Gravity.getAbsoluteGravity(dVar5.f24890g, layoutDirection);
                    int i28 = absoluteGravity & 112;
                    if (i28 == 48) {
                        rectE.top = Math.max(rectE.top, rectE2.bottom);
                    } else if (i28 == 80) {
                        rectE.bottom = Math.max(rectE.bottom, getHeight() - rectE2.top);
                    }
                    int i29 = absoluteGravity & 7;
                    if (i29 == 3) {
                        rectE.left = Math.max(rectE.left, rectE2.right);
                    } else if (i29 == 5) {
                        rectE.right = Math.max(rectE.right, getWidth() - rectE2.left);
                    }
                }
                if (dVar5.f24891h != 0 && view3.getVisibility() == 0 && view3.isLaidOut() && view3.getWidth() > 0 && view3.getHeight() > 0) {
                    d dVar6 = (d) view3.getLayoutParams();
                    b bVar2 = dVar6.f24884a;
                    Rect rectE7 = e();
                    Rect rectE8 = e();
                    rectE8.set(view3.getLeft(), view3.getTop(), view3.getRight(), view3.getBottom());
                    if (bVar2 == null || !bVar2.e(view3, rectE7)) {
                        rectE7.set(rectE8);
                    } else if (!rectE8.contains(rectE7)) {
                        throw new IllegalArgumentException("Rect should be within the child's bounds. Rect:" + rectE7.toShortString() + " | Bounds:" + rectE8.toShortString());
                    }
                    rectE8.setEmpty();
                    eVar.a(rectE8);
                    if (rectE7.isEmpty()) {
                        rectE7.setEmpty();
                        eVar.a(rectE7);
                    } else {
                        int absoluteGravity2 = Gravity.getAbsoluteGravity(dVar6.f24891h, layoutDirection);
                        if ((absoluteGravity2 & 48) != 48 || (i17 = (rectE7.top - ((ViewGroup.MarginLayoutParams) dVar6).topMargin) - dVar6.f24893j) >= (i18 = rectE.top)) {
                            z10 = false;
                        } else {
                            w(i18 - i17, view3);
                            z10 = true;
                        }
                        if ((absoluteGravity2 & 80) == 80 && (height = ((getHeight() - rectE7.bottom) - ((ViewGroup.MarginLayoutParams) dVar6).bottomMargin) + dVar6.f24893j) < (i16 = rectE.bottom)) {
                            w(height - i16, view3);
                        } else if (!z10) {
                            w(0, view3);
                        }
                        if ((absoluteGravity2 & 3) != 3 || (i14 = (rectE7.left - ((ViewGroup.MarginLayoutParams) dVar6).leftMargin) - dVar6.f24892i) >= (i15 = rectE.left)) {
                            z11 = false;
                        } else {
                            v(i15 - i14, view3);
                            z11 = true;
                        }
                        if ((absoluteGravity2 & 5) == 5 && (width = ((getWidth() - rectE7.right) - ((ViewGroup.MarginLayoutParams) dVar6).rightMargin) + dVar6.f24892i) < (i13 = rectE.right)) {
                            v(width - i13, view3);
                        } else if (!z11) {
                            v(0, view3);
                        }
                        rectE7.setEmpty();
                        eVar.a(rectE7);
                    }
                }
                if (i10 != 2) {
                    rect = rect4;
                    rect.set(((d) view3.getLayoutParams()).f24900q);
                    if (rect.equals(rectE2)) {
                        arrayList = arrayList4;
                        i12 = i27;
                    } else {
                        ((d) view3.getLayoutParams()).f24900q.set(rectE2);
                    }
                } else {
                    rect = rect4;
                }
                int i30 = i11 + 1;
                i12 = i27;
                while (true) {
                    arrayList = arrayList4;
                    if (i30 >= i12) {
                        break;
                    }
                    View view4 = (View) arrayList.get(i30);
                    d dVar7 = (d) view4.getLayoutParams();
                    b bVar3 = dVar7.f24884a;
                    if (bVar3 != null && bVar3.f(view4, view3)) {
                        if (i10 == 0 && dVar7.f24899p) {
                            dVar7.f24899p = false;
                        } else {
                            if (i10 != 2) {
                                zH = bVar3.h(this, view4, view3);
                            } else {
                                bVar3.i(this, view3);
                                zH = true;
                            }
                            if (i10 == 1) {
                                dVar7.f24899p = zH;
                            }
                        }
                    }
                    i30++;
                    arrayList4 = arrayList;
                }
            } else {
                arrayList = arrayList3;
                i12 = size;
                rect = rectE3;
                i11 = i23;
            }
            i23 = i11 + 1;
            rectE3 = rect;
            size = i12;
            arrayList3 = arrayList;
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onAttachedToWindow() {
        super.onAttachedToWindow();
        u();
        if (this.f1515m) {
            if (this.f1514l == null) {
                this.f1514l = new e(this, 0);
            }
            getViewTreeObserver().addOnPreDrawListener(this.f1514l);
        }
        if (this.Q == null) {
            WeakHashMap weakHashMap = s1.f1815a;
            if (getFitsSystemWindows()) {
                g1.c(this);
            }
        }
        this.f1510h = true;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        u();
        if (this.f1515m && this.f1514l != null) {
            getViewTreeObserver().removeOnPreDrawListener(this.f1514l);
        }
        View view = this.f1513k;
        if (view != null) {
            onStopNestedScroll(view);
        }
        this.f1510h = false;
    }

    @Override // android.view.View
    public final void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (!this.R || this.S == null) {
            return;
        }
        f3 f3Var = this.Q;
        int iD = f3Var != null ? f3Var.d() : 0;
        if (iD > 0) {
            this.S.setBounds(0, 0, getWidth(), iD);
            this.S.draw(canvas);
        }
    }

    @Override // android.view.ViewGroup
    public final boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 0) {
            u();
        }
        boolean zS = s(motionEvent, 0);
        if (actionMasked == 1 || actionMasked == 3) {
            this.f1512j = null;
            u();
        }
        return zS;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onLayout(boolean z10, int i10, int i11, int i12, int i13) {
        b bVar;
        int layoutDirection = getLayoutDirection();
        ArrayList arrayList = this.f1503a;
        int size = arrayList.size();
        for (int i14 = 0; i14 < size; i14++) {
            View view = (View) arrayList.get(i14);
            if (view.getVisibility() != 8 && ((bVar = ((d) view.getLayoutParams()).f24884a) == null || !bVar.l(this, view, layoutDirection))) {
                p(layoutDirection, view);
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:40:0x00aa  */
    /* JADX WARN: Removed duplicated region for block: B:62:0x0107  */
    /* JADX WARN: Removed duplicated region for block: B:71:0x0128 A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:72:0x012a  */
    /* JADX WARN: Removed duplicated region for block: B:80:0x0143  */
    /* JADX WARN: Removed duplicated region for block: B:83:0x0176  */
    @Override // android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void onMeasure(int i10, int i11) {
        boolean z10;
        boolean z11;
        int i12;
        int i13;
        int iMax;
        int iMakeMeasureSpec;
        int iMakeMeasureSpec2;
        int i14;
        ArrayList arrayList;
        int i15;
        int i16;
        int i17;
        int i18;
        int i19;
        int i20;
        int i21;
        boolean z12;
        int i22;
        int i23;
        int absoluteGravity;
        t();
        int childCount = getChildCount();
        int i24 = 0;
        loop0: while (true) {
            if (i24 >= childCount) {
                z10 = false;
                break;
            }
            View childAt = getChildAt(i24);
            s sVar = this.f1504b.f24906b;
            int i25 = sVar.f968c;
            for (int i26 = 0; i26 < i25; i26++) {
                ArrayList arrayList2 = (ArrayList) sVar.m(i26);
                if (arrayList2 != null && arrayList2.contains(childAt)) {
                    z10 = true;
                    break loop0;
                }
            }
            i24++;
        }
        if (z10 != this.f1515m) {
            if (z10) {
                if (this.f1510h) {
                    if (this.f1514l == null) {
                        this.f1514l = new e(this, 0);
                    }
                    getViewTreeObserver().addOnPreDrawListener(this.f1514l);
                }
                this.f1515m = true;
            } else {
                if (this.f1510h && this.f1514l != null) {
                    getViewTreeObserver().removeOnPreDrawListener(this.f1514l);
                }
                this.f1515m = false;
            }
        }
        int paddingLeft = getPaddingLeft();
        int paddingTop = getPaddingTop();
        int paddingRight = getPaddingRight();
        int paddingBottom = getPaddingBottom();
        int layoutDirection = getLayoutDirection();
        boolean z13 = layoutDirection == 1;
        int mode = View.MeasureSpec.getMode(i10);
        int size = View.MeasureSpec.getSize(i10);
        int mode2 = View.MeasureSpec.getMode(i11);
        int size2 = View.MeasureSpec.getSize(i11);
        int i27 = paddingLeft + paddingRight;
        int i28 = paddingTop + paddingBottom;
        int suggestedMinimumWidth = getSuggestedMinimumWidth();
        int suggestedMinimumHeight = getSuggestedMinimumHeight();
        if (this.Q != null) {
            WeakHashMap weakHashMap = s1.f1815a;
            z11 = getFitsSystemWindows();
        }
        ArrayList arrayList3 = this.f1503a;
        int size3 = arrayList3.size();
        int i29 = suggestedMinimumWidth;
        int i30 = suggestedMinimumHeight;
        int iCombineMeasuredStates = 0;
        int i31 = 0;
        while (i31 < size3) {
            View view = (View) arrayList3.get(i31);
            int i32 = iCombineMeasuredStates;
            if (view.getVisibility() == 8) {
                i14 = size3;
                arrayList = arrayList3;
                i19 = paddingLeft;
                i15 = paddingRight;
                i16 = layoutDirection;
                iCombineMeasuredStates = i32;
                z12 = false;
                i21 = i31;
            } else {
                d dVar = (d) view.getLayoutParams();
                int i33 = dVar.f24888e;
                if (i33 < 0 || mode == 0) {
                    i12 = i31;
                    i13 = i30;
                } else {
                    i12 = i31;
                    int[] iArr = this.f1511i;
                    if (iArr == null) {
                        toString();
                        i13 = i30;
                    } else {
                        i13 = i30;
                        if (i33 < 0 || i33 >= iArr.length) {
                            toString();
                        } else {
                            i22 = iArr[i33];
                            i23 = dVar.f24886c;
                            if (i23 == 0) {
                                i23 = 8388661;
                            }
                            absoluteGravity = Gravity.getAbsoluteGravity(i23, layoutDirection) & 7;
                            if (!(absoluteGravity == 3 || z13) || (absoluteGravity == 5 && z13)) {
                                iMax = Math.max(0, (size - paddingRight) - i22);
                            } else if ((absoluteGravity == 5 && !z13) || (absoluteGravity == 3 && z13)) {
                                iMax = Math.max(0, i22 - paddingLeft);
                            }
                            if (!z11) {
                                WeakHashMap weakHashMap2 = s1.f1815a;
                                if (view.getFitsSystemWindows()) {
                                    iMakeMeasureSpec = i10;
                                    iMakeMeasureSpec2 = i11;
                                } else {
                                    int iC = this.Q.c() + this.Q.b();
                                    int iA = this.Q.a() + this.Q.d();
                                    iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(size - iC, mode);
                                    iMakeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(size2 - iA, mode2);
                                }
                                b bVar = dVar.f24884a;
                                if (bVar != null) {
                                    i21 = i12;
                                    i15 = paddingRight;
                                    i17 = i13;
                                    z12 = false;
                                    i19 = paddingLeft;
                                    i20 = i32;
                                    i16 = layoutDirection;
                                    i18 = i29;
                                    i14 = size3;
                                    arrayList = arrayList3;
                                    if (!bVar.m(this, view, iMakeMeasureSpec, iMax, iMakeMeasureSpec2)) {
                                    }
                                    int iMax2 = Math.max(i18, view.getMeasuredWidth() + i27 + ((ViewGroup.MarginLayoutParams) dVar).leftMargin + ((ViewGroup.MarginLayoutParams) dVar).rightMargin);
                                    int iMax3 = Math.max(i17, view.getMeasuredHeight() + i28 + ((ViewGroup.MarginLayoutParams) dVar).topMargin + ((ViewGroup.MarginLayoutParams) dVar).bottomMargin);
                                    i29 = iMax2;
                                    iCombineMeasuredStates = View.combineMeasuredStates(i20, view.getMeasuredState());
                                    i30 = iMax3;
                                } else {
                                    i14 = size3;
                                    arrayList = arrayList3;
                                    i15 = paddingRight;
                                    i16 = layoutDirection;
                                    i17 = i13;
                                    i18 = i29;
                                    i19 = paddingLeft;
                                    i20 = i32;
                                    i21 = i12;
                                    z12 = false;
                                }
                                measureChildWithMargins(view, iMakeMeasureSpec, iMax, iMakeMeasureSpec2, 0);
                                int iMax22 = Math.max(i18, view.getMeasuredWidth() + i27 + ((ViewGroup.MarginLayoutParams) dVar).leftMargin + ((ViewGroup.MarginLayoutParams) dVar).rightMargin);
                                int iMax32 = Math.max(i17, view.getMeasuredHeight() + i28 + ((ViewGroup.MarginLayoutParams) dVar).topMargin + ((ViewGroup.MarginLayoutParams) dVar).bottomMargin);
                                i29 = iMax22;
                                iCombineMeasuredStates = View.combineMeasuredStates(i20, view.getMeasuredState());
                                i30 = iMax32;
                            }
                        }
                    }
                    i22 = 0;
                    i23 = dVar.f24886c;
                    if (i23 == 0) {
                    }
                    absoluteGravity = Gravity.getAbsoluteGravity(i23, layoutDirection) & 7;
                    if (absoluteGravity == 3) {
                        if (absoluteGravity == 5) {
                        }
                    } else if (absoluteGravity == 5) {
                    }
                }
                iMax = 0;
                if (!z11) {
                }
            }
            i31 = i21 + 1;
            paddingLeft = i19;
            paddingRight = i15;
            layoutDirection = i16;
            size3 = i14;
            arrayList3 = arrayList;
        }
        int i34 = iCombineMeasuredStates;
        setMeasuredDimension(View.resolveSizeAndState(i29, i10, (-16777216) & i34), View.resolveSizeAndState(i30, i11, i34 << 16));
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final boolean onNestedFling(View view, float f10, float f11, boolean z10) {
        int childCount = getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            View childAt = getChildAt(i10);
            if (childAt.getVisibility() != 8) {
                d dVar = (d) childAt.getLayoutParams();
                if (dVar.a(0)) {
                    b bVar = dVar.f24884a;
                }
            }
        }
        return false;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final boolean onNestedPreFling(View view, float f10, float f11) {
        b bVar;
        int childCount = getChildCount();
        boolean zN = false;
        for (int i10 = 0; i10 < childCount; i10++) {
            View childAt = getChildAt(i10);
            if (childAt.getVisibility() != 8) {
                d dVar = (d) childAt.getLayoutParams();
                if (dVar.a(0) && (bVar = dVar.f24884a) != null) {
                    zN |= bVar.n(view);
                }
            }
        }
        return zN;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void onNestedPreScroll(View view, int i10, int i11, int[] iArr) {
        onNestedPreScroll(view, i10, i11, iArr, 0);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void onNestedScroll(View view, int i10, int i11, int i12, int i13) {
        onNestedScroll(view, i10, i11, i12, i13, 0);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void onNestedScrollAccepted(View view, View view2, int i10) {
        onNestedScrollAccepted(view, view2, i10, 0);
    }

    @Override // android.view.View
    public final void onRestoreInstanceState(Parcelable parcelable) {
        Parcelable parcelable2;
        if (!(parcelable instanceof d0.f)) {
            super.onRestoreInstanceState(parcelable);
            return;
        }
        d0.f fVar = (d0.f) parcelable;
        super.onRestoreInstanceState(fVar.getSuperState());
        SparseArray sparseArray = fVar.f24903c;
        int childCount = getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            View childAt = getChildAt(i10);
            int id2 = childAt.getId();
            b bVar = l(childAt).f24884a;
            if (id2 != -1 && bVar != null && (parcelable2 = (Parcelable) sparseArray.get(id2)) != null) {
                bVar.r(childAt, parcelable2);
            }
        }
    }

    @Override // android.view.View
    public final Parcelable onSaveInstanceState() {
        Parcelable parcelableS;
        d0.f fVar = new d0.f(super.onSaveInstanceState());
        SparseArray sparseArray = new SparseArray();
        int childCount = getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            View childAt = getChildAt(i10);
            int id2 = childAt.getId();
            b bVar = ((d) childAt.getLayoutParams()).f24884a;
            if (id2 != -1 && bVar != null && (parcelableS = bVar.s(childAt)) != null) {
                sparseArray.append(id2, parcelableS);
            }
        }
        fVar.f24903c = sparseArray;
        return fVar;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final boolean onStartNestedScroll(View view, View view2, int i10) {
        return onStartNestedScroll(view, view2, i10, 0);
    }

    @Override // androidx.core.view.h0
    public final void onStopNestedScroll(View view, int i10) {
        k0 k0Var = this.V;
        if (i10 == 1) {
            k0Var.f1774b = 0;
        } else {
            k0Var.f1773a = 0;
        }
        int childCount = getChildCount();
        for (int i11 = 0; i11 < childCount; i11++) {
            View childAt = getChildAt(i11);
            d dVar = (d) childAt.getLayoutParams();
            if (dVar.a(i10)) {
                b bVar = dVar.f24884a;
                if (bVar != null) {
                    bVar.u(this, childAt, view, i10);
                }
                if (i10 == 0) {
                    dVar.f24897n = false;
                } else if (i10 == 1) {
                    dVar.f24898o = false;
                }
                dVar.f24899p = false;
            }
        }
        this.f1513k = null;
    }

    @Override // android.view.View
    public final boolean onTouchEvent(MotionEvent motionEvent) {
        boolean zS;
        int actionMasked = motionEvent.getActionMasked();
        View view = this.f1512j;
        boolean z10 = false;
        if (view != null) {
            b bVar = ((d) view.getLayoutParams()).f24884a;
            zS = bVar != null ? bVar.v(this, this.f1512j, motionEvent) : false;
        } else {
            zS = s(motionEvent, 1);
            if (actionMasked != 0 && zS) {
                z10 = true;
            }
        }
        if (this.f1512j == null || actionMasked == 3) {
            zS |= super.onTouchEvent(motionEvent);
        } else if (z10) {
            MotionEvent motionEventObtain = MotionEvent.obtain(motionEvent);
            motionEventObtain.setAction(3);
            super.onTouchEvent(motionEventObtain);
            motionEventObtain.recycle();
        }
        if (actionMasked == 1 || actionMasked == 3) {
            this.f1512j = null;
            u();
        }
        return zS;
    }

    /* JADX WARN: Removed duplicated region for block: B:37:0x00b0  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x00b6  */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00bd  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x00c4  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void p(int i10, View view) {
        Rect rectE;
        Rect rectE2;
        int i11;
        d dVar = (d) view.getLayoutParams();
        View view2 = dVar.f24894k;
        if (view2 == null && dVar.f24889f != -1) {
            throw new IllegalStateException("An anchor may not be changed after CoordinatorLayout measurement begins before layout is complete.");
        }
        f fVar = f1502d0;
        if (view2 != null) {
            rectE = e();
            rectE2 = e();
            try {
                j(rectE, view2);
                d dVar2 = (d) view.getLayoutParams();
                int measuredWidth = view.getMeasuredWidth();
                int measuredHeight = view.getMeasuredHeight();
                k(i10, rectE, rectE2, dVar2, measuredWidth, measuredHeight);
                f(dVar2, rectE2, measuredWidth, measuredHeight);
                view.layout(rectE2.left, rectE2.top, rectE2.right, rectE2.bottom);
                return;
            } finally {
                rectE.setEmpty();
                fVar.a(rectE);
                rectE2.setEmpty();
                fVar.a(rectE2);
            }
        }
        int i12 = dVar.f24888e;
        if (i12 < 0) {
            d dVar3 = (d) view.getLayoutParams();
            rectE = e();
            rectE.set(getPaddingLeft() + ((ViewGroup.MarginLayoutParams) dVar3).leftMargin, getPaddingTop() + ((ViewGroup.MarginLayoutParams) dVar3).topMargin, (getWidth() - getPaddingRight()) - ((ViewGroup.MarginLayoutParams) dVar3).rightMargin, (getHeight() - getPaddingBottom()) - ((ViewGroup.MarginLayoutParams) dVar3).bottomMargin);
            if (this.Q != null) {
                WeakHashMap weakHashMap = s1.f1815a;
                if (getFitsSystemWindows() && !view.getFitsSystemWindows()) {
                    rectE.left = this.Q.b() + rectE.left;
                    rectE.top = this.Q.d() + rectE.top;
                    rectE.right -= this.Q.c();
                    rectE.bottom -= this.Q.a();
                }
            }
            rectE2 = e();
            int i13 = dVar3.f24886c;
            if ((i13 & 7) == 0) {
                i13 |= 8388611;
            }
            if ((i13 & 112) == 0) {
                i13 |= 48;
            }
            Gravity.apply(i13, view.getMeasuredWidth(), view.getMeasuredHeight(), rectE, rectE2, i10);
            view.layout(rectE2.left, rectE2.top, rectE2.right, rectE2.bottom);
            return;
        }
        d dVar4 = (d) view.getLayoutParams();
        int i14 = dVar4.f24886c;
        if (i14 == 0) {
            i14 = 8388661;
        }
        int absoluteGravity = Gravity.getAbsoluteGravity(i14, i10);
        int i15 = absoluteGravity & 7;
        int i16 = absoluteGravity & 112;
        int width = getWidth();
        int height = getHeight();
        int measuredWidth2 = view.getMeasuredWidth();
        int measuredHeight2 = view.getMeasuredHeight();
        if (i10 == 1) {
            i12 = width - i12;
        }
        int[] iArr = this.f1511i;
        int i17 = 0;
        if (iArr == null || i12 < 0 || i12 >= iArr.length) {
            toString();
            i11 = 0;
            int i18 = i11 - measuredWidth2;
            if (i15 != 1) {
            }
            if (i16 != 16) {
            }
            int iMax = Math.max(getPaddingLeft() + ((ViewGroup.MarginLayoutParams) dVar4).leftMargin, Math.min(i18, ((width - getPaddingRight()) - measuredWidth2) - ((ViewGroup.MarginLayoutParams) dVar4).rightMargin));
            int iMax2 = Math.max(getPaddingTop() + ((ViewGroup.MarginLayoutParams) dVar4).topMargin, Math.min(i17, ((height - getPaddingBottom()) - measuredHeight2) - ((ViewGroup.MarginLayoutParams) dVar4).bottomMargin));
            view.layout(iMax, iMax2, measuredWidth2 + iMax, measuredHeight2 + iMax2);
        }
        i11 = iArr[i12];
        int i182 = i11 - measuredWidth2;
        if (i15 != 1) {
            i182 += measuredWidth2 / 2;
        } else if (i15 == 5) {
            i182 += measuredWidth2;
        }
        if (i16 != 16) {
            i17 = measuredHeight2 / 2;
        } else if (i16 == 80) {
            i17 = measuredHeight2;
        }
        int iMax3 = Math.max(getPaddingLeft() + ((ViewGroup.MarginLayoutParams) dVar4).leftMargin, Math.min(i182, ((width - getPaddingRight()) - measuredWidth2) - ((ViewGroup.MarginLayoutParams) dVar4).rightMargin));
        int iMax22 = Math.max(getPaddingTop() + ((ViewGroup.MarginLayoutParams) dVar4).topMargin, Math.min(i17, ((height - getPaddingBottom()) - measuredHeight2) - ((ViewGroup.MarginLayoutParams) dVar4).bottomMargin));
        view.layout(iMax3, iMax22, measuredWidth2 + iMax3, measuredHeight2 + iMax22);
    }

    public final void q(View view, int i10, int i11, int i12) {
        measureChildWithMargins(view, i10, i11, i12, 0);
    }

    public final boolean r(b bVar, View view, MotionEvent motionEvent, int i10) {
        if (i10 == 0) {
            return bVar.k(this, view, motionEvent);
        }
        if (i10 == 1) {
            return bVar.v(this, view, motionEvent);
        }
        throw new IllegalArgumentException();
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final boolean requestChildRectangleOnScreen(View view, Rect rect, boolean z10) {
        b bVar = ((d) view.getLayoutParams()).f24884a;
        if (bVar == null || !bVar.q(this, view, rect, z10)) {
            return super.requestChildRectangleOnScreen(view, rect, z10);
        }
        return true;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void requestDisallowInterceptTouchEvent(boolean z10) {
        super.requestDisallowInterceptTouchEvent(z10);
        if (!z10 || this.f1509g) {
            return;
        }
        if (this.f1512j == null) {
            int childCount = getChildCount();
            MotionEvent motionEventObtain = null;
            for (int i10 = 0; i10 < childCount; i10++) {
                View childAt = getChildAt(i10);
                b bVar = ((d) childAt.getLayoutParams()).f24884a;
                if (bVar != null) {
                    if (motionEventObtain == null) {
                        long jUptimeMillis = SystemClock.uptimeMillis();
                        motionEventObtain = MotionEvent.obtain(jUptimeMillis, jUptimeMillis, 3, 0.0f, 0.0f, 0);
                    }
                    bVar.k(this, childAt, motionEventObtain);
                }
            }
            if (motionEventObtain != null) {
                motionEventObtain.recycle();
            }
        }
        u();
        this.f1509g = true;
    }

    public final boolean s(MotionEvent motionEvent, int i10) {
        boolean z10;
        int actionMasked = motionEvent.getActionMasked();
        ArrayList arrayList = this.f1505c;
        arrayList.clear();
        boolean zIsChildrenDrawingOrderEnabled = isChildrenDrawingOrderEnabled();
        int childCount = getChildCount();
        for (int i11 = childCount - 1; i11 >= 0; i11--) {
            arrayList.add(getChildAt(zIsChildrenDrawingOrderEnabled ? getChildDrawingOrder(childCount, i11) : i11));
        }
        g gVar = f1501c0;
        if (gVar != null) {
            Collections.sort(arrayList, gVar);
        }
        int size = arrayList.size();
        MotionEvent motionEventObtain = null;
        boolean zR = false;
        boolean z11 = false;
        for (int i12 = 0; i12 < size; i12++) {
            View view = (View) arrayList.get(i12);
            d dVar = (d) view.getLayoutParams();
            b bVar = dVar.f24884a;
            if (!(zR || z11) || actionMasked == 0) {
                if (!z11 && !zR && bVar != null && (zR = r(bVar, view, motionEvent, i10))) {
                    this.f1512j = view;
                    if (actionMasked != 3 && actionMasked != 1) {
                        for (int i13 = 0; i13 < i12; i13++) {
                            View view2 = (View) arrayList.get(i13);
                            b bVar2 = ((d) view2.getLayoutParams()).f24884a;
                            if (bVar2 != null) {
                                if (motionEventObtain == null) {
                                    motionEventObtain = MotionEvent.obtain(motionEvent);
                                    motionEventObtain.setAction(3);
                                }
                                r(bVar2, view2, motionEventObtain, i10);
                            }
                        }
                    }
                }
                if (dVar.f24884a == null) {
                    dVar.f24896m = false;
                }
                boolean z12 = dVar.f24896m;
                if (z12) {
                    z10 = true;
                } else {
                    dVar.f24896m = z12;
                    z10 = z12;
                }
                z11 = z10 && !z12;
                if (z10 && !z11) {
                    break;
                }
            } else if (bVar != null) {
                if (motionEventObtain == null) {
                    motionEventObtain = MotionEvent.obtain(motionEvent);
                    motionEventObtain.setAction(3);
                }
                r(bVar, view, motionEventObtain, i10);
            }
        }
        arrayList.clear();
        if (motionEventObtain != null) {
            motionEventObtain.recycle();
        }
        return zR;
    }

    @Override // android.view.View
    public void setFitsSystemWindows(boolean z10) {
        super.setFitsSystemWindows(z10);
        x();
    }

    @Override // android.view.ViewGroup
    public void setOnHierarchyChangeListener(ViewGroup.OnHierarchyChangeListener onHierarchyChangeListener) {
        this.T = onHierarchyChangeListener;
    }

    public void setStatusBarBackground(Drawable drawable) {
        Drawable drawable2 = this.S;
        if (drawable2 != drawable) {
            if (drawable2 != null) {
                drawable2.setCallback(null);
            }
            Drawable drawableMutate = drawable != null ? drawable.mutate() : null;
            this.S = drawableMutate;
            if (drawableMutate != null) {
                if (drawableMutate.isStateful()) {
                    this.S.setState(getDrawableState());
                }
                this.S.setLayoutDirection(getLayoutDirection());
                this.S.setVisible(getVisibility() == 0, false);
                this.S.setCallback(this);
            }
            postInvalidateOnAnimation();
        }
    }

    public void setStatusBarBackgroundColor(@ColorInt int i10) {
        setStatusBarBackground(new ColorDrawable(i10));
    }

    public void setStatusBarBackgroundResource(@DrawableRes int i10) {
        setStatusBarBackground(i10 != 0 ? g0.d.getDrawable(getContext(), i10) : null);
    }

    @Override // android.view.View
    public void setVisibility(int i10) {
        super.setVisibility(i10);
        boolean z10 = i10 == 0;
        Drawable drawable = this.S;
        if (drawable == null || drawable.isVisible() == z10) {
            return;
        }
        this.S.setVisible(z10, false);
    }

    /* JADX WARN: Removed duplicated region for block: B:33:0x0076  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x00b7  */
    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void t() {
        u.h hVar;
        View viewFindViewById;
        View childAt;
        int layoutDirection;
        int absoluteGravity;
        b bVar;
        ArrayList arrayList = this.f1503a;
        arrayList.clear();
        h hVar2 = this.f1504b;
        s sVar = hVar2.f24906b;
        int i10 = sVar.f968c;
        int i11 = 0;
        while (true) {
            hVar = hVar2.f24905a;
            if (i11 >= i10) {
                break;
            }
            ArrayList arrayList2 = (ArrayList) sVar.m(i11);
            if (arrayList2 != null) {
                arrayList2.clear();
                hVar.a(arrayList2);
            }
            i11++;
        }
        sVar.clear();
        int childCount = getChildCount();
        int i12 = 0;
        loop1: while (true) {
            s sVar2 = hVar2.f24906b;
            if (i12 >= childCount) {
                ArrayList arrayList3 = hVar2.f24907c;
                arrayList3.clear();
                HashSet hashSet = hVar2.f24908d;
                hashSet.clear();
                int i13 = sVar2.f968c;
                for (int i14 = 0; i14 < i13; i14++) {
                    hVar2.a(sVar2.i(i14), arrayList3, hashSet);
                }
                arrayList.addAll(arrayList3);
                Collections.reverse(arrayList);
                return;
            }
            View childAt2 = getChildAt(i12);
            d dVarL = l(childAt2);
            int i15 = dVarL.f24889f;
            if (i15 == -1) {
                dVarL.f24895l = null;
                dVarL.f24894k = null;
            } else {
                View view = dVarL.f24894k;
                if (view == null || view.getId() != i15) {
                    viewFindViewById = findViewById(i15);
                    dVarL.f24894k = viewFindViewById;
                    if (viewFindViewById != null) {
                        if (!isInEditMode()) {
                            throw new IllegalStateException("Could not find CoordinatorLayout descendant view with id " + getResources().getResourceName(i15) + " to anchor view " + childAt2);
                        }
                        dVarL.f24895l = null;
                        dVarL.f24894k = null;
                    } else if (viewFindViewById != this) {
                        for (ViewParent parent = viewFindViewById.getParent(); parent != this && parent != null; parent = parent.getParent()) {
                            if (parent != childAt2) {
                                if (parent instanceof View) {
                                    viewFindViewById = parent;
                                }
                            } else {
                                if (!isInEditMode()) {
                                    throw new IllegalStateException("Anchor must not be a descendant of the anchored view");
                                }
                                dVarL.f24895l = null;
                                dVarL.f24894k = null;
                            }
                        }
                        dVarL.f24895l = viewFindViewById;
                    } else {
                        if (!isInEditMode()) {
                            throw new IllegalStateException("View can not be anchored to the the parent CoordinatorLayout");
                        }
                        dVarL.f24895l = null;
                        dVarL.f24894k = null;
                    }
                } else {
                    View view2 = dVarL.f24894k;
                    for (ViewParent parent2 = view2.getParent(); parent2 != this; parent2 = parent2.getParent()) {
                        if (parent2 == null || parent2 == childAt2) {
                            dVarL.f24895l = null;
                            dVarL.f24894k = null;
                            viewFindViewById = findViewById(i15);
                            dVarL.f24894k = viewFindViewById;
                            if (viewFindViewById != null) {
                            }
                        } else {
                            if (parent2 instanceof View) {
                                view2 = parent2;
                            }
                        }
                    }
                    dVarL.f24895l = view2;
                }
            }
            if (!sVar2.containsKey(childAt2)) {
                sVar2.put(childAt2, null);
            }
            for (int i16 = 0; i16 < childCount; i16++) {
                if (i16 != i12 && ((childAt = getChildAt(i16)) == dVarL.f24895l || (((absoluteGravity = Gravity.getAbsoluteGravity(((d) childAt.getLayoutParams()).f24890g, (layoutDirection = getLayoutDirection()))) != 0 && (Gravity.getAbsoluteGravity(dVarL.f24891h, layoutDirection) & absoluteGravity) == absoluteGravity) || ((bVar = dVarL.f24884a) != null && bVar.f(childAt2, childAt))))) {
                    if (!sVar2.containsKey(childAt) && !sVar2.containsKey(childAt)) {
                        sVar2.put(childAt, null);
                    }
                    if (!sVar2.containsKey(childAt) || !sVar2.containsKey(childAt2)) {
                        break loop1;
                    }
                    ArrayList arrayList4 = (ArrayList) sVar2.get(childAt);
                    if (arrayList4 == null) {
                        arrayList4 = (ArrayList) hVar.acquire();
                        if (arrayList4 == null) {
                            arrayList4 = new ArrayList();
                        }
                        sVar2.put(childAt, arrayList4);
                    }
                    arrayList4.add(childAt2);
                }
            }
            i12++;
        }
        throw new IllegalArgumentException("All nodes must be present in the graph before being added as an edge");
    }

    public final void u() {
        View view = this.f1512j;
        if (view != null) {
            b bVar = ((d) view.getLayoutParams()).f24884a;
            if (bVar != null) {
                long jUptimeMillis = SystemClock.uptimeMillis();
                MotionEvent motionEventObtain = MotionEvent.obtain(jUptimeMillis, jUptimeMillis, 3, 0.0f, 0.0f, 0);
                bVar.v(this, this.f1512j, motionEventObtain);
                motionEventObtain.recycle();
            }
            this.f1512j = null;
        }
        int childCount = getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            ((d) getChildAt(i10).getLayoutParams()).f24896m = false;
        }
        this.f1509g = false;
    }

    @Override // android.view.View
    public final boolean verifyDrawable(Drawable drawable) {
        return super.verifyDrawable(drawable) || drawable == this.S;
    }

    public final void x() {
        WeakHashMap weakHashMap = s1.f1815a;
        if (!getFitsSystemWindows()) {
            s1.setOnApplyWindowInsetsListener(this, null);
            return;
        }
        if (this.U == null) {
            this.U = new c(this, 4);
        }
        s1.setOnApplyWindowInsetsListener(this, this.U);
        setSystemUiVisibility(1280);
    }

    public CoordinatorLayout(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, c0.a.coordinatorLayoutStyle);
    }

    @Override // android.view.ViewGroup
    public final ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return layoutParams instanceof d ? new d((d) layoutParams) : layoutParams instanceof ViewGroup.MarginLayoutParams ? new d((ViewGroup.MarginLayoutParams) layoutParams) : new d(layoutParams);
    }

    @Override // androidx.core.view.h0
    public final void onNestedPreScroll(View view, int i10, int i11, int[] iArr, int i12) {
        b bVar;
        int childCount = getChildCount();
        boolean z10 = false;
        int iMax = 0;
        int iMax2 = 0;
        for (int i13 = 0; i13 < childCount; i13++) {
            View childAt = getChildAt(i13);
            if (childAt.getVisibility() != 8) {
                d dVar = (d) childAt.getLayoutParams();
                if (dVar.a(i12) && (bVar = dVar.f24884a) != null) {
                    int[] iArr2 = this.f1506d;
                    iArr2[0] = 0;
                    iArr2[1] = 0;
                    bVar.o(this, childAt, view, i10, i11, iArr2, i12);
                    int[] iArr3 = this.f1506d;
                    iMax = i10 > 0 ? Math.max(iMax, iArr3[0]) : Math.min(iMax, iArr3[0]);
                    iMax2 = i11 > 0 ? Math.max(iMax2, iArr3[1]) : Math.min(iMax2, iArr3[1]);
                    z10 = true;
                }
            }
        }
        iArr[0] = iMax;
        iArr[1] = iMax2;
        if (z10) {
            o(1);
        }
    }

    @Override // androidx.core.view.h0
    public final void onNestedScroll(View view, int i10, int i11, int i12, int i13, int i14) {
        onNestedScroll(view, i10, i11, i12, i13, 0, this.f1507e);
    }

    @Override // androidx.core.view.h0
    public final void onNestedScrollAccepted(View view, View view2, int i10, int i11) {
        this.V.a(i10, i11);
        this.f1513k = view2;
        int childCount = getChildCount();
        for (int i12 = 0; i12 < childCount; i12++) {
            ((d) getChildAt(i12).getLayoutParams()).getClass();
        }
    }

    @Override // androidx.core.view.h0
    public final boolean onStartNestedScroll(View view, View view2, int i10, int i11) {
        int childCount = getChildCount();
        boolean z10 = false;
        for (int i12 = 0; i12 < childCount; i12++) {
            View childAt = getChildAt(i12);
            if (childAt.getVisibility() != 8) {
                d dVar = (d) childAt.getLayoutParams();
                b bVar = dVar.f24884a;
                if (bVar != null) {
                    boolean zT = bVar.t(this, childAt, view, view2, i10, i11);
                    z10 |= zT;
                    if (i11 == 0) {
                        dVar.f24897n = zT;
                    } else if (i11 == 1) {
                        dVar.f24898o = zT;
                    }
                } else if (i11 == 0) {
                    dVar.f24897n = false;
                } else if (i11 == 1) {
                    dVar.f24898o = false;
                }
            }
        }
        return z10;
    }

    public CoordinatorLayout(Context context, AttributeSet attributeSet, @AttrRes int i10) {
        TypedArray typedArrayObtainStyledAttributes;
        super(context, attributeSet, i10);
        this.f1503a = new ArrayList();
        this.f1504b = new h();
        this.f1505c = new ArrayList();
        this.f1506d = new int[2];
        this.f1507e = new int[2];
        this.f1508f = new int[2];
        this.V = new k0();
        if (i10 == 0) {
            typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, c0.c.CoordinatorLayout, 0, c0.b.Widget_Support_CoordinatorLayout);
        } else {
            typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, c0.c.CoordinatorLayout, i10, 0);
        }
        if (i10 == 0) {
            s1.saveAttributeDataForStyleable(this, context, c0.c.CoordinatorLayout, attributeSet, typedArrayObtainStyledAttributes, 0, c0.b.Widget_Support_CoordinatorLayout);
        } else {
            s1.saveAttributeDataForStyleable(this, context, c0.c.CoordinatorLayout, attributeSet, typedArrayObtainStyledAttributes, i10, 0);
        }
        int resourceId = typedArrayObtainStyledAttributes.getResourceId(c0.c.CoordinatorLayout_keylines, 0);
        if (resourceId != 0) {
            Resources resources = context.getResources();
            int[] intArray = resources.getIntArray(resourceId);
            this.f1511i = intArray;
            float f10 = resources.getDisplayMetrics().density;
            int length = intArray.length;
            for (int i11 = 0; i11 < length; i11++) {
                this.f1511i[i11] = (int) (r12[i11] * f10);
            }
        }
        this.S = typedArrayObtainStyledAttributes.getDrawable(c0.c.CoordinatorLayout_statusBarBackground);
        typedArrayObtainStyledAttributes.recycle();
        x();
        super.setOnHierarchyChangeListener(new d0.c(this));
        if (getImportantForAccessibility() == 0) {
            setImportantForAccessibility(1);
        }
    }

    @Override // androidx.core.view.i0
    public final void onNestedScroll(View view, int i10, int i11, int i12, int i13, int i14, int[] iArr) {
        b bVar;
        int iMin;
        int iMin2;
        int childCount = getChildCount();
        boolean z10 = false;
        int i15 = 0;
        int i16 = 0;
        for (int i17 = 0; i17 < childCount; i17++) {
            View childAt = getChildAt(i17);
            if (childAt.getVisibility() != 8) {
                d dVar = (d) childAt.getLayoutParams();
                if (dVar.a(i14) && (bVar = dVar.f24884a) != null) {
                    int[] iArr2 = this.f1506d;
                    iArr2[0] = 0;
                    iArr2[1] = 0;
                    bVar.p(this, childAt, i11, i12, i13, iArr2);
                    if (i12 > 0) {
                        iMin = Math.max(i15, iArr2[0]);
                    } else {
                        iMin = Math.min(i15, iArr2[0]);
                    }
                    i15 = iMin;
                    if (i13 > 0) {
                        iMin2 = Math.max(i16, iArr2[1]);
                    } else {
                        iMin2 = Math.min(i16, iArr2[1]);
                    }
                    i16 = iMin2;
                    z10 = true;
                }
            }
        }
        iArr[0] = iArr[0] + i15;
        iArr[1] = iArr[1] + i16;
        if (z10) {
            o(1);
        }
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void onStopNestedScroll(View view) {
        onStopNestedScroll(view, 0);
    }
}
