package com.google.android.material.bottomsheet;

import B7.a;
import M.AbstractC0195z;
import M.B;
import M.C0171a;
import M.C0172b;
import M.J;
import N.c;
import N1.C0222x;
import R0.h;
import T.d;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.os.Build;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.AbsSavedState;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.accessibility.AccessibilityNodeInfo;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.martsnew.tv.R;
import d5.AbstractC0844a;
import e0.C0853a;
import g3.p;
import h3.AbstractC1031a;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import m3.C1162a;
import m3.C1163b;
import m3.RunnableC1164c;
import x3.f;
import x3.g;
import x3.k;
import z.AbstractC1769a;
import z.C1772d;

/* JADX INFO: loaded from: classes.dex */
public class BottomSheetBehavior<V extends View> extends AbstractC1769a {

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

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public final float f10114B;

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public boolean f10115C;
    public boolean D;

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    public final boolean f10116E;

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

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    public d f10118G;
    public boolean H;

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

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

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

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

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

    /* JADX INFO: renamed from: N, reason: collision with root package name */
    public WeakReference f10124N;

    /* JADX INFO: renamed from: O, reason: collision with root package name */
    public WeakReference f10125O;

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

    /* JADX INFO: renamed from: Q, reason: collision with root package name */
    public VelocityTracker f10127Q;

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

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

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

    /* JADX INFO: renamed from: U, reason: collision with root package name */
    public HashMap f10131U;

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

    /* JADX INFO: renamed from: W, reason: collision with root package name */
    public final C1162a f10133W;

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final boolean f10141h;
    public g i;

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

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

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public final boolean f10144l;

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

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final boolean f10146n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final boolean f10147o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public final boolean f10148p;

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

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

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

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

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public RunnableC1164c f10153u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public final ValueAnimator f10154v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final int f10155w;

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

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

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public final float f10158z;

    public BottomSheetBehavior() {
        this.f10134a = 0;
        this.f10135b = true;
        this.f10142j = -1;
        this.f10153u = null;
        this.f10158z = 0.5f;
        this.f10114B = -1.0f;
        this.f10116E = true;
        this.f10117F = 4;
        this.f10126P = new ArrayList();
        this.f10132V = -1;
        this.f10133W = new C1162a(this);
    }

    public static View v(View view) {
        Field field = J.f4065a;
        if (B.g(view)) {
            return view;
        }
        if (!(view instanceof ViewGroup)) {
            return null;
        }
        ViewGroup viewGroup = (ViewGroup) view;
        int childCount = viewGroup.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View viewV = v(viewGroup.getChildAt(i));
            if (viewV != null) {
                return viewV;
            }
        }
        return null;
    }

    public final void A(View view, int i) {
        int iW;
        int i5;
        if (i == 4) {
            iW = this.f10113A;
        } else if (i == 6) {
            iW = this.f10157y;
            if (this.f10135b && iW <= (i5 = this.f10156x)) {
                i = 3;
                iW = i5;
            }
        } else if (i == 3) {
            iW = w();
        } else {
            if (!this.f10115C || i != 5) {
                throw new IllegalArgumentException(AbstractC0844a.j("Illegal state argument: ", i));
            }
            iW = this.f10123M;
        }
        C(i, iW, view, false);
    }

    public final boolean B(View view, float f3) {
        if (this.D) {
            return true;
        }
        if (view.getTop() < this.f10113A) {
            return false;
        }
        return Math.abs(((f3 * 0.1f) + ((float) view.getTop())) - ((float) this.f10113A)) / ((float) s()) > 0.5f;
    }

    /* JADX WARN: Code restructure failed: missing block: B:15:0x002c, code lost:
    
        if (r4 != false) goto L16;
     */
    /* JADX WARN: Code restructure failed: missing block: B:16:0x002e, code lost:
    
        z(2);
        E(r3);
     */
    /* JADX WARN: Code restructure failed: missing block: B:17:0x0037, code lost:
    
        if (r2.f10153u != null) goto L19;
     */
    /* JADX WARN: Code restructure failed: missing block: B:18:0x0039, code lost:
    
        r2.f10153u = new m3.RunnableC1164c(r2, r5, r3);
     */
    /* JADX WARN: Code restructure failed: missing block: B:19:0x0040, code lost:
    
        r4 = r2.f10153u;
     */
    /* JADX WARN: Code restructure failed: missing block: B:20:0x0044, code lost:
    
        if (r4.f14599r != false) goto L23;
     */
    /* JADX WARN: Code restructure failed: missing block: B:21:0x0046, code lost:
    
        r4.f14600s = r3;
        r3 = M.J.f4065a;
        r5.postOnAnimation(r4);
        r2.f10153u.f14599r = true;
     */
    /* JADX WARN: Code restructure failed: missing block: B:22:0x0052, code lost:
    
        return;
     */
    /* JADX WARN: Code restructure failed: missing block: B:23:0x0053, code lost:
    
        r4.f14600s = r3;
     */
    /* JADX WARN: Code restructure failed: missing block: B:24:0x0055, code lost:
    
        return;
     */
    /* JADX WARN: Code restructure failed: missing block: B:6:0x000e, code lost:
    
        if (r0.o(r5.getLeft(), r4) != false) goto L16;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void C(int i, int i5, View view, boolean z8) {
        d dVar = this.f10118G;
        if (dVar != null) {
            if (!z8) {
                int left = view.getLeft();
                dVar.f6333r = view;
                dVar.f6319c = -1;
                boolean zH = dVar.h(left, i5, 0, 0);
                if (!zH && dVar.f6317a == 0 && dVar.f6333r != null) {
                    dVar.f6333r = null;
                }
            }
        }
        z(i);
    }

    public final void D() {
        View view;
        int iA;
        WeakReference weakReference = this.f10124N;
        if (weakReference == null || (view = (View) weakReference.get()) == null) {
            return;
        }
        J.g(view, 524288);
        J.e(view, 0);
        J.g(view, 262144);
        J.e(view, 0);
        J.g(view, 1048576);
        J.e(view, 0);
        int i = this.f10132V;
        if (i != -1) {
            J.g(view, i);
            J.e(view, 0);
        }
        if (!this.f10135b && this.f10117F != 6) {
            String string = view.getResources().getString(R.string.bottomsheet_action_expand_halfway);
            a aVar = new a(i, 7, this);
            ArrayList arrayListC = J.c(view);
            int i5 = 0;
            while (true) {
                if (i5 >= arrayListC.size()) {
                    int i8 = -1;
                    for (int i9 = 0; i9 < 32 && i8 == -1; i9++) {
                        int i10 = J.f4067c[i9];
                        boolean z8 = true;
                        for (int i11 = 0; i11 < arrayListC.size(); i11++) {
                            z8 &= ((c) arrayListC.get(i11)).a() != i10;
                        }
                        if (z8) {
                            i8 = i10;
                        }
                    }
                    iA = i8;
                } else {
                    if (TextUtils.equals(string, ((AccessibilityNodeInfo.AccessibilityAction) ((c) arrayListC.get(i5)).f4365a).getLabel())) {
                        iA = ((c) arrayListC.get(i5)).a();
                        break;
                    }
                    i5++;
                }
            }
            if (iA != -1) {
                c cVar = new c(null, iA, string, aVar, null);
                View.AccessibilityDelegate accessibilityDelegateB = J.b(view);
                C0172b c0172b = accessibilityDelegateB == null ? null : accessibilityDelegateB instanceof C0171a ? ((C0171a) accessibilityDelegateB).f4095a : new C0172b(accessibilityDelegateB);
                if (c0172b == null) {
                    c0172b = new C0172b();
                }
                J.j(view, c0172b);
                J.g(view, cVar.a());
                J.c(view).add(cVar);
                J.e(view, 0);
            }
            this.f10132V = iA;
        }
        if (this.f10115C) {
            int i12 = 5;
            if (this.f10117F != 5) {
                J.h(view, c.f4358j, new a(i12, 7, this));
            }
        }
        int i13 = this.f10117F;
        int i14 = 4;
        int i15 = 3;
        if (i13 == 3) {
            J.h(view, c.i, new a(this.f10135b ? 4 : 6, 7, this));
            return;
        }
        if (i13 == 4) {
            J.h(view, c.f4357h, new a(this.f10135b ? 3 : 6, 7, this));
        } else {
            if (i13 != 6) {
                return;
            }
            J.h(view, c.i, new a(i14, 7, this));
            J.h(view, c.f4357h, new a(i15, 7, this));
        }
    }

    public final void E(int i) {
        ValueAnimator valueAnimator = this.f10154v;
        if (i == 2) {
            return;
        }
        boolean z8 = i == 3;
        if (this.f10152t != z8) {
            this.f10152t = z8;
            if (this.i == null || valueAnimator == null) {
                return;
            }
            if (valueAnimator.isRunning()) {
                valueAnimator.reverse();
                return;
            }
            float f3 = z8 ? 0.0f : 1.0f;
            valueAnimator.setFloatValues(1.0f - f3, f3);
            valueAnimator.start();
        }
    }

    public final void F(boolean z8) {
        WeakReference weakReference = this.f10124N;
        if (weakReference == null) {
            return;
        }
        ViewParent parent = ((View) weakReference.get()).getParent();
        if (parent instanceof CoordinatorLayout) {
            CoordinatorLayout coordinatorLayout = (CoordinatorLayout) parent;
            int childCount = coordinatorLayout.getChildCount();
            if (z8) {
                if (this.f10131U != null) {
                    return;
                } else {
                    this.f10131U = new HashMap(childCount);
                }
            }
            for (int i = 0; i < childCount; i++) {
                View childAt = coordinatorLayout.getChildAt(i);
                if (childAt != this.f10124N.get() && z8) {
                    this.f10131U.put(childAt, Integer.valueOf(childAt.getImportantForAccessibility()));
                }
            }
            if (z8) {
                return;
            }
            this.f10131U = null;
        }
    }

    public final void G() {
        View view;
        if (this.f10124N != null) {
            r();
            if (this.f10117F != 4 || (view = (View) this.f10124N.get()) == null) {
                return;
            }
            view.requestLayout();
        }
    }

    @Override // z.AbstractC1769a
    public final void c(C1772d c1772d) {
        this.f10124N = null;
        this.f10118G = null;
    }

    @Override // z.AbstractC1769a
    public final void e() {
        this.f10124N = null;
        this.f10118G = null;
    }

    @Override // z.AbstractC1769a
    public final boolean f(CoordinatorLayout coordinatorLayout, View view, MotionEvent motionEvent) {
        d dVar;
        if (!view.isShown() || !this.f10116E) {
            this.H = true;
            return false;
        }
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 0) {
            this.f10128R = -1;
            VelocityTracker velocityTracker = this.f10127Q;
            if (velocityTracker != null) {
                velocityTracker.recycle();
                this.f10127Q = null;
            }
        }
        if (this.f10127Q == null) {
            this.f10127Q = VelocityTracker.obtain();
        }
        this.f10127Q.addMovement(motionEvent);
        if (actionMasked == 0) {
            int x8 = (int) motionEvent.getX();
            this.f10129S = (int) motionEvent.getY();
            if (this.f10117F != 2) {
                WeakReference weakReference = this.f10125O;
                View view2 = weakReference != null ? (View) weakReference.get() : null;
                if (view2 != null && coordinatorLayout.o(view2, x8, this.f10129S)) {
                    this.f10128R = motionEvent.getPointerId(motionEvent.getActionIndex());
                    this.f10130T = true;
                }
            }
            this.H = this.f10128R == -1 && !coordinatorLayout.o(view, x8, this.f10129S);
        } else if (actionMasked == 1 || actionMasked == 3) {
            this.f10130T = false;
            this.f10128R = -1;
            if (this.H) {
                this.H = false;
                return false;
            }
        }
        if (this.H || (dVar = this.f10118G) == null || !dVar.p(motionEvent)) {
            WeakReference weakReference2 = this.f10125O;
            View view3 = weakReference2 != null ? (View) weakReference2.get() : null;
            if (actionMasked != 2 || view3 == null || this.H || this.f10117F == 1 || coordinatorLayout.o(view3, (int) motionEvent.getX(), (int) motionEvent.getY()) || this.f10118G == null || Math.abs(this.f10129S - motionEvent.getY()) <= this.f10118G.f6318b) {
                return false;
            }
        }
        return true;
    }

    @Override // z.AbstractC1769a
    public final boolean g(CoordinatorLayout coordinatorLayout, View view, int i) {
        g gVar;
        int i5 = 2;
        int i8 = this.f10142j;
        int i9 = 1;
        Field field = J.f4065a;
        if (coordinatorLayout.getFitsSystemWindows() && !view.getFitsSystemWindows()) {
            view.setFitsSystemWindows(true);
        }
        if (this.f10124N == null) {
            this.f10139f = coordinatorLayout.getResources().getDimensionPixelSize(R.dimen.design_bottom_sheet_peek_height_min);
            boolean z8 = (Build.VERSION.SDK_INT < 29 || this.f10144l || this.f10138e) ? false : true;
            if (this.f10145m || this.f10146n || this.f10147o || z8) {
                K.g gVar2 = new K.g(this, z8);
                int paddingStart = view.getPaddingStart();
                view.getPaddingTop();
                int paddingEnd = view.getPaddingEnd();
                int paddingBottom = view.getPaddingBottom();
                h hVar = new h();
                hVar.f5896a = paddingStart;
                hVar.f5897b = paddingEnd;
                hVar.f5898c = paddingBottom;
                B.k(view, new C0853a(gVar2, 21, hVar));
                if (view.isAttachedToWindow()) {
                    AbstractC0195z.c(view);
                } else {
                    view.addOnAttachStateChangeListener(new U.d(i9));
                }
            }
            this.f10124N = new WeakReference(view);
            if (this.f10141h && (gVar = this.i) != null) {
                view.setBackground(gVar);
            }
            g gVar3 = this.i;
            if (gVar3 != null) {
                float fE = this.f10114B;
                if (fE == -1.0f) {
                    fE = B.e(view);
                }
                gVar3.h(fE);
                boolean z9 = this.f10117F == 3;
                this.f10152t = z9;
                g gVar4 = this.i;
                float f3 = z9 ? 0.0f : 1.0f;
                f fVar = gVar4.f18614q;
                if (fVar.i != f3) {
                    fVar.i = f3;
                    gVar4.f18618u = true;
                    gVar4.invalidateSelf();
                }
            }
            D();
            if (view.getImportantForAccessibility() == 0) {
                view.setImportantForAccessibility(1);
            }
            if (view.getMeasuredWidth() > i8 && i8 != -1) {
                ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
                layoutParams.width = i8;
                view.post(new p(view, i5, layoutParams));
            }
        }
        if (this.f10118G == null) {
            this.f10118G = new d(coordinatorLayout.getContext(), coordinatorLayout, this.f10133W);
        }
        int top = view.getTop();
        coordinatorLayout.q(view, i);
        this.f10122L = coordinatorLayout.getWidth();
        this.f10123M = coordinatorLayout.getHeight();
        int height = view.getHeight();
        this.f10121K = height;
        int i10 = this.f10123M;
        int i11 = i10 - height;
        int i12 = this.f10150r;
        if (i11 < i12) {
            if (this.f10148p) {
                this.f10121K = i10;
            } else {
                this.f10121K = i10 - i12;
            }
        }
        this.f10156x = Math.max(0, i10 - this.f10121K);
        this.f10157y = (int) ((1.0f - this.f10158z) * this.f10123M);
        r();
        int i13 = this.f10117F;
        if (i13 == 3) {
            view.offsetTopAndBottom(w());
        } else if (i13 == 6) {
            view.offsetTopAndBottom(this.f10157y);
        } else if (this.f10115C && i13 == 5) {
            view.offsetTopAndBottom(this.f10123M);
        } else if (i13 == 4) {
            view.offsetTopAndBottom(this.f10113A);
        } else if (i13 == 1 || i13 == 2) {
            view.offsetTopAndBottom(top - view.getTop());
        }
        this.f10125O = new WeakReference(v(view));
        return true;
    }

    @Override // z.AbstractC1769a
    public final boolean i(View view) {
        WeakReference weakReference = this.f10125O;
        return (weakReference == null || view != weakReference.get() || this.f10117F == 3) ? false : true;
    }

    @Override // z.AbstractC1769a
    public final void j(CoordinatorLayout coordinatorLayout, View view, View view2, int i, int i5, int[] iArr, int i8) {
        boolean z8 = this.f10116E;
        if (i8 == 1) {
            return;
        }
        WeakReference weakReference = this.f10125O;
        if (view2 != (weakReference != null ? (View) weakReference.get() : null)) {
            return;
        }
        int top = view.getTop();
        int i9 = top - i5;
        if (i5 > 0) {
            if (i9 < w()) {
                int iW = top - w();
                iArr[1] = iW;
                Field field = J.f4065a;
                view.offsetTopAndBottom(-iW);
                z(3);
            } else {
                if (!z8) {
                    return;
                }
                iArr[1] = i5;
                Field field2 = J.f4065a;
                view.offsetTopAndBottom(-i5);
                z(1);
            }
        } else if (i5 < 0 && !view2.canScrollVertically(-1)) {
            int i10 = this.f10113A;
            if (i9 > i10 && !this.f10115C) {
                int i11 = top - i10;
                iArr[1] = i11;
                Field field3 = J.f4065a;
                view.offsetTopAndBottom(-i11);
                z(4);
            } else {
                if (!z8) {
                    return;
                }
                iArr[1] = i5;
                Field field4 = J.f4065a;
                view.offsetTopAndBottom(-i5);
                z(1);
            }
        }
        u(view.getTop());
        this.f10119I = i5;
        this.f10120J = true;
    }

    @Override // z.AbstractC1769a
    public final void m(View view, Parcelable parcelable) {
        C1163b c1163b = (C1163b) parcelable;
        int i = this.f10134a;
        if (i != 0) {
            if (i == -1 || (i & 1) == 1) {
                this.f10137d = c1163b.f14594t;
            }
            if (i == -1 || (i & 2) == 2) {
                this.f10135b = c1163b.f14595u;
            }
            if (i == -1 || (i & 4) == 4) {
                this.f10115C = c1163b.f14596v;
            }
            if (i == -1 || (i & 8) == 8) {
                this.D = c1163b.f14597w;
            }
        }
        int i5 = c1163b.f14593s;
        if (i5 == 1 || i5 == 2) {
            this.f10117F = 4;
        } else {
            this.f10117F = i5;
        }
    }

    @Override // z.AbstractC1769a
    public final Parcelable n(View view) {
        AbsSavedState absSavedState = View.BaseSavedState.EMPTY_STATE;
        return new C1163b(this);
    }

    @Override // z.AbstractC1769a
    public final boolean o(View view, int i, int i5) {
        this.f10119I = 0;
        this.f10120J = false;
        return (i & 2) != 0;
    }

    /* JADX WARN: Removed duplicated region for block: B:31:0x0062  */
    @Override // z.AbstractC1769a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void p(View view, View view2, int i) {
        int iW;
        float yVelocity;
        int i5 = 3;
        if (view.getTop() == w()) {
            z(3);
            return;
        }
        WeakReference weakReference = this.f10125O;
        if (weakReference != null && view2 == weakReference.get() && this.f10120J) {
            if (this.f10119I > 0) {
                if (this.f10135b) {
                    iW = this.f10156x;
                } else {
                    int top = view.getTop();
                    int i8 = this.f10157y;
                    if (top > i8) {
                        i5 = 6;
                        iW = i8;
                    } else {
                        iW = w();
                    }
                }
            } else if (this.f10115C) {
                VelocityTracker velocityTracker = this.f10127Q;
                if (velocityTracker == null) {
                    yVelocity = 0.0f;
                } else {
                    velocityTracker.computeCurrentVelocity(1000, this.f10136c);
                    yVelocity = this.f10127Q.getYVelocity(this.f10128R);
                }
                if (B(view, yVelocity)) {
                    iW = this.f10123M;
                    i5 = 5;
                }
            } else if (this.f10119I == 0) {
                int top2 = view.getTop();
                if (!this.f10135b) {
                    int i9 = this.f10157y;
                    if (top2 < i9) {
                        if (top2 < Math.abs(top2 - this.f10113A)) {
                            iW = w();
                        } else {
                            iW = this.f10157y;
                        }
                    } else if (Math.abs(top2 - i9) < Math.abs(top2 - this.f10113A)) {
                        iW = this.f10157y;
                    } else {
                        iW = this.f10113A;
                        i5 = 4;
                    }
                    i5 = 6;
                } else if (Math.abs(top2 - this.f10156x) < Math.abs(top2 - this.f10113A)) {
                    iW = this.f10156x;
                } else {
                    iW = this.f10113A;
                    i5 = 4;
                }
            } else {
                if (this.f10135b) {
                    iW = this.f10113A;
                } else {
                    int top3 = view.getTop();
                    if (Math.abs(top3 - this.f10157y) < Math.abs(top3 - this.f10113A)) {
                        iW = this.f10157y;
                        i5 = 6;
                    } else {
                        iW = this.f10113A;
                    }
                }
                i5 = 4;
            }
            C(i5, iW, view, false);
            this.f10120J = false;
        }
    }

    @Override // z.AbstractC1769a
    public final boolean q(View view, MotionEvent motionEvent) {
        if (!view.isShown()) {
            return false;
        }
        int actionMasked = motionEvent.getActionMasked();
        if (this.f10117F == 1 && actionMasked == 0) {
            return true;
        }
        d dVar = this.f10118G;
        if (dVar != null) {
            dVar.j(motionEvent);
        }
        if (actionMasked == 0) {
            this.f10128R = -1;
            VelocityTracker velocityTracker = this.f10127Q;
            if (velocityTracker != null) {
                velocityTracker.recycle();
                this.f10127Q = null;
            }
        }
        if (this.f10127Q == null) {
            this.f10127Q = VelocityTracker.obtain();
        }
        this.f10127Q.addMovement(motionEvent);
        if (this.f10118G != null && actionMasked == 2 && !this.H) {
            float fAbs = Math.abs(this.f10129S - motionEvent.getY());
            d dVar2 = this.f10118G;
            if (fAbs > dVar2.f6318b) {
                dVar2.b(view, motionEvent.getPointerId(motionEvent.getActionIndex()));
            }
        }
        return !this.H;
    }

    public final void r() {
        int iS = s();
        if (this.f10135b) {
            this.f10113A = Math.max(this.f10123M - iS, this.f10156x);
        } else {
            this.f10113A = this.f10123M - iS;
        }
    }

    public final int s() {
        int i;
        return this.f10138e ? Math.min(Math.max(this.f10139f, this.f10123M - ((this.f10122L * 9) / 16)), this.f10121K) + this.f10149q : (this.f10144l || this.f10145m || (i = this.f10143k) <= 0) ? this.f10137d + this.f10149q : Math.max(this.f10137d, i + this.f10140g);
    }

    public final void t(Context context, AttributeSet attributeSet, boolean z8, ColorStateList colorStateList) {
        if (this.f10141h) {
            this.f10151s = k.b(context, attributeSet, R.attr.bottomSheetStyle, R.style.Widget_Design_BottomSheet_Modal).a();
            g gVar = new g(this.f10151s);
            this.i = gVar;
            gVar.g(context);
            if (z8 && colorStateList != null) {
                this.i.i(colorStateList);
                return;
            }
            TypedValue typedValue = new TypedValue();
            context.getTheme().resolveAttribute(android.R.attr.colorBackground, typedValue, true);
            this.i.setTint(typedValue.data);
        }
    }

    public final void u(int i) {
        if (((View) this.f10124N.get()) != null) {
            ArrayList arrayList = this.f10126P;
            if (arrayList.isEmpty()) {
                return;
            }
            int i5 = this.f10113A;
            if (i <= i5 && i5 != w()) {
                w();
            }
            if (arrayList.size() <= 0) {
                return;
            }
            arrayList.get(0).getClass();
            throw new ClassCastException();
        }
    }

    public final int w() {
        if (this.f10135b) {
            return this.f10156x;
        }
        return Math.max(this.f10155w, this.f10148p ? 0 : this.f10150r);
    }

    public final void x(int i) {
        if (i == -1) {
            if (this.f10138e) {
                return;
            } else {
                this.f10138e = true;
            }
        } else {
            if (!this.f10138e && this.f10137d == i) {
                return;
            }
            this.f10138e = false;
            this.f10137d = Math.max(0, i);
        }
        G();
    }

    public final void y(int i) {
        if (i == this.f10117F) {
            return;
        }
        if (this.f10124N == null) {
            if (i == 4 || i == 3 || i == 6 || (this.f10115C && i == 5)) {
                this.f10117F = i;
                return;
            }
            return;
        }
        View view = (View) this.f10124N.get();
        if (view == null) {
            return;
        }
        ViewParent parent = view.getParent();
        if (parent != null && parent.isLayoutRequested()) {
            Field field = J.f4065a;
            if (view.isAttachedToWindow()) {
                view.post(new d.f(this, view, i));
                return;
            }
        }
        A(view, i);
    }

    public final void z(int i) {
        if (this.f10117F == i) {
            return;
        }
        this.f10117F = i;
        WeakReference weakReference = this.f10124N;
        if (weakReference == null || ((View) weakReference.get()) == null) {
            return;
        }
        if (i == 3) {
            F(true);
        } else if (i == 6 || i == 5 || i == 4) {
            F(false);
        }
        E(i);
        ArrayList arrayList = this.f10126P;
        if (arrayList.size() <= 0) {
            D();
        } else {
            arrayList.get(0).getClass();
            throw new ClassCastException();
        }
    }

    public BottomSheetBehavior(Context context, AttributeSet attributeSet) {
        int i;
        int i5 = 1;
        this.f10134a = 0;
        this.f10135b = true;
        this.f10142j = -1;
        this.f10153u = null;
        this.f10158z = 0.5f;
        this.f10114B = -1.0f;
        this.f10116E = true;
        this.f10117F = 4;
        this.f10126P = new ArrayList();
        this.f10132V = -1;
        this.f10133W = new C1162a(this);
        this.f10140g = context.getResources().getDimensionPixelSize(R.dimen.mtrl_min_touch_target_size);
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, AbstractC1031a.f13396b);
        this.f10141h = typedArrayObtainStyledAttributes.hasValue(16);
        boolean zHasValue = typedArrayObtainStyledAttributes.hasValue(2);
        if (zHasValue) {
            t(context, attributeSet, zHasValue, s7.d.q(context, typedArrayObtainStyledAttributes, 2));
        } else {
            t(context, attributeSet, zHasValue, null);
        }
        ValueAnimator valueAnimatorOfFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
        this.f10154v = valueAnimatorOfFloat;
        valueAnimatorOfFloat.setDuration(500L);
        this.f10154v.addUpdateListener(new C0222x(i5, this));
        this.f10114B = typedArrayObtainStyledAttributes.getDimension(1, -1.0f);
        if (typedArrayObtainStyledAttributes.hasValue(0)) {
            this.f10142j = typedArrayObtainStyledAttributes.getDimensionPixelSize(0, -1);
        }
        TypedValue typedValuePeekValue = typedArrayObtainStyledAttributes.peekValue(8);
        if (typedValuePeekValue != null && (i = typedValuePeekValue.data) == -1) {
            x(i);
        } else {
            x(typedArrayObtainStyledAttributes.getDimensionPixelSize(8, -1));
        }
        boolean z8 = typedArrayObtainStyledAttributes.getBoolean(7, false);
        if (this.f10115C != z8) {
            this.f10115C = z8;
            if (!z8 && this.f10117F == 5) {
                y(4);
            }
            D();
        }
        this.f10144l = typedArrayObtainStyledAttributes.getBoolean(11, false);
        boolean z9 = typedArrayObtainStyledAttributes.getBoolean(5, true);
        if (this.f10135b != z9) {
            this.f10135b = z9;
            if (this.f10124N != null) {
                r();
            }
            z((this.f10135b && this.f10117F == 6) ? 3 : this.f10117F);
            D();
        }
        this.D = typedArrayObtainStyledAttributes.getBoolean(10, false);
        this.f10116E = typedArrayObtainStyledAttributes.getBoolean(3, true);
        this.f10134a = typedArrayObtainStyledAttributes.getInt(9, 0);
        float f3 = typedArrayObtainStyledAttributes.getFloat(6, 0.5f);
        if (f3 > 0.0f && f3 < 1.0f) {
            this.f10158z = f3;
            if (this.f10124N != null) {
                this.f10157y = (int) ((1.0f - f3) * this.f10123M);
            }
            TypedValue typedValuePeekValue2 = typedArrayObtainStyledAttributes.peekValue(4);
            if (typedValuePeekValue2 != null && typedValuePeekValue2.type == 16) {
                int i8 = typedValuePeekValue2.data;
                if (i8 >= 0) {
                    this.f10155w = i8;
                } else {
                    throw new IllegalArgumentException("offset must be greater than or equal to 0");
                }
            } else {
                int dimensionPixelOffset = typedArrayObtainStyledAttributes.getDimensionPixelOffset(4, 0);
                if (dimensionPixelOffset >= 0) {
                    this.f10155w = dimensionPixelOffset;
                } else {
                    throw new IllegalArgumentException("offset must be greater than or equal to 0");
                }
            }
            this.f10145m = typedArrayObtainStyledAttributes.getBoolean(12, false);
            this.f10146n = typedArrayObtainStyledAttributes.getBoolean(13, false);
            this.f10147o = typedArrayObtainStyledAttributes.getBoolean(14, false);
            this.f10148p = typedArrayObtainStyledAttributes.getBoolean(15, true);
            typedArrayObtainStyledAttributes.recycle();
            this.f10136c = ViewConfiguration.get(context).getScaledMaximumFlingVelocity();
            return;
        }
        throw new IllegalArgumentException("ratio must be a float value between 0 and 1");
    }

    @Override // z.AbstractC1769a
    public final void k(CoordinatorLayout coordinatorLayout, View view, int i, int i5, int i8, int[] iArr) {
    }
}
