package w;

import androidx.constraintlayout.core.widgets.ConstraintAnchor$Type;
import androidx.constraintlayout.core.widgets.ConstraintWidget$DimensionBehaviour;
import com.google.android.gms.measurement.internal.u1;
import java.util.HashMap;

/* JADX INFO: loaded from: classes.dex */
public final class a extends j {

    /* JADX INFO: renamed from: x0, reason: collision with root package name */
    public int f34000x0 = 0;

    /* JADX INFO: renamed from: y0, reason: collision with root package name */
    public boolean f34001y0 = true;
    public int z0 = 0;
    public boolean A0 = false;

    @Override // w.d
    public final boolean C() {
        return this.A0;
    }

    @Override // w.d
    public final boolean D() {
        return this.A0;
    }

    public final boolean V() {
        int i10;
        int i11;
        int i12;
        boolean z10 = true;
        int i13 = 0;
        while (true) {
            i10 = this.f34107w0;
            if (i13 >= i10) {
                break;
            }
            d dVar = this.f34106v0[i13];
            if ((this.f34001y0 || dVar.d()) && ((((i11 = this.f34000x0) == 0 || i11 == 1) && !dVar.C()) || (((i12 = this.f34000x0) == 2 || i12 == 3) && !dVar.D()))) {
                z10 = false;
            }
            i13++;
        }
        if (!z10 || i10 <= 0) {
            return false;
        }
        int iMax = 0;
        boolean z11 = false;
        for (int i14 = 0; i14 < this.f34107w0; i14++) {
            d dVar2 = this.f34106v0[i14];
            if (this.f34001y0 || dVar2.d()) {
                ConstraintAnchor$Type constraintAnchor$Type = ConstraintAnchor$Type.f1006d;
                ConstraintAnchor$Type constraintAnchor$Type2 = ConstraintAnchor$Type.f1004b;
                ConstraintAnchor$Type constraintAnchor$Type3 = ConstraintAnchor$Type.f1005c;
                ConstraintAnchor$Type constraintAnchor$Type4 = ConstraintAnchor$Type.f1003a;
                if (!z11) {
                    int i15 = this.f34000x0;
                    if (i15 == 0) {
                        iMax = dVar2.k(constraintAnchor$Type4).d();
                    } else if (i15 == 1) {
                        iMax = dVar2.k(constraintAnchor$Type3).d();
                    } else if (i15 == 2) {
                        iMax = dVar2.k(constraintAnchor$Type2).d();
                    } else if (i15 == 3) {
                        iMax = dVar2.k(constraintAnchor$Type).d();
                    }
                    z11 = true;
                }
                int i16 = this.f34000x0;
                if (i16 == 0) {
                    iMax = Math.min(iMax, dVar2.k(constraintAnchor$Type4).d());
                } else if (i16 == 1) {
                    iMax = Math.max(iMax, dVar2.k(constraintAnchor$Type3).d());
                } else if (i16 == 2) {
                    iMax = Math.min(iMax, dVar2.k(constraintAnchor$Type2).d());
                } else if (i16 == 3) {
                    iMax = Math.max(iMax, dVar2.k(constraintAnchor$Type).d());
                }
            }
        }
        int i17 = iMax + this.z0;
        int i18 = this.f34000x0;
        if (i18 == 0 || i18 == 1) {
            L(i17, i17);
        } else {
            M(i17, i17);
        }
        this.A0 = true;
        return true;
    }

    public final int W() {
        int i10 = this.f34000x0;
        if (i10 == 0 || i10 == 1) {
            return 0;
        }
        return (i10 == 2 || i10 == 3) ? 1 : -1;
    }

    @Override // w.d
    public final void c(u.f fVar, boolean z10) {
        boolean z11;
        int i10;
        c[] cVarArr = this.R;
        c cVar = this.J;
        cVarArr[0] = cVar;
        c cVar2 = this.K;
        int i11 = 2;
        cVarArr[2] = cVar2;
        c cVar3 = this.L;
        cVarArr[1] = cVar3;
        c cVar4 = this.M;
        cVarArr[3] = cVar4;
        for (c cVar5 : cVarArr) {
            cVar5.f34027i = fVar.k(cVar5);
        }
        int i12 = this.f34000x0;
        if (i12 < 0 || i12 >= 4) {
            return;
        }
        c cVar6 = cVarArr[i12];
        if (!this.A0) {
            V();
        }
        if (this.A0) {
            this.A0 = false;
            int i13 = this.f34000x0;
            if (i13 == 0 || i13 == 1) {
                fVar.d(cVar.f34027i, this.f34029a0);
                fVar.d(cVar3.f34027i, this.f34029a0);
                return;
            } else {
                if (i13 == 2 || i13 == 3) {
                    fVar.d(cVar2.f34027i, this.f34031b0);
                    fVar.d(cVar4.f34027i, this.f34031b0);
                    return;
                }
                return;
            }
        }
        for (int i14 = 0; i14 < this.f34107w0; i14++) {
            d dVar = this.f34106v0[i14];
            if (this.f34001y0 || dVar.d()) {
                int i15 = this.f34000x0;
                ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour = ConstraintWidget$DimensionBehaviour.f1014c;
                if (((i15 == 0 || i15 == 1) && dVar.U[0] == constraintWidget$DimensionBehaviour && dVar.J.f34024f != null && dVar.L.f34024f != null) || ((i15 == 2 || i15 == 3) && dVar.U[1] == constraintWidget$DimensionBehaviour && dVar.K.f34024f != null && dVar.M.f34024f != null)) {
                    z11 = true;
                    break;
                }
            }
        }
        z11 = false;
        boolean z12 = cVar.g() || cVar3.g();
        boolean z13 = cVar2.g() || cVar4.g();
        int i16 = (z11 || !(((i10 = this.f34000x0) == 0 && z12) || ((i10 == 2 && z13) || ((i10 == 1 && z12) || (i10 == 3 && z13))))) ? 4 : 5;
        int i17 = 0;
        while (i17 < this.f34107w0) {
            d dVar2 = this.f34106v0[i17];
            if (this.f34001y0 || dVar2.d()) {
                u.k kVarK = fVar.k(dVar2.R[this.f34000x0]);
                int i18 = this.f34000x0;
                c cVar7 = dVar2.R[i18];
                cVar7.f34027i = kVarK;
                c cVar8 = cVar7.f34024f;
                int i19 = (cVar8 == null || cVar8.f34022d != this) ? 0 : cVar7.f34025g;
                if (i18 == 0 || i18 == i11) {
                    u.k kVar = cVar6.f34027i;
                    int i20 = this.z0 - i19;
                    u.d dVarL = fVar.l();
                    u.k kVarM = fVar.m();
                    kVarM.f33158d = 0;
                    dVarL.c(kVar, kVarK, kVarM, i20);
                    fVar.c(dVarL);
                } else {
                    u.k kVar2 = cVar6.f34027i;
                    int i21 = this.z0 + i19;
                    u.d dVarL2 = fVar.l();
                    u.k kVarM2 = fVar.m();
                    kVarM2.f33158d = 0;
                    dVarL2.b(kVar2, kVarK, kVarM2, i21);
                    fVar.c(dVarL2);
                }
                fVar.e(cVar6.f34027i, kVarK, this.z0 + i19, i16);
            }
            i17++;
            i11 = 2;
        }
        int i22 = this.f34000x0;
        if (i22 == 0) {
            fVar.e(cVar3.f34027i, cVar.f34027i, 0, 8);
            fVar.e(cVar.f34027i, this.V.L.f34027i, 0, 4);
            fVar.e(cVar.f34027i, this.V.J.f34027i, 0, 0);
            return;
        }
        if (i22 == 1) {
            fVar.e(cVar.f34027i, cVar3.f34027i, 0, 8);
            fVar.e(cVar.f34027i, this.V.J.f34027i, 0, 4);
            fVar.e(cVar.f34027i, this.V.L.f34027i, 0, 0);
        } else if (i22 == 2) {
            fVar.e(cVar4.f34027i, cVar2.f34027i, 0, 8);
            fVar.e(cVar2.f34027i, this.V.M.f34027i, 0, 4);
            fVar.e(cVar2.f34027i, this.V.K.f34027i, 0, 0);
        } else if (i22 == 3) {
            fVar.e(cVar2.f34027i, cVar4.f34027i, 0, 8);
            fVar.e(cVar2.f34027i, this.V.K.f34027i, 0, 4);
            fVar.e(cVar2.f34027i, this.V.M.f34027i, 0, 0);
        }
    }

    @Override // w.d
    public final boolean d() {
        return true;
    }

    @Override // w.j, w.d
    public final void h(d dVar, HashMap map) {
        super.h(dVar, map);
        a aVar = (a) dVar;
        this.f34000x0 = aVar.f34000x0;
        this.f34001y0 = aVar.f34001y0;
        this.z0 = aVar.z0;
    }

    @Override // w.d
    public final String toString() {
        String strO = defpackage.e.o(new StringBuilder("[Barrier] "), this.f34049k0, " {");
        for (int i10 = 0; i10 < this.f34107w0; i10++) {
            d dVar = this.f34106v0[i10];
            if (i10 > 0) {
                strO = u1.j(strO, ", ");
            }
            StringBuilder sbC = u.a.c(strO);
            sbC.append(dVar.f34049k0);
            strO = sbC.toString();
        }
        return u1.j(strO, "}");
    }
}
