package com.google.android.material.bottomsheet;

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.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
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 androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.ifpdos.udi.service.core.pc.R;
import d.h.b.h;
import d.h.j.i0.c;
import d.h.j.y;
import d.j.b.e;
import g.e.a.a.r.l;
import g.e.a.a.r.m;
import g.e.a.a.r.o;
import g.e.a.a.w.g;
import g.e.a.a.w.j;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

/* JADX INFO: loaded from: classes.dex */
public class BottomSheetBehavior<V extends View> extends CoordinatorLayout.c<V> {
    public int A;
    public float B;
    public boolean C;
    public boolean D;
    public boolean E;
    public int F;
    public d.j.b.e G;
    public boolean H;
    public int I;
    public boolean J;
    public int K;
    public int L;
    public int M;
    public WeakReference<V> N;
    public WeakReference<View> O;
    public final ArrayList<d> P;
    public VelocityTracker Q;
    public int R;
    public int S;
    public boolean T;
    public Map<View, Integer> U;
    public int V;
    public final e.c W;
    public int a;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public BottomSheetBehavior<V>.f f1045u;

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

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

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

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

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

    public class a implements Runnable {

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public final /* synthetic */ View f1051f;

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        public final /* synthetic */ ViewGroup.LayoutParams f1052m;

        public a(BottomSheetBehavior bottomSheetBehavior, View view, ViewGroup.LayoutParams layoutParams) {
            this.f1051f = view;
            this.f1052m = layoutParams;
        }

        @Override // java.lang.Runnable
        public void run() {
            this.f1051f.setLayoutParams(this.f1052m);
        }
    }

    public class b implements Runnable {

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public final /* synthetic */ View f1053f;

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        public final /* synthetic */ int f1054m;

        public b(View view, int i2) {
            this.f1053f = view;
            this.f1054m = i2;
        }

        @Override // java.lang.Runnable
        public void run() {
            BottomSheetBehavior.this.L(this.f1053f, this.f1054m);
        }
    }

    public class c extends e.c {
        public c() {
        }

        @Override // d.j.b.e.c
        public int a(View view, int i2, int i3) {
            return view.getLeft();
        }

        @Override // d.j.b.e.c
        public int b(View view, int i2, int i3) {
            int iG = BottomSheetBehavior.this.G();
            BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.this;
            return h.g(i2, iG, bottomSheetBehavior.C ? bottomSheetBehavior.M : bottomSheetBehavior.A);
        }

        @Override // d.j.b.e.c
        public int d(View view) {
            BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.this;
            return bottomSheetBehavior.C ? bottomSheetBehavior.M : bottomSheetBehavior.A;
        }

        @Override // d.j.b.e.c
        public void f(int i2) {
            if (i2 == 1) {
                BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.this;
                if (bottomSheetBehavior.E) {
                    bottomSheetBehavior.K(1);
                }
            }
        }

        @Override // d.j.b.e.c
        public void g(View view, int i2, int i3, int i4, int i5) {
            BottomSheetBehavior.this.E(i3);
        }

        /* JADX WARN: Code restructure failed: missing block: B:30:0x0084, code lost:
        
            if (java.lang.Math.abs(r8.getTop() - r7.a.G()) < java.lang.Math.abs(r8.getTop() - r7.a.f1049y)) goto L31;
         */
        /* JADX WARN: Code restructure failed: missing block: B:31:0x0086, code lost:
        
            r9 = r7.a.G();
         */
        /* JADX WARN: Code restructure failed: missing block: B:41:0x00be, code lost:
        
            if (java.lang.Math.abs(r9 - r7.a.f1049y) < java.lang.Math.abs(r9 - r7.a.A)) goto L42;
         */
        /* JADX WARN: Code restructure failed: missing block: B:53:0x00f6, code lost:
        
            if (r9 < java.lang.Math.abs(r9 - r10.A)) goto L31;
         */
        /* JADX WARN: Code restructure failed: missing block: B:56:0x0108, code lost:
        
            if (java.lang.Math.abs(r9 - r0) < java.lang.Math.abs(r9 - r7.a.A)) goto L42;
         */
        @Override // d.j.b.e.c
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public void h(android.view.View r8, float r9, float r10) {
            /*
                Method dump skipped, instruction units count: 273
                To view this dump add '--comments-level debug' option
            */
            throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.bottomsheet.BottomSheetBehavior.c.h(android.view.View, float, float):void");
        }

        @Override // d.j.b.e.c
        public boolean i(View view, int i2) {
            BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.this;
            int i3 = bottomSheetBehavior.F;
            if (i3 == 1 || bottomSheetBehavior.T) {
                return false;
            }
            if (i3 == 3 && bottomSheetBehavior.R == i2) {
                WeakReference<View> weakReference = bottomSheetBehavior.O;
                View view2 = weakReference != null ? weakReference.get() : null;
                if (view2 != null && view2.canScrollVertically(-1)) {
                    return false;
                }
            }
            WeakReference<V> weakReference2 = BottomSheetBehavior.this.N;
            return weakReference2 != null && weakReference2.get() == view;
        }
    }

    public static abstract class d {
        public abstract void a(View view, float f2);

        public abstract void b(View view, int i2);
    }

    public static class e extends d.j.a.a {
        public static final Parcelable.Creator<e> CREATOR = new a();

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

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

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

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

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

        public static class a implements Parcelable.ClassLoaderCreator<e> {
            @Override // android.os.Parcelable.Creator
            public Object createFromParcel(Parcel parcel) {
                return new e(parcel, (ClassLoader) null);
            }

            @Override // android.os.Parcelable.Creator
            public Object[] newArray(int i2) {
                return new e[i2];
            }

            @Override // android.os.Parcelable.ClassLoaderCreator
            public e createFromParcel(Parcel parcel, ClassLoader classLoader) {
                return new e(parcel, classLoader);
            }
        }

        public e(Parcel parcel, ClassLoader classLoader) {
            super(parcel, classLoader);
            this.f1056n = parcel.readInt();
            this.f1057o = parcel.readInt();
            this.f1058p = parcel.readInt() == 1;
            this.f1059q = parcel.readInt() == 1;
            this.f1060r = parcel.readInt() == 1;
        }

        public e(Parcelable parcelable, BottomSheetBehavior<?> bottomSheetBehavior) {
            super(parcelable);
            this.f1056n = bottomSheetBehavior.F;
            this.f1057o = bottomSheetBehavior.f1028d;
            this.f1058p = bottomSheetBehavior.f1026b;
            this.f1059q = bottomSheetBehavior.C;
            this.f1060r = bottomSheetBehavior.D;
        }

        @Override // d.j.a.a, android.os.Parcelable
        public void writeToParcel(Parcel parcel, int i2) {
            parcel.writeParcelable(this.f2846m, i2);
            parcel.writeInt(this.f1056n);
            parcel.writeInt(this.f1057o);
            parcel.writeInt(this.f1058p ? 1 : 0);
            parcel.writeInt(this.f1059q ? 1 : 0);
            parcel.writeInt(this.f1060r ? 1 : 0);
        }
    }

    public class f implements Runnable {

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public final View f1061f;

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

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

        public f(View view, int i2) {
            this.f1061f = view;
            this.f1063n = i2;
        }

        @Override // java.lang.Runnable
        public void run() {
            d.j.b.e eVar = BottomSheetBehavior.this.G;
            if (eVar == null || !eVar.i(true)) {
                BottomSheetBehavior.this.K(this.f1063n);
            } else {
                View view = this.f1061f;
                AtomicInteger atomicInteger = y.a;
                y.c.m(view, this);
            }
            this.f1062m = false;
        }
    }

    public BottomSheetBehavior() {
        this.a = 0;
        this.f1026b = true;
        this.f1034j = -1;
        this.f1045u = null;
        this.f1050z = 0.5f;
        this.B = -1.0f;
        this.E = true;
        this.F = 4;
        this.P = new ArrayList<>();
        this.V = -1;
        this.W = new c();
    }

    public BottomSheetBehavior(Context context, AttributeSet attributeSet) {
        int dimensionPixelOffset;
        int i2;
        super(context, attributeSet);
        this.a = 0;
        this.f1026b = true;
        this.f1034j = -1;
        this.f1045u = null;
        this.f1050z = 0.5f;
        this.B = -1.0f;
        this.E = true;
        this.F = 4;
        this.P = new ArrayList<>();
        this.V = -1;
        this.W = new c();
        this.f1031g = context.getResources().getDimensionPixelSize(R.dimen.mtrl_min_touch_target_size);
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, g.e.a.a.b.f3537b);
        this.f1032h = typedArrayObtainStyledAttributes.hasValue(16);
        boolean zHasValue = typedArrayObtainStyledAttributes.hasValue(2);
        if (zHasValue) {
            D(context, attributeSet, zHasValue, g.e.a.a.a.i(context, typedArrayObtainStyledAttributes, 2));
        } else {
            D(context, attributeSet, zHasValue, null);
        }
        ValueAnimator valueAnimatorOfFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
        this.f1046v = valueAnimatorOfFloat;
        valueAnimatorOfFloat.setDuration(500L);
        this.f1046v.addUpdateListener(new g.e.a.a.g.a(this));
        this.B = typedArrayObtainStyledAttributes.getDimension(1, -1.0f);
        if (typedArrayObtainStyledAttributes.hasValue(0)) {
            this.f1034j = typedArrayObtainStyledAttributes.getDimensionPixelSize(0, -1);
        }
        TypedValue typedValuePeekValue = typedArrayObtainStyledAttributes.peekValue(8);
        if (typedValuePeekValue == null || (i2 = typedValuePeekValue.data) != -1) {
            I(typedArrayObtainStyledAttributes.getDimensionPixelSize(8, -1));
        } else {
            I(i2);
        }
        boolean z2 = typedArrayObtainStyledAttributes.getBoolean(7, false);
        if (this.C != z2) {
            this.C = z2;
            if (!z2 && this.F == 5) {
                J(4);
            }
            P();
        }
        this.f1036l = typedArrayObtainStyledAttributes.getBoolean(11, false);
        boolean z3 = typedArrayObtainStyledAttributes.getBoolean(5, true);
        if (this.f1026b != z3) {
            this.f1026b = z3;
            if (this.N != null) {
                B();
            }
            K((this.f1026b && this.F == 6) ? 3 : this.F);
            P();
        }
        this.D = typedArrayObtainStyledAttributes.getBoolean(10, false);
        this.E = typedArrayObtainStyledAttributes.getBoolean(3, true);
        this.a = typedArrayObtainStyledAttributes.getInt(9, 0);
        float f2 = typedArrayObtainStyledAttributes.getFloat(6, 0.5f);
        if (f2 <= 0.0f || f2 >= 1.0f) {
            throw new IllegalArgumentException("ratio must be a float value between 0 and 1");
        }
        this.f1050z = f2;
        if (this.N != null) {
            this.f1049y = (int) ((1.0f - f2) * this.M);
        }
        TypedValue typedValuePeekValue2 = typedArrayObtainStyledAttributes.peekValue(4);
        if (typedValuePeekValue2 == null || typedValuePeekValue2.type != 16) {
            dimensionPixelOffset = typedArrayObtainStyledAttributes.getDimensionPixelOffset(4, 0);
            if (dimensionPixelOffset < 0) {
                throw new IllegalArgumentException("offset must be greater than or equal to 0");
            }
        } else {
            dimensionPixelOffset = typedValuePeekValue2.data;
            if (dimensionPixelOffset < 0) {
                throw new IllegalArgumentException("offset must be greater than or equal to 0");
            }
        }
        this.f1047w = dimensionPixelOffset;
        this.f1037m = typedArrayObtainStyledAttributes.getBoolean(12, false);
        this.f1038n = typedArrayObtainStyledAttributes.getBoolean(13, false);
        this.f1039o = typedArrayObtainStyledAttributes.getBoolean(14, false);
        this.f1040p = typedArrayObtainStyledAttributes.getBoolean(15, true);
        typedArrayObtainStyledAttributes.recycle();
        this.f1027c = ViewConfiguration.get(context).getScaledMaximumFlingVelocity();
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public boolean A(CoordinatorLayout coordinatorLayout, V v2, MotionEvent motionEvent) {
        if (!v2.isShown()) {
            return false;
        }
        int actionMasked = motionEvent.getActionMasked();
        if (this.F == 1 && actionMasked == 0) {
            return true;
        }
        d.j.b.e eVar = this.G;
        if (eVar != null) {
            eVar.n(motionEvent);
        }
        if (actionMasked == 0) {
            this.R = -1;
            VelocityTracker velocityTracker = this.Q;
            if (velocityTracker != null) {
                velocityTracker.recycle();
                this.Q = null;
            }
        }
        if (this.Q == null) {
            this.Q = VelocityTracker.obtain();
        }
        this.Q.addMovement(motionEvent);
        if (this.G != null && actionMasked == 2 && !this.H) {
            float fAbs = Math.abs(this.S - motionEvent.getY());
            d.j.b.e eVar2 = this.G;
            if (fAbs > eVar2.f2866c) {
                eVar2.b(v2, motionEvent.getPointerId(motionEvent.getActionIndex()));
            }
        }
        return !this.H;
    }

    public final void B() {
        int iC = C();
        if (this.f1026b) {
            this.A = Math.max(this.M - iC, this.f1048x);
        } else {
            this.A = this.M - iC;
        }
    }

    public final int C() {
        int i2;
        return this.f1029e ? Math.min(Math.max(this.f1030f, this.M - ((this.L * 9) / 16)), this.K) + this.f1041q : (this.f1036l || this.f1037m || (i2 = this.f1035k) <= 0) ? this.f1028d + this.f1041q : Math.max(this.f1028d, i2 + this.f1031g);
    }

    public final void D(Context context, AttributeSet attributeSet, boolean z2, ColorStateList colorStateList) {
        if (this.f1032h) {
            this.f1043s = j.b(context, attributeSet, R.attr.bottomSheetStyle, 2131886682).a();
            g gVar = new g(this.f1043s);
            this.f1033i = gVar;
            gVar.f3851n.f3864b = new g.e.a.a.o.a(context);
            gVar.w();
            if (z2 && colorStateList != null) {
                this.f1033i.p(colorStateList);
                return;
            }
            TypedValue typedValue = new TypedValue();
            context.getTheme().resolveAttribute(android.R.attr.colorBackground, typedValue, true);
            this.f1033i.setTint(typedValue.data);
        }
    }

    public void E(int i2) {
        float f2;
        float fG;
        V v2 = this.N.get();
        if (v2 == null || this.P.isEmpty()) {
            return;
        }
        int i3 = this.A;
        if (i2 > i3 || i3 == G()) {
            int i4 = this.A;
            f2 = i4 - i2;
            fG = this.M - i4;
        } else {
            int i5 = this.A;
            f2 = i5 - i2;
            fG = i5 - G();
        }
        float f3 = f2 / fG;
        for (int i6 = 0; i6 < this.P.size(); i6++) {
            this.P.get(i6).a(v2, f3);
        }
    }

    public View F(View view) {
        AtomicInteger atomicInteger = y.a;
        if (y.h.p(view)) {
            return view;
        }
        if (!(view instanceof ViewGroup)) {
            return null;
        }
        ViewGroup viewGroup = (ViewGroup) view;
        int childCount = viewGroup.getChildCount();
        for (int i2 = 0; i2 < childCount; i2++) {
            View viewF = F(viewGroup.getChildAt(i2));
            if (viewF != null) {
                return viewF;
            }
        }
        return null;
    }

    public int G() {
        if (this.f1026b) {
            return this.f1048x;
        }
        return Math.max(this.f1047w, this.f1040p ? 0 : this.f1042r);
    }

    public final void H(V v2, c.a aVar, int i2) {
        y.n(v2, aVar, null, new g.e.a.a.g.c(this, i2));
    }

    /* JADX WARN: Removed duplicated region for block: B:12:0x0015  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void I(int r4) {
        /*
            r3 = this;
            r0 = 1
            r1 = -1
            r2 = 0
            if (r4 != r1) goto Lc
            boolean r4 = r3.f1029e
            if (r4 != 0) goto L15
            r3.f1029e = r0
            goto L1f
        Lc:
            boolean r1 = r3.f1029e
            if (r1 != 0) goto L17
            int r1 = r3.f1028d
            if (r1 == r4) goto L15
            goto L17
        L15:
            r0 = r2
            goto L1f
        L17:
            r3.f1029e = r2
            int r4 = java.lang.Math.max(r2, r4)
            r3.f1028d = r4
        L1f:
            if (r0 == 0) goto L24
            r3.S(r2)
        L24:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.bottomsheet.BottomSheetBehavior.I(int):void");
    }

    public void J(int i2) {
        if (i2 == this.F) {
            return;
        }
        if (this.N != null) {
            M(i2);
            return;
        }
        if (i2 == 4 || i2 == 3 || i2 == 6 || (this.C && i2 == 5)) {
            this.F = i2;
        }
    }

    public void K(int i2) {
        V v2;
        if (this.F == i2) {
            return;
        }
        this.F = i2;
        WeakReference<V> weakReference = this.N;
        if (weakReference == null || (v2 = weakReference.get()) == null) {
            return;
        }
        if (i2 == 3) {
            R(true);
        } else if (i2 == 6 || i2 == 5 || i2 == 4) {
            R(false);
        }
        Q(i2);
        for (int i3 = 0; i3 < this.P.size(); i3++) {
            this.P.get(i3).b(v2, i2);
        }
        P();
    }

    public void L(View view, int i2) {
        int iG;
        int i3;
        if (i2 == 4) {
            iG = this.A;
        } else if (i2 == 6) {
            int i4 = this.f1049y;
            if (!this.f1026b || i4 > (i3 = this.f1048x)) {
                iG = i4;
            } else {
                i2 = 3;
                iG = i3;
            }
        } else if (i2 == 3) {
            iG = G();
        } else {
            if (!this.C || i2 != 5) {
                throw new IllegalArgumentException(g.a.a.a.a.l("Illegal state argument: ", i2));
            }
            iG = this.M;
        }
        O(view, i2, iG, false);
    }

    public final void M(int i2) {
        V v2 = this.N.get();
        if (v2 == null) {
            return;
        }
        ViewParent parent = v2.getParent();
        if (parent != null && parent.isLayoutRequested()) {
            AtomicInteger atomicInteger = y.a;
            if (y.f.b(v2)) {
                v2.post(new b(v2, i2));
                return;
            }
        }
        L(v2, i2);
    }

    public boolean N(View view, float f2) {
        if (this.D) {
            return true;
        }
        if (view.getTop() < this.A) {
            return false;
        }
        return Math.abs(((f2 * 0.1f) + ((float) view.getTop())) - ((float) this.A)) / ((float) C()) > 0.5f;
    }

    /* JADX WARN: Removed duplicated region for block: B:16:0x002f  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void O(android.view.View r5, int r6, int r7, boolean r8) {
        /*
            r4 = this;
            d.j.b.e r0 = r4.G
            r1 = 1
            r2 = 0
            if (r0 == 0) goto L30
            if (r8 == 0) goto L13
            int r8 = r5.getLeft()
            boolean r7 = r0.t(r8, r7)
            if (r7 == 0) goto L30
            goto L2f
        L13:
            int r8 = r5.getLeft()
            r0.f2882s = r5
            r3 = -1
            r0.f2867d = r3
            boolean r7 = r0.l(r8, r7, r2, r2)
            if (r7 != 0) goto L2d
            int r8 = r0.f2865b
            if (r8 != 0) goto L2d
            android.view.View r8 = r0.f2882s
            if (r8 == 0) goto L2d
            r8 = 0
            r0.f2882s = r8
        L2d:
            if (r7 == 0) goto L30
        L2f:
            r2 = r1
        L30:
            if (r2 == 0) goto L56
            r7 = 2
            r4.K(r7)
            r4.Q(r6)
            com.google.android.material.bottomsheet.BottomSheetBehavior<V>$f r7 = r4.f1045u
            if (r7 != 0) goto L44
            com.google.android.material.bottomsheet.BottomSheetBehavior$f r7 = new com.google.android.material.bottomsheet.BottomSheetBehavior$f
            r7.<init>(r5, r6)
            r4.f1045u = r7
        L44:
            com.google.android.material.bottomsheet.BottomSheetBehavior<V>$f r7 = r4.f1045u
            boolean r8 = r7.f1062m
            r7.f1063n = r6
            if (r8 != 0) goto L59
            java.util.concurrent.atomic.AtomicInteger r6 = d.h.j.y.a
            d.h.j.y.c.m(r5, r7)
            com.google.android.material.bottomsheet.BottomSheetBehavior<V>$f r5 = r4.f1045u
            r5.f1062m = r1
            goto L59
        L56:
            r4.K(r6)
        L59:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.bottomsheet.BottomSheetBehavior.O(android.view.View, int, int, boolean):void");
    }

    public final void P() {
        V v2;
        int i2;
        c.a aVar;
        int iA;
        WeakReference<V> weakReference = this.N;
        if (weakReference == null || (v2 = weakReference.get()) == null) {
            return;
        }
        y.m(524288, v2);
        y.j(v2, 0);
        y.m(262144, v2);
        y.j(v2, 0);
        y.m(1048576, v2);
        y.j(v2, 0);
        int i3 = this.V;
        if (i3 != -1) {
            y.m(i3, v2);
            y.j(v2, 0);
        }
        if (!this.f1026b && this.F != 6) {
            String string = v2.getResources().getString(R.string.bottomsheet_action_expand_halfway);
            g.e.a.a.g.c cVar = new g.e.a.a.g.c(this, 6);
            List<c.a> listH = y.h(v2);
            int i4 = 0;
            while (true) {
                if (i4 >= listH.size()) {
                    int i5 = 0;
                    int i6 = -1;
                    while (true) {
                        int[] iArr = y.f2793e;
                        if (i5 >= iArr.length || i6 != -1) {
                            break;
                        }
                        int i7 = iArr[i5];
                        boolean z2 = true;
                        for (int i8 = 0; i8 < listH.size(); i8++) {
                            z2 &= listH.get(i8).a() != i7;
                        }
                        if (z2) {
                            i6 = i7;
                        }
                        i5++;
                    }
                    iA = i6;
                } else {
                    if (TextUtils.equals(string, listH.get(i4).b())) {
                        iA = listH.get(i4).a();
                        break;
                    }
                    i4++;
                }
            }
            if (iA != -1) {
                y.a(v2, new c.a(null, iA, string, cVar, null));
            }
            this.V = iA;
        }
        if (this.C && this.F != 5) {
            H(v2, c.a.f2775f, 5);
        }
        int i9 = this.F;
        if (i9 == 3) {
            i2 = this.f1026b ? 4 : 6;
            aVar = c.a.f2774e;
        } else {
            if (i9 != 4) {
                if (i9 != 6) {
                    return;
                }
                H(v2, c.a.f2774e, 4);
                H(v2, c.a.f2773d, 3);
                return;
            }
            i2 = this.f1026b ? 3 : 6;
            aVar = c.a.f2773d;
        }
        H(v2, aVar, i2);
    }

    public final void Q(int i2) {
        ValueAnimator valueAnimator;
        if (i2 == 2) {
            return;
        }
        boolean z2 = i2 == 3;
        if (this.f1044t != z2) {
            this.f1044t = z2;
            if (this.f1033i == null || (valueAnimator = this.f1046v) == null) {
                return;
            }
            if (valueAnimator.isRunning()) {
                this.f1046v.reverse();
                return;
            }
            float f2 = z2 ? 0.0f : 1.0f;
            this.f1046v.setFloatValues(1.0f - f2, f2);
            this.f1046v.start();
        }
    }

    public final void R(boolean z2) {
        WeakReference<V> weakReference = this.N;
        if (weakReference == null) {
            return;
        }
        ViewParent parent = weakReference.get().getParent();
        if (parent instanceof CoordinatorLayout) {
            CoordinatorLayout coordinatorLayout = (CoordinatorLayout) parent;
            int childCount = coordinatorLayout.getChildCount();
            if (z2) {
                if (this.U != null) {
                    return;
                } else {
                    this.U = new HashMap(childCount);
                }
            }
            for (int i2 = 0; i2 < childCount; i2++) {
                View childAt = coordinatorLayout.getChildAt(i2);
                if (childAt != this.N.get() && z2) {
                    this.U.put(childAt, Integer.valueOf(childAt.getImportantForAccessibility()));
                }
            }
            if (z2) {
                return;
            }
            this.U = null;
        }
    }

    public final void S(boolean z2) {
        V v2;
        if (this.N != null) {
            B();
            if (this.F != 4 || (v2 = this.N.get()) == null) {
                return;
            }
            if (z2) {
                M(this.F);
            } else {
                v2.requestLayout();
            }
        }
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public void f(CoordinatorLayout.f fVar) {
        this.N = null;
        this.G = null;
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public void i() {
        this.N = null;
        this.G = null;
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public boolean j(CoordinatorLayout coordinatorLayout, V v2, MotionEvent motionEvent) {
        d.j.b.e eVar;
        if (!v2.isShown() || !this.E) {
            this.H = true;
            return false;
        }
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 0) {
            this.R = -1;
            VelocityTracker velocityTracker = this.Q;
            if (velocityTracker != null) {
                velocityTracker.recycle();
                this.Q = null;
            }
        }
        if (this.Q == null) {
            this.Q = VelocityTracker.obtain();
        }
        this.Q.addMovement(motionEvent);
        if (actionMasked == 0) {
            int x2 = (int) motionEvent.getX();
            this.S = (int) motionEvent.getY();
            if (this.F != 2) {
                WeakReference<View> weakReference = this.O;
                View view = weakReference != null ? weakReference.get() : null;
                if (view != null && coordinatorLayout.p(view, x2, this.S)) {
                    this.R = motionEvent.getPointerId(motionEvent.getActionIndex());
                    this.T = true;
                }
            }
            this.H = this.R == -1 && !coordinatorLayout.p(v2, x2, this.S);
        } else if (actionMasked == 1 || actionMasked == 3) {
            this.T = false;
            this.R = -1;
            if (this.H) {
                this.H = false;
                return false;
            }
        }
        if (!this.H && (eVar = this.G) != null && eVar.u(motionEvent)) {
            return true;
        }
        WeakReference<View> weakReference2 = this.O;
        View view2 = weakReference2 != null ? weakReference2.get() : null;
        return (actionMasked != 2 || view2 == null || this.H || this.F == 1 || coordinatorLayout.p(view2, (int) motionEvent.getX(), (int) motionEvent.getY()) || this.G == null || Math.abs(((float) this.S) - motionEvent.getY()) <= ((float) this.G.f2866c)) ? false : true;
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public boolean k(CoordinatorLayout coordinatorLayout, V v2, int i2) {
        int iG;
        g gVar;
        AtomicInteger atomicInteger = y.a;
        if (y.c.b(coordinatorLayout) && !y.c.b(v2)) {
            v2.setFitsSystemWindows(true);
        }
        if (this.N == null) {
            this.f1030f = coordinatorLayout.getResources().getDimensionPixelSize(R.dimen.design_bottom_sheet_peek_height_min);
            boolean z2 = (Build.VERSION.SDK_INT < 29 || this.f1036l || this.f1029e) ? false : true;
            if (this.f1037m || this.f1038n || this.f1039o || z2) {
                y.h.u(v2, new l(new g.e.a.a.g.b(this, z2), new o(y.d.f(v2), v2.getPaddingTop(), y.d.e(v2), v2.getPaddingBottom())));
                if (y.f.b(v2)) {
                    y.g.c(v2);
                } else {
                    v2.addOnAttachStateChangeListener(new m());
                }
            }
            this.N = new WeakReference<>(v2);
            if (this.f1032h && (gVar = this.f1033i) != null) {
                y.c.q(v2, gVar);
            }
            g gVar2 = this.f1033i;
            if (gVar2 != null) {
                float fI = this.B;
                if (fI == -1.0f) {
                    fI = y.h.i(v2);
                }
                gVar2.o(fI);
                boolean z3 = this.F == 3;
                this.f1044t = z3;
                this.f1033i.q(z3 ? 0.0f : 1.0f);
            }
            P();
            if (y.c.c(v2) == 0) {
                y.c.s(v2, 1);
            }
            int measuredWidth = v2.getMeasuredWidth();
            int i3 = this.f1034j;
            if (measuredWidth > i3 && i3 != -1) {
                ViewGroup.LayoutParams layoutParams = v2.getLayoutParams();
                layoutParams.width = this.f1034j;
                v2.post(new a(this, v2, layoutParams));
            }
        }
        if (this.G == null) {
            this.G = new d.j.b.e(coordinatorLayout.getContext(), coordinatorLayout, this.W);
        }
        int top = v2.getTop();
        coordinatorLayout.r(v2, i2);
        this.L = coordinatorLayout.getWidth();
        this.M = coordinatorLayout.getHeight();
        int height = v2.getHeight();
        this.K = height;
        int i4 = this.M;
        int i5 = i4 - height;
        int i6 = this.f1042r;
        if (i5 < i6) {
            if (this.f1040p) {
                this.K = i4;
            } else {
                this.K = i4 - i6;
            }
        }
        this.f1048x = Math.max(0, i4 - this.K);
        this.f1049y = (int) ((1.0f - this.f1050z) * this.M);
        B();
        int i7 = this.F;
        if (i7 == 3) {
            iG = G();
        } else if (i7 == 6) {
            iG = this.f1049y;
        } else if (this.C && i7 == 5) {
            iG = this.M;
        } else {
            if (i7 != 4) {
                if (i7 == 1 || i7 == 2) {
                    v2.offsetTopAndBottom(top - v2.getTop());
                }
                this.O = new WeakReference<>(F(v2));
                return true;
            }
            iG = this.A;
        }
        v2.offsetTopAndBottom(iG);
        this.O = new WeakReference<>(F(v2));
        return true;
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public boolean n(CoordinatorLayout coordinatorLayout, V v2, View view, float f2, float f3) {
        WeakReference<View> weakReference = this.O;
        return (weakReference == null || view != weakReference.get() || this.F == 3) ? false : true;
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public void p(CoordinatorLayout coordinatorLayout, V v2, View view, int i2, int i3, int[] iArr, int i4) {
        int i5;
        if (i4 == 1) {
            return;
        }
        WeakReference<View> weakReference = this.O;
        if (view != (weakReference != null ? weakReference.get() : null)) {
            return;
        }
        int top = v2.getTop();
        int i6 = top - i3;
        if (i3 > 0) {
            if (i6 < G()) {
                iArr[1] = top - G();
                int i7 = -iArr[1];
                AtomicInteger atomicInteger = y.a;
                v2.offsetTopAndBottom(i7);
                i5 = 3;
                K(i5);
            } else {
                if (!this.E) {
                    return;
                }
                iArr[1] = i3;
                int i8 = -i3;
                AtomicInteger atomicInteger2 = y.a;
                v2.offsetTopAndBottom(i8);
                K(1);
            }
        } else if (i3 < 0 && !view.canScrollVertically(-1)) {
            int i9 = this.A;
            if (i6 > i9 && !this.C) {
                iArr[1] = top - i9;
                int i10 = -iArr[1];
                AtomicInteger atomicInteger3 = y.a;
                v2.offsetTopAndBottom(i10);
                i5 = 4;
                K(i5);
            } else {
                if (!this.E) {
                    return;
                }
                iArr[1] = i3;
                int i82 = -i3;
                AtomicInteger atomicInteger22 = y.a;
                v2.offsetTopAndBottom(i82);
                K(1);
            }
        }
        E(v2.getTop());
        this.I = i3;
        this.J = true;
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public void r(CoordinatorLayout coordinatorLayout, V v2, View view, int i2, int i3, int i4, int i5, int i6, int[] iArr) {
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public void u(CoordinatorLayout coordinatorLayout, V v2, Parcelable parcelable) {
        e eVar = (e) parcelable;
        int i2 = this.a;
        if (i2 != 0) {
            if (i2 == -1 || (i2 & 1) == 1) {
                this.f1028d = eVar.f1057o;
            }
            if (i2 == -1 || (i2 & 2) == 2) {
                this.f1026b = eVar.f1058p;
            }
            if (i2 == -1 || (i2 & 4) == 4) {
                this.C = eVar.f1059q;
            }
            if (i2 == -1 || (i2 & 8) == 8) {
                this.D = eVar.f1060r;
            }
        }
        int i3 = eVar.f1056n;
        if (i3 == 1 || i3 == 2) {
            this.F = 4;
        } else {
            this.F = i3;
        }
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public Parcelable v(CoordinatorLayout coordinatorLayout, V v2) {
        return new e((Parcelable) View.BaseSavedState.EMPTY_STATE, (BottomSheetBehavior<?>) this);
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public boolean x(CoordinatorLayout coordinatorLayout, V v2, View view, View view2, int i2, int i3) {
        this.I = 0;
        this.J = false;
        return (i2 & 2) != 0;
    }

    /* JADX WARN: Code restructure failed: missing block: B:40:0x0084, code lost:
    
        if (r4 < java.lang.Math.abs(r4 - r3.A)) goto L41;
     */
    /* JADX WARN: Code restructure failed: missing block: B:43:0x0098, code lost:
    
        if (java.lang.Math.abs(r4 - r1) < java.lang.Math.abs(r4 - r3.A)) goto L50;
     */
    /* JADX WARN: Code restructure failed: missing block: B:49:0x00b3, code lost:
    
        if (java.lang.Math.abs(r4 - r3.f1049y) < java.lang.Math.abs(r4 - r3.A)) goto L50;
     */
    /* JADX WARN: Removed duplicated region for block: B:30:0x0058  */
    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void z(androidx.coordinatorlayout.widget.CoordinatorLayout r4, V r5, android.view.View r6, int r7) {
        /*
            r3 = this;
            int r4 = r5.getTop()
            int r7 = r3.G()
            r0 = 3
            if (r4 != r7) goto Lf
            r3.K(r0)
            return
        Lf:
            java.lang.ref.WeakReference<android.view.View> r4 = r3.O
            if (r4 == 0) goto Lc3
            java.lang.Object r4 = r4.get()
            if (r6 != r4) goto Lc3
            boolean r4 = r3.J
            if (r4 != 0) goto L1f
            goto Lc3
        L1f:
            int r4 = r3.I
            r6 = 4
            r7 = 6
            if (r4 <= 0) goto L34
            boolean r4 = r3.f1026b
            if (r4 == 0) goto L2a
            goto L75
        L2a:
            int r4 = r5.getTop()
            int r6 = r3.f1049y
            if (r4 <= r6) goto L86
            goto Lb7
        L34:
            boolean r4 = r3.C
            if (r4 == 0) goto L58
            android.view.VelocityTracker r4 = r3.Q
            if (r4 != 0) goto L3e
            r4 = 0
            goto L4d
        L3e:
            r1 = 1000(0x3e8, float:1.401E-42)
            float r2 = r3.f1027c
            r4.computeCurrentVelocity(r1, r2)
            android.view.VelocityTracker r4 = r3.Q
            int r1 = r3.R
            float r4 = r4.getYVelocity(r1)
        L4d:
            boolean r4 = r3.N(r5, r4)
            if (r4 == 0) goto L58
            int r4 = r3.M
            r0 = 5
            goto Lbd
        L58:
            int r4 = r3.I
            if (r4 != 0) goto L9b
            int r4 = r5.getTop()
            boolean r1 = r3.f1026b
            if (r1 == 0) goto L78
            int r7 = r3.f1048x
            int r7 = r4 - r7
            int r7 = java.lang.Math.abs(r7)
            int r1 = r3.A
            int r4 = r4 - r1
            int r4 = java.lang.Math.abs(r4)
            if (r7 >= r4) goto Lba
        L75:
            int r4 = r3.f1048x
            goto Lbd
        L78:
            int r1 = r3.f1049y
            if (r4 >= r1) goto L8b
            int r6 = r3.A
            int r6 = r4 - r6
            int r6 = java.lang.Math.abs(r6)
            if (r4 >= r6) goto Lb5
        L86:
            int r4 = r3.G()
            goto Lbd
        L8b:
            int r0 = r4 - r1
            int r0 = java.lang.Math.abs(r0)
            int r1 = r3.A
            int r4 = r4 - r1
            int r4 = java.lang.Math.abs(r4)
            if (r0 >= r4) goto Lba
            goto Lb5
        L9b:
            boolean r4 = r3.f1026b
            if (r4 == 0) goto La0
            goto Lba
        La0:
            int r4 = r5.getTop()
            int r0 = r3.f1049y
            int r0 = r4 - r0
            int r0 = java.lang.Math.abs(r0)
            int r1 = r3.A
            int r4 = r4 - r1
            int r4 = java.lang.Math.abs(r4)
            if (r0 >= r4) goto Lba
        Lb5:
            int r6 = r3.f1049y
        Lb7:
            r4 = r6
            r0 = r7
            goto Lbd
        Lba:
            int r4 = r3.A
            r0 = r6
        Lbd:
            r6 = 0
            r3.O(r5, r0, r4, r6)
            r3.J = r6
        Lc3:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.bottomsheet.BottomSheetBehavior.z(androidx.coordinatorlayout.widget.CoordinatorLayout, android.view.View, android.view.View, int):void");
    }
}
