package a0;

import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.Xml;
import android.view.View;
import androidx.constraintlayout.motion.widget.MotionLayout;

/* JADX INFO: loaded from: classes.dex */
public final class a0 implements View.OnClickListener {

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

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

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

    public a0(Context context, b0 b0Var, XmlResourceParser xmlResourceParser) {
        this.f6b = -1;
        this.f7c = 17;
        this.f5a = b0Var;
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlResourceParser), androidx.constraintlayout.widget.s.OnClick);
        int indexCount = typedArrayObtainStyledAttributes.getIndexCount();
        for (int i10 = 0; i10 < indexCount; i10++) {
            int index = typedArrayObtainStyledAttributes.getIndex(i10);
            if (index == androidx.constraintlayout.widget.s.OnClick_targetId) {
                this.f6b = typedArrayObtainStyledAttributes.getResourceId(index, this.f6b);
            } else if (index == androidx.constraintlayout.widget.s.OnClick_clickAction) {
                this.f7c = typedArrayObtainStyledAttributes.getInt(index, this.f7c);
            }
        }
        typedArrayObtainStyledAttributes.recycle();
    }

    public final void a(MotionLayout motionLayout, int i10, b0 b0Var) {
        int i11 = this.f6b;
        View viewFindViewById = motionLayout;
        if (i11 != -1) {
            viewFindViewById = motionLayout.findViewById(i11);
        }
        if (viewFindViewById == null) {
            return;
        }
        int i12 = b0Var.f11d;
        int i13 = b0Var.f10c;
        if (i12 == -1) {
            viewFindViewById.setOnClickListener(this);
            return;
        }
        int i14 = this.f7c;
        int i15 = i14 & 1;
        if (((i15 != 0 && i10 == i12) | (i15 != 0 && i10 == i12) | ((i14 & 256) != 0 && i10 == i12) | ((i14 & 16) != 0 && i10 == i13)) || ((i14 & 4096) != 0 && i10 == i13)) {
            viewFindViewById.setOnClickListener(this);
        }
    }

    @Override // android.view.View.OnClickListener
    public final void onClick(View view) {
        b0 b0Var = this.f5a;
        androidx.constraintlayout.motion.widget.b bVar = b0Var.f17j;
        MotionLayout motionLayout = bVar.f1134a;
        if (motionLayout.f1099d0) {
            if (b0Var.f11d == -1) {
                int currentState = motionLayout.getCurrentState();
                if (currentState != -1) {
                    b0 b0Var2 = new b0(b0Var.f17j, b0Var);
                    b0Var2.f11d = currentState;
                    b0Var2.f10c = b0Var.f10c;
                    motionLayout.setTransition(b0Var2);
                    motionLayout.u();
                    return;
                }
                int i10 = b0Var.f10c;
                if (motionLayout.isAttachedToWindow()) {
                    motionLayout.v(i10, -1);
                    return;
                }
                if (motionLayout.V0 == null) {
                    motionLayout.V0 = new androidx.constraintlayout.motion.widget.a(motionLayout);
                }
                motionLayout.V0.f1132d = i10;
                return;
            }
            b0 b0Var3 = bVar.f1136c;
            int i11 = this.f7c;
            int i12 = i11 & 1;
            boolean z10 = true;
            boolean z11 = false;
            boolean z12 = (i12 == 0 && (i11 & 256) == 0) ? false : true;
            int i13 = i11 & 16;
            if (i13 == 0 && (i11 & 4096) == 0) {
                z10 = false;
            }
            if (z12 && z10) {
                if (b0Var3 != b0Var) {
                    motionLayout.setTransition(b0Var);
                }
                if (motionLayout.getCurrentState() != motionLayout.getEndState() && motionLayout.getProgress() <= 0.5f) {
                    z10 = false;
                    z11 = z12;
                }
            } else {
                z11 = z12;
            }
            if (b0Var != b0Var3) {
                int i14 = b0Var.f10c;
                int i15 = b0Var.f11d;
                if (i15 != -1) {
                    int i16 = motionLayout.W;
                    if (i16 != i15 && i16 != i14) {
                        return;
                    }
                } else if (motionLayout.W == i14) {
                    return;
                }
            }
            if (z11 && i12 != 0) {
                motionLayout.setTransition(b0Var);
                motionLayout.u();
                return;
            }
            if (z10 && i13 != 0) {
                motionLayout.setTransition(b0Var);
                motionLayout.h(0.0f);
            } else if (z11 && (i11 & 256) != 0) {
                motionLayout.setTransition(b0Var);
                motionLayout.setProgress(1.0f);
            } else {
                if (!z10 || (i11 & 4096) == 0) {
                    return;
                }
                motionLayout.setTransition(b0Var);
                motionLayout.setProgress(0.0f);
            }
        }
    }
}
