package com.google.android.material.appbar;

import android.animation.AnimatorInflater;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.AbsSavedState;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import android.view.animation.Interpolator;
import android.widget.AbsListView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.f0;
import androidx.core.view.f3;
import androidx.core.view.s1;
import androidx.core.view.x1;
import com.google.android.gms.measurement.internal.u1;
import com.google.android.material.internal.q0;
import com.google.android.material.search.SearchBar;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.WeakHashMap;
import kotlinx.coroutines.y;

/* JADX INFO: loaded from: classes2.dex */
public class AppBarLayout extends LinearLayout implements d0.a {

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    public static final int f22138a0 = x8.l.Widget_Design_AppBarLayout;
    public final LinkedHashSet Q;
    public final long R;
    public final TimeInterpolator S;
    public int[] T;
    public int U;
    public final float V;
    public Behavior W;

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

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

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

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

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

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

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

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

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

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

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

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

    @Nullable
    private f3 lastInsets;

    @Nullable
    private ColorStateList liftOnScrollColor;

    @Nullable
    private ValueAnimator liftOnScrollColorAnimator;

    @Nullable
    private ValueAnimator.AnimatorUpdateListener liftOnScrollColorUpdateListener;

    @Nullable
    private WeakReference<View> liftOnScrollTargetView;

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

    @Nullable
    private Drawable statusBarForeground;

    @Nullable
    private Integer statusBarForegroundOriginalColor;

    public static class BaseBehavior<T extends AppBarLayout> extends p {

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

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

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

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

        @Nullable
        private WeakReference<View> lastNestedScrollingChildRef;

        public BaseBehavior() {
            this.f22210e = -1;
            this.f22212g = -1;
        }

        @Nullable
        private View findFirstScrollingChild(@NonNull CoordinatorLayout coordinatorLayout) {
            int childCount = coordinatorLayout.getChildCount();
            for (int i10 = 0; i10 < childCount; i10++) {
                View childAt = coordinatorLayout.getChildAt(i10);
                if ((childAt instanceof f0) || (childAt instanceof AbsListView) || (childAt instanceof ScrollView)) {
                    return childAt;
                }
            }
            return null;
        }

        @Nullable
        private static View getAppBarChildOnOffset(@NonNull AppBarLayout appBarLayout, int i10) {
            int iAbs = Math.abs(i10);
            int childCount = appBarLayout.getChildCount();
            for (int i11 = 0; i11 < childCount; i11++) {
                View childAt = appBarLayout.getChildAt(i11);
                if (iAbs >= childAt.getTop() && iAbs <= childAt.getBottom()) {
                    return childAt;
                }
            }
            return null;
        }

        /* JADX INFO: Access modifiers changed from: private */
        @Nullable
        public View getChildWithScrollingBehavior(CoordinatorLayout coordinatorLayout) {
            int childCount = coordinatorLayout.getChildCount();
            for (int i10 = 0; i10 < childCount; i10++) {
                View childAt = coordinatorLayout.getChildAt(i10);
                if (((d0.d) childAt.getLayoutParams()).f24884a instanceof ScrollingViewBehavior) {
                    return childAt;
                }
            }
            return null;
        }

        @Override // com.google.android.material.appbar.p
        public final void A(CoordinatorLayout coordinatorLayout, View view) {
            AppBarLayout appBarLayout = (AppBarLayout) view;
            G(coordinatorLayout, appBarLayout);
            if (appBarLayout.f22149k) {
                appBarLayout.g(appBarLayout.shouldLift(findFirstScrollingChild(coordinatorLayout)));
            }
        }

        /* JADX WARN: Removed duplicated region for block: B:33:0x0092  */
        /* JADX WARN: Removed duplicated region for block: B:34:0x0097  */
        /* JADX WARN: Removed duplicated region for block: B:37:0x00a3  */
        /* JADX WARN: Removed duplicated region for block: B:59:0x014c  */
        /* JADX WARN: Removed duplicated region for block: B:60:0x014f  */
        @Override // com.google.android.material.appbar.p
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final int B(CoordinatorLayout coordinatorLayout, View view, int i10, int i11, int i12) {
            int top;
            s sVar;
            boolean zB;
            int topInset;
            AppBarLayout appBarLayout = (AppBarLayout) view;
            int iZ = z();
            int i13 = 0;
            if (i11 == 0 || iZ < i11 || iZ > i12) {
                this.f22152h = 0;
            } else {
                int iH = y.h(i10, i11, i12);
                if (iZ != iH) {
                    if (appBarLayout.f22143e) {
                        int iAbs = Math.abs(iH);
                        int childCount = appBarLayout.getChildCount();
                        int i14 = 0;
                        while (true) {
                            if (i14 >= childCount) {
                                break;
                            }
                            View childAt = appBarLayout.getChildAt(i14);
                            k kVar = (k) childAt.getLayoutParams();
                            Interpolator interpolator = kVar.f22203c;
                            if (iAbs < childAt.getTop() || iAbs > childAt.getBottom()) {
                                i14++;
                            } else if (interpolator != null) {
                                int i15 = kVar.f22201a;
                                if ((i15 & 1) != 0) {
                                    topInset = childAt.getHeight() + ((LinearLayout.LayoutParams) kVar).topMargin + ((LinearLayout.LayoutParams) kVar).bottomMargin;
                                    if ((i15 & 2) != 0) {
                                        topInset -= childAt.getMinimumHeight();
                                    }
                                } else {
                                    topInset = 0;
                                }
                                if (childAt.getFitsSystemWindows()) {
                                    topInset -= appBarLayout.getTopInset();
                                }
                                if (topInset > 0) {
                                    float f10 = topInset;
                                    top = (childAt.getTop() + Math.round(interpolator.getInterpolation((iAbs - childAt.getTop()) / f10) * f10)) * Integer.signum(iH);
                                }
                            }
                        }
                        top = iH;
                        sVar = this.f22217a;
                        if (sVar == null) {
                            zB = sVar.b(top);
                        } else {
                            this.f22218b = top;
                            zB = false;
                        }
                        int i16 = iZ - iH;
                        this.f22152h = iH - top;
                        int i17 = 1;
                        if (zB) {
                            int i18 = 0;
                            while (i18 < appBarLayout.getChildCount()) {
                                k kVar2 = (k) appBarLayout.getChildAt(i18).getLayoutParams();
                                i scrollEffect = kVar2.getScrollEffect();
                                if (scrollEffect != null && (kVar2.f22201a & i17) != 0) {
                                    View childAt2 = appBarLayout.getChildAt(i18);
                                    float fW = w();
                                    j jVar = (j) scrollEffect;
                                    Rect rect = jVar.f22199a;
                                    childAt2.getDrawingRect(rect);
                                    appBarLayout.offsetDescendantRectToMyCoords(childAt2, rect);
                                    rect.offset(0, -appBarLayout.getTopInset());
                                    float fAbs = rect.top - Math.abs(fW);
                                    if (fAbs <= 0.0f) {
                                        float f11 = 1.0f - y.f(Math.abs(fAbs / rect.height()), 0.0f, 1.0f);
                                        float fHeight = (-fAbs) - ((rect.height() * 0.3f) * (1.0f - (f11 * f11)));
                                        childAt2.setTranslationY(fHeight);
                                        Rect rect2 = jVar.f22200b;
                                        childAt2.getDrawingRect(rect2);
                                        rect2.offset(0, (int) (-fHeight));
                                        if (fHeight >= rect2.height()) {
                                            childAt2.setAlpha(0.0f);
                                        } else {
                                            childAt2.setAlpha(1.0f);
                                        }
                                        childAt2.setClipBounds(rect2);
                                    } else {
                                        childAt2.setClipBounds(null);
                                        childAt2.setTranslationY(0.0f);
                                        childAt2.setAlpha(1.0f);
                                    }
                                }
                                i18++;
                                i17 = 1;
                            }
                        }
                        if (!zB && appBarLayout.f22143e) {
                            coordinatorLayout.g(appBarLayout);
                        }
                        appBarLayout.e(w());
                        H(coordinatorLayout, appBarLayout, iH, iH >= iZ ? -1 : 1, false);
                        i13 = i16;
                    } else {
                        top = iH;
                        sVar = this.f22217a;
                        if (sVar == null) {
                        }
                        int i162 = iZ - iH;
                        this.f22152h = iH - top;
                        int i172 = 1;
                        if (zB) {
                        }
                        if (!zB) {
                            coordinatorLayout.g(appBarLayout);
                        }
                        appBarLayout.e(w());
                        H(coordinatorLayout, appBarLayout, iH, iH >= iZ ? -1 : 1, false);
                        i13 = i162;
                    }
                }
            }
            if (!s1.d(coordinatorLayout)) {
                s1.setAccessibilityDelegate(coordinatorLayout, new d(coordinatorLayout, this, appBarLayout));
            }
            return i13;
        }

        public final void E(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, int i10) {
            int iAbs = Math.abs(z() - i10);
            float fAbs = Math.abs(0.0f);
            int iRound = fAbs > 0.0f ? Math.round((iAbs / fAbs) * 1000.0f) * 3 : (int) (((iAbs / appBarLayout.getHeight()) + 1.0f) * 150.0f);
            int iZ = z();
            if (iZ == i10) {
                ValueAnimator valueAnimator = this.f22154j;
                if (valueAnimator == null || !valueAnimator.isRunning()) {
                    return;
                }
                this.f22154j.cancel();
                return;
            }
            ValueAnimator valueAnimator2 = this.f22154j;
            if (valueAnimator2 == null) {
                ValueAnimator valueAnimator3 = new ValueAnimator();
                this.f22154j = valueAnimator3;
                valueAnimator3.setInterpolator(y8.a.f36868e);
                this.f22154j.addUpdateListener(new c(coordinatorLayout, this, appBarLayout));
            } else {
                valueAnimator2.cancel();
            }
            this.f22154j.setDuration(Math.min(iRound, 600));
            this.f22154j.setIntValues(iZ, i10);
            this.f22154j.start();
        }

        public final void F(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, View view, int i10, int[] iArr) {
            int i11;
            int downNestedPreScrollRange;
            if (i10 != 0) {
                if (i10 < 0) {
                    i11 = -appBarLayout.getTotalScrollRange();
                    downNestedPreScrollRange = appBarLayout.getDownNestedPreScrollRange() + i11;
                } else {
                    i11 = -appBarLayout.getUpNestedPreScrollRange();
                    downNestedPreScrollRange = 0;
                }
                int i12 = i11;
                int i13 = downNestedPreScrollRange;
                if (i12 != i13) {
                    iArr[1] = B(coordinatorLayout, appBarLayout, z() - i10, i12, i13);
                }
            }
            if (appBarLayout.f22149k) {
                appBarLayout.g(appBarLayout.shouldLift(view));
            }
        }

        public final void G(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout) {
            int paddingTop = appBarLayout.getPaddingTop() + appBarLayout.getTopInset();
            int iZ = z() - paddingTop;
            int childCount = appBarLayout.getChildCount();
            int i10 = 0;
            while (true) {
                if (i10 >= childCount) {
                    i10 = -1;
                    break;
                }
                View childAt = appBarLayout.getChildAt(i10);
                int top = childAt.getTop();
                int bottom = childAt.getBottom();
                k kVar = (k) childAt.getLayoutParams();
                if ((kVar.f22201a & 32) == 32) {
                    top -= ((LinearLayout.LayoutParams) kVar).topMargin;
                    bottom += ((LinearLayout.LayoutParams) kVar).bottomMargin;
                }
                int i11 = -iZ;
                if (top <= i11 && bottom >= i11) {
                    break;
                } else {
                    i10++;
                }
            }
            if (i10 >= 0) {
                View childAt2 = appBarLayout.getChildAt(i10);
                k kVar2 = (k) childAt2.getLayoutParams();
                int i12 = kVar2.f22201a;
                if ((i12 & 17) == 17) {
                    int topInset = -childAt2.getTop();
                    int minimumHeight = -childAt2.getBottom();
                    if (i10 == 0 && appBarLayout.getFitsSystemWindows() && childAt2.getFitsSystemWindows()) {
                        topInset -= appBarLayout.getTopInset();
                    }
                    if ((i12 & 2) == 2) {
                        minimumHeight += childAt2.getMinimumHeight();
                    } else if ((i12 & 5) == 5) {
                        int minimumHeight2 = childAt2.getMinimumHeight() + minimumHeight;
                        if (iZ < minimumHeight2) {
                            topInset = minimumHeight2;
                        } else {
                            minimumHeight = minimumHeight2;
                        }
                    }
                    if ((i12 & 32) == 32) {
                        topInset += ((LinearLayout.LayoutParams) kVar2).topMargin;
                        minimumHeight -= ((LinearLayout.LayoutParams) kVar2).bottomMargin;
                    }
                    if (iZ < (minimumHeight + topInset) / 2) {
                        topInset = minimumHeight;
                    }
                    E(coordinatorLayout, appBarLayout, y.h(topInset + paddingTop, -appBarLayout.getTotalScrollRange(), 0));
                }
            }
        }

        /* JADX WARN: Removed duplicated region for block: B:18:0x003e  */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final void H(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, int i10, int i11, boolean z10) {
            boolean zShouldLift;
            View appBarChildOnOffset = getAppBarChildOnOffset(appBarLayout, i10);
            if (appBarChildOnOffset != null) {
                int i12 = ((k) appBarChildOnOffset.getLayoutParams()).f22201a;
                if ((i12 & 1) != 0) {
                    int minimumHeight = appBarChildOnOffset.getMinimumHeight();
                    zShouldLift = true;
                    if (i11 <= 0 || (i12 & 12) == 0 ? (i12 & 2) == 0 || (-i10) < (appBarChildOnOffset.getBottom() - minimumHeight) - appBarLayout.getTopInset() : (-i10) < (appBarChildOnOffset.getBottom() - minimumHeight) - appBarLayout.getTopInset()) {
                        zShouldLift = false;
                    }
                }
            }
            if (appBarLayout.f22149k) {
                zShouldLift = appBarLayout.shouldLift(findFirstScrollingChild(coordinatorLayout));
            }
            boolean zG = appBarLayout.g(zShouldLift);
            if (!z10) {
                if (zG) {
                    ArrayList arrayList = (ArrayList) coordinatorLayout.f1504b.f24906b.get(appBarLayout);
                    List arrayList2 = arrayList == null ? null : new ArrayList(arrayList);
                    if (arrayList2 == null) {
                        arrayList2 = Collections.emptyList();
                    }
                    int size = arrayList2.size();
                    for (int i13 = 0; i13 < size; i13++) {
                        d0.b bVar = ((d0.d) ((View) arrayList2.get(i13)).getLayoutParams()).f24884a;
                        if (bVar instanceof ScrollingViewBehavior) {
                            if (((ScrollingViewBehavior) bVar).f22216f == 0) {
                                return;
                            }
                        }
                    }
                    return;
                }
                return;
            }
            if (appBarLayout.getBackground() != null) {
                appBarLayout.getBackground().jumpToCurrentState();
            }
            if (appBarLayout.getForeground() != null) {
                appBarLayout.getForeground().jumpToCurrentState();
            }
            if (appBarLayout.getStateListAnimator() != null) {
                appBarLayout.getStateListAnimator().jumpToCurrentState();
            }
        }

        @Override // com.google.android.material.appbar.r, d0.b
        public final boolean l(CoordinatorLayout coordinatorLayout, View view, int i10) {
            AppBarLayout appBarLayout = (AppBarLayout) view;
            super.l(coordinatorLayout, appBarLayout, i10);
            int pendingAction = appBarLayout.getPendingAction();
            g gVar = this.f22155k;
            if (gVar == null || (pendingAction & 8) != 0) {
                if (pendingAction != 0) {
                    boolean z10 = (pendingAction & 4) != 0;
                    if ((pendingAction & 2) != 0) {
                        int i11 = -appBarLayout.getUpNestedPreScrollRange();
                        if (z10) {
                            E(coordinatorLayout, appBarLayout, i11);
                        } else {
                            C(coordinatorLayout, appBarLayout, i11);
                        }
                    } else if ((pendingAction & 1) != 0) {
                        if (z10) {
                            E(coordinatorLayout, appBarLayout, 0);
                        } else {
                            C(coordinatorLayout, appBarLayout, 0);
                        }
                    }
                }
            } else if (gVar.f22194c) {
                C(coordinatorLayout, appBarLayout, -appBarLayout.getTotalScrollRange());
            } else if (gVar.f22195d) {
                C(coordinatorLayout, appBarLayout, 0);
            } else {
                View childAt = appBarLayout.getChildAt(gVar.f22196e);
                int i12 = -childAt.getBottom();
                C(coordinatorLayout, appBarLayout, this.f22155k.f22198g ? appBarLayout.getTopInset() + childAt.getMinimumHeight() + i12 : Math.round(childAt.getHeight() * this.f22155k.f22197f) + i12);
            }
            appBarLayout.f22144f = 0;
            this.f22155k = null;
            int iH = y.h(w(), -appBarLayout.getTotalScrollRange(), 0);
            s sVar = this.f22217a;
            if (sVar != null) {
                sVar.b(iH);
            } else {
                this.f22218b = iH;
            }
            H(coordinatorLayout, appBarLayout, w(), 0, true);
            appBarLayout.e(w());
            if (!s1.d(coordinatorLayout)) {
                s1.setAccessibilityDelegate(coordinatorLayout, new d(coordinatorLayout, this, appBarLayout));
            }
            return true;
        }

        @Override // d0.b
        public final boolean m(CoordinatorLayout coordinatorLayout, View view, int i10, int i11, int i12) {
            AppBarLayout appBarLayout = (AppBarLayout) view;
            if (((ViewGroup.MarginLayoutParams) ((d0.d) appBarLayout.getLayoutParams())).height != -2) {
                return false;
            }
            coordinatorLayout.q(appBarLayout, i10, i11, View.MeasureSpec.makeMeasureSpec(0, 0));
            return true;
        }

        @Override // d0.b
        public final /* bridge */ /* synthetic */ void o(CoordinatorLayout coordinatorLayout, View view, View view2, int i10, int i11, int[] iArr, int i12) {
            F(coordinatorLayout, (AppBarLayout) view, view2, i11, iArr);
        }

        @Override // d0.b
        public final void p(CoordinatorLayout coordinatorLayout, View view, int i10, int i11, int i12, int[] iArr) {
            AppBarLayout appBarLayout = (AppBarLayout) view;
            if (i12 < 0) {
                iArr[1] = B(coordinatorLayout, appBarLayout, z() - i12, -appBarLayout.getDownNestedScrollRange(), 0);
            }
            if (i12 != 0 || s1.d(coordinatorLayout)) {
                return;
            }
            s1.setAccessibilityDelegate(coordinatorLayout, new d(coordinatorLayout, this, appBarLayout));
        }

        @Override // d0.b
        public final void r(View view, Parcelable parcelable) {
            if (!(parcelable instanceof g)) {
                this.f22155k = null;
            } else {
                restoreScrollState((g) parcelable, true);
                this.f22155k.getSuperState();
            }
        }

        public void restoreScrollState(@Nullable g gVar, boolean z10) {
            if (this.f22155k == null || z10) {
                this.f22155k = gVar;
            }
        }

        @Override // d0.b
        public final Parcelable s(View view) {
            AbsSavedState absSavedState = View.BaseSavedState.EMPTY_STATE;
            g gVarSaveScrollState = saveScrollState(absSavedState, (AppBarLayout) view);
            return gVarSaveScrollState == null ? absSavedState : gVarSaveScrollState;
        }

        @Nullable
        public g saveScrollState(@Nullable Parcelable parcelable, @NonNull T t10) {
            int iW = w();
            int childCount = t10.getChildCount();
            for (int i10 = 0; i10 < childCount; i10++) {
                View childAt = t10.getChildAt(i10);
                int bottom = childAt.getBottom() + iW;
                if (childAt.getTop() + iW <= 0 && bottom >= 0) {
                    if (parcelable == null) {
                        parcelable = x0.b.f34320b;
                    }
                    g gVar = new g(parcelable);
                    boolean z10 = iW == 0;
                    gVar.f22195d = z10;
                    gVar.f22194c = !z10 && (-iW) >= t10.getTotalScrollRange();
                    gVar.f22196e = i10;
                    gVar.f22198g = bottom == t10.getTopInset() + childAt.getMinimumHeight();
                    gVar.f22197f = bottom / childAt.getHeight();
                    return gVar;
                }
            }
            return null;
        }

        public void setDragCallback(@Nullable e eVar) {
        }

        @Override // d0.b
        public final boolean t(CoordinatorLayout coordinatorLayout, View view, View view2, View view3, int i10, int i11) {
            ValueAnimator valueAnimator;
            AppBarLayout appBarLayout = (AppBarLayout) view;
            boolean z10 = (i10 & 2) != 0 && (appBarLayout.f22149k || appBarLayout.f22148j || (appBarLayout.getTotalScrollRange() != 0 && coordinatorLayout.getHeight() - view2.getHeight() <= appBarLayout.getHeight()));
            if (z10 && (valueAnimator = this.f22154j) != null) {
                valueAnimator.cancel();
            }
            this.lastNestedScrollingChildRef = null;
            this.f22153i = i11;
            return z10;
        }

        @Override // d0.b
        public final void u(CoordinatorLayout coordinatorLayout, View view, View view2, int i10) {
            AppBarLayout appBarLayout = (AppBarLayout) view;
            if (this.f22153i == 0 || i10 == 1) {
                G(coordinatorLayout, appBarLayout);
                if (appBarLayout.f22149k) {
                    appBarLayout.g(appBarLayout.shouldLift(view2));
                }
            }
            this.lastNestedScrollingChildRef = new WeakReference<>(view2);
        }

        @Override // com.google.android.material.appbar.p
        public final boolean y(View view) {
            WeakReference<View> weakReference = this.lastNestedScrollingChildRef;
            if (weakReference == null) {
                return true;
            }
            View view2 = weakReference.get();
            return (view2 == null || !view2.isShown() || view2.canScrollVertically(-1)) ? false : true;
        }

        @Override // com.google.android.material.appbar.p
        public final int z() {
            return w() + this.f22152h;
        }

        public BaseBehavior(Context context, AttributeSet attributeSet) {
            super(0);
            this.f22210e = -1;
            this.f22212g = -1;
        }
    }

    public static class Behavior extends BaseBehavior<AppBarLayout> {
        public Behavior() {
        }

        @Override // com.google.android.material.appbar.AppBarLayout.BaseBehavior
        public /* bridge */ /* synthetic */ void setDragCallback(@Nullable e eVar) {
            super.setDragCallback(eVar);
        }

        public Behavior(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
        }
    }

    public static class ScrollingViewBehavior extends q {
        public ScrollingViewBehavior() {
        }

        @Override // d0.b
        public final boolean f(View view, View view2) {
            return view2 instanceof AppBarLayout;
        }

        @Override // com.google.android.material.appbar.q
        @Nullable
        public /* bridge */ /* synthetic */ View findFirstDependency(@NonNull List list) {
            return findFirstDependency((List<View>) list);
        }

        @Override // d0.b
        public boolean h(CoordinatorLayout coordinatorLayout, View view, View view2) {
            d0.b bVar = ((d0.d) view2.getLayoutParams()).f24884a;
            if (bVar instanceof BaseBehavior) {
                int bottom = (((view2.getBottom() - view.getTop()) + ((BaseBehavior) bVar).f22152h) + this.f22215e) - y(view2);
                WeakHashMap weakHashMap = s1.f1815a;
                view.offsetTopAndBottom(bottom);
            }
            if (!(view2 instanceof AppBarLayout)) {
                return false;
            }
            AppBarLayout appBarLayout = (AppBarLayout) view2;
            if (!appBarLayout.f22149k) {
                return false;
            }
            appBarLayout.g(appBarLayout.shouldLift(view));
            return false;
        }

        @Override // d0.b
        public final void i(CoordinatorLayout coordinatorLayout, View view) {
            if (view instanceof AppBarLayout) {
                s1.setAccessibilityDelegate(coordinatorLayout, null);
            }
        }

        @Override // d0.b
        public final boolean q(CoordinatorLayout coordinatorLayout, View view, Rect rect, boolean z10) {
            AppBarLayout appBarLayoutFindFirstDependency = findFirstDependency((List<View>) coordinatorLayout.i(view));
            if (appBarLayoutFindFirstDependency != null) {
                Rect rect2 = new Rect(rect);
                rect2.offset(view.getLeft(), view.getTop());
                int width = coordinatorLayout.getWidth();
                int height = coordinatorLayout.getHeight();
                Rect rect3 = this.f22213c;
                rect3.set(0, 0, width, height);
                if (!rect3.contains(rect2)) {
                    appBarLayoutFindFirstDependency.setExpanded(false, !z10);
                    return true;
                }
            }
            return false;
        }

        public ScrollingViewBehavior(Context context, AttributeSet attributeSet) {
            super(0);
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, x8.m.ScrollingViewBehavior_Layout);
            this.f22216f = typedArrayObtainStyledAttributes.getDimensionPixelSize(x8.m.ScrollingViewBehavior_Layout_behavior_overlapTop, 0);
            typedArrayObtainStyledAttributes.recycle();
        }

        @Override // com.google.android.material.appbar.q
        @Nullable
        public AppBarLayout findFirstDependency(@NonNull List<View> list) {
            int size = list.size();
            for (int i10 = 0; i10 < size; i10++) {
                View view = list.get(i10);
                if (view instanceof AppBarLayout) {
                    return (AppBarLayout) view;
                }
            }
            return null;
        }
    }

    public AppBarLayout(@NonNull Context context) {
        this(context, null);
    }

    public static void a(AppBarLayout appBarLayout, ColorStateList colorStateList, com.google.android.material.shape.k kVar, Integer num, ValueAnimator valueAnimator) {
        Integer num2;
        appBarLayout.getClass();
        float fFloatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        int iE = h9.a.e(fFloatValue, appBarLayout.U, colorStateList.getDefaultColor());
        kVar.setFillColor(ColorStateList.valueOf(iE));
        if (appBarLayout.statusBarForeground != null && (num2 = appBarLayout.statusBarForegroundOriginalColor) != null && num2.equals(num)) {
            appBarLayout.statusBarForeground.setTint(iE);
        }
        ArrayList arrayList = appBarLayout.f22151m;
        if (!arrayList.isEmpty()) {
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                u1.x(it.next());
                if (kVar.getFillColor() != null) {
                    throw null;
                }
            }
        }
        LinkedHashSet linkedHashSet = appBarLayout.Q;
        if (linkedHashSet.isEmpty()) {
            return;
        }
        Iterator it2 = linkedHashSet.iterator();
        while (it2.hasNext()) {
            SearchBar searchBar = ((s9.a) it2.next()).f32673a;
            if (searchBar.liftOnScrollColor != null) {
                searchBar.N0.setFillColor(ColorStateList.valueOf(h9.a.e(fFloatValue, searchBar.D0, searchBar.liftOnScrollColor.getDefaultColor())));
            }
        }
    }

    public static void b(AppBarLayout appBarLayout, com.google.android.material.shape.k kVar, ValueAnimator valueAnimator) {
        appBarLayout.getClass();
        float fFloatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
        kVar.w(fFloatValue);
        Drawable drawable = appBarLayout.statusBarForeground;
        if (drawable instanceof com.google.android.material.shape.k) {
            ((com.google.android.material.shape.k) drawable).w(fFloatValue);
        }
        Iterator it = appBarLayout.f22151m.iterator();
        if (it.hasNext()) {
            u1.x(it.next());
            throw null;
        }
        for (s9.a aVar : appBarLayout.Q) {
            float f10 = fFloatValue / appBarLayout.V;
            SearchBar searchBar = aVar.f32673a;
            if (searchBar.liftOnScrollColor != null) {
                searchBar.N0.setFillColor(ColorStateList.valueOf(h9.a.e(f10, searchBar.D0, searchBar.liftOnScrollColor.getDefaultColor())));
            }
        }
    }

    public static k c(ViewGroup.LayoutParams layoutParams) {
        if (layoutParams instanceof LinearLayout.LayoutParams) {
            k kVar = new k((LinearLayout.LayoutParams) layoutParams);
            kVar.f22201a = 1;
            return kVar;
        }
        if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
            k kVar2 = new k((ViewGroup.MarginLayoutParams) layoutParams);
            kVar2.f22201a = 1;
            return kVar2;
        }
        k kVar3 = new k(layoutParams);
        kVar3.f22201a = 1;
        return kVar3;
    }

    @Nullable
    private Integer extractStatusBarForegroundColor() {
        Drawable drawable = this.statusBarForeground;
        if (drawable instanceof com.google.android.material.shape.k) {
            return Integer.valueOf(((com.google.android.material.shape.k) drawable).W);
        }
        ColorStateList colorStateListOrNull = j9.c.getColorStateListOrNull(drawable);
        if (colorStateListOrNull != null) {
            return Integer.valueOf(colorStateListOrNull.getDefaultColor());
        }
        return null;
    }

    @Nullable
    private View findLiftOnScrollTargetView(@Nullable View view) {
        int i10;
        if (this.liftOnScrollTargetView == null && (i10 = this.f22150l) != -1) {
            View viewFindViewById = view != null ? view.findViewById(i10) : null;
            if (viewFindViewById == null && (getParent() instanceof ViewGroup)) {
                viewFindViewById = ((ViewGroup) getParent()).findViewById(this.f22150l);
            }
            if (viewFindViewById != null) {
                this.liftOnScrollTargetView = new WeakReference<>(viewFindViewById);
            }
        }
        WeakReference<View> weakReference = this.liftOnScrollTargetView;
        if (weakReference != null) {
            return weakReference.get();
        }
        return null;
    }

    @Nullable
    private com.google.android.material.shape.k maybeConvertToMaterialShapeDrawable(Drawable drawable) {
        if (drawable instanceof com.google.android.material.shape.k) {
            return (com.google.android.material.shape.k) drawable;
        }
        ColorStateList colorStateListOrNull = j9.c.getColorStateListOrNull(drawable);
        if (colorStateListOrNull == null) {
            return null;
        }
        com.google.android.material.shape.k kVar = new com.google.android.material.shape.k();
        kVar.setFillColor(colorStateListOrNull);
        return kVar;
    }

    public void addOnOffsetChangedListener(@Nullable h hVar) {
        if (this.f22145g == null) {
            this.f22145g = new ArrayList();
        }
        if (hVar == null || this.f22145g.contains(hVar)) {
            return;
        }
        this.f22145g.add(hVar);
    }

    @Override // android.widget.LinearLayout, android.view.ViewGroup
    public final boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return layoutParams instanceof k;
    }

    public final void d() {
        Behavior behavior = this.W;
        g gVarSaveScrollState = (behavior == null || this.f22140b == -1 || this.f22144f != 0) ? null : behavior.saveScrollState(x0.b.f34320b, this);
        this.f22140b = -1;
        this.f22141c = -1;
        this.f22142d = -1;
        if (gVarSaveScrollState != null) {
            this.W.restoreScrollState(gVarSaveScrollState, false);
        }
    }

    @Override // android.view.View
    public final void draw(Canvas canvas) {
        super.draw(canvas);
        if (this.statusBarForeground == null || getTopInset() <= 0) {
            return;
        }
        int iSave = canvas.save();
        canvas.translate(0.0f, -this.f22139a);
        this.statusBarForeground.draw(canvas);
        canvas.restoreToCount(iSave);
    }

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

    public final void e(int i10) {
        this.f22139a = i10;
        if (!willNotDraw()) {
            postInvalidateOnAnimation();
        }
        ArrayList arrayList = this.f22145g;
        if (arrayList != null) {
            int size = arrayList.size();
            for (int i11 = 0; i11 < size; i11++) {
                h hVar = (h) this.f22145g.get(i11);
                if (hVar != null) {
                    hVar.a(this, i10);
                }
            }
        }
    }

    public final void f(f3 f3Var) {
        if (!getFitsSystemWindows()) {
            f3Var = null;
        }
        if (p0.c.equals(this.lastInsets, f3Var)) {
            return;
        }
        this.lastInsets = f3Var;
        setWillNotDraw(!(this.statusBarForeground != null && getTopInset() > 0));
        requestLayout();
    }

    public final boolean g(boolean z10) {
        if (!(!this.f22146h) || this.f22148j == z10) {
            return false;
        }
        this.f22148j = z10;
        refreshDrawableState();
        if (!(getBackground() instanceof com.google.android.material.shape.k)) {
            return true;
        }
        if (this.liftOnScrollColor != null) {
            h(z10 ? 0.0f : 1.0f, z10 ? 1.0f : 0.0f);
            return true;
        }
        if (!this.f22149k) {
            return true;
        }
        float f10 = this.V;
        h(z10 ? 0.0f : f10, z10 ? f10 : 0.0f);
        return true;
    }

    @Override // android.widget.LinearLayout, android.view.ViewGroup
    public final ViewGroup.LayoutParams generateDefaultLayoutParams() {
        k kVar = new k(-1, -2);
        kVar.f22201a = 1;
        return kVar;
    }

    @Override // android.widget.LinearLayout, android.view.ViewGroup
    public final /* bridge */ /* synthetic */ ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return c(layoutParams);
    }

    @Override // d0.a
    @NonNull
    public d0.b getBehavior() {
        Behavior behavior = new Behavior();
        this.W = behavior;
        return behavior;
    }

    public int getDownNestedPreScrollRange() {
        int iMin;
        int minimumHeight;
        int i10 = this.f22141c;
        if (i10 != -1) {
            return i10;
        }
        int i11 = 0;
        for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
            View childAt = getChildAt(childCount);
            if (childAt.getVisibility() != 8) {
                k kVar = (k) childAt.getLayoutParams();
                int measuredHeight = childAt.getMeasuredHeight();
                int i12 = kVar.f22201a;
                if ((i12 & 5) != 5) {
                    if (i11 > 0) {
                        break;
                    }
                } else {
                    int i13 = ((LinearLayout.LayoutParams) kVar).topMargin + ((LinearLayout.LayoutParams) kVar).bottomMargin;
                    if ((i12 & 8) != 0) {
                        minimumHeight = childAt.getMinimumHeight();
                    } else if ((i12 & 2) != 0) {
                        minimumHeight = measuredHeight - childAt.getMinimumHeight();
                    } else {
                        iMin = i13 + measuredHeight;
                        if (childCount == 0 && childAt.getFitsSystemWindows()) {
                            iMin = Math.min(iMin, measuredHeight - getTopInset());
                        }
                        i11 += iMin;
                    }
                    iMin = minimumHeight + i13;
                    if (childCount == 0) {
                        iMin = Math.min(iMin, measuredHeight - getTopInset());
                    }
                    i11 += iMin;
                }
            }
        }
        int iMax = Math.max(0, i11);
        this.f22141c = iMax;
        return iMax;
    }

    public int getDownNestedScrollRange() {
        int i10 = this.f22142d;
        if (i10 != -1) {
            return i10;
        }
        int childCount = getChildCount();
        int i11 = 0;
        int minimumHeight = 0;
        while (true) {
            if (i11 >= childCount) {
                break;
            }
            View childAt = getChildAt(i11);
            if (childAt.getVisibility() != 8) {
                k kVar = (k) childAt.getLayoutParams();
                int measuredHeight = ((LinearLayout.LayoutParams) kVar).topMargin + ((LinearLayout.LayoutParams) kVar).bottomMargin + childAt.getMeasuredHeight();
                int i12 = kVar.f22201a;
                if ((i12 & 1) == 0) {
                    break;
                }
                minimumHeight += measuredHeight;
                if ((i12 & 2) != 0) {
                    minimumHeight -= childAt.getMinimumHeight();
                    break;
                }
            }
            i11++;
        }
        int iMax = Math.max(0, minimumHeight);
        this.f22142d = iMax;
        return iMax;
    }

    @IdRes
    public int getLiftOnScrollTargetViewId() {
        return this.f22150l;
    }

    @Nullable
    public com.google.android.material.shape.k getMaterialShapeBackground() {
        Drawable background = getBackground();
        if (background instanceof com.google.android.material.shape.k) {
            return (com.google.android.material.shape.k) background;
        }
        return null;
    }

    public final int getMinimumHeightForVisibleOverlappingContent() {
        int topInset = getTopInset();
        int minimumHeight = getMinimumHeight();
        if (minimumHeight != 0) {
            int i10 = (minimumHeight * 2) + topInset;
            return i10 < getHeight() ? i10 : minimumHeight + topInset;
        }
        int childCount = getChildCount();
        int minimumHeight2 = childCount >= 1 ? getChildAt(childCount - 1).getMinimumHeight() : 0;
        if (minimumHeight2 == 0) {
            return getHeight() / 3;
        }
        int i11 = (minimumHeight2 * 2) + topInset;
        return i11 < getHeight() ? i11 : minimumHeight2 + topInset;
    }

    public int getPendingAction() {
        return this.f22144f;
    }

    @Nullable
    public Drawable getStatusBarForeground() {
        return this.statusBarForeground;
    }

    @Deprecated
    public float getTargetElevation() {
        return 0.0f;
    }

    @VisibleForTesting
    public final int getTopInset() {
        f3 f3Var = this.lastInsets;
        if (f3Var != null) {
            return f3Var.d();
        }
        return 0;
    }

    public final int getTotalScrollRange() {
        int i10 = this.f22140b;
        if (i10 != -1) {
            return i10;
        }
        int childCount = getChildCount();
        int i11 = 0;
        int minimumHeight = 0;
        while (true) {
            if (i11 >= childCount) {
                break;
            }
            View childAt = getChildAt(i11);
            if (childAt.getVisibility() != 8) {
                k kVar = (k) childAt.getLayoutParams();
                int measuredHeight = childAt.getMeasuredHeight();
                int i12 = kVar.f22201a;
                if ((i12 & 1) == 0) {
                    break;
                }
                int topInset = measuredHeight + ((LinearLayout.LayoutParams) kVar).topMargin + ((LinearLayout.LayoutParams) kVar).bottomMargin + minimumHeight;
                if (i11 == 0 && childAt.getFitsSystemWindows()) {
                    topInset -= getTopInset();
                }
                minimumHeight = topInset;
                if ((i12 & 2) != 0) {
                    minimumHeight -= childAt.getMinimumHeight();
                    break;
                }
            }
            i11++;
        }
        int iMax = Math.max(0, minimumHeight);
        this.f22140b = iMax;
        return iMax;
    }

    public int getUpNestedPreScrollRange() {
        return getTotalScrollRange();
    }

    public final void h(float f10, float f11) {
        ValueAnimator valueAnimator = this.liftOnScrollColorAnimator;
        if (valueAnimator != null) {
            valueAnimator.cancel();
        }
        ValueAnimator valueAnimatorOfFloat = ValueAnimator.ofFloat(f10, f11);
        this.liftOnScrollColorAnimator = valueAnimatorOfFloat;
        valueAnimatorOfFloat.setDuration(this.R);
        this.liftOnScrollColorAnimator.setInterpolator(this.S);
        ValueAnimator.AnimatorUpdateListener animatorUpdateListener = this.liftOnScrollColorUpdateListener;
        if (animatorUpdateListener != null) {
            this.liftOnScrollColorAnimator.addUpdateListener(animatorUpdateListener);
        }
        this.liftOnScrollColorAnimator.start();
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onAttachedToWindow() {
        super.onAttachedToWindow();
        com.bumptech.glide.f.u(this);
    }

    @Override // android.view.ViewGroup, android.view.View
    public final int[] onCreateDrawableState(int i10) {
        if (this.T == null) {
            this.T = new int[4];
        }
        int[] iArr = this.T;
        int[] iArrOnCreateDrawableState = super.onCreateDrawableState(i10 + iArr.length);
        boolean z10 = this.f22147i;
        int i11 = x8.c.state_liftable;
        if (!z10) {
            i11 = -i11;
        }
        iArr[0] = i11;
        iArr[1] = (z10 && this.f22148j) ? x8.c.state_lifted : -x8.c.state_lifted;
        int i12 = x8.c.state_collapsible;
        if (!z10) {
            i12 = -i12;
        }
        iArr[2] = i12;
        iArr[3] = (z10 && this.f22148j) ? x8.c.state_collapsed : -x8.c.state_collapsed;
        return View.mergeDrawableStates(iArrOnCreateDrawableState, iArr);
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        WeakReference<View> weakReference = this.liftOnScrollTargetView;
        if (weakReference != null) {
            weakReference.clear();
        }
        this.liftOnScrollTargetView = null;
    }

    @Override // android.widget.LinearLayout, android.view.ViewGroup, android.view.View
    public final void onLayout(boolean z10, int i10, int i11, int i12, int i13) {
        super.onLayout(z10, i10, i11, i12, i13);
        boolean z11 = false;
        if (getFitsSystemWindows() && getChildCount() > 0) {
            View childAt = getChildAt(0);
            if (childAt.getVisibility() != 8 && !childAt.getFitsSystemWindows()) {
                int topInset = getTopInset();
                for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
                    View childAt2 = getChildAt(childCount);
                    WeakHashMap weakHashMap = s1.f1815a;
                    childAt2.offsetTopAndBottom(topInset);
                }
            }
        }
        d();
        this.f22143e = false;
        int childCount2 = getChildCount();
        int i14 = 0;
        while (true) {
            if (i14 >= childCount2) {
                break;
            }
            if (((k) getChildAt(i14).getLayoutParams()).f22203c != null) {
                this.f22143e = true;
                break;
            }
            i14++;
        }
        Drawable drawable = this.statusBarForeground;
        if (drawable != null) {
            drawable.setBounds(0, 0, getWidth(), getTopInset());
        }
        if (this.f22146h) {
            return;
        }
        if (this.f22149k) {
            z11 = true;
            break;
        }
        int childCount3 = getChildCount();
        for (int i15 = 0; i15 < childCount3; i15++) {
            int i16 = ((k) getChildAt(i15).getLayoutParams()).f22201a;
            if ((i16 & 1) == 1 && (i16 & 10) != 0) {
                z11 = true;
                break;
            }
        }
        if (this.f22147i != z11) {
            this.f22147i = z11;
            refreshDrawableState();
        }
    }

    @Override // android.widget.LinearLayout, android.view.View
    public final void onMeasure(int i10, int i11) {
        super.onMeasure(i10, i11);
        int mode = View.MeasureSpec.getMode(i11);
        if (mode != 1073741824 && getFitsSystemWindows() && getChildCount() > 0) {
            View childAt = getChildAt(0);
            if (childAt.getVisibility() != 8 && !childAt.getFitsSystemWindows()) {
                int measuredHeight = getMeasuredHeight();
                if (mode == Integer.MIN_VALUE) {
                    measuredHeight = y.h(getTopInset() + getMeasuredHeight(), 0, View.MeasureSpec.getSize(i11));
                } else if (mode == 0) {
                    measuredHeight += getTopInset();
                }
                setMeasuredDimension(getMeasuredWidth(), measuredHeight);
            }
        }
        d();
    }

    public void removeOnOffsetChangedListener(@Nullable h hVar) {
        ArrayList arrayList = this.f22145g;
        if (arrayList == null || hVar == null) {
            return;
        }
        arrayList.remove(hVar);
    }

    @Override // android.view.View
    public void setBackground(Drawable drawable) {
        Context context = getContext();
        final com.google.android.material.shape.k kVarMaybeConvertToMaterialShapeDrawable = maybeConvertToMaterialShapeDrawable(drawable);
        if (kVarMaybeConvertToMaterialShapeDrawable != null && kVarMaybeConvertToMaterialShapeDrawable.getFillColor() != null) {
            this.U = kVarMaybeConvertToMaterialShapeDrawable.getFillColor().getDefaultColor();
            final ColorStateList colorStateList = this.liftOnScrollColor;
            if (colorStateList != null) {
                final Integer colorOrNull = h9.a.getColorOrNull(getContext(), x8.c.colorSurface);
                this.liftOnScrollColorUpdateListener = new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.appbar.a
                    @Override // android.animation.ValueAnimator.AnimatorUpdateListener
                    public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                        AppBarLayout.a(this.f22182a, colorStateList, kVarMaybeConvertToMaterialShapeDrawable, colorOrNull, valueAnimator);
                    }
                };
            } else {
                kVarMaybeConvertToMaterialShapeDrawable.s(context);
                this.liftOnScrollColorUpdateListener = new x1(this, kVarMaybeConvertToMaterialShapeDrawable, 1);
            }
            drawable = kVarMaybeConvertToMaterialShapeDrawable;
        }
        super.setBackground(drawable);
    }

    @Override // android.view.View
    public void setElevation(float f10) {
        super.setElevation(f10);
        com.bumptech.glide.f.t(this, f10);
    }

    public void setExpanded(boolean z10) {
        setExpanded(z10, isLaidOut());
    }

    public void setLiftOnScroll(boolean z10) {
        this.f22149k = z10;
    }

    public void setLiftOnScrollColor(@Nullable ColorStateList colorStateList) {
        if (this.liftOnScrollColor != colorStateList) {
            this.liftOnScrollColor = colorStateList;
            setBackground(getBackground());
        }
    }

    public void setLiftOnScrollTargetView(@Nullable View view) {
        this.f22150l = -1;
        if (view != null) {
            this.liftOnScrollTargetView = new WeakReference<>(view);
            return;
        }
        WeakReference<View> weakReference = this.liftOnScrollTargetView;
        if (weakReference != null) {
            weakReference.clear();
        }
        this.liftOnScrollTargetView = null;
    }

    public void setLiftOnScrollTargetViewId(@IdRes int i10) {
        this.f22150l = i10;
        WeakReference<View> weakReference = this.liftOnScrollTargetView;
        if (weakReference != null) {
            weakReference.clear();
        }
        this.liftOnScrollTargetView = null;
    }

    public void setLiftableOverrideEnabled(boolean z10) {
        this.f22146h = z10;
    }

    @Override // android.widget.LinearLayout
    public void setOrientation(int i10) {
        if (i10 != 1) {
            throw new IllegalArgumentException("AppBarLayout is always vertical and does not support horizontal orientation");
        }
        super.setOrientation(i10);
    }

    public void setPendingAction(int i10) {
        this.f22144f = i10;
    }

    public void setStatusBarForeground(@Nullable Drawable drawable) {
        Drawable drawable2 = this.statusBarForeground;
        if (drawable2 != drawable) {
            if (drawable2 != null) {
                drawable2.setCallback(null);
            }
            this.statusBarForeground = drawable != null ? drawable.mutate() : null;
            this.statusBarForegroundOriginalColor = extractStatusBarForegroundColor();
            Drawable drawable3 = this.statusBarForeground;
            boolean z10 = false;
            if (drawable3 != null) {
                if (drawable3.isStateful()) {
                    this.statusBarForeground.setState(getDrawableState());
                }
                this.statusBarForeground.setLayoutDirection(getLayoutDirection());
                this.statusBarForeground.setVisible(getVisibility() == 0, false);
                this.statusBarForeground.setCallback(this);
            }
            if (this.statusBarForeground != null && getTopInset() > 0) {
                z10 = true;
            }
            setWillNotDraw(!z10);
            postInvalidateOnAnimation();
        }
    }

    public void setStatusBarForegroundColor(@ColorInt int i10) {
        setStatusBarForeground(new ColorDrawable(i10));
    }

    public void setStatusBarForegroundResource(@DrawableRes int i10) {
        setStatusBarForeground(f.a.getDrawable(getContext(), i10));
    }

    @Deprecated
    public void setTargetElevation(float f10) {
        t.a(f10, this);
    }

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

    public boolean shouldLift(@Nullable View view) {
        View viewFindLiftOnScrollTargetView = findLiftOnScrollTargetView(view);
        if (viewFindLiftOnScrollTargetView != null) {
            view = viewFindLiftOnScrollTargetView;
        }
        return view != null && (view.canScrollVertically(-1) || view.getScrollY() > 0);
    }

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

    public AppBarLayout(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, x8.c.appBarLayoutStyle);
    }

    @Override // android.widget.LinearLayout, android.view.ViewGroup
    public final /* bridge */ /* synthetic */ LinearLayout.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return c(layoutParams);
    }

    public void setExpanded(boolean z10, boolean z11) {
        this.f22144f = (z10 ? 1 : 2) | (z11 ? 4 : 0) | 8;
        requestLayout();
    }

    /* JADX WARN: Finally extract failed */
    /* JADX WARN: Illegal instructions before constructor call */
    public AppBarLayout(@NonNull Context context, @Nullable AttributeSet attributeSet, int i10) {
        int i11 = f22138a0;
        super(x9.a.wrap(context, attributeSet, i10, i11), attributeSet, i10);
        this.f22140b = -1;
        this.f22141c = -1;
        this.f22142d = -1;
        this.f22144f = 0;
        this.f22151m = new ArrayList();
        this.Q = new LinkedHashSet();
        Context context2 = getContext();
        setOrientation(1);
        if (getOutlineProvider() == ViewOutlineProvider.BACKGROUND) {
            setOutlineProvider(ViewOutlineProvider.BOUNDS);
        }
        Context context3 = getContext();
        TypedArray typedArrayC = q0.c(context3, attributeSet, t.f22223a, i10, i11, new int[0]);
        try {
            if (typedArrayC.hasValue(0)) {
                setStateListAnimator(AnimatorInflater.loadStateListAnimator(context3, typedArrayC.getResourceId(0, 0)));
            }
            typedArrayC.recycle();
            TypedArray typedArrayC2 = q0.c(context2, attributeSet, x8.m.AppBarLayout, i10, i11, new int[0]);
            this.liftOnScrollColor = q9.d.getColorStateList(context2, typedArrayC2, x8.m.AppBarLayout_liftOnScrollColor);
            this.R = com.bumptech.glide.f.o(context2, x8.c.motionDurationMedium2, getResources().getInteger(x8.h.app_bar_elevation_anim_duration));
            this.S = com.bumptech.glide.f.p(context2, x8.c.motionEasingStandardInterpolator, y8.a.f36864a);
            int i12 = x8.m.AppBarLayout_expanded;
            if (typedArrayC2.hasValue(i12)) {
                this.f22144f = typedArrayC2.getBoolean(i12, false) ? 1 : 2;
                requestLayout();
            }
            if (typedArrayC2.hasValue(x8.m.AppBarLayout_elevation)) {
                t.a(typedArrayC2.getDimensionPixelSize(r14, 0), this);
            }
            setBackground(typedArrayC2.getDrawable(x8.m.AppBarLayout_android_background));
            if (Build.VERSION.SDK_INT >= 26) {
                int i13 = x8.m.AppBarLayout_android_keyboardNavigationCluster;
                if (typedArrayC2.hasValue(i13)) {
                    setKeyboardNavigationCluster(typedArrayC2.getBoolean(i13, false));
                }
                int i14 = x8.m.AppBarLayout_android_touchscreenBlocksFocus;
                if (typedArrayC2.hasValue(i14)) {
                    setTouchscreenBlocksFocus(typedArrayC2.getBoolean(i14, false));
                }
            }
            this.V = getResources().getDimension(x8.e.design_appbar_elevation);
            this.f22149k = typedArrayC2.getBoolean(x8.m.AppBarLayout_liftOnScroll, false);
            this.f22150l = typedArrayC2.getResourceId(x8.m.AppBarLayout_liftOnScrollTargetViewId, -1);
            setStatusBarForeground(typedArrayC2.getDrawable(x8.m.AppBarLayout_statusBarForeground));
            typedArrayC2.recycle();
            s1.setOnApplyWindowInsetsListener(this, new b(this, 0));
        } catch (Throwable th) {
            typedArrayC.recycle();
            throw th;
        }
    }

    @Override // android.widget.LinearLayout, android.view.ViewGroup
    public final LinearLayout.LayoutParams generateDefaultLayoutParams() {
        k kVar = new k(-1, -2);
        kVar.f22201a = 1;
        return kVar;
    }

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

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