package w;

import u.AbstractC1563h;

/* JADX INFO: renamed from: w.k, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1693k extends AbstractC1694l {

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

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

    @Override // w.InterfaceC1686d
    public final void a(InterfaceC1686d interfaceC1686d) {
        float f3;
        float f7;
        float f8;
        int i;
        if (AbstractC1563h.c(this.f18163j) == 3) {
            v.d dVar = this.f18156b;
            l(dVar.f17923y, dVar.f17874A, 1);
            return;
        }
        C1688f c1688f = this.f18159e;
        if (c1688f.f18140c && !c1688f.f18146j && this.f18158d == 3) {
            v.d dVar2 = this.f18156b;
            int i5 = dVar2.f17909k;
            if (i5 == 2) {
                v.d dVar3 = dVar2.f17880I;
                if (dVar3 != null) {
                    if (dVar3.f17904e.f18159e.f18146j) {
                        c1688f.d((int) ((r5.f18144g * dVar2.f17916r) + 0.5f));
                    }
                }
            } else if (i5 == 3) {
                C1688f c1688f2 = dVar2.f17903d.f18159e;
                if (c1688f2.f18146j) {
                    int i8 = dVar2.f17884M;
                    if (i8 == -1) {
                        f3 = c1688f2.f18144g;
                        f7 = dVar2.f17883L;
                    } else if (i8 == 0) {
                        f8 = c1688f2.f18144g * dVar2.f17883L;
                        i = (int) (f8 + 0.5f);
                        c1688f.d(i);
                    } else if (i8 != 1) {
                        i = 0;
                        c1688f.d(i);
                    } else {
                        f3 = c1688f2.f18144g;
                        f7 = dVar2.f17883L;
                    }
                    f8 = f3 / f7;
                    i = (int) (f8 + 0.5f);
                    c1688f.d(i);
                }
            }
        }
        C1687e c1687e = this.f18162h;
        if (c1687e.f18140c) {
            C1687e c1687e2 = this.i;
            if (c1687e2.f18140c) {
                if (c1687e.f18146j && c1687e2.f18146j && c1688f.f18146j) {
                    return;
                }
                if (!c1688f.f18146j && this.f18158d == 3) {
                    v.d dVar4 = this.f18156b;
                    if (dVar4.f17908j == 0 && !dVar4.r()) {
                        C1687e c1687e3 = (C1687e) c1687e.f18148l.get(0);
                        C1687e c1687e4 = (C1687e) c1687e2.f18148l.get(0);
                        int i9 = c1687e3.f18144g + c1687e.f18143f;
                        int i10 = c1687e4.f18144g + c1687e2.f18143f;
                        c1687e.d(i9);
                        c1687e2.d(i10);
                        c1688f.d(i10 - i9);
                        return;
                    }
                }
                if (!c1688f.f18146j && this.f18158d == 3 && this.f18155a == 1 && c1687e.f18148l.size() > 0 && c1687e2.f18148l.size() > 0) {
                    C1687e c1687e5 = (C1687e) c1687e.f18148l.get(0);
                    int i11 = (((C1687e) c1687e2.f18148l.get(0)).f18144g + c1687e2.f18143f) - (c1687e5.f18144g + c1687e.f18143f);
                    int i12 = c1688f.f18149m;
                    if (i11 < i12) {
                        c1688f.d(i11);
                    } else {
                        c1688f.d(i12);
                    }
                }
                if (c1688f.f18146j && c1687e.f18148l.size() > 0 && c1687e2.f18148l.size() > 0) {
                    C1687e c1687e6 = (C1687e) c1687e.f18148l.get(0);
                    C1687e c1687e7 = (C1687e) c1687e2.f18148l.get(0);
                    int i13 = c1687e6.f18144g;
                    int i14 = c1687e.f18143f + i13;
                    int i15 = c1687e7.f18144g;
                    int i16 = c1687e2.f18143f + i15;
                    float f9 = this.f18156b.f17891T;
                    if (c1687e6 == c1687e7) {
                        f9 = 0.5f;
                    } else {
                        i13 = i14;
                        i15 = i16;
                    }
                    c1687e.d((int) ((((i15 - i13) - c1688f.f18144g) * f9) + i13 + 0.5f));
                    c1687e2.d(c1687e.f18144g + c1688f.f18144g);
                }
            }
        }
    }

    @Override // w.AbstractC1694l
    public final void d() {
        v.d dVar;
        v.d dVar2;
        v.d dVar3;
        v.d dVar4;
        v.d dVar5 = this.f18156b;
        boolean z8 = dVar5.f17897a;
        C1688f c1688f = this.f18159e;
        if (z8) {
            c1688f.d(dVar5.i());
        }
        boolean z9 = c1688f.f18146j;
        C1687e c1687e = this.i;
        C1687e c1687e2 = this.f18162h;
        if (!z9) {
            v.d dVar6 = this.f18156b;
            this.f18158d = dVar6.f17902c0[1];
            if (dVar6.f17921w) {
                this.f18154l = new C1683a(this);
            }
            int i = this.f18158d;
            if (i != 3) {
                if (i == 4 && (dVar4 = this.f18156b.f17880I) != null && dVar4.f17902c0[1] == 1) {
                    int i5 = (dVar4.i() - this.f18156b.f17923y.c()) - this.f18156b.f17874A.c();
                    C1693k c1693k = dVar4.f17904e;
                    AbstractC1694l.b(c1687e2, c1693k.f18162h, this.f18156b.f17923y.c());
                    AbstractC1694l.b(c1687e, c1693k.i, -this.f18156b.f17874A.c());
                    c1688f.d(i5);
                    return;
                }
                if (i == 1) {
                    c1688f.d(this.f18156b.i());
                }
            }
        } else if (this.f18158d == 4 && (dVar2 = (dVar = this.f18156b).f17880I) != null && dVar2.f17902c0[1] == 1) {
            C1693k c1693k2 = dVar2.f17904e;
            AbstractC1694l.b(c1687e2, c1693k2.f18162h, dVar.f17923y.c());
            AbstractC1694l.b(c1687e, c1693k2.i, -this.f18156b.f17874A.c());
            return;
        }
        boolean z10 = c1688f.f18146j;
        C1687e c1687e3 = this.f18153k;
        if (z10) {
            v.d dVar7 = this.f18156b;
            if (dVar7.f17897a) {
                v.c[] cVarArr = dVar7.f17878F;
                v.c cVar = cVarArr[2];
                v.c cVar2 = cVar.f17870d;
                if (cVar2 != null && cVarArr[3].f17870d != null) {
                    if (dVar7.r()) {
                        c1687e2.f18143f = this.f18156b.f17878F[2].c();
                        c1687e.f18143f = -this.f18156b.f17878F[3].c();
                    } else {
                        C1687e c1687eH = AbstractC1694l.h(this.f18156b.f17878F[2]);
                        if (c1687eH != null) {
                            AbstractC1694l.b(c1687e2, c1687eH, this.f18156b.f17878F[2].c());
                        }
                        C1687e c1687eH2 = AbstractC1694l.h(this.f18156b.f17878F[3]);
                        if (c1687eH2 != null) {
                            AbstractC1694l.b(c1687e, c1687eH2, -this.f18156b.f17878F[3].c());
                        }
                        c1687e2.f18139b = true;
                        c1687e.f18139b = true;
                    }
                    v.d dVar8 = this.f18156b;
                    if (dVar8.f17921w) {
                        AbstractC1694l.b(c1687e3, c1687e2, dVar8.f17887P);
                        return;
                    }
                    return;
                }
                if (cVar2 != null) {
                    C1687e c1687eH3 = AbstractC1694l.h(cVar);
                    if (c1687eH3 != null) {
                        AbstractC1694l.b(c1687e2, c1687eH3, this.f18156b.f17878F[2].c());
                        AbstractC1694l.b(c1687e, c1687e2, c1688f.f18144g);
                        v.d dVar9 = this.f18156b;
                        if (dVar9.f17921w) {
                            AbstractC1694l.b(c1687e3, c1687e2, dVar9.f17887P);
                            return;
                        }
                        return;
                    }
                    return;
                }
                v.c cVar3 = cVarArr[3];
                if (cVar3.f17870d != null) {
                    C1687e c1687eH4 = AbstractC1694l.h(cVar3);
                    if (c1687eH4 != null) {
                        AbstractC1694l.b(c1687e, c1687eH4, -this.f18156b.f17878F[3].c());
                        AbstractC1694l.b(c1687e2, c1687e, -c1688f.f18144g);
                    }
                    v.d dVar10 = this.f18156b;
                    if (dVar10.f17921w) {
                        AbstractC1694l.b(c1687e3, c1687e2, dVar10.f17887P);
                        return;
                    }
                    return;
                }
                v.c cVar4 = cVarArr[4];
                if (cVar4.f17870d != null) {
                    C1687e c1687eH5 = AbstractC1694l.h(cVar4);
                    if (c1687eH5 != null) {
                        AbstractC1694l.b(c1687e3, c1687eH5, 0);
                        AbstractC1694l.b(c1687e2, c1687e3, -this.f18156b.f17887P);
                        AbstractC1694l.b(c1687e, c1687e2, c1688f.f18144g);
                        return;
                    }
                    return;
                }
                if ((dVar7 instanceof v.i) || dVar7.f17880I == null || dVar7.g(7).f17870d != null) {
                    return;
                }
                v.d dVar11 = this.f18156b;
                AbstractC1694l.b(c1687e2, dVar11.f17880I.f17904e.f18162h, dVar11.n());
                AbstractC1694l.b(c1687e, c1687e2, c1688f.f18144g);
                v.d dVar12 = this.f18156b;
                if (dVar12.f17921w) {
                    AbstractC1694l.b(c1687e3, c1687e2, dVar12.f17887P);
                    return;
                }
                return;
            }
        }
        if (z10 || this.f18158d != 3) {
            c1688f.b(this);
        } else {
            v.d dVar13 = this.f18156b;
            int i8 = dVar13.f17909k;
            if (i8 == 2) {
                v.d dVar14 = dVar13.f17880I;
                if (dVar14 != null) {
                    C1688f c1688f2 = dVar14.f17904e.f18159e;
                    c1688f.f18148l.add(c1688f2);
                    c1688f2.f18147k.add(c1688f);
                    c1688f.f18139b = true;
                    c1688f.f18147k.add(c1687e2);
                    c1688f.f18147k.add(c1687e);
                }
            } else if (i8 == 3 && !dVar13.r()) {
                v.d dVar15 = this.f18156b;
                if (dVar15.f17908j != 3) {
                    C1688f c1688f3 = dVar15.f17903d.f18159e;
                    c1688f.f18148l.add(c1688f3);
                    c1688f3.f18147k.add(c1688f);
                    c1688f.f18139b = true;
                    c1688f.f18147k.add(c1687e2);
                    c1688f.f18147k.add(c1687e);
                }
            }
        }
        v.d dVar16 = this.f18156b;
        v.c[] cVarArr2 = dVar16.f17878F;
        v.c cVar5 = cVarArr2[2];
        v.c cVar6 = cVar5.f17870d;
        if (cVar6 != null && cVarArr2[3].f17870d != null) {
            if (dVar16.r()) {
                c1687e2.f18143f = this.f18156b.f17878F[2].c();
                c1687e.f18143f = -this.f18156b.f17878F[3].c();
            } else {
                C1687e c1687eH6 = AbstractC1694l.h(this.f18156b.f17878F[2]);
                C1687e c1687eH7 = AbstractC1694l.h(this.f18156b.f17878F[3]);
                c1687eH6.b(this);
                c1687eH7.b(this);
                this.f18163j = 4;
            }
            if (this.f18156b.f17921w) {
                c(c1687e3, c1687e2, 1, this.f18154l);
            }
        } else if (cVar6 != null) {
            C1687e c1687eH8 = AbstractC1694l.h(cVar5);
            if (c1687eH8 != null) {
                AbstractC1694l.b(c1687e2, c1687eH8, this.f18156b.f17878F[2].c());
                c(c1687e, c1687e2, 1, c1688f);
                if (this.f18156b.f17921w) {
                    c(c1687e3, c1687e2, 1, this.f18154l);
                }
                if (this.f18158d == 3) {
                    v.d dVar17 = this.f18156b;
                    if (dVar17.f17883L > 0.0f) {
                        C1691i c1691i = dVar17.f17903d;
                        if (c1691i.f18158d == 3) {
                            c1691i.f18159e.f18147k.add(c1688f);
                            c1688f.f18148l.add(this.f18156b.f17903d.f18159e);
                            c1688f.f18138a = this;
                        }
                    }
                }
            }
        } else {
            v.c cVar7 = cVarArr2[3];
            if (cVar7.f17870d != null) {
                C1687e c1687eH9 = AbstractC1694l.h(cVar7);
                if (c1687eH9 != null) {
                    AbstractC1694l.b(c1687e, c1687eH9, -this.f18156b.f17878F[3].c());
                    c(c1687e2, c1687e, -1, c1688f);
                    if (this.f18156b.f17921w) {
                        c(c1687e3, c1687e2, 1, this.f18154l);
                    }
                }
            } else {
                v.c cVar8 = cVarArr2[4];
                if (cVar8.f17870d != null) {
                    C1687e c1687eH10 = AbstractC1694l.h(cVar8);
                    if (c1687eH10 != null) {
                        AbstractC1694l.b(c1687e3, c1687eH10, 0);
                        c(c1687e2, c1687e3, -1, this.f18154l);
                        c(c1687e, c1687e2, 1, c1688f);
                    }
                } else if (!(dVar16 instanceof v.i) && (dVar3 = dVar16.f17880I) != null) {
                    AbstractC1694l.b(c1687e2, dVar3.f17904e.f18162h, dVar16.n());
                    c(c1687e, c1687e2, 1, c1688f);
                    if (this.f18156b.f17921w) {
                        c(c1687e3, c1687e2, 1, this.f18154l);
                    }
                    if (this.f18158d == 3) {
                        v.d dVar18 = this.f18156b;
                        if (dVar18.f17883L > 0.0f) {
                            C1691i c1691i2 = dVar18.f17903d;
                            if (c1691i2.f18158d == 3) {
                                c1691i2.f18159e.f18147k.add(c1688f);
                                c1688f.f18148l.add(this.f18156b.f17903d.f18159e);
                                c1688f.f18138a = this;
                            }
                        }
                    }
                }
            }
        }
        if (c1688f.f18148l.size() == 0) {
            c1688f.f18140c = true;
        }
    }

    @Override // w.AbstractC1694l
    public final void e() {
        C1687e c1687e = this.f18162h;
        if (c1687e.f18146j) {
            this.f18156b.f17886O = c1687e.f18144g;
        }
    }

    @Override // w.AbstractC1694l
    public final void f() {
        this.f18157c = null;
        this.f18162h.c();
        this.i.c();
        this.f18153k.c();
        this.f18159e.c();
        this.f18161g = false;
    }

    @Override // w.AbstractC1694l
    public final boolean k() {
        return this.f18158d != 3 || this.f18156b.f17909k == 0;
    }

    public final void m() {
        this.f18161g = false;
        C1687e c1687e = this.f18162h;
        c1687e.c();
        c1687e.f18146j = false;
        C1687e c1687e2 = this.i;
        c1687e2.c();
        c1687e2.f18146j = false;
        C1687e c1687e3 = this.f18153k;
        c1687e3.c();
        c1687e3.f18146j = false;
        this.f18159e.f18146j = false;
    }

    public final String toString() {
        return "VerticalRun " + this.f18156b.f17894W;
    }
}
