package U;

import K.AbstractC0454g0;
import T0.C0596g;
import T0.C0604o;
import T0.C0606q;
import T0.K;
import T0.L;
import T0.O;
import X0.InterfaceC0807u;
import a.AbstractC0872a;
import e4.C;
import h1.C2069a;
import java.util.List;
import kotlin.jvm.internal.o;
import x4.y;

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

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public InterfaceC0807u f6737b;

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

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

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

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

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

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

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public h1.c f6745j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public O f6746k;
    public C0606q l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public h1.m f6747m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public L f6748n;

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public long f6744i = a.f6724a;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public int f6749o = -1;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public int f6750p = -1;

    public d(C0596g c0596g, O o6, InterfaceC0807u interfaceC0807u, int i6, boolean z6, int i7, int i8, List list) {
        this.f6736a = c0596g;
        this.f6737b = interfaceC0807u;
        this.f6738c = i6;
        this.f6739d = z6;
        this.f6740e = i7;
        this.f6741f = i8;
        this.f6742g = list;
        this.f6746k = o6;
    }

    public final int a(int i6, h1.m mVar) {
        int i7 = this.f6749o;
        int i8 = this.f6750p;
        if (i6 == i7 && i7 != -1) {
            return i8;
        }
        long jA = h1.b.a(0, i6, 0, Integer.MAX_VALUE);
        if (this.f6741f > 1) {
            b bVar = this.f6743h;
            O o6 = this.f6746k;
            h1.c cVar = this.f6745j;
            o.e(cVar);
            b bVarF = AbstractC0872a.F(bVar, mVar, o6, cVar, this.f6737b);
            this.f6743h = bVarF;
            jA = bVarF.a(this.f6741f, jA);
        }
        int i9 = AbstractC0454g0.i(b(jA, mVar).f6536e);
        int i10 = C2069a.i(jA);
        if (i9 < i10) {
            i9 = i10;
        }
        this.f6749o = i6;
        this.f6750p = i9;
        return i9;
    }

    public final C0604o b(long j4, h1.m mVar) {
        C0606q c0606qE = e(mVar);
        long jE = L4.a.E(j4, this.f6739d, this.f6738c, c0606qE.c());
        boolean z6 = this.f6739d;
        int i6 = this.f6738c;
        int i7 = this.f6740e;
        return new C0604o(c0606qE, jE, ((z6 || !(i6 == 2 || i6 == 4 || i6 == 5)) && i7 >= 1) ? i7 : 1, i6);
    }

    public final boolean c(long j4, h1.m mVar) {
        this.f6751q = (this.f6751q << 2) | 3;
        if (this.f6741f > 1) {
            b bVar = this.f6743h;
            O o6 = this.f6746k;
            h1.c cVar = this.f6745j;
            o.e(cVar);
            b bVarF = AbstractC0872a.F(bVar, mVar, o6, cVar, this.f6737b);
            this.f6743h = bVarF;
            j4 = bVarF.a(this.f6741f, j4);
        }
        L l = this.f6748n;
        if (l != null) {
            C0604o c0604o = l.f6472b;
            if (!c0604o.f6532a.a()) {
                K k6 = l.f6471a;
                if (mVar == k6.f6468h) {
                    long j6 = k6.f6470j;
                    if (C2069a.b(j4, j6) || (C2069a.h(j4) == C2069a.h(j6) && C2069a.j(j4) == C2069a.j(j6) && C2069a.g(j4) >= c0604o.f6536e && !c0604o.f6534c)) {
                        L l6 = this.f6748n;
                        o.e(l6);
                        if (C2069a.b(j4, l6.f6471a.f6470j)) {
                            return false;
                        }
                        L l7 = this.f6748n;
                        o.e(l7);
                        this.f6748n = f(mVar, j4, l7.f6472b);
                        return true;
                    }
                }
            }
        }
        this.f6748n = f(mVar, j4, b(j4, mVar));
        return true;
    }

    public final void d(h1.c cVar) {
        long jA;
        h1.c cVar2 = this.f6745j;
        if (cVar != null) {
            int i6 = a.f6725b;
            jA = a.a(cVar.a(), cVar.T());
        } else {
            jA = a.f6724a;
        }
        if (cVar2 == null) {
            this.f6745j = cVar;
            this.f6744i = jA;
        } else if (cVar == null || this.f6744i != jA) {
            this.f6745j = cVar;
            this.f6744i = jA;
            this.f6751q = (this.f6751q << 2) | 1;
            this.l = null;
            this.f6748n = null;
            this.f6750p = -1;
            this.f6749o = -1;
        }
    }

    public final C0606q e(h1.m mVar) {
        C0606q c0606q = this.l;
        if (c0606q == null || mVar != this.f6747m || c0606q.a()) {
            this.f6747m = mVar;
            C0596g c0596g = this.f6736a;
            O oD0 = C.d0(this.f6746k, mVar);
            h1.c cVar = this.f6745j;
            o.e(cVar);
            InterfaceC0807u interfaceC0807u = this.f6737b;
            List list = this.f6742g;
            if (list == null) {
                list = y.f26065a;
            }
            c0606q = new C0606q(c0596g, oD0, list, cVar, interfaceC0807u);
        }
        this.l = c0606q;
        return c0606q;
    }

    public final L f(h1.m mVar, long j4, C0604o c0604o) {
        float fMin = Math.min(c0604o.f6532a.c(), c0604o.f6535d);
        C0596g c0596g = this.f6736a;
        O o6 = this.f6746k;
        List list = this.f6742g;
        if (list == null) {
            list = y.f26065a;
        }
        int i6 = this.f6740e;
        boolean z6 = this.f6739d;
        int i7 = this.f6738c;
        h1.c cVar = this.f6745j;
        o.e(cVar);
        return new L(new K(c0596g, o6, list, i6, z6, i7, cVar, mVar, this.f6737b, j4), c0604o, h1.b.d(j4, (((long) AbstractC0454g0.i(fMin)) << 32) | (((long) AbstractC0454g0.i(c0604o.f6536e)) & 4294967295L)));
    }

    public final String toString() {
        K k6;
        StringBuilder sb = new StringBuilder("MultiParagraphLayoutCache(textLayoutResult=");
        Object c2069a = "null";
        sb.append(this.f6748n != null ? "<TextLayoutResult>" : "null");
        sb.append(", lastDensity=");
        sb.append((Object) a.b(this.f6744i));
        sb.append(", history=");
        sb.append(this.f6751q);
        sb.append(", constraints=");
        L l = this.f6748n;
        if (l != null && (k6 = l.f6471a) != null) {
            c2069a = new C2069a(k6.f6470j);
        }
        sb.append(c2069a);
        sb.append(')');
        return sb.toString();
    }
}
