package w;

import androidx.constraintlayout.core.widgets.ConstraintWidget$DimensionBehaviour;

/* JADX INFO: loaded from: classes.dex */
public final class f {

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public c f34081d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public c f34082e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public c f34083f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public c f34084g;

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

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

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

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

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

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ g f34095r;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public d f34079b = null;

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

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

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

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

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

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

    public f(g gVar, int i10, c cVar, c cVar2, c cVar3, c cVar4, int i11) {
        this.f34095r = gVar;
        this.f34085h = 0;
        this.f34086i = 0;
        this.f34087j = 0;
        this.f34088k = 0;
        this.f34094q = 0;
        this.f34078a = i10;
        this.f34081d = cVar;
        this.f34082e = cVar2;
        this.f34083f = cVar3;
        this.f34084g = cVar4;
        this.f34085h = gVar.B0;
        this.f34086i = gVar.f34109x0;
        this.f34087j = gVar.C0;
        this.f34088k = gVar.f34110y0;
        this.f34094q = i11;
    }

    public final void a(d dVar) {
        int i10 = this.f34078a;
        ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour = ConstraintWidget$DimensionBehaviour.f1014c;
        g gVar = this.f34095r;
        if (i10 == 0) {
            int iY = gVar.Y(this.f34094q, dVar);
            if (dVar.U[0] == constraintWidget$DimensionBehaviour) {
                this.f34093p++;
                iY = 0;
            }
            this.f34089l = iY + (dVar.f34045i0 != 8 ? gVar.U0 : 0) + this.f34089l;
            int iX = gVar.X(this.f34094q, dVar);
            if (this.f34079b == null || this.f34080c < iX) {
                this.f34079b = dVar;
                this.f34080c = iX;
                this.f34090m = iX;
            }
        } else {
            int iY2 = gVar.Y(this.f34094q, dVar);
            int iX2 = gVar.X(this.f34094q, dVar);
            if (dVar.U[1] == constraintWidget$DimensionBehaviour) {
                this.f34093p++;
                iX2 = 0;
            }
            this.f34090m = iX2 + (dVar.f34045i0 != 8 ? gVar.V0 : 0) + this.f34090m;
            if (this.f34079b == null || this.f34080c < iY2) {
                this.f34079b = dVar;
                this.f34080c = iY2;
                this.f34089l = iY2;
            }
        }
        this.f34092o++;
    }

    public final void b(int i10, boolean z10, boolean z11) {
        g gVar;
        int i11;
        int i12;
        int i13;
        d dVar;
        int i14;
        char c6;
        int i15;
        float f10;
        float f11;
        int i16;
        float f12;
        int i17;
        int i18 = this.f34092o;
        int i19 = 0;
        while (true) {
            gVar = this.f34095r;
            if (i19 >= i18 || (i17 = this.f34091n + i19) >= gVar.f34101g1) {
                break;
            }
            d dVar2 = gVar.f34100f1[i17];
            if (dVar2 != null) {
                dVar2.F();
            }
            i19++;
        }
        if (i18 == 0 || this.f34079b == null) {
            return;
        }
        boolean z12 = z11 && i10 == 0;
        int i20 = -1;
        int i21 = -1;
        for (int i22 = 0; i22 < i18; i22++) {
            int i23 = this.f34091n + (z10 ? (i18 - 1) - i22 : i22);
            if (i23 >= gVar.f34101g1) {
                break;
            }
            d dVar3 = gVar.f34100f1[i23];
            if (dVar3 != null && dVar3.f34045i0 == 0) {
                if (i20 == -1) {
                    i20 = i22;
                }
                i21 = i22;
            }
        }
        if (this.f34078a != 0) {
            d dVar4 = this.f34079b;
            dVar4.f34053m0 = gVar.I0;
            int i24 = this.f34085h;
            if (i10 > 0) {
                i24 += gVar.U0;
            }
            c cVar = dVar4.J;
            c cVar2 = dVar4.L;
            if (z10) {
                cVar2.a(this.f34083f, i24);
                if (z11) {
                    cVar.a(this.f34081d, this.f34087j);
                }
                if (i10 > 0) {
                    this.f34083f.f34022d.J.a(cVar2, 0);
                }
            } else {
                cVar.a(this.f34081d, i24);
                if (z11) {
                    cVar2.a(this.f34083f, this.f34087j);
                }
                if (i10 > 0) {
                    this.f34081d.f34022d.L.a(cVar, 0);
                }
            }
            d dVar5 = null;
            for (int i25 = 0; i25 < i18; i25++) {
                int i26 = this.f34091n + i25;
                if (i26 >= gVar.f34101g1) {
                    return;
                }
                d dVar6 = gVar.f34100f1[i26];
                if (dVar6 != null) {
                    c cVar3 = dVar6.K;
                    if (i25 == 0) {
                        dVar6.g(cVar3, this.f34082e, this.f34086i);
                        int i27 = gVar.J0;
                        float f13 = gVar.P0;
                        if (this.f34091n == 0) {
                            i13 = gVar.L0;
                            i11 = i27;
                            i12 = -1;
                            if (i13 != -1) {
                                f13 = gVar.R0;
                            }
                            dVar6.f34055n0 = i13;
                            dVar6.f34041g0 = f13;
                        } else {
                            i11 = i27;
                            i12 = -1;
                        }
                        if (!z11 || (i13 = gVar.N0) == i12) {
                            i13 = i11;
                        } else {
                            f13 = gVar.T0;
                        }
                        dVar6.f34055n0 = i13;
                        dVar6.f34041g0 = f13;
                    }
                    if (i25 == i18 - 1) {
                        dVar6.g(dVar6.M, this.f34084g, this.f34088k);
                    }
                    if (dVar5 != null) {
                        int i28 = gVar.V0;
                        c cVar4 = dVar5.M;
                        cVar3.a(cVar4, i28);
                        if (i25 == i20) {
                            int i29 = this.f34086i;
                            if (cVar3.h()) {
                                cVar3.f34026h = i29;
                            }
                        }
                        cVar4.a(cVar3, 0);
                        if (i25 == i21 + 1) {
                            int i30 = this.f34088k;
                            if (cVar4.h()) {
                                cVar4.f34026h = i30;
                            }
                        }
                    }
                    if (dVar6 != dVar4) {
                        c cVar5 = dVar6.L;
                        c cVar6 = dVar6.J;
                        if (z10) {
                            int i31 = gVar.W0;
                            if (i31 == 0) {
                                cVar5.a(cVar2, 0);
                            } else if (i31 == 1) {
                                cVar6.a(cVar, 0);
                            } else if (i31 == 2) {
                                cVar6.a(cVar, 0);
                                cVar5.a(cVar2, 0);
                            }
                            dVar5 = dVar6;
                        } else {
                            int i32 = gVar.W0;
                            if (i32 == 0) {
                                cVar6.a(cVar, 0);
                            } else if (i32 == 1) {
                                cVar5.a(cVar2, 0);
                            } else if (i32 == 2) {
                                if (z12) {
                                    cVar6.a(this.f34081d, this.f34085h);
                                    cVar5.a(this.f34083f, this.f34087j);
                                } else {
                                    cVar6.a(cVar, 0);
                                    cVar5.a(cVar2, 0);
                                }
                            }
                            dVar5 = dVar6;
                        }
                    } else {
                        dVar5 = dVar6;
                    }
                }
            }
            return;
        }
        d dVar7 = this.f34079b;
        dVar7.f34055n0 = gVar.J0;
        int i33 = this.f34086i;
        if (i10 > 0) {
            i33 += gVar.V0;
        }
        c cVar7 = this.f34082e;
        c cVar8 = dVar7.K;
        cVar8.a(cVar7, i33);
        c cVar9 = dVar7.M;
        if (z11) {
            cVar9.a(this.f34084g, this.f34088k);
        }
        if (i10 > 0) {
            this.f34082e.f34022d.M.a(cVar8, 0);
        }
        if (gVar.X0 != 3 || dVar7.E) {
            dVar = dVar7;
        } else {
            for (int i34 = 0; i34 < i18; i34++) {
                int i35 = this.f34091n + (z10 ? (i18 - 1) - i34 : i34);
                if (i35 >= gVar.f34101g1) {
                    break;
                }
                dVar = gVar.f34100f1[i35];
                if (dVar.E) {
                    break;
                }
            }
            dVar = dVar7;
        }
        int i36 = 0;
        d dVar8 = null;
        while (i36 < i18) {
            int i37 = z10 ? (i18 - 1) - i36 : i36;
            int i38 = this.f34091n + i37;
            if (i38 >= gVar.f34101g1) {
                return;
            }
            d dVar9 = gVar.f34100f1[i38];
            if (dVar9 == null) {
                i14 = i18;
                c6 = 3;
            } else {
                c cVar10 = dVar9.J;
                if (i36 == 0) {
                    dVar9.g(cVar10, this.f34081d, this.f34085h);
                }
                if (i37 == 0) {
                    int i39 = gVar.I0;
                    if (z10) {
                        i15 = i39;
                        f10 = 1.0f - gVar.O0;
                    } else {
                        i15 = i39;
                        f10 = gVar.O0;
                    }
                    if (this.f34091n == 0) {
                        int i40 = gVar.K0;
                        f11 = f10;
                        if (i40 != -1) {
                            f12 = z10 ? 1.0f - gVar.Q0 : gVar.Q0;
                            i16 = i40;
                        }
                        dVar9.f34053m0 = i16;
                        dVar9.f34039f0 = f12;
                    } else {
                        f11 = f10;
                    }
                    if (!z11 || (i16 = gVar.M0) == -1) {
                        i16 = i15;
                        f12 = f11;
                    } else {
                        f12 = z10 ? 1.0f - gVar.S0 : gVar.S0;
                    }
                    dVar9.f34053m0 = i16;
                    dVar9.f34039f0 = f12;
                }
                if (i36 == i18 - 1) {
                    i14 = i18;
                    dVar9.g(dVar9.L, this.f34083f, this.f34087j);
                } else {
                    i14 = i18;
                }
                if (dVar8 != null) {
                    int i41 = gVar.U0;
                    c cVar11 = dVar8.L;
                    cVar10.a(cVar11, i41);
                    if (i36 == i20) {
                        int i42 = this.f34085h;
                        if (cVar10.h()) {
                            cVar10.f34026h = i42;
                        }
                    }
                    cVar11.a(cVar10, 0);
                    if (i36 == i21 + 1) {
                        int i43 = this.f34087j;
                        if (cVar11.h()) {
                            cVar11.f34026h = i43;
                        }
                    }
                }
                if (dVar9 != dVar7) {
                    int i44 = gVar.X0;
                    c6 = 3;
                    if (i44 == 3 && dVar.E && dVar9 != dVar && dVar9.E) {
                        dVar9.N.a(dVar.N, 0);
                    } else {
                        c cVar12 = dVar9.K;
                        if (i44 != 0) {
                            c cVar13 = dVar9.M;
                            if (i44 == 1) {
                                cVar13.a(cVar9, 0);
                            } else if (z12) {
                                cVar12.a(this.f34082e, this.f34086i);
                                cVar13.a(this.f34084g, this.f34088k);
                            } else {
                                cVar12.a(cVar8, 0);
                                cVar13.a(cVar9, 0);
                            }
                        } else {
                            cVar12.a(cVar8, 0);
                        }
                    }
                } else {
                    c6 = 3;
                }
                dVar8 = dVar9;
            }
            i36++;
            i18 = i14;
        }
    }

    public final int c() {
        return this.f34078a == 1 ? this.f34090m - this.f34095r.V0 : this.f34090m;
    }

    public final int d() {
        return this.f34078a == 0 ? this.f34089l - this.f34095r.U0 : this.f34089l;
    }

    public final void e(int i10) {
        int i11 = this.f34093p;
        if (i11 == 0) {
            return;
        }
        int i12 = this.f34092o;
        int i13 = i10 / i11;
        for (int i14 = 0; i14 < i12; i14++) {
            int i15 = this.f34091n;
            int i16 = i15 + i14;
            g gVar = this.f34095r;
            if (i16 >= gVar.f34101g1) {
                break;
            }
            d dVar = gVar.f34100f1[i15 + i14];
            int i17 = this.f34078a;
            ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour = ConstraintWidget$DimensionBehaviour.f1012a;
            ConstraintWidget$DimensionBehaviour constraintWidget$DimensionBehaviour2 = ConstraintWidget$DimensionBehaviour.f1014c;
            if (i17 == 0) {
                if (dVar != null) {
                    ConstraintWidget$DimensionBehaviour[] constraintWidget$DimensionBehaviourArr = dVar.U;
                    if (constraintWidget$DimensionBehaviourArr[0] == constraintWidget$DimensionBehaviour2 && dVar.f34062r == 0) {
                        gVar.W(dVar, constraintWidget$DimensionBehaviour, i13, constraintWidget$DimensionBehaviourArr[1], dVar.m());
                    }
                }
            } else if (dVar != null) {
                ConstraintWidget$DimensionBehaviour[] constraintWidget$DimensionBehaviourArr2 = dVar.U;
                if (constraintWidget$DimensionBehaviourArr2[1] == constraintWidget$DimensionBehaviour2 && dVar.f34064s == 0) {
                    gVar.W(dVar, constraintWidget$DimensionBehaviourArr2[0], dVar.s(), constraintWidget$DimensionBehaviour, i13);
                }
            }
        }
        this.f34089l = 0;
        this.f34090m = 0;
        this.f34079b = null;
        this.f34080c = 0;
        int i18 = this.f34092o;
        for (int i19 = 0; i19 < i18; i19++) {
            int i20 = this.f34091n + i19;
            g gVar2 = this.f34095r;
            if (i20 >= gVar2.f34101g1) {
                return;
            }
            d dVar2 = gVar2.f34100f1[i20];
            if (this.f34078a == 0) {
                int iS = dVar2.s();
                int i21 = gVar2.U0;
                if (dVar2.f34045i0 == 8) {
                    i21 = 0;
                }
                this.f34089l = iS + i21 + this.f34089l;
                int iX = gVar2.X(this.f34094q, dVar2);
                if (this.f34079b == null || this.f34080c < iX) {
                    this.f34079b = dVar2;
                    this.f34080c = iX;
                    this.f34090m = iX;
                }
            } else {
                int iY = gVar2.Y(this.f34094q, dVar2);
                int iX2 = gVar2.X(this.f34094q, dVar2);
                int i22 = gVar2.V0;
                if (dVar2.f34045i0 == 8) {
                    i22 = 0;
                }
                this.f34090m = iX2 + i22 + this.f34090m;
                if (this.f34079b == null || this.f34080c < iY) {
                    this.f34079b = dVar2;
                    this.f34080c = iY;
                    this.f34089l = iY;
                }
            }
        }
    }

    public final void f(int i10, c cVar, c cVar2, c cVar3, c cVar4, int i11, int i12, int i13, int i14, int i15) {
        this.f34078a = i10;
        this.f34081d = cVar;
        this.f34082e = cVar2;
        this.f34083f = cVar3;
        this.f34084g = cVar4;
        this.f34085h = i11;
        this.f34086i = i12;
        this.f34087j = i13;
        this.f34088k = i14;
        this.f34094q = i15;
    }
}
