package U;

import G0.InterfaceC0274t;
import K.AbstractC0454g0;
import T0.C0590a;
import T0.O;
import T0.t;
import X0.InterfaceC0807u;
import a.AbstractC0872a;
import c1.C1228c;
import e4.C;
import h1.C2069a;
import kotlin.jvm.internal.o;
import x4.y;

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public boolean f6762k;
    public long l;

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

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

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

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

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

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public long f6766p = h1.b.h(0, 0, 0, 0);

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

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

    public e(String str, O o6, InterfaceC0807u interfaceC0807u, int i6, boolean z6, int i7, int i8) {
        this.f6752a = str;
        this.f6753b = o6;
        this.f6754c = interfaceC0807u;
        this.f6755d = i6;
        this.f6756e = z6;
        this.f6757f = i7;
        this.f6758g = i8;
        long j4 = 0;
        this.l = (j4 & 4294967295L) | (j4 << 32);
    }

    public static long f(e eVar, long j4, h1.m mVar) {
        O o6 = eVar.f6753b;
        b bVar = eVar.f6763m;
        InterfaceC0274t interfaceC0274t = eVar.f6760i;
        o.e(interfaceC0274t);
        b bVarF = AbstractC0872a.F(bVar, mVar, o6, interfaceC0274t, eVar.f6754c);
        eVar.f6763m = bVarF;
        return bVarF.a(eVar.f6758g, j4);
    }

    public final int a(int i6, h1.m mVar) {
        int i7 = this.f6767q;
        int i8 = this.f6768r;
        if (i6 == i7 && i7 != -1) {
            return i8;
        }
        long jA = h1.b.a(0, i6, 0, Integer.MAX_VALUE);
        if (this.f6758g > 1) {
            jA = f(this, jA, mVar);
        }
        t tVarE = e(mVar);
        long jE = L4.a.E(jA, this.f6756e, this.f6755d, tVarE.c());
        boolean z6 = this.f6756e;
        int i9 = this.f6755d;
        int i10 = this.f6757f;
        int i11 = AbstractC0454g0.i(new C0590a((C1228c) tVarE, ((z6 || !(i9 == 2 || i9 == 4 || i9 == 5)) && i10 >= 1) ? i10 : 1, i9, jE).b());
        int i12 = C2069a.i(jA);
        if (i11 < i12) {
            i11 = i12;
        }
        this.f6767q = i6;
        this.f6768r = i11;
        return i11;
    }

    public final boolean b(long j4, h1.m mVar) {
        t tVar;
        this.f6769s = (this.f6769s << 2) | 3;
        boolean z6 = true;
        long jF = this.f6758g > 1 ? f(this, j4, mVar) : j4;
        C0590a c0590a = this.f6761j;
        boolean z7 = false;
        if (c0590a != null && (tVar = this.f6764n) != null && !tVar.a() && mVar == this.f6765o && (C2069a.b(jF, this.f6766p) || (C2069a.h(jF) == C2069a.h(this.f6766p) && C2069a.j(jF) == C2069a.j(this.f6766p) && C2069a.g(jF) >= c0590a.b() && !c0590a.f6493d.f6846d))) {
            if (!C2069a.b(jF, this.f6766p)) {
                C0590a c0590a2 = this.f6761j;
                o.e(c0590a2);
                this.l = h1.b.d(jF, (((long) AbstractC0454g0.i(Math.min(c0590a2.f6490a.l.c(), c0590a2.d()))) << 32) | (((long) AbstractC0454g0.i(c0590a2.b())) & 4294967295L));
                if (this.f6755d == 3 || (((int) (r12 >> 32)) >= c0590a2.d() && ((int) (4294967295L & r12)) >= c0590a2.b())) {
                    z6 = false;
                }
                this.f6762k = z6;
                this.f6766p = jF;
            }
            return false;
        }
        t tVarE = e(mVar);
        long jE = L4.a.E(jF, this.f6756e, this.f6755d, tVarE.c());
        boolean z8 = this.f6756e;
        int i6 = this.f6755d;
        int i7 = this.f6757f;
        C0590a c0590a3 = new C0590a((C1228c) tVarE, ((z8 || !(i6 == 2 || i6 == 4 || i6 == 5)) && i7 >= 1) ? i7 : 1, i6, jE);
        this.f6766p = jF;
        this.l = h1.b.d(jF, (((long) AbstractC0454g0.i(c0590a3.b())) & 4294967295L) | (((long) AbstractC0454g0.i(c0590a3.d())) << 32));
        if (this.f6755d != 3 && (((int) (r1 >> 32)) < c0590a3.d() || ((int) (r1 & 4294967295L)) < c0590a3.b())) {
            z7 = true;
        }
        this.f6762k = z7;
        this.f6761j = c0590a3;
        return true;
    }

    public final void c() {
        this.f6761j = null;
        this.f6764n = null;
        this.f6765o = null;
        this.f6767q = -1;
        this.f6768r = -1;
        this.f6766p = h1.b.h(0, 0, 0, 0);
        long j4 = 0;
        this.l = (j4 & 4294967295L) | (j4 << 32);
        this.f6762k = false;
    }

    public final void d(InterfaceC0274t interfaceC0274t) {
        long jA;
        InterfaceC0274t interfaceC0274t2 = this.f6760i;
        if (interfaceC0274t != null) {
            int i6 = a.f6725b;
            jA = a.a(interfaceC0274t.a(), interfaceC0274t.T());
        } else {
            jA = a.f6724a;
        }
        if (interfaceC0274t2 == null) {
            this.f6760i = interfaceC0274t;
            this.f6759h = jA;
        } else if (interfaceC0274t == null || this.f6759h != jA) {
            this.f6760i = interfaceC0274t;
            this.f6759h = jA;
            this.f6769s = (this.f6769s << 2) | 1;
            c();
        }
    }

    public final t e(h1.m mVar) {
        t c1228c = this.f6764n;
        if (c1228c == null || mVar != this.f6765o || c1228c.a()) {
            this.f6765o = mVar;
            String str = this.f6752a;
            O oD0 = C.d0(this.f6753b, mVar);
            y yVar = y.f26065a;
            InterfaceC0274t interfaceC0274t = this.f6760i;
            o.e(interfaceC0274t);
            c1228c = new C1228c(str, oD0, yVar, yVar, this.f6754c, interfaceC0274t);
        }
        this.f6764n = c1228c;
        return c1228c;
    }

    public final String toString() {
        StringBuilder sb = new StringBuilder("ParagraphLayoutCache(paragraph=");
        sb.append(this.f6761j != null ? "<paragraph>" : "null");
        sb.append(", lastDensity=");
        sb.append((Object) a.b(this.f6759h));
        sb.append(", history=");
        return Z0.o.k(this.f6769s, ", constraints=$)", sb);
    }
}
