package c.e.b.h.l;

import c.e.b.h.c;
import c.e.b.h.d;
import c.e.b.h.l.f;
import c.e.b.h.l.o;

/* JADX INFO: compiled from: VerticalWidgetRun.java */
/* JADX INFO: loaded from: classes.dex */
public class m extends o {

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

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

    public m(c.e.b.h.d dVar) {
        super(dVar);
        f fVar = new f(this);
        this.f1172k = fVar;
        this.f1173l = null;
        this.f1185h.f1161e = f.a.TOP;
        this.f1186i.f1161e = f.a.BOTTOM;
        fVar.f1161e = f.a.BASELINE;
        this.f1183f = 1;
    }

    @Override // c.e.b.h.l.o, c.e.b.h.l.d
    public void a(d dVar) {
        float f2;
        float f3;
        float f4;
        int i2;
        int iOrdinal = this.f1187j.ordinal();
        if (iOrdinal != 1 && iOrdinal != 2 && iOrdinal == 3) {
            c.e.b.h.d dVar2 = this.f1179b;
            l(dVar2.E, dVar2.G, 1);
            return;
        }
        g gVar = this.f1182e;
        if (gVar.f1159c && !gVar.f1166j && this.f1181d == d.a.MATCH_CONSTRAINT) {
            c.e.b.h.d dVar3 = this.f1179b;
            int i3 = dVar3.m;
            if (i3 == 2) {
                c.e.b.h.d dVar4 = dVar3.P;
                if (dVar4 != null) {
                    if (dVar4.f1130e.f1182e.f1166j) {
                        gVar.c((int) ((r0.f1163g * dVar3.t) + 0.5f));
                    }
                }
            } else if (i3 == 3) {
                g gVar2 = dVar3.f1129d.f1182e;
                if (gVar2.f1166j) {
                    int i4 = dVar3.T;
                    if (i4 == -1) {
                        f2 = gVar2.f1163g;
                        f3 = dVar3.S;
                    } else if (i4 == 0) {
                        f4 = gVar2.f1163g * dVar3.S;
                        i2 = (int) (f4 + 0.5f);
                        gVar.c(i2);
                    } else if (i4 != 1) {
                        i2 = 0;
                        gVar.c(i2);
                    } else {
                        f2 = gVar2.f1163g;
                        f3 = dVar3.S;
                    }
                    f4 = f2 / f3;
                    i2 = (int) (f4 + 0.5f);
                    gVar.c(i2);
                }
            }
        }
        f fVar = this.f1185h;
        if (fVar.f1159c) {
            f fVar2 = this.f1186i;
            if (fVar2.f1159c) {
                if (fVar.f1166j && fVar2.f1166j && this.f1182e.f1166j) {
                    return;
                }
                if (!this.f1182e.f1166j && this.f1181d == d.a.MATCH_CONSTRAINT) {
                    c.e.b.h.d dVar5 = this.f1179b;
                    if (dVar5.f1137l == 0 && !dVar5.y()) {
                        f fVar3 = this.f1185h.f1168l.get(0);
                        f fVar4 = this.f1186i.f1168l.get(0);
                        int i5 = fVar3.f1163g;
                        f fVar5 = this.f1185h;
                        int i6 = i5 + fVar5.f1162f;
                        int i7 = fVar4.f1163g + this.f1186i.f1162f;
                        fVar5.c(i6);
                        this.f1186i.c(i7);
                        this.f1182e.c(i7 - i6);
                        return;
                    }
                }
                if (!this.f1182e.f1166j && this.f1181d == d.a.MATCH_CONSTRAINT && this.a == 1 && this.f1185h.f1168l.size() > 0 && this.f1186i.f1168l.size() > 0) {
                    f fVar6 = this.f1185h.f1168l.get(0);
                    int i8 = (this.f1186i.f1168l.get(0).f1163g + this.f1186i.f1162f) - (fVar6.f1163g + this.f1185h.f1162f);
                    g gVar3 = this.f1182e;
                    int i9 = gVar3.m;
                    if (i8 < i9) {
                        gVar3.c(i8);
                    } else {
                        gVar3.c(i9);
                    }
                }
                if (this.f1182e.f1166j && this.f1185h.f1168l.size() > 0 && this.f1186i.f1168l.size() > 0) {
                    f fVar7 = this.f1185h.f1168l.get(0);
                    f fVar8 = this.f1186i.f1168l.get(0);
                    int i10 = fVar7.f1163g;
                    f fVar9 = this.f1185h;
                    int i11 = fVar9.f1162f + i10;
                    int i12 = fVar8.f1163g;
                    int i13 = this.f1186i.f1162f + i12;
                    float f5 = this.f1179b.a0;
                    if (fVar7 == fVar8) {
                        f5 = 0.5f;
                    } else {
                        i10 = i11;
                        i12 = i13;
                    }
                    fVar9.c((int) ((((i12 - i10) - this.f1182e.f1163g) * f5) + i10 + 0.5f));
                    this.f1186i.c(this.f1185h.f1163g + this.f1182e.f1163g);
                }
            }
        }
    }

    @Override // c.e.b.h.l.o
    public void d() {
        c.e.b.h.d dVar;
        c.e.b.h.d dVar2;
        c.e.b.h.d dVar3;
        c.e.b.h.d dVar4 = this.f1179b;
        if (dVar4.a) {
            this.f1182e.c(dVar4.l());
        }
        if (!this.f1182e.f1166j) {
            this.f1181d = this.f1179b.q();
            if (this.f1179b.y) {
                this.f1173l = new a(this);
            }
            d.a aVar = this.f1181d;
            if (aVar != d.a.MATCH_CONSTRAINT) {
                if (aVar == d.a.MATCH_PARENT && (dVar3 = this.f1179b.P) != null && dVar3.q() == d.a.FIXED) {
                    int iL = (dVar3.l() - this.f1179b.E.d()) - this.f1179b.G.d();
                    b(this.f1185h, dVar3.f1130e.f1185h, this.f1179b.E.d());
                    b(this.f1186i, dVar3.f1130e.f1186i, -this.f1179b.G.d());
                    this.f1182e.c(iL);
                    return;
                }
                if (this.f1181d == d.a.FIXED) {
                    this.f1182e.c(this.f1179b.l());
                }
            }
        } else if (this.f1181d == d.a.MATCH_PARENT && (dVar = this.f1179b.P) != null && dVar.q() == d.a.FIXED) {
            b(this.f1185h, dVar.f1130e.f1185h, this.f1179b.E.d());
            b(this.f1186i, dVar.f1130e.f1186i, -this.f1179b.G.d());
            return;
        }
        g gVar = this.f1182e;
        boolean z = gVar.f1166j;
        if (z) {
            c.e.b.h.d dVar5 = this.f1179b;
            if (dVar5.a) {
                c.e.b.h.c[] cVarArr = dVar5.L;
                if (cVarArr[2].f1123f != null && cVarArr[3].f1123f != null) {
                    if (dVar5.y()) {
                        this.f1185h.f1162f = this.f1179b.L[2].d();
                        this.f1186i.f1162f = -this.f1179b.L[3].d();
                    } else {
                        f fVarH = h(this.f1179b.L[2]);
                        if (fVarH != null) {
                            f fVar = this.f1185h;
                            int iD = this.f1179b.L[2].d();
                            fVar.f1168l.add(fVarH);
                            fVar.f1162f = iD;
                            fVarH.f1167k.add(fVar);
                        }
                        f fVarH2 = h(this.f1179b.L[3]);
                        if (fVarH2 != null) {
                            f fVar2 = this.f1186i;
                            int i2 = -this.f1179b.L[3].d();
                            fVar2.f1168l.add(fVarH2);
                            fVar2.f1162f = i2;
                            fVarH2.f1167k.add(fVar2);
                        }
                        this.f1185h.f1158b = true;
                        this.f1186i.f1158b = true;
                    }
                    c.e.b.h.d dVar6 = this.f1179b;
                    if (dVar6.y) {
                        b(this.f1172k, this.f1185h, dVar6.W);
                        return;
                    }
                    return;
                }
                if (cVarArr[2].f1123f != null) {
                    f fVarH3 = h(cVarArr[2]);
                    if (fVarH3 != null) {
                        f fVar3 = this.f1185h;
                        int iD2 = this.f1179b.L[2].d();
                        fVar3.f1168l.add(fVarH3);
                        fVar3.f1162f = iD2;
                        fVarH3.f1167k.add(fVar3);
                        b(this.f1186i, this.f1185h, this.f1182e.f1163g);
                        c.e.b.h.d dVar7 = this.f1179b;
                        if (dVar7.y) {
                            b(this.f1172k, this.f1185h, dVar7.W);
                            return;
                        }
                        return;
                    }
                    return;
                }
                if (cVarArr[3].f1123f != null) {
                    f fVarH4 = h(cVarArr[3]);
                    if (fVarH4 != null) {
                        f fVar4 = this.f1186i;
                        int i3 = -this.f1179b.L[3].d();
                        fVar4.f1168l.add(fVarH4);
                        fVar4.f1162f = i3;
                        fVarH4.f1167k.add(fVar4);
                        b(this.f1185h, this.f1186i, -this.f1182e.f1163g);
                    }
                    c.e.b.h.d dVar8 = this.f1179b;
                    if (dVar8.y) {
                        b(this.f1172k, this.f1185h, dVar8.W);
                        return;
                    }
                    return;
                }
                if (cVarArr[4].f1123f != null) {
                    f fVarH5 = h(cVarArr[4]);
                    if (fVarH5 != null) {
                        f fVar5 = this.f1172k;
                        fVar5.f1168l.add(fVarH5);
                        fVar5.f1162f = 0;
                        fVarH5.f1167k.add(fVar5);
                        b(this.f1185h, this.f1172k, -this.f1179b.W);
                        b(this.f1186i, this.f1185h, this.f1182e.f1163g);
                        return;
                    }
                    return;
                }
                if ((dVar5 instanceof c.e.b.h.g) || dVar5.P == null || dVar5.i(c.a.CENTER).f1123f != null) {
                    return;
                }
                c.e.b.h.d dVar9 = this.f1179b;
                b(this.f1185h, dVar9.P.f1130e.f1185h, dVar9.t());
                b(this.f1186i, this.f1185h, this.f1182e.f1163g);
                c.e.b.h.d dVar10 = this.f1179b;
                if (dVar10.y) {
                    b(this.f1172k, this.f1185h, dVar10.W);
                    return;
                }
                return;
            }
        }
        if (z || this.f1181d != d.a.MATCH_CONSTRAINT) {
            gVar.f1167k.add(this);
            if (gVar.f1166j) {
                a(this);
            }
        } else {
            c.e.b.h.d dVar11 = this.f1179b;
            int i4 = dVar11.m;
            if (i4 == 2) {
                c.e.b.h.d dVar12 = dVar11.P;
                if (dVar12 != null) {
                    g gVar2 = dVar12.f1130e.f1182e;
                    gVar.f1168l.add(gVar2);
                    gVar2.f1167k.add(this.f1182e);
                    g gVar3 = this.f1182e;
                    gVar3.f1158b = true;
                    gVar3.f1167k.add(this.f1185h);
                    this.f1182e.f1167k.add(this.f1186i);
                }
            } else if (i4 == 3 && !dVar11.y()) {
                c.e.b.h.d dVar13 = this.f1179b;
                if (dVar13.f1137l != 3) {
                    g gVar4 = dVar13.f1129d.f1182e;
                    this.f1182e.f1168l.add(gVar4);
                    gVar4.f1167k.add(this.f1182e);
                    g gVar5 = this.f1182e;
                    gVar5.f1158b = true;
                    gVar5.f1167k.add(this.f1185h);
                    this.f1182e.f1167k.add(this.f1186i);
                }
            }
        }
        c.e.b.h.d dVar14 = this.f1179b;
        c.e.b.h.c[] cVarArr2 = dVar14.L;
        if (cVarArr2[2].f1123f != null && cVarArr2[3].f1123f != null) {
            if (dVar14.y()) {
                this.f1185h.f1162f = this.f1179b.L[2].d();
                this.f1186i.f1162f = -this.f1179b.L[3].d();
            } else {
                f fVarH6 = h(this.f1179b.L[2]);
                f fVarH7 = h(this.f1179b.L[3]);
                fVarH6.f1167k.add(this);
                if (fVarH6.f1166j) {
                    a(this);
                }
                fVarH7.f1167k.add(this);
                if (fVarH7.f1166j) {
                    a(this);
                }
                this.f1187j = o.a.CENTER;
            }
            if (this.f1179b.y) {
                c(this.f1172k, this.f1185h, 1, this.f1173l);
            }
        } else if (cVarArr2[2].f1123f != null) {
            f fVarH8 = h(cVarArr2[2]);
            if (fVarH8 != null) {
                f fVar6 = this.f1185h;
                int iD3 = this.f1179b.L[2].d();
                fVar6.f1168l.add(fVarH8);
                fVar6.f1162f = iD3;
                fVarH8.f1167k.add(fVar6);
                c(this.f1186i, this.f1185h, 1, this.f1182e);
                if (this.f1179b.y) {
                    c(this.f1172k, this.f1185h, 1, this.f1173l);
                }
                d.a aVar2 = this.f1181d;
                d.a aVar3 = d.a.MATCH_CONSTRAINT;
                if (aVar2 == aVar3) {
                    c.e.b.h.d dVar15 = this.f1179b;
                    if (dVar15.S > 0.0f) {
                        k kVar = dVar15.f1129d;
                        if (kVar.f1181d == aVar3) {
                            kVar.f1182e.f1167k.add(this.f1182e);
                            this.f1182e.f1168l.add(this.f1179b.f1129d.f1182e);
                            this.f1182e.a = this;
                        }
                    }
                }
            }
        } else if (cVarArr2[3].f1123f != null) {
            f fVarH9 = h(cVarArr2[3]);
            if (fVarH9 != null) {
                f fVar7 = this.f1186i;
                int i5 = -this.f1179b.L[3].d();
                fVar7.f1168l.add(fVarH9);
                fVar7.f1162f = i5;
                fVarH9.f1167k.add(fVar7);
                c(this.f1185h, this.f1186i, -1, this.f1182e);
                if (this.f1179b.y) {
                    c(this.f1172k, this.f1185h, 1, this.f1173l);
                }
            }
        } else if (cVarArr2[4].f1123f != null) {
            f fVarH10 = h(cVarArr2[4]);
            if (fVarH10 != null) {
                f fVar8 = this.f1172k;
                fVar8.f1168l.add(fVarH10);
                fVar8.f1162f = 0;
                fVarH10.f1167k.add(fVar8);
                c(this.f1185h, this.f1172k, -1, this.f1173l);
                c(this.f1186i, this.f1185h, 1, this.f1182e);
            }
        } else if (!(dVar14 instanceof c.e.b.h.g) && (dVar2 = dVar14.P) != null) {
            b(this.f1185h, dVar2.f1130e.f1185h, dVar14.t());
            c(this.f1186i, this.f1185h, 1, this.f1182e);
            if (this.f1179b.y) {
                c(this.f1172k, this.f1185h, 1, this.f1173l);
            }
            d.a aVar4 = this.f1181d;
            d.a aVar5 = d.a.MATCH_CONSTRAINT;
            if (aVar4 == aVar5) {
                c.e.b.h.d dVar16 = this.f1179b;
                if (dVar16.S > 0.0f) {
                    k kVar2 = dVar16.f1129d;
                    if (kVar2.f1181d == aVar5) {
                        kVar2.f1182e.f1167k.add(this.f1182e);
                        this.f1182e.f1168l.add(this.f1179b.f1129d.f1182e);
                        this.f1182e.a = this;
                    }
                }
            }
        }
        if (this.f1182e.f1168l.size() == 0) {
            this.f1182e.f1159c = true;
        }
    }

    @Override // c.e.b.h.l.o
    public void e() {
        f fVar = this.f1185h;
        if (fVar.f1166j) {
            this.f1179b.V = fVar.f1163g;
        }
    }

    @Override // c.e.b.h.l.o
    public void f() {
        this.f1180c = null;
        this.f1185h.b();
        this.f1186i.b();
        this.f1172k.b();
        this.f1182e.b();
        this.f1184g = false;
    }

    @Override // c.e.b.h.l.o
    public boolean k() {
        return this.f1181d != d.a.MATCH_CONSTRAINT || this.f1179b.m == 0;
    }

    public void m() {
        this.f1184g = false;
        this.f1185h.b();
        this.f1185h.f1166j = false;
        this.f1186i.b();
        this.f1186i.f1166j = false;
        this.f1172k.b();
        this.f1172k.f1166j = false;
        this.f1182e.f1166j = false;
    }

    public String toString() {
        StringBuilder sbB = d.b.a.a.a.B("VerticalRun ");
        sbB.append(this.f1179b.d0);
        return sbB.toString();
    }
}
