package c.e.b.h;

import c.e.b.h.c;
import c.e.b.h.d;

/* JADX INFO: compiled from: Barrier.java */
/* JADX INFO: loaded from: classes.dex */
public class a extends h {
    public int n0 = 0;
    public boolean o0 = true;
    public int p0 = 0;
    public boolean q0 = false;

    @Override // c.e.b.h.d
    public boolean A() {
        return this.q0;
    }

    @Override // c.e.b.h.d
    public boolean B() {
        return this.q0;
    }

    public boolean R() {
        int i2;
        int i3;
        int i4;
        int i5 = 0;
        boolean z = true;
        while (true) {
            i2 = this.m0;
            if (i5 >= i2) {
                break;
            }
            d dVar = this.l0[i5];
            if ((this.o0 || dVar.e()) && ((((i3 = this.n0) == 0 || i3 == 1) && !dVar.A()) || (((i4 = this.n0) == 2 || i4 == 3) && !dVar.B()))) {
                z = false;
            }
            i5++;
        }
        if (!z || i2 <= 0) {
            return false;
        }
        int iMax = 0;
        boolean z2 = false;
        for (int i6 = 0; i6 < this.m0; i6++) {
            d dVar2 = this.l0[i6];
            if (this.o0 || dVar2.e()) {
                if (!z2) {
                    int i7 = this.n0;
                    if (i7 == 0) {
                        iMax = dVar2.i(c.a.LEFT).c();
                    } else if (i7 == 1) {
                        iMax = dVar2.i(c.a.RIGHT).c();
                    } else if (i7 == 2) {
                        iMax = dVar2.i(c.a.TOP).c();
                    } else if (i7 == 3) {
                        iMax = dVar2.i(c.a.BOTTOM).c();
                    }
                    z2 = true;
                }
                int i8 = this.n0;
                if (i8 == 0) {
                    iMax = Math.min(iMax, dVar2.i(c.a.LEFT).c());
                } else if (i8 == 1) {
                    iMax = Math.max(iMax, dVar2.i(c.a.RIGHT).c());
                } else if (i8 == 2) {
                    iMax = Math.min(iMax, dVar2.i(c.a.TOP).c());
                } else if (i8 == 3) {
                    iMax = Math.max(iMax, dVar2.i(c.a.BOTTOM).c());
                }
            }
        }
        int i9 = iMax + this.p0;
        int i10 = this.n0;
        if (i10 == 0 || i10 == 1) {
            G(i9, i9);
        } else {
            H(i9, i9);
        }
        this.q0 = true;
        return true;
    }

    public int S() {
        int i2 = this.n0;
        if (i2 == 0 || i2 == 1) {
            return 0;
        }
        return (i2 == 2 || i2 == 3) ? 1 : -1;
    }

    @Override // c.e.b.h.d
    public void d(c.e.b.d dVar, boolean z) {
        c[] cVarArr;
        boolean z2;
        int i2;
        int i3;
        int i4;
        c[] cVarArr2 = this.L;
        cVarArr2[0] = this.D;
        cVarArr2[2] = this.E;
        cVarArr2[1] = this.F;
        cVarArr2[3] = this.G;
        int i5 = 0;
        while (true) {
            cVarArr = this.L;
            if (i5 >= cVarArr.length) {
                break;
            }
            cVarArr[i5].f1126i = dVar.l(cVarArr[i5]);
            i5++;
        }
        int i6 = this.n0;
        if (i6 < 0 || i6 >= 4) {
            return;
        }
        c cVar = cVarArr[i6];
        if (!this.q0) {
            R();
        }
        if (this.q0) {
            this.q0 = false;
            int i7 = this.n0;
            if (i7 == 0 || i7 == 1) {
                dVar.e(this.D.f1126i, this.U);
                dVar.e(this.F.f1126i, this.U);
                return;
            } else {
                if (i7 == 2 || i7 == 3) {
                    dVar.e(this.E.f1126i, this.V);
                    dVar.e(this.G.f1126i, this.V);
                    return;
                }
                return;
            }
        }
        for (int i8 = 0; i8 < this.m0; i8++) {
            d dVar2 = this.l0[i8];
            if ((this.o0 || dVar2.e()) && ((((i3 = this.n0) == 0 || i3 == 1) && dVar2.m() == d.a.MATCH_CONSTRAINT && dVar2.D.f1123f != null && dVar2.F.f1123f != null) || (((i4 = this.n0) == 2 || i4 == 3) && dVar2.q() == d.a.MATCH_CONSTRAINT && dVar2.E.f1123f != null && dVar2.G.f1123f != null))) {
                z2 = true;
                break;
            }
        }
        z2 = false;
        boolean z3 = this.D.e() || this.F.e();
        boolean z4 = this.E.e() || this.G.e();
        int i9 = !z2 && (((i2 = this.n0) == 0 && z3) || ((i2 == 2 && z4) || ((i2 == 1 && z3) || (i2 == 3 && z4)))) ? 5 : 4;
        for (int i10 = 0; i10 < this.m0; i10++) {
            d dVar3 = this.l0[i10];
            if (this.o0 || dVar3.e()) {
                c.e.b.g gVarL = dVar.l(dVar3.L[this.n0]);
                c[] cVarArr3 = dVar3.L;
                int i11 = this.n0;
                cVarArr3[i11].f1126i = gVarL;
                int i12 = (cVarArr3[i11].f1123f == null || cVarArr3[i11].f1123f.f1121d != this) ? 0 : cVarArr3[i11].f1124g + 0;
                if (i11 == 0 || i11 == 2) {
                    c.e.b.g gVar = cVar.f1126i;
                    int i13 = this.p0 - i12;
                    c.e.b.b bVarM = dVar.m();
                    c.e.b.g gVarN = dVar.n();
                    gVarN.f1100e = 0;
                    bVarM.f(gVar, gVarL, gVarN, i13);
                    dVar.c(bVarM);
                } else {
                    c.e.b.g gVar2 = cVar.f1126i;
                    int i14 = this.p0 + i12;
                    c.e.b.b bVarM2 = dVar.m();
                    c.e.b.g gVarN2 = dVar.n();
                    gVarN2.f1100e = 0;
                    bVarM2.e(gVar2, gVarL, gVarN2, i14);
                    dVar.c(bVarM2);
                }
                dVar.d(cVar.f1126i, gVarL, this.p0 + i12, i9);
            }
        }
        int i15 = this.n0;
        if (i15 == 0) {
            dVar.d(this.F.f1126i, this.D.f1126i, 0, 8);
            dVar.d(this.D.f1126i, this.P.F.f1126i, 0, 4);
            dVar.d(this.D.f1126i, this.P.D.f1126i, 0, 0);
            return;
        }
        if (i15 == 1) {
            dVar.d(this.D.f1126i, this.F.f1126i, 0, 8);
            dVar.d(this.D.f1126i, this.P.D.f1126i, 0, 4);
            dVar.d(this.D.f1126i, this.P.F.f1126i, 0, 0);
        } else if (i15 == 2) {
            dVar.d(this.G.f1126i, this.E.f1126i, 0, 8);
            dVar.d(this.E.f1126i, this.P.G.f1126i, 0, 4);
            dVar.d(this.E.f1126i, this.P.E.f1126i, 0, 0);
        } else if (i15 == 3) {
            dVar.d(this.E.f1126i, this.G.f1126i, 0, 8);
            dVar.d(this.E.f1126i, this.P.E.f1126i, 0, 4);
            dVar.d(this.E.f1126i, this.P.G.f1126i, 0, 0);
        }
    }

    @Override // c.e.b.h.d
    public boolean e() {
        return true;
    }

    @Override // c.e.b.h.d
    public String toString() {
        String strV = d.b.a.a.a.v(d.b.a.a.a.B("[Barrier] "), this.d0, " {");
        for (int i2 = 0; i2 < this.m0; i2++) {
            d dVar = this.l0[i2];
            if (i2 > 0) {
                strV = d.b.a.a.a.p(strV, ", ");
            }
            StringBuilder sbB = d.b.a.a.a.B(strV);
            sbB.append(dVar.d0);
            strV = sbB.toString();
        }
        return d.b.a.a.a.p(strV, "}");
    }
}
