package b.e.a.j;

import b.e.a.j.c;

/* JADX INFO: loaded from: classes.dex */
public class a extends h {
    public int t0 = 0;
    public boolean u0 = true;
    public int v0 = 0;
    public boolean w0 = false;

    @Override // b.e.a.j.d
    public boolean D() {
        return this.w0;
    }

    @Override // b.e.a.j.d
    public boolean E() {
        return this.w0;
    }

    public boolean W() {
        int i;
        c cVarI;
        c cVarI2;
        c cVarI3;
        int i2;
        int i3;
        c.a aVar = c.a.BOTTOM;
        c.a aVar2 = c.a.TOP;
        c.a aVar3 = c.a.RIGHT;
        c.a aVar4 = c.a.LEFT;
        int i4 = 0;
        boolean z = true;
        while (true) {
            i = this.s0;
            if (i4 >= i) {
                break;
            }
            d dVar = this.r0[i4];
            if ((this.u0 || dVar.e()) && ((((i2 = this.t0) == 0 || i2 == 1) && !dVar.D()) || (((i3 = this.t0) == 2 || i3 == 3) && !dVar.E()))) {
                z = false;
            }
            i4++;
        }
        if (!z || i <= 0) {
            return false;
        }
        int iMax = 0;
        boolean z2 = false;
        for (int i5 = 0; i5 < this.s0; i5++) {
            d dVar2 = this.r0[i5];
            if (this.u0 || dVar2.e()) {
                if (!z2) {
                    int i6 = this.t0;
                    if (i6 == 0) {
                        cVarI3 = dVar2.i(aVar4);
                    } else if (i6 == 1) {
                        cVarI3 = dVar2.i(aVar3);
                    } else if (i6 == 2) {
                        cVarI3 = dVar2.i(aVar2);
                    } else {
                        if (i6 == 3) {
                            cVarI3 = dVar2.i(aVar);
                        }
                        z2 = true;
                    }
                    iMax = cVarI3.c();
                    z2 = true;
                }
                int i7 = this.t0;
                if (i7 == 0) {
                    cVarI2 = dVar2.i(aVar4);
                } else {
                    if (i7 == 1) {
                        cVarI = dVar2.i(aVar3);
                    } else if (i7 == 2) {
                        cVarI2 = dVar2.i(aVar2);
                    } else if (i7 == 3) {
                        cVarI = dVar2.i(aVar);
                    }
                    iMax = Math.max(iMax, cVarI.c());
                }
                iMax = Math.min(iMax, cVarI2.c());
            }
        }
        int i8 = iMax + this.v0;
        int i9 = this.t0;
        if (i9 == 0 || i9 == 1) {
            L(i8, i8);
        } else {
            M(i8, i8);
        }
        this.w0 = true;
        return true;
    }

    public int X() {
        int i = this.t0;
        if (i == 0 || i == 1) {
            return 0;
        }
        return (i == 2 || i == 3) ? 1 : -1;
    }

    @Override // b.e.a.j.d
    public void d(b.e.a.d dVar, boolean z) {
        c[] cVarArr;
        boolean z2;
        b.e.a.h hVar;
        c cVar;
        int i;
        int i2;
        int i3;
        b.e.a.h hVar2;
        int i4;
        c[] cVarArr2 = this.R;
        cVarArr2[0] = this.J;
        cVarArr2[2] = this.K;
        cVarArr2[1] = this.L;
        cVarArr2[3] = this.M;
        int i5 = 0;
        while (true) {
            cVarArr = this.R;
            if (i5 >= cVarArr.length) {
                break;
            }
            cVarArr[i5].i = dVar.l(cVarArr[i5]);
            i5++;
        }
        int i6 = this.t0;
        if (i6 < 0 || i6 >= 4) {
            return;
        }
        c cVar2 = cVarArr[i6];
        if (!this.w0) {
            W();
        }
        if (this.w0) {
            this.w0 = false;
            int i7 = this.t0;
            if (i7 == 0 || i7 == 1) {
                dVar.e(this.J.i, this.a0);
                hVar2 = this.L.i;
                i4 = this.a0;
            } else {
                if (i7 != 2 && i7 != 3) {
                    return;
                }
                dVar.e(this.K.i, this.b0);
                hVar2 = this.M.i;
                i4 = this.b0;
            }
            dVar.e(hVar2, i4);
            return;
        }
        for (int i8 = 0; i8 < this.s0; i8++) {
            d dVar2 = this.r0[i8];
            if ((this.u0 || dVar2.e()) && ((((i2 = this.t0) == 0 || i2 == 1) && dVar2.m() == 3 && dVar2.J.f744f != null && dVar2.L.f744f != null) || (((i3 = this.t0) == 2 || i3 == 3) && dVar2.t() == 3 && dVar2.K.f744f != null && dVar2.M.f744f != null))) {
                z2 = true;
                break;
            }
        }
        z2 = false;
        boolean z3 = this.J.e() || this.L.e();
        boolean z4 = this.K.e() || this.M.e();
        int i9 = !z2 && (((i = this.t0) == 0 && z3) || ((i == 2 && z4) || ((i == 1 && z3) || (i == 3 && z4)))) ? 5 : 4;
        for (int i10 = 0; i10 < this.s0; i10++) {
            d dVar3 = this.r0[i10];
            if (this.u0 || dVar3.e()) {
                b.e.a.h hVarL = dVar.l(dVar3.R[this.t0]);
                c[] cVarArr3 = dVar3.R;
                int i11 = this.t0;
                cVarArr3[i11].i = hVarL;
                int i12 = (cVarArr3[i11].f744f == null || cVarArr3[i11].f744f.f742d != this) ? 0 : cVarArr3[i11].g + 0;
                if (i11 == 0 || i11 == 2) {
                    b.e.a.h hVar3 = cVar2.i;
                    int i13 = this.v0 - i12;
                    b.e.a.b bVarM = dVar.m();
                    b.e.a.h hVarN = dVar.n();
                    hVarN.f728e = 0;
                    bVarM.f(hVar3, hVarL, hVarN, i13);
                    dVar.c(bVarM);
                } else {
                    b.e.a.h hVar4 = cVar2.i;
                    int i14 = this.v0 + i12;
                    b.e.a.b bVarM2 = dVar.m();
                    b.e.a.h hVarN2 = dVar.n();
                    hVarN2.f728e = 0;
                    bVarM2.e(hVar4, hVarL, hVarN2, i14);
                    dVar.c(bVarM2);
                }
                dVar.d(cVar2.i, hVarL, this.v0 + i12, i9);
            }
        }
        int i15 = this.t0;
        if (i15 == 0) {
            dVar.d(this.L.i, this.J.i, 0, 8);
            dVar.d(this.J.i, this.V.L.i, 0, 4);
            hVar = this.J.i;
            cVar = this.V.J;
        } else if (i15 == 1) {
            dVar.d(this.J.i, this.L.i, 0, 8);
            dVar.d(this.J.i, this.V.J.i, 0, 4);
            hVar = this.J.i;
            cVar = this.V.L;
        } else if (i15 == 2) {
            dVar.d(this.M.i, this.K.i, 0, 8);
            dVar.d(this.K.i, this.V.M.i, 0, 4);
            hVar = this.K.i;
            cVar = this.V.K;
        } else {
            if (i15 != 3) {
                return;
            }
            dVar.d(this.K.i, this.M.i, 0, 8);
            dVar.d(this.K.i, this.V.K.i, 0, 4);
            hVar = this.K.i;
            cVar = this.V.M;
        }
        dVar.d(hVar, cVar.i, 0, 0);
    }

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

    @Override // b.e.a.j.d
    public String toString() {
        StringBuilder sbD = c.a.a.a.a.d("[Barrier] ");
        sbD.append(this.j0);
        sbD.append(" {");
        String string = sbD.toString();
        for (int i = 0; i < this.s0; i++) {
            d dVar = this.r0[i];
            if (i > 0) {
                string = c.a.a.a.a.b(string, ", ");
            }
            StringBuilder sbD2 = c.a.a.a.a.d(string);
            sbD2.append(dVar.j0);
            string = sbD2.toString();
        }
        return c.a.a.a.a.b(string, "}");
    }
}
