package androidx.constraintlayout.helper.widget;

import a0.d0;
import a0.e;
import a0.j;
import a0.q;
import a0.y;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import androidx.constraintlayout.motion.widget.MotionHelper;
import androidx.constraintlayout.motion.widget.MotionLayout;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.s;
import java.util.ArrayList;
import java.util.HashMap;
import o6.b;

/* JADX INFO: loaded from: classes.dex */
public class MotionEffect extends MotionHelper {
    public float Q;
    public int R;
    public int S;
    public int T;
    public int U;
    public boolean V;
    public int W;

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

    public MotionEffect(Context context) {
        super(context);
        this.Q = 0.1f;
        this.R = 49;
        this.S = 50;
        this.T = 0;
        this.U = 0;
        this.V = true;
        this.W = -1;
        this.f1088a0 = -1;
    }

    /* JADX WARN: Code restructure failed: missing block: B:57:0x016a, code lost:
    
        if (r14 == 0.0f) goto L60;
     */
    /* JADX WARN: Code restructure failed: missing block: B:68:0x0180, code lost:
    
        if (r14 == 0.0f) goto L60;
     */
    /* JADX WARN: Removed duplicated region for block: B:101:0x01d7  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x0147  */
    /* JADX WARN: Removed duplicated region for block: B:92:0x01ac  */
    @Override // androidx.constraintlayout.motion.widget.MotionHelper
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void s(MotionLayout motionLayout, HashMap map) {
        e eVar;
        e eVar2;
        e eVar3;
        e eVar4;
        int i10;
        e eVar5;
        View[] viewArr;
        e eVar6;
        int i11;
        MotionEffect motionEffect = this;
        HashMap map2 = map;
        View[] viewArrK = motionEffect.k((ConstraintLayout) getParent());
        if (viewArrK == null) {
            b.n();
            return;
        }
        e eVar7 = new e();
        e eVar8 = new e();
        eVar7.h(Float.valueOf(motionEffect.Q), "alpha");
        eVar8.h(Float.valueOf(motionEffect.Q), "alpha");
        int i12 = motionEffect.R;
        eVar7.f26a = i12;
        eVar8.f26a = motionEffect.S;
        j jVar = new j();
        jVar.f26a = i12;
        int i13 = 0;
        jVar.f113o = 0;
        jVar.h(0, "percentX");
        jVar.h(0, "percentY");
        j jVar2 = new j();
        jVar2.f26a = motionEffect.S;
        jVar2.f113o = 0;
        jVar2.h(1, "percentX");
        jVar2.h(1, "percentY");
        e eVar9 = null;
        if (motionEffect.T > 0) {
            eVar = new e();
            eVar2 = new e();
            eVar.h(Integer.valueOf(motionEffect.T), "translationX");
            eVar.f26a = motionEffect.S;
            eVar2.h(0, "translationX");
            eVar2.f26a = motionEffect.S - 1;
        } else {
            eVar = null;
            eVar2 = null;
        }
        if (motionEffect.U > 0) {
            eVar9 = new e();
            eVar3 = new e();
            eVar9.h(Integer.valueOf(motionEffect.U), "translationY");
            eVar9.f26a = motionEffect.S;
            eVar3.h(0, "translationY");
            eVar3.f26a = motionEffect.S - 1;
        } else {
            eVar3 = null;
        }
        int i14 = motionEffect.f1088a0;
        if (i14 == -1) {
            int[] iArr = new int[4];
            int i15 = 0;
            while (i15 < viewArrK.length) {
                q qVar = (q) map2.get(viewArrK[i15]);
                if (qVar == null) {
                    eVar6 = eVar3;
                } else {
                    y yVar = qVar.f172g;
                    float f10 = yVar.f225e;
                    y yVar2 = qVar.f171f;
                    eVar6 = eVar3;
                    float f11 = f10 - yVar2.f225e;
                    float f12 = yVar.f226f - yVar2.f226f;
                    if (f12 < 0.0f) {
                        i11 = 1;
                        iArr[1] = iArr[1] + 1;
                    } else {
                        i11 = 1;
                    }
                    if (f12 > 0.0f) {
                        iArr[0] = iArr[0] + i11;
                    }
                    if (f11 > 0.0f) {
                        iArr[3] = iArr[3] + i11;
                    }
                    if (f11 < 0.0f) {
                        iArr[2] = iArr[2] + i11;
                    }
                }
                i15++;
                eVar3 = eVar6;
                i13 = 0;
            }
            eVar4 = eVar3;
            int i16 = iArr[i13];
            i14 = i13;
            for (int i17 = 1; i17 < 4; i17++) {
                int i18 = iArr[i17];
                if (i16 < i18) {
                    i16 = i18;
                    i14 = i17;
                }
            }
        } else {
            eVar4 = eVar3;
        }
        int i19 = 0;
        while (i19 < viewArrK.length) {
            q qVar2 = (q) map2.get(viewArrK[i19]);
            if (qVar2 == null) {
                viewArr = viewArrK;
                eVar5 = eVar4;
            } else {
                y yVar3 = qVar2.f172g;
                float f13 = yVar3.f225e;
                y yVar4 = qVar2.f171f;
                float f14 = f13 - yVar4.f225e;
                float f15 = yVar3.f226f - yVar4.f226f;
                if (i14 == 0) {
                    if (f15 > 0.0f) {
                        if (motionEffect.V) {
                        }
                        viewArr = viewArrK;
                        eVar5 = eVar4;
                    }
                    i10 = motionEffect.W;
                    if (i10 != -1) {
                        qVar2.a(eVar7);
                        qVar2.a(eVar8);
                        qVar2.a(jVar);
                        qVar2.a(jVar2);
                        if (motionEffect.T > 0) {
                            qVar2.a(eVar);
                            qVar2.a(eVar2);
                        }
                        if (motionEffect.U > 0) {
                            qVar2.a(eVar9);
                            eVar5 = eVar4;
                            qVar2.a(eVar5);
                        } else {
                            eVar5 = eVar4;
                        }
                    } else {
                        eVar5 = eVar4;
                        androidx.constraintlayout.motion.widget.b bVar = motionLayout.R;
                        if (bVar != null) {
                            for (d0 d0Var : (ArrayList) bVar.f1150q.f29640b) {
                                viewArr = viewArrK;
                                if (d0Var.f44a == i10) {
                                    ArrayList arrayList = (ArrayList) d0Var.f49f.f101a.get(-1);
                                    if (arrayList != null) {
                                        qVar2.f188w.addAll(arrayList);
                                    }
                                } else {
                                    viewArrK = viewArr;
                                }
                            }
                        }
                    }
                    viewArr = viewArrK;
                } else if (i14 == 1) {
                    if (f15 < 0.0f) {
                        if (motionEffect.V) {
                        }
                        viewArr = viewArrK;
                        eVar5 = eVar4;
                    }
                    i10 = motionEffect.W;
                    if (i10 != -1) {
                    }
                    viewArr = viewArrK;
                } else if (i14 == 2) {
                    if (f14 >= 0.0f || (motionEffect.V && f15 != 0.0f)) {
                        i10 = motionEffect.W;
                        if (i10 != -1) {
                        }
                        viewArr = viewArrK;
                    } else {
                        viewArr = viewArrK;
                        eVar5 = eVar4;
                    }
                } else if (i14 != 3 || f14 <= 0.0f || (motionEffect.V && f15 != 0.0f)) {
                    i10 = motionEffect.W;
                    if (i10 != -1) {
                    }
                    viewArr = viewArrK;
                }
            }
            i19++;
            motionEffect = this;
            map2 = map;
            eVar4 = eVar5;
            viewArrK = viewArr;
        }
    }

    public final void t(Context context, AttributeSet attributeSet) {
        if (attributeSet != null) {
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, s.MotionEffect);
            int indexCount = typedArrayObtainStyledAttributes.getIndexCount();
            for (int i10 = 0; i10 < indexCount; i10++) {
                int index = typedArrayObtainStyledAttributes.getIndex(i10);
                if (index == s.MotionEffect_motionEffect_start) {
                    int i11 = typedArrayObtainStyledAttributes.getInt(index, this.R);
                    this.R = i11;
                    this.R = Math.max(Math.min(i11, 99), 0);
                } else if (index == s.MotionEffect_motionEffect_end) {
                    int i12 = typedArrayObtainStyledAttributes.getInt(index, this.S);
                    this.S = i12;
                    this.S = Math.max(Math.min(i12, 99), 0);
                } else if (index == s.MotionEffect_motionEffect_translationX) {
                    this.T = typedArrayObtainStyledAttributes.getDimensionPixelOffset(index, this.T);
                } else if (index == s.MotionEffect_motionEffect_translationY) {
                    this.U = typedArrayObtainStyledAttributes.getDimensionPixelOffset(index, this.U);
                } else if (index == s.MotionEffect_motionEffect_alpha) {
                    this.Q = typedArrayObtainStyledAttributes.getFloat(index, this.Q);
                } else if (index == s.MotionEffect_motionEffect_move) {
                    this.f1088a0 = typedArrayObtainStyledAttributes.getInt(index, this.f1088a0);
                } else if (index == s.MotionEffect_motionEffect_strict) {
                    this.V = typedArrayObtainStyledAttributes.getBoolean(index, this.V);
                } else if (index == s.MotionEffect_motionEffect_viewTransition) {
                    this.W = typedArrayObtainStyledAttributes.getResourceId(index, this.W);
                }
            }
            int i13 = this.R;
            int i14 = this.S;
            if (i13 == i14) {
                if (i13 > 0) {
                    this.R = i13 - 1;
                } else {
                    this.S = i14 + 1;
                }
            }
            typedArrayObtainStyledAttributes.recycle();
        }
    }

    public MotionEffect(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.Q = 0.1f;
        this.R = 49;
        this.S = 50;
        this.T = 0;
        this.U = 0;
        this.V = true;
        this.W = -1;
        this.f1088a0 = -1;
        t(context, attributeSet);
    }

    public MotionEffect(Context context, AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        this.Q = 0.1f;
        this.R = 49;
        this.S = 50;
        this.T = 0;
        this.U = 0;
        this.V = true;
        this.W = -1;
        this.f1088a0 = -1;
        t(context, attributeSet);
    }
}
