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.Paint;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewTreeObserver;
import androidx.core.view.j0;
import androidx.core.view.o;
import androidx.core.view.p;
import androidx.core.view.r;
import androidx.core.view.s;
import androidx.core.view.y;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/* JADX INFO: loaded from: classes.dex */
public class CoordinatorLayout extends ViewGroup implements o, p {
    static final ThreadLocal<Map<String, Constructor<c>>> A;
    static final Comparator<View> B;
    private static final androidx.core.util.e<Rect> C;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    static final String f1550y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    static final Class<?>[] f1551z;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private final List<View> f1552e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private final androidx.coordinatorlayout.widget.a<View> f1553f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private final List<View> f1554g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private final List<View> f1555h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private Paint f1556i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private final int[] f1557j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private final int[] f1558k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    private boolean f1559l;

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

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    private int[] f1561n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    private View f1562o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    private View f1563p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    private g f1564q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    private boolean f1565r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    private j0 f1566s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    private boolean f1567t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    private Drawable f1568u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    ViewGroup.OnHierarchyChangeListener f1569v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    private s f1570w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    private final r f1571x;

    class a implements s {
        a() {
        }

        @Override // androidx.core.view.s
        public j0 a(View view, j0 j0Var) {
            return CoordinatorLayout.this.W(j0Var);
        }
    }

    public interface b {
        c getBehavior();
    }

    public static abstract class c<V extends View> {
        public c() {
        }

        public boolean A(CoordinatorLayout coordinatorLayout, V v2, View view, View view2, int i3, int i4) {
            if (i4 == 0) {
                return z(coordinatorLayout, v2, view, view2, i3);
            }
            return false;
        }

        @Deprecated
        public void B(CoordinatorLayout coordinatorLayout, V v2, View view) {
        }

        public void C(CoordinatorLayout coordinatorLayout, V v2, View view, int i3) {
            if (i3 == 0) {
                B(coordinatorLayout, v2, view);
            }
        }

        public boolean D(CoordinatorLayout coordinatorLayout, V v2, MotionEvent motionEvent) {
            return false;
        }

        public boolean a(CoordinatorLayout coordinatorLayout, V v2) {
            return d(coordinatorLayout, v2) > 0.0f;
        }

        public boolean b(CoordinatorLayout coordinatorLayout, V v2, Rect rect) {
            return false;
        }

        public int c(CoordinatorLayout coordinatorLayout, V v2) {
            return -16777216;
        }

        public float d(CoordinatorLayout coordinatorLayout, V v2) {
            return 0.0f;
        }

        public boolean e(CoordinatorLayout coordinatorLayout, V v2, View view) {
            return false;
        }

        public j0 f(CoordinatorLayout coordinatorLayout, V v2, j0 j0Var) {
            return j0Var;
        }

        public void g(f fVar) {
        }

        public boolean h(CoordinatorLayout coordinatorLayout, V v2, View view) {
            return false;
        }

        public void i(CoordinatorLayout coordinatorLayout, V v2, View view) {
        }

        public void j() {
        }

        public boolean k(CoordinatorLayout coordinatorLayout, V v2, MotionEvent motionEvent) {
            return false;
        }

        public boolean l(CoordinatorLayout coordinatorLayout, V v2, int i3) {
            return false;
        }

        public boolean m(CoordinatorLayout coordinatorLayout, V v2, int i3, int i4, int i5, int i6) {
            return false;
        }

        public boolean n(CoordinatorLayout coordinatorLayout, V v2, View view, float f3, float f4, boolean z2) {
            return false;
        }

        public boolean o(CoordinatorLayout coordinatorLayout, V v2, View view, float f3, float f4) {
            return false;
        }

        @Deprecated
        public void p(CoordinatorLayout coordinatorLayout, V v2, View view, int i3, int i4, int[] iArr) {
        }

        public void q(CoordinatorLayout coordinatorLayout, V v2, View view, int i3, int i4, int[] iArr, int i5) {
            if (i5 == 0) {
                p(coordinatorLayout, v2, view, i3, i4, iArr);
            }
        }

        @Deprecated
        public void r(CoordinatorLayout coordinatorLayout, V v2, View view, int i3, int i4, int i5, int i6) {
        }

        @Deprecated
        public void s(CoordinatorLayout coordinatorLayout, V v2, View view, int i3, int i4, int i5, int i6, int i7) {
            if (i7 == 0) {
                r(coordinatorLayout, v2, view, i3, i4, i5, i6);
            }
        }

        public void t(CoordinatorLayout coordinatorLayout, V v2, View view, int i3, int i4, int i5, int i6, int i7, int[] iArr) {
            iArr[0] = iArr[0] + i5;
            iArr[1] = iArr[1] + i6;
            s(coordinatorLayout, v2, view, i3, i4, i5, i6, i7);
        }

        @Deprecated
        public void u(CoordinatorLayout coordinatorLayout, V v2, View view, View view2, int i3) {
        }

        public void v(CoordinatorLayout coordinatorLayout, V v2, View view, View view2, int i3, int i4) {
            if (i4 == 0) {
                u(coordinatorLayout, v2, view, view2, i3);
            }
        }

        public boolean w(CoordinatorLayout coordinatorLayout, V v2, Rect rect, boolean z2) {
            return false;
        }

        public void x(CoordinatorLayout coordinatorLayout, V v2, Parcelable parcelable) {
        }

        public Parcelable y(CoordinatorLayout coordinatorLayout, V v2) {
            return View.BaseSavedState.EMPTY_STATE;
        }

        @Deprecated
        public boolean z(CoordinatorLayout coordinatorLayout, V v2, View view, View view2, int i3) {
            return false;
        }

        public c(Context context, AttributeSet attributeSet) {
        }
    }

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

    private class e implements ViewGroup.OnHierarchyChangeListener {
        e() {
        }

        @Override // android.view.ViewGroup.OnHierarchyChangeListener
        public void onChildViewAdded(View view, View view2) {
            ViewGroup.OnHierarchyChangeListener onHierarchyChangeListener = CoordinatorLayout.this.f1569v;
            if (onHierarchyChangeListener != null) {
                onHierarchyChangeListener.onChildViewAdded(view, view2);
            }
        }

        @Override // android.view.ViewGroup.OnHierarchyChangeListener
        public void onChildViewRemoved(View view, View view2) {
            CoordinatorLayout.this.H(2);
            ViewGroup.OnHierarchyChangeListener onHierarchyChangeListener = CoordinatorLayout.this.f1569v;
            if (onHierarchyChangeListener != null) {
                onHierarchyChangeListener.onChildViewRemoved(view, view2);
            }
        }
    }

    class g implements ViewTreeObserver.OnPreDrawListener {
        g() {
        }

        @Override // android.view.ViewTreeObserver.OnPreDrawListener
        public boolean onPreDraw() {
            CoordinatorLayout.this.H(0);
            return true;
        }
    }

    static class i implements Comparator<View> {
        i() {
        }

        @Override // java.util.Comparator
        /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
        public int compare(View view, View view2) {
            float fO = y.O(view);
            float fO2 = y.O(view2);
            if (fO > fO2) {
                return -1;
            }
            return fO < fO2 ? 1 : 0;
        }
    }

    static {
        Package r02 = CoordinatorLayout.class.getPackage();
        f1550y = r02 != null ? r02.getName() : null;
        if (Build.VERSION.SDK_INT >= 21) {
            B = new i();
        } else {
            B = null;
        }
        f1551z = new Class[]{Context.class, AttributeSet.class};
        A = new ThreadLocal<>();
        C = new androidx.core.util.g(12);
    }

    public CoordinatorLayout(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, q.a.f5772a);
    }

    private boolean A(View view) {
        return this.f1553f.j(view);
    }

    private void C(View view, int i3) {
        f fVar = (f) view.getLayoutParams();
        Rect rectA = a();
        rectA.set(getPaddingLeft() + ((ViewGroup.MarginLayoutParams) fVar).leftMargin, getPaddingTop() + ((ViewGroup.MarginLayoutParams) fVar).topMargin, (getWidth() - getPaddingRight()) - ((ViewGroup.MarginLayoutParams) fVar).rightMargin, (getHeight() - getPaddingBottom()) - ((ViewGroup.MarginLayoutParams) fVar).bottomMargin);
        if (this.f1566s != null && y.B(this) && !y.B(view)) {
            rectA.left += this.f1566s.i();
            rectA.top += this.f1566s.k();
            rectA.right -= this.f1566s.j();
            rectA.bottom -= this.f1566s.h();
        }
        Rect rectA2 = a();
        androidx.core.view.e.a(S(fVar.f1576c), view.getMeasuredWidth(), view.getMeasuredHeight(), rectA, rectA2, i3);
        view.layout(rectA2.left, rectA2.top, rectA2.right, rectA2.bottom);
        O(rectA);
        O(rectA2);
    }

    private void D(View view, View view2, int i3) {
        Rect rectA = a();
        Rect rectA2 = a();
        try {
            t(view2, rectA);
            u(view, i3, rectA, rectA2);
            view.layout(rectA2.left, rectA2.top, rectA2.right, rectA2.bottom);
        } finally {
            O(rectA);
            O(rectA2);
        }
    }

    private void E(View view, int i3, int i4) {
        f fVar = (f) view.getLayoutParams();
        int iB = androidx.core.view.e.b(T(fVar.f1576c), i4);
        int i5 = iB & 7;
        int i6 = iB & 112;
        int width = getWidth();
        int height = getHeight();
        int measuredWidth = view.getMeasuredWidth();
        int measuredHeight = view.getMeasuredHeight();
        if (i4 == 1) {
            i3 = width - i3;
        }
        int iW = w(i3) - measuredWidth;
        int i7 = 0;
        if (i5 == 1) {
            iW += measuredWidth / 2;
        } else if (i5 == 5) {
            iW += measuredWidth;
        }
        if (i6 == 16) {
            i7 = 0 + (measuredHeight / 2);
        } else if (i6 == 80) {
            i7 = measuredHeight + 0;
        }
        int iMax = Math.max(getPaddingLeft() + ((ViewGroup.MarginLayoutParams) fVar).leftMargin, Math.min(iW, ((width - getPaddingRight()) - measuredWidth) - ((ViewGroup.MarginLayoutParams) fVar).rightMargin));
        int iMax2 = Math.max(getPaddingTop() + ((ViewGroup.MarginLayoutParams) fVar).topMargin, Math.min(i7, ((height - getPaddingBottom()) - measuredHeight) - ((ViewGroup.MarginLayoutParams) fVar).bottomMargin));
        view.layout(iMax, iMax2, measuredWidth + iMax, measuredHeight + iMax2);
    }

    private void F(View view, Rect rect, int i3) {
        boolean z2;
        boolean z3;
        int width;
        int i4;
        int i5;
        int i6;
        int height;
        int i7;
        int i8;
        int i9;
        if (y.V(view) && view.getWidth() > 0 && view.getHeight() > 0) {
            f fVar = (f) view.getLayoutParams();
            c cVarF = fVar.f();
            Rect rectA = a();
            Rect rectA2 = a();
            rectA2.set(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
            if (cVarF == null || !cVarF.b(this, view, rectA)) {
                rectA.set(rectA2);
            } else if (!rectA2.contains(rectA)) {
                throw new IllegalArgumentException("Rect should be within the child's bounds. Rect:" + rectA.toShortString() + " | Bounds:" + rectA2.toShortString());
            }
            O(rectA2);
            if (rectA.isEmpty()) {
                O(rectA);
                return;
            }
            int iB = androidx.core.view.e.b(fVar.f1581h, i3);
            boolean z4 = true;
            if ((iB & 48) != 48 || (i8 = (rectA.top - ((ViewGroup.MarginLayoutParams) fVar).topMargin) - fVar.f1583j) >= (i9 = rect.top)) {
                z2 = false;
            } else {
                V(view, i9 - i8);
                z2 = true;
            }
            if ((iB & 80) == 80 && (height = ((getHeight() - rectA.bottom) - ((ViewGroup.MarginLayoutParams) fVar).bottomMargin) + fVar.f1583j) < (i7 = rect.bottom)) {
                V(view, height - i7);
                z2 = true;
            }
            if (!z2) {
                V(view, 0);
            }
            if ((iB & 3) != 3 || (i5 = (rectA.left - ((ViewGroup.MarginLayoutParams) fVar).leftMargin) - fVar.f1582i) >= (i6 = rect.left)) {
                z3 = false;
            } else {
                U(view, i6 - i5);
                z3 = true;
            }
            if ((iB & 5) != 5 || (width = ((getWidth() - rectA.right) - ((ViewGroup.MarginLayoutParams) fVar).rightMargin) + fVar.f1582i) >= (i4 = rect.right)) {
                z4 = z3;
            } else {
                U(view, width - i4);
            }
            if (!z4) {
                U(view, 0);
            }
            O(rectA);
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    static c K(Context context, AttributeSet attributeSet, String str) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        if (str.startsWith(".")) {
            str = context.getPackageName() + str;
        } else if (str.indexOf(46) < 0) {
            String str2 = f1550y;
            if (!TextUtils.isEmpty(str2)) {
                str = str2 + '.' + str;
            }
        }
        try {
            ThreadLocal<Map<String, Constructor<c>>> threadLocal = A;
            Map<String, Constructor<c>> map = threadLocal.get();
            if (map == null) {
                map = new HashMap<>();
                threadLocal.set(map);
            }
            Constructor<c> constructor = map.get(str);
            if (constructor == null) {
                constructor = Class.forName(str, false, context.getClassLoader()).getConstructor(f1551z);
                constructor.setAccessible(true);
                map.put(str, constructor);
            }
            return constructor.newInstance(context, attributeSet);
        } catch (Exception e3) {
            throw new RuntimeException("Could not inflate Behavior subclass " + str, e3);
        }
    }

    private boolean L(MotionEvent motionEvent, int i3) {
        int actionMasked = motionEvent.getActionMasked();
        List<View> list = this.f1554g;
        z(list);
        int size = list.size();
        MotionEvent motionEventObtain = null;
        boolean zK = false;
        boolean z2 = false;
        for (int i4 = 0; i4 < size; i4++) {
            View view = list.get(i4);
            f fVar = (f) view.getLayoutParams();
            c cVarF = fVar.f();
            if (!(zK || z2) || actionMasked == 0) {
                if (!zK && cVarF != null) {
                    if (i3 == 0) {
                        zK = cVarF.k(this, view, motionEvent);
                    } else if (i3 == 1) {
                        zK = cVarF.D(this, view, motionEvent);
                    }
                    if (zK) {
                        this.f1562o = view;
                    }
                }
                boolean zC = fVar.c();
                boolean zI = fVar.i(this, view);
                z2 = zI && !zC;
                if (zI && !z2) {
                    break;
                }
            } else if (cVarF != null) {
                if (motionEventObtain == null) {
                    long jUptimeMillis = SystemClock.uptimeMillis();
                    motionEventObtain = MotionEvent.obtain(jUptimeMillis, jUptimeMillis, 3, 0.0f, 0.0f, 0);
                }
                if (i3 == 0) {
                    cVarF.k(this, view, motionEventObtain);
                } else if (i3 == 1) {
                    cVarF.D(this, view, motionEventObtain);
                }
            }
        }
        list.clear();
        return zK;
    }

    private void M() {
        this.f1552e.clear();
        this.f1553f.c();
        int childCount = getChildCount();
        for (int i3 = 0; i3 < childCount; i3++) {
            View childAt = getChildAt(i3);
            f fVarY = y(childAt);
            fVarY.d(this, childAt);
            this.f1553f.b(childAt);
            for (int i4 = 0; i4 < childCount; i4++) {
                if (i4 != i3) {
                    View childAt2 = getChildAt(i4);
                    if (fVarY.b(this, childAt, childAt2)) {
                        if (!this.f1553f.d(childAt2)) {
                            this.f1553f.b(childAt2);
                        }
                        this.f1553f.a(childAt2, childAt);
                    }
                }
            }
        }
        this.f1552e.addAll(this.f1553f.i());
        Collections.reverse(this.f1552e);
    }

    private static void O(Rect rect) {
        rect.setEmpty();
        C.a(rect);
    }

    private void Q(boolean z2) {
        int childCount = getChildCount();
        for (int i3 = 0; i3 < childCount; i3++) {
            View childAt = getChildAt(i3);
            c cVarF = ((f) childAt.getLayoutParams()).f();
            if (cVarF != null) {
                long jUptimeMillis = SystemClock.uptimeMillis();
                MotionEvent motionEventObtain = MotionEvent.obtain(jUptimeMillis, jUptimeMillis, 3, 0.0f, 0.0f, 0);
                if (z2) {
                    cVarF.k(this, childAt, motionEventObtain);
                } else {
                    cVarF.D(this, childAt, motionEventObtain);
                }
                motionEventObtain.recycle();
            }
        }
        for (int i4 = 0; i4 < childCount; i4++) {
            ((f) getChildAt(i4).getLayoutParams()).m();
        }
        this.f1562o = null;
        this.f1559l = false;
    }

    private static int R(int i3) {
        if (i3 == 0) {
            return 17;
        }
        return i3;
    }

    private static int S(int i3) {
        if ((i3 & 7) == 0) {
            i3 |= 8388611;
        }
        return (i3 & 112) == 0 ? i3 | 48 : i3;
    }

    private static int T(int i3) {
        if (i3 == 0) {
            return 8388661;
        }
        return i3;
    }

    private void U(View view, int i3) {
        f fVar = (f) view.getLayoutParams();
        int i4 = fVar.f1582i;
        if (i4 != i3) {
            y.b0(view, i3 - i4);
            fVar.f1582i = i3;
        }
    }

    private void V(View view, int i3) {
        f fVar = (f) view.getLayoutParams();
        int i4 = fVar.f1583j;
        if (i4 != i3) {
            y.c0(view, i3 - i4);
            fVar.f1583j = i3;
        }
    }

    private void X() {
        if (Build.VERSION.SDK_INT < 21) {
            return;
        }
        if (!y.B(this)) {
            y.D0(this, null);
            return;
        }
        if (this.f1570w == null) {
            this.f1570w = new a();
        }
        y.D0(this, this.f1570w);
        setSystemUiVisibility(1280);
    }

    private static Rect a() {
        Rect rectB = C.b();
        return rectB == null ? new Rect() : rectB;
    }

    private static int c(int i3, int i4, int i5) {
        return i3 < i4 ? i4 : i3 > i5 ? i5 : i3;
    }

    private void e(f fVar, Rect rect, int i3, int i4) {
        int width = getWidth();
        int height = getHeight();
        int iMax = Math.max(getPaddingLeft() + ((ViewGroup.MarginLayoutParams) fVar).leftMargin, Math.min(rect.left, ((width - getPaddingRight()) - i3) - ((ViewGroup.MarginLayoutParams) fVar).rightMargin));
        int iMax2 = Math.max(getPaddingTop() + ((ViewGroup.MarginLayoutParams) fVar).topMargin, Math.min(rect.top, ((height - getPaddingBottom()) - i4) - ((ViewGroup.MarginLayoutParams) fVar).bottomMargin));
        rect.set(iMax, iMax2, i3 + iMax, i4 + iMax2);
    }

    private j0 f(j0 j0Var) {
        c cVarF;
        if (j0Var.n()) {
            return j0Var;
        }
        int childCount = getChildCount();
        for (int i3 = 0; i3 < childCount; i3++) {
            View childAt = getChildAt(i3);
            if (y.B(childAt) && (cVarF = ((f) childAt.getLayoutParams()).f()) != null) {
                j0Var = cVarF.f(this, childAt, j0Var);
                if (j0Var.n()) {
                    break;
                }
            }
        }
        return j0Var;
    }

    private void v(View view, int i3, Rect rect, Rect rect2, f fVar, int i4, int i5) {
        int iB = androidx.core.view.e.b(R(fVar.f1576c), i3);
        int iB2 = androidx.core.view.e.b(S(fVar.f1577d), i3);
        int i6 = iB & 7;
        int i7 = iB & 112;
        int i8 = iB2 & 7;
        int i9 = iB2 & 112;
        int iWidth = i8 != 1 ? i8 != 5 ? rect.left : rect.right : rect.left + (rect.width() / 2);
        int iHeight = i9 != 16 ? i9 != 80 ? rect.top : rect.bottom : rect.top + (rect.height() / 2);
        if (i6 == 1) {
            iWidth -= i4 / 2;
        } else if (i6 != 5) {
            iWidth -= i4;
        }
        if (i7 == 16) {
            iHeight -= i5 / 2;
        } else if (i7 != 80) {
            iHeight -= i5;
        }
        rect2.set(iWidth, iHeight, i4 + iWidth, i5 + iHeight);
    }

    private int w(int i3) {
        int[] iArr = this.f1561n;
        if (iArr == null) {
            Log.e("CoordinatorLayout", "No keylines defined for " + this + " - attempted index lookup " + i3);
            return 0;
        }
        if (i3 >= 0 && i3 < iArr.length) {
            return iArr[i3];
        }
        Log.e("CoordinatorLayout", "Keyline index " + i3 + " out of range for " + this);
        return 0;
    }

    private void z(List<View> list) {
        list.clear();
        boolean zIsChildrenDrawingOrderEnabled = isChildrenDrawingOrderEnabled();
        int childCount = getChildCount();
        for (int i3 = childCount - 1; i3 >= 0; i3--) {
            list.add(getChildAt(zIsChildrenDrawingOrderEnabled ? getChildDrawingOrder(childCount, i3) : i3));
        }
        Comparator<View> comparator = B;
        if (comparator != null) {
            Collections.sort(list, comparator);
        }
    }

    public boolean B(View view, int i3, int i4) {
        Rect rectA = a();
        t(view, rectA);
        try {
            return rectA.contains(i3, i4);
        } finally {
            O(rectA);
        }
    }

    void G(View view, int i3) {
        c cVarF;
        f fVar = (f) view.getLayoutParams();
        if (fVar.f1584k != null) {
            Rect rectA = a();
            Rect rectA2 = a();
            Rect rectA3 = a();
            t(fVar.f1584k, rectA);
            q(view, false, rectA2);
            int measuredWidth = view.getMeasuredWidth();
            int measuredHeight = view.getMeasuredHeight();
            v(view, i3, rectA, rectA3, fVar, measuredWidth, measuredHeight);
            boolean z2 = (rectA3.left == rectA2.left && rectA3.top == rectA2.top) ? false : true;
            e(fVar, rectA3, measuredWidth, measuredHeight);
            int i4 = rectA3.left - rectA2.left;
            int i5 = rectA3.top - rectA2.top;
            if (i4 != 0) {
                y.b0(view, i4);
            }
            if (i5 != 0) {
                y.c0(view, i5);
            }
            if (z2 && (cVarF = fVar.f()) != null) {
                cVarF.h(this, view, fVar.f1584k);
            }
            O(rectA);
            O(rectA2);
            O(rectA3);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:46:0x00ca  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    final void H(int r18) {
        /*
            Method dump skipped, instruction units count: 273
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.coordinatorlayout.widget.CoordinatorLayout.H(int):void");
    }

    public void I(View view, int i3) {
        f fVar = (f) view.getLayoutParams();
        if (fVar.a()) {
            throw new IllegalStateException("An anchor may not be changed after CoordinatorLayout measurement begins before layout is complete.");
        }
        View view2 = fVar.f1584k;
        if (view2 != null) {
            D(view, view2, i3);
            return;
        }
        int i4 = fVar.f1578e;
        if (i4 >= 0) {
            E(view, i4, i3);
        } else {
            C(view, i3);
        }
    }

    public void J(View view, int i3, int i4, int i5, int i6) {
        measureChildWithMargins(view, i3, i4, i5, i6);
    }

    void N(View view, Rect rect) {
        ((f) view.getLayoutParams()).q(rect);
    }

    void P() {
        if (this.f1560m && this.f1564q != null) {
            getViewTreeObserver().removeOnPreDrawListener(this.f1564q);
        }
        this.f1565r = false;
    }

    final j0 W(j0 j0Var) {
        if (androidx.core.util.c.a(this.f1566s, j0Var)) {
            return j0Var;
        }
        this.f1566s = j0Var;
        boolean z2 = j0Var != null && j0Var.k() > 0;
        this.f1567t = z2;
        setWillNotDraw(!z2 && getBackground() == null);
        j0 j0VarF = f(j0Var);
        requestLayout();
        return j0VarF;
    }

    void b() {
        if (this.f1560m) {
            if (this.f1564q == null) {
                this.f1564q = new g();
            }
            getViewTreeObserver().addOnPreDrawListener(this.f1564q);
        }
        this.f1565r = true;
    }

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

    @Override // androidx.core.view.o
    public void d(View view, View view2, int i3, int i4) {
        c cVarF;
        this.f1571x.c(view, view2, i3, i4);
        this.f1563p = view2;
        int childCount = getChildCount();
        for (int i5 = 0; i5 < childCount; i5++) {
            View childAt = getChildAt(i5);
            f fVar = (f) childAt.getLayoutParams();
            if (fVar.j(i4) && (cVarF = fVar.f()) != null) {
                cVarF.v(this, childAt, view, view2, i3, i4);
            }
        }
    }

    @Override // android.view.ViewGroup
    protected boolean drawChild(Canvas canvas, View view, long j3) {
        f fVar = (f) view.getLayoutParams();
        c cVar = fVar.f1574a;
        if (cVar != null) {
            float fD = cVar.d(this, view);
            if (fD > 0.0f) {
                if (this.f1556i == null) {
                    this.f1556i = new Paint();
                }
                this.f1556i.setColor(fVar.f1574a.c(this, view));
                this.f1556i.setAlpha(c(Math.round(fD * 255.0f), 0, 255));
                int iSave = canvas.save();
                if (view.isOpaque()) {
                    canvas.clipRect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom(), Region.Op.DIFFERENCE);
                }
                canvas.drawRect(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() - getPaddingBottom(), this.f1556i);
                canvas.restoreToCount(iSave);
            }
        }
        return super.drawChild(canvas, view, j3);
    }

    @Override // android.view.ViewGroup, android.view.View
    protected void drawableStateChanged() {
        super.drawableStateChanged();
        int[] drawableState = getDrawableState();
        Drawable drawable = this.f1568u;
        boolean state = false;
        if (drawable != null && drawable.isStateful()) {
            state = false | drawable.setState(drawableState);
        }
        if (state) {
            invalidate();
        }
    }

    public void g(View view) {
        List listG = this.f1553f.g(view);
        if (listG == null || listG.isEmpty()) {
            return;
        }
        for (int i3 = 0; i3 < listG.size(); i3++) {
            View view2 = (View) listG.get(i3);
            c cVarF = ((f) view2.getLayoutParams()).f();
            if (cVarF != null) {
                cVarF.h(this, view2, view);
            }
        }
    }

    final List<View> getDependencySortedChildren() {
        M();
        return Collections.unmodifiableList(this.f1552e);
    }

    public final j0 getLastWindowInsets() {
        return this.f1566s;
    }

    @Override // android.view.ViewGroup
    public int getNestedScrollAxes() {
        return this.f1571x.a();
    }

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

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

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

    void h() {
        int childCount = getChildCount();
        boolean z2 = false;
        int i3 = 0;
        while (true) {
            if (i3 >= childCount) {
                break;
            }
            if (A(getChildAt(i3))) {
                z2 = true;
                break;
            }
            i3++;
        }
        if (z2 != this.f1565r) {
            if (z2) {
                b();
            } else {
                P();
            }
        }
    }

    @Override // androidx.core.view.o
    public void i(View view, int i3) {
        this.f1571x.d(view, i3);
        int childCount = getChildCount();
        for (int i4 = 0; i4 < childCount; i4++) {
            View childAt = getChildAt(i4);
            f fVar = (f) childAt.getLayoutParams();
            if (fVar.j(i3)) {
                c cVarF = fVar.f();
                if (cVarF != null) {
                    cVarF.C(this, childAt, view, i3);
                }
                fVar.l(i3);
                fVar.k();
            }
        }
        this.f1563p = null;
    }

    @Override // androidx.core.view.o
    public void j(View view, int i3, int i4, int[] iArr, int i5) {
        c cVarF;
        int childCount = getChildCount();
        boolean z2 = false;
        int iMax = 0;
        int iMax2 = 0;
        for (int i6 = 0; i6 < childCount; i6++) {
            View childAt = getChildAt(i6);
            if (childAt.getVisibility() != 8) {
                f fVar = (f) childAt.getLayoutParams();
                if (fVar.j(i5) && (cVarF = fVar.f()) != null) {
                    int[] iArr2 = this.f1557j;
                    iArr2[0] = 0;
                    iArr2[1] = 0;
                    cVarF.q(this, childAt, view, i3, i4, iArr2, i5);
                    int[] iArr3 = this.f1557j;
                    iMax = i3 > 0 ? Math.max(iMax, iArr3[0]) : Math.min(iMax, iArr3[0]);
                    int[] iArr4 = this.f1557j;
                    iMax2 = i4 > 0 ? Math.max(iMax2, iArr4[1]) : Math.min(iMax2, iArr4[1]);
                    z2 = true;
                }
            }
        }
        iArr[0] = iMax;
        iArr[1] = iMax2;
        if (z2) {
            H(1);
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // android.view.ViewGroup
    /* JADX INFO: renamed from: k, reason: merged with bridge method [inline-methods] */
    public f generateDefaultLayoutParams() {
        return new f(-2, -2);
    }

    @Override // android.view.ViewGroup
    /* JADX INFO: renamed from: l, reason: merged with bridge method [inline-methods] */
    public f generateLayoutParams(AttributeSet attributeSet) {
        return new f(getContext(), attributeSet);
    }

    @Override // androidx.core.view.p
    public void m(View view, int i3, int i4, int i5, int i6, int i7, int[] iArr) {
        c cVarF;
        boolean z2;
        int iMin;
        int childCount = getChildCount();
        boolean z3 = false;
        int iMax = 0;
        int i8 = 0;
        for (int i9 = 0; i9 < childCount; i9++) {
            View childAt = getChildAt(i9);
            if (childAt.getVisibility() != 8) {
                f fVar = (f) childAt.getLayoutParams();
                if (fVar.j(i7) && (cVarF = fVar.f()) != null) {
                    int[] iArr2 = this.f1557j;
                    iArr2[0] = 0;
                    iArr2[1] = 0;
                    cVarF.t(this, childAt, view, i3, i4, i5, i6, i7, iArr2);
                    int[] iArr3 = this.f1557j;
                    iMax = i5 > 0 ? Math.max(iMax, iArr3[0]) : Math.min(iMax, iArr3[0]);
                    if (i6 > 0) {
                        z2 = true;
                        iMin = Math.max(i8, this.f1557j[1]);
                    } else {
                        z2 = true;
                        iMin = Math.min(i8, this.f1557j[1]);
                    }
                    i8 = iMin;
                    z3 = z2;
                }
            }
        }
        iArr[0] = iArr[0] + iMax;
        iArr[1] = iArr[1] + i8;
        if (z3) {
            H(1);
        }
    }

    @Override // androidx.core.view.o
    public void n(View view, int i3, int i4, int i5, int i6, int i7) {
        m(view, i3, i4, i5, i6, 0, this.f1558k);
    }

    @Override // androidx.core.view.o
    public boolean o(View view, View view2, int i3, int i4) {
        int childCount = getChildCount();
        boolean z2 = false;
        for (int i5 = 0; i5 < childCount; i5++) {
            View childAt = getChildAt(i5);
            if (childAt.getVisibility() != 8) {
                f fVar = (f) childAt.getLayoutParams();
                c cVarF = fVar.f();
                if (cVarF != null) {
                    boolean zA = cVarF.A(this, childAt, view, view2, i3, i4);
                    z2 |= zA;
                    fVar.r(i4, zA);
                } else {
                    fVar.r(i4, false);
                }
            }
        }
        return z2;
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        Q(false);
        if (this.f1565r) {
            if (this.f1564q == null) {
                this.f1564q = new g();
            }
            getViewTreeObserver().addOnPreDrawListener(this.f1564q);
        }
        if (this.f1566s == null && y.B(this)) {
            y.o0(this);
        }
        this.f1560m = true;
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        Q(false);
        if (this.f1565r && this.f1564q != null) {
            getViewTreeObserver().removeOnPreDrawListener(this.f1564q);
        }
        View view = this.f1563p;
        if (view != null) {
            onStopNestedScroll(view);
        }
        this.f1560m = false;
    }

    @Override // android.view.View
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (!this.f1567t || this.f1568u == null) {
            return;
        }
        j0 j0Var = this.f1566s;
        int iK = j0Var != null ? j0Var.k() : 0;
        if (iK > 0) {
            this.f1568u.setBounds(0, 0, getWidth(), iK);
            this.f1568u.draw(canvas);
        }
    }

    @Override // android.view.ViewGroup
    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 0) {
            Q(true);
        }
        boolean zL = L(motionEvent, 0);
        if (actionMasked == 1 || actionMasked == 3) {
            Q(true);
        }
        return zL;
    }

    @Override // android.view.ViewGroup, android.view.View
    protected void onLayout(boolean z2, int i3, int i4, int i5, int i6) {
        c cVarF;
        int iE = y.E(this);
        int size = this.f1552e.size();
        for (int i7 = 0; i7 < size; i7++) {
            View view = this.f1552e.get(i7);
            if (view.getVisibility() != 8 && ((cVarF = ((f) view.getLayoutParams()).f()) == null || !cVarF.l(this, view, iE))) {
                I(view, iE);
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:39:0x00f1  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x00fb  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x011d  */
    @Override // android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    protected void onMeasure(int r31, int r32) {
        /*
            Method dump skipped, instruction units count: 391
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.coordinatorlayout.widget.CoordinatorLayout.onMeasure(int, int):void");
    }

    @Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.q
    public boolean onNestedFling(View view, float f3, float f4, boolean z2) {
        c cVarF;
        int childCount = getChildCount();
        boolean zN = false;
        for (int i3 = 0; i3 < childCount; i3++) {
            View childAt = getChildAt(i3);
            if (childAt.getVisibility() != 8) {
                f fVar = (f) childAt.getLayoutParams();
                if (fVar.j(0) && (cVarF = fVar.f()) != null) {
                    zN |= cVarF.n(this, childAt, view, f3, f4, z2);
                }
            }
        }
        if (zN) {
            H(1);
        }
        return zN;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.q
    public boolean onNestedPreFling(View view, float f3, float f4) {
        c cVarF;
        int childCount = getChildCount();
        boolean zO = false;
        for (int i3 = 0; i3 < childCount; i3++) {
            View childAt = getChildAt(i3);
            if (childAt.getVisibility() != 8) {
                f fVar = (f) childAt.getLayoutParams();
                if (fVar.j(0) && (cVarF = fVar.f()) != null) {
                    zO |= cVarF.o(this, childAt, view, f3, f4);
                }
            }
        }
        return zO;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.q
    public void onNestedPreScroll(View view, int i3, int i4, int[] iArr) {
        j(view, i3, i4, iArr, 0);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.q
    public void onNestedScroll(View view, int i3, int i4, int i5, int i6) {
        n(view, i3, i4, i5, i6, 0);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.q
    public void onNestedScrollAccepted(View view, View view2, int i3) {
        d(view, view2, i3, 0);
    }

    @Override // android.view.View
    protected void onRestoreInstanceState(Parcelable parcelable) {
        Parcelable parcelable2;
        if (!(parcelable instanceof h)) {
            super.onRestoreInstanceState(parcelable);
            return;
        }
        h hVar = (h) parcelable;
        super.onRestoreInstanceState(hVar.j());
        SparseArray<Parcelable> sparseArray = hVar.f1592g;
        int childCount = getChildCount();
        for (int i3 = 0; i3 < childCount; i3++) {
            View childAt = getChildAt(i3);
            int id = childAt.getId();
            c cVarF = y(childAt).f();
            if (id != -1 && cVarF != null && (parcelable2 = sparseArray.get(id)) != null) {
                cVarF.x(this, childAt, parcelable2);
            }
        }
    }

    @Override // android.view.View
    protected Parcelable onSaveInstanceState() {
        Parcelable parcelableY;
        h hVar = new h(super.onSaveInstanceState());
        SparseArray<Parcelable> sparseArray = new SparseArray<>();
        int childCount = getChildCount();
        for (int i3 = 0; i3 < childCount; i3++) {
            View childAt = getChildAt(i3);
            int id = childAt.getId();
            c cVarF = ((f) childAt.getLayoutParams()).f();
            if (id != -1 && cVarF != null && (parcelableY = cVarF.y(this, childAt)) != null) {
                sparseArray.append(id, parcelableY);
            }
        }
        hVar.f1592g = sparseArray;
        return hVar;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.q
    public boolean onStartNestedScroll(View view, View view2, int i3) {
        return o(view, view2, i3, 0);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.q
    public void onStopNestedScroll(View view) {
        i(view, 0);
    }

    /* JADX WARN: Removed duplicated region for block: B:11:0x002b A[PHI: r3
      0x002b: PHI (r3v4 boolean) = (r3v2 boolean), (r3v5 boolean) binds: [B:9:0x0022, B:5:0x0012] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:14:0x0031  */
    /* JADX WARN: Removed duplicated region for block: B:15:0x0037  */
    /* JADX WARN: Removed duplicated region for block: B:18:0x004c  */
    /* JADX WARN: Removed duplicated region for block: B:22:0x0054  */
    @Override // android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean onTouchEvent(android.view.MotionEvent r18) {
        /*
            r17 = this;
            r0 = r17
            r1 = r18
            int r2 = r18.getActionMasked()
            android.view.View r3 = r0.f1562o
            r4 = 1
            r5 = 0
            if (r3 != 0) goto L15
            boolean r3 = r0.L(r1, r4)
            if (r3 == 0) goto L2b
            goto L16
        L15:
            r3 = r5
        L16:
            android.view.View r6 = r0.f1562o
            android.view.ViewGroup$LayoutParams r6 = r6.getLayoutParams()
            androidx.coordinatorlayout.widget.CoordinatorLayout$f r6 = (androidx.coordinatorlayout.widget.CoordinatorLayout.f) r6
            androidx.coordinatorlayout.widget.CoordinatorLayout$c r6 = r6.f()
            if (r6 == 0) goto L2b
            android.view.View r7 = r0.f1562o
            boolean r6 = r6.D(r0, r7, r1)
            goto L2c
        L2b:
            r6 = r5
        L2c:
            android.view.View r7 = r0.f1562o
            r8 = 0
            if (r7 != 0) goto L37
            boolean r1 = super.onTouchEvent(r18)
            r6 = r6 | r1
            goto L4a
        L37:
            if (r3 == 0) goto L4a
            long r11 = android.os.SystemClock.uptimeMillis()
            r13 = 3
            r14 = 0
            r15 = 0
            r16 = 0
            r9 = r11
            android.view.MotionEvent r8 = android.view.MotionEvent.obtain(r9, r11, r13, r14, r15, r16)
            super.onTouchEvent(r8)
        L4a:
            if (r8 == 0) goto L4f
            r8.recycle()
        L4f:
            if (r2 == r4) goto L54
            r1 = 3
            if (r2 != r1) goto L57
        L54:
            r0.Q(r5)
        L57:
            return r6
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.coordinatorlayout.widget.CoordinatorLayout.onTouchEvent(android.view.MotionEvent):boolean");
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // android.view.ViewGroup
    /* JADX INFO: renamed from: p, reason: merged with bridge method [inline-methods] */
    public f generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return layoutParams instanceof f ? new f((f) layoutParams) : layoutParams instanceof ViewGroup.MarginLayoutParams ? new f((ViewGroup.MarginLayoutParams) layoutParams) : new f(layoutParams);
    }

    void q(View view, boolean z2, Rect rect) {
        if (view.isLayoutRequested() || view.getVisibility() == 8) {
            rect.setEmpty();
        } else if (z2) {
            t(view, rect);
        } else {
            rect.set(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
        }
    }

    public List<View> r(View view) {
        List<View> listH = this.f1553f.h(view);
        this.f1555h.clear();
        if (listH != null) {
            this.f1555h.addAll(listH);
        }
        return this.f1555h;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public boolean requestChildRectangleOnScreen(View view, Rect rect, boolean z2) {
        c cVarF = ((f) view.getLayoutParams()).f();
        if (cVarF == null || !cVarF.w(this, view, rect, z2)) {
            return super.requestChildRectangleOnScreen(view, rect, z2);
        }
        return true;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public void requestDisallowInterceptTouchEvent(boolean z2) {
        super.requestDisallowInterceptTouchEvent(z2);
        if (!z2 || this.f1559l) {
            return;
        }
        Q(false);
        this.f1559l = true;
    }

    public List<View> s(View view) {
        List listG = this.f1553f.g(view);
        this.f1555h.clear();
        if (listG != null) {
            this.f1555h.addAll(listG);
        }
        return this.f1555h;
    }

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

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

    public void setStatusBarBackground(Drawable drawable) {
        Drawable drawable2 = this.f1568u;
        if (drawable2 != drawable) {
            if (drawable2 != null) {
                drawable2.setCallback(null);
            }
            Drawable drawableMutate = drawable != null ? drawable.mutate() : null;
            this.f1568u = drawableMutate;
            if (drawableMutate != null) {
                if (drawableMutate.isStateful()) {
                    this.f1568u.setState(getDrawableState());
                }
                androidx.core.graphics.drawable.a.m(this.f1568u, y.E(this));
                this.f1568u.setVisible(getVisibility() == 0, false);
                this.f1568u.setCallback(this);
            }
            y.i0(this);
        }
    }

    public void setStatusBarBackgroundColor(int i3) {
        setStatusBarBackground(new ColorDrawable(i3));
    }

    public void setStatusBarBackgroundResource(int i3) {
        setStatusBarBackground(i3 != 0 ? androidx.core.content.a.d(getContext(), i3) : null);
    }

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

    void t(View view, Rect rect) {
        androidx.coordinatorlayout.widget.b.a(this, view, rect);
    }

    void u(View view, int i3, Rect rect, Rect rect2) {
        f fVar = (f) view.getLayoutParams();
        int measuredWidth = view.getMeasuredWidth();
        int measuredHeight = view.getMeasuredHeight();
        v(view, i3, rect, rect2, fVar, measuredWidth, measuredHeight);
        e(fVar, rect2, measuredWidth, measuredHeight);
    }

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

    void x(View view, Rect rect) {
        rect.set(((f) view.getLayoutParams()).h());
    }

    /* JADX WARN: Multi-variable type inference failed */
    f y(View view) {
        f fVar = (f) view.getLayoutParams();
        if (!fVar.f1575b) {
            if (view instanceof b) {
                c behavior = ((b) view).getBehavior();
                if (behavior == null) {
                    Log.e("CoordinatorLayout", "Attached behavior class is null");
                }
                fVar.o(behavior);
                fVar.f1575b = true;
            } else {
                d dVar = null;
                for (Class<?> superclass = view.getClass(); superclass != null; superclass = superclass.getSuperclass()) {
                    dVar = (d) superclass.getAnnotation(d.class);
                    if (dVar != null) {
                        break;
                    }
                }
                if (dVar != null) {
                    try {
                        fVar.o(dVar.value().getDeclaredConstructor(new Class[0]).newInstance(new Object[0]));
                    } catch (Exception e3) {
                        Log.e("CoordinatorLayout", "Default behavior class " + dVar.value().getName() + " could not be instantiated. Did you forget a default constructor?", e3);
                    }
                }
                fVar.f1575b = true;
            }
        }
        return fVar;
    }

    public CoordinatorLayout(Context context, AttributeSet attributeSet, int i3) {
        super(context, attributeSet, i3);
        this.f1552e = new ArrayList();
        this.f1553f = new androidx.coordinatorlayout.widget.a<>();
        this.f1554g = new ArrayList();
        this.f1555h = new ArrayList();
        this.f1557j = new int[2];
        this.f1558k = new int[2];
        this.f1571x = new r(this);
        TypedArray typedArrayObtainStyledAttributes = i3 == 0 ? context.obtainStyledAttributes(attributeSet, q.c.f5774a, 0, q.b.f5773a) : context.obtainStyledAttributes(attributeSet, q.c.f5774a, i3, 0);
        if (Build.VERSION.SDK_INT >= 29) {
            if (i3 == 0) {
                saveAttributeDataForStyleable(context, q.c.f5774a, attributeSet, typedArrayObtainStyledAttributes, 0, q.b.f5773a);
            } else {
                saveAttributeDataForStyleable(context, q.c.f5774a, attributeSet, typedArrayObtainStyledAttributes, i3, 0);
            }
        }
        int resourceId = typedArrayObtainStyledAttributes.getResourceId(q.c.f5775b, 0);
        if (resourceId != 0) {
            Resources resources = context.getResources();
            this.f1561n = resources.getIntArray(resourceId);
            float f3 = resources.getDisplayMetrics().density;
            int length = this.f1561n.length;
            for (int i4 = 0; i4 < length; i4++) {
                this.f1561n[i4] = (int) (r12[i4] * f3);
            }
        }
        this.f1568u = typedArrayObtainStyledAttributes.getDrawable(q.c.f5776c);
        typedArrayObtainStyledAttributes.recycle();
        X();
        super.setOnHierarchyChangeListener(new e());
        if (y.C(this) == 0) {
            y.B0(this, 1);
        }
    }

    protected static class h extends w.a {
        public static final Parcelable.Creator<h> CREATOR = new a();

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        SparseArray<Parcelable> f1592g;

        static class a implements Parcelable.ClassLoaderCreator<h> {
            a() {
            }

            @Override // android.os.Parcelable.Creator
            /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
            public h createFromParcel(Parcel parcel) {
                return new h(parcel, null);
            }

            @Override // android.os.Parcelable.ClassLoaderCreator
            /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
            public h createFromParcel(Parcel parcel, ClassLoader classLoader) {
                return new h(parcel, classLoader);
            }

            @Override // android.os.Parcelable.Creator
            /* JADX INFO: renamed from: c, reason: merged with bridge method [inline-methods] */
            public h[] newArray(int i3) {
                return new h[i3];
            }
        }

        public h(Parcel parcel, ClassLoader classLoader) {
            super(parcel, classLoader);
            int i3 = parcel.readInt();
            int[] iArr = new int[i3];
            parcel.readIntArray(iArr);
            Parcelable[] parcelableArray = parcel.readParcelableArray(classLoader);
            this.f1592g = new SparseArray<>(i3);
            for (int i4 = 0; i4 < i3; i4++) {
                this.f1592g.append(iArr[i4], parcelableArray[i4]);
            }
        }

        @Override // w.a, android.os.Parcelable
        public void writeToParcel(Parcel parcel, int i3) {
            super.writeToParcel(parcel, i3);
            SparseArray<Parcelable> sparseArray = this.f1592g;
            int size = sparseArray != null ? sparseArray.size() : 0;
            parcel.writeInt(size);
            int[] iArr = new int[size];
            Parcelable[] parcelableArr = new Parcelable[size];
            for (int i4 = 0; i4 < size; i4++) {
                iArr[i4] = this.f1592g.keyAt(i4);
                parcelableArr[i4] = this.f1592g.valueAt(i4);
            }
            parcel.writeIntArray(iArr);
            parcel.writeParcelableArray(parcelableArr, i3);
        }

        public h(Parcelable parcelable) {
            super(parcelable);
        }
    }

    public static class f extends ViewGroup.MarginLayoutParams {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        c f1574a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        boolean f1575b;

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

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

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

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

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

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

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

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        int f1583j;

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

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        View f1585l;

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

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        private boolean f1587n;

        /* JADX INFO: renamed from: o, reason: collision with root package name */
        private boolean f1588o;

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        private boolean f1589p;

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        final Rect f1590q;

        public f(int i3, int i4) {
            super(i3, i4);
            this.f1575b = false;
            this.f1576c = 0;
            this.f1577d = 0;
            this.f1578e = -1;
            this.f1579f = -1;
            this.f1580g = 0;
            this.f1581h = 0;
            this.f1590q = new Rect();
        }

        private void n(View view, CoordinatorLayout coordinatorLayout) {
            View viewFindViewById = coordinatorLayout.findViewById(this.f1579f);
            this.f1584k = viewFindViewById;
            if (viewFindViewById == null) {
                if (coordinatorLayout.isInEditMode()) {
                    this.f1585l = null;
                    this.f1584k = null;
                    return;
                }
                throw new IllegalStateException("Could not find CoordinatorLayout descendant view with id " + coordinatorLayout.getResources().getResourceName(this.f1579f) + " to anchor view " + view);
            }
            if (viewFindViewById == coordinatorLayout) {
                if (!coordinatorLayout.isInEditMode()) {
                    throw new IllegalStateException("View can not be anchored to the the parent CoordinatorLayout");
                }
                this.f1585l = null;
                this.f1584k = null;
                return;
            }
            for (ViewParent parent = viewFindViewById.getParent(); parent != coordinatorLayout && parent != null; parent = parent.getParent()) {
                if (parent == view) {
                    if (!coordinatorLayout.isInEditMode()) {
                        throw new IllegalStateException("Anchor must not be a descendant of the anchored view");
                    }
                    this.f1585l = null;
                    this.f1584k = null;
                    return;
                }
                if (parent instanceof View) {
                    viewFindViewById = parent;
                }
            }
            this.f1585l = viewFindViewById;
        }

        private boolean s(View view, int i3) {
            int iB = androidx.core.view.e.b(((f) view.getLayoutParams()).f1580g, i3);
            return iB != 0 && (androidx.core.view.e.b(this.f1581h, i3) & iB) == iB;
        }

        private boolean t(View view, CoordinatorLayout coordinatorLayout) {
            if (this.f1584k.getId() != this.f1579f) {
                return false;
            }
            View view2 = this.f1584k;
            for (ViewParent parent = view2.getParent(); parent != coordinatorLayout; parent = parent.getParent()) {
                if (parent == null || parent == view) {
                    this.f1585l = null;
                    this.f1584k = null;
                    return false;
                }
                if (parent instanceof View) {
                    view2 = parent;
                }
            }
            this.f1585l = view2;
            return true;
        }

        boolean a() {
            return this.f1584k == null && this.f1579f != -1;
        }

        boolean b(CoordinatorLayout coordinatorLayout, View view, View view2) {
            c cVar;
            return view2 == this.f1585l || s(view2, y.E(coordinatorLayout)) || ((cVar = this.f1574a) != null && cVar.e(coordinatorLayout, view, view2));
        }

        boolean c() {
            if (this.f1574a == null) {
                this.f1586m = false;
            }
            return this.f1586m;
        }

        View d(CoordinatorLayout coordinatorLayout, View view) {
            if (this.f1579f == -1) {
                this.f1585l = null;
                this.f1584k = null;
                return null;
            }
            if (this.f1584k == null || !t(view, coordinatorLayout)) {
                n(view, coordinatorLayout);
            }
            return this.f1584k;
        }

        public int e() {
            return this.f1579f;
        }

        public c f() {
            return this.f1574a;
        }

        boolean g() {
            return this.f1589p;
        }

        Rect h() {
            return this.f1590q;
        }

        boolean i(CoordinatorLayout coordinatorLayout, View view) {
            boolean z2 = this.f1586m;
            if (z2) {
                return true;
            }
            c cVar = this.f1574a;
            boolean zA = (cVar != null ? cVar.a(coordinatorLayout, view) : false) | z2;
            this.f1586m = zA;
            return zA;
        }

        boolean j(int i3) {
            if (i3 == 0) {
                return this.f1587n;
            }
            if (i3 != 1) {
                return false;
            }
            return this.f1588o;
        }

        void k() {
            this.f1589p = false;
        }

        void l(int i3) {
            r(i3, false);
        }

        void m() {
            this.f1586m = false;
        }

        public void o(c cVar) {
            c cVar2 = this.f1574a;
            if (cVar2 != cVar) {
                if (cVar2 != null) {
                    cVar2.j();
                }
                this.f1574a = cVar;
                this.f1575b = true;
                if (cVar != null) {
                    cVar.g(this);
                }
            }
        }

        void p(boolean z2) {
            this.f1589p = z2;
        }

        void q(Rect rect) {
            this.f1590q.set(rect);
        }

        void r(int i3, boolean z2) {
            if (i3 == 0) {
                this.f1587n = z2;
            } else {
                if (i3 != 1) {
                    return;
                }
                this.f1588o = z2;
            }
        }

        f(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
            this.f1575b = false;
            this.f1576c = 0;
            this.f1577d = 0;
            this.f1578e = -1;
            this.f1579f = -1;
            this.f1580g = 0;
            this.f1581h = 0;
            this.f1590q = new Rect();
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, q.c.f5777d);
            this.f1576c = typedArrayObtainStyledAttributes.getInteger(q.c.f5778e, 0);
            this.f1579f = typedArrayObtainStyledAttributes.getResourceId(q.c.f5779f, -1);
            this.f1577d = typedArrayObtainStyledAttributes.getInteger(q.c.f5780g, 0);
            this.f1578e = typedArrayObtainStyledAttributes.getInteger(q.c.f5784k, -1);
            this.f1580g = typedArrayObtainStyledAttributes.getInt(q.c.f5783j, 0);
            this.f1581h = typedArrayObtainStyledAttributes.getInt(q.c.f5782i, 0);
            int i3 = q.c.f5781h;
            boolean zHasValue = typedArrayObtainStyledAttributes.hasValue(i3);
            this.f1575b = zHasValue;
            if (zHasValue) {
                this.f1574a = CoordinatorLayout.K(context, attributeSet, typedArrayObtainStyledAttributes.getString(i3));
            }
            typedArrayObtainStyledAttributes.recycle();
            c cVar = this.f1574a;
            if (cVar != null) {
                cVar.g(this);
            }
        }

        public f(f fVar) {
            super((ViewGroup.MarginLayoutParams) fVar);
            this.f1575b = false;
            this.f1576c = 0;
            this.f1577d = 0;
            this.f1578e = -1;
            this.f1579f = -1;
            this.f1580g = 0;
            this.f1581h = 0;
            this.f1590q = new Rect();
        }

        public f(ViewGroup.MarginLayoutParams marginLayoutParams) {
            super(marginLayoutParams);
            this.f1575b = false;
            this.f1576c = 0;
            this.f1577d = 0;
            this.f1578e = -1;
            this.f1579f = -1;
            this.f1580g = 0;
            this.f1581h = 0;
            this.f1590q = new Rect();
        }

        public f(ViewGroup.LayoutParams layoutParams) {
            super(layoutParams);
            this.f1575b = false;
            this.f1576c = 0;
            this.f1577d = 0;
            this.f1578e = -1;
            this.f1579f = -1;
            this.f1580g = 0;
            this.f1581h = 0;
            this.f1590q = new Rect();
        }
    }
}
