package o;

import com.google.android.gms.common.api.Api;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class EV {
    public String a;
    public C0733af0 b;
    public InterfaceC2221qA c;
    public int d;
    public boolean e;
    public int f;
    public int g;
    public InterfaceC2281qr i;
    public J4 j;
    public boolean k;
    public long l;
    public EP m;
    public DV n;

    /* renamed from: o, reason: collision with root package name */
    public EnumC1280gK f104o;
    public long s;
    public long h = AbstractC2512tH.a;
    public long p = AbstractC0842bm.h(0, 0, 0, 0);
    public int q = -1;
    public int r = -1;

    public EV(String str, C0733af0 c0733af0, InterfaceC2221qA interfaceC2221qA, int i, boolean z, int i2, int i3) {
        this.a = str;
        this.b = c0733af0;
        this.c = interfaceC2221qA;
        this.d = i;
        this.e = z;
        this.f = i2;
        this.g = i3;
        long j = 0;
        this.l = (j & 4294967295L) | (j << 32);
    }

    public final int a(int i, EnumC1280gK enumC1280gK) {
        int i2 = this.q;
        int i3 = this.r;
        if (i == i2 && i2 != -1) {
            return i3;
        }
        long jA = AbstractC0842bm.a(0, i, 0, Api.BaseClientBuilder.API_PRIORITY_OTHER);
        if (this.g > 1) {
            EP epX = C1884mi0.x(this.m, enumC1280gK, this.b, this.i, this.c);
            this.m = epX;
            jA = epX.a(this.g, jA);
        }
        DV dvE = e(enumC1280gK);
        long jZ = As0.z(jA, this.e, this.d, dvE.c());
        boolean z = this.e;
        int i4 = this.d;
        int i5 = this.f;
        int iK = C2887xC.k(new J4((N4) dvE, ((z || !(i4 == 2 || i4 == 4 || i4 == 5)) && i5 >= 1) ? i5 : 1, i4, jZ).b());
        int i6 = C0634Yl.i(jA);
        if (iK < i6) {
            iK = i6;
        }
        this.q = i;
        this.r = iK;
        return iK;
    }

    public final boolean b(long j, EnumC1280gK enumC1280gK) {
        long jA;
        DV dv;
        this.s = (this.s << 2) | 3;
        boolean z = true;
        if (this.g > 1) {
            EP epX = C1884mi0.x(this.m, enumC1280gK, this.b, this.i, this.c);
            this.m = epX;
            jA = epX.a(this.g, j);
        } else {
            jA = j;
        }
        J4 j4 = this.j;
        boolean z2 = false;
        if (j4 != null && (dv = this.n) != null && !dv.b() && enumC1280gK == this.f104o && (C0634Yl.b(jA, this.p) || (C0634Yl.h(jA) == C0634Yl.h(this.p) && C0634Yl.j(jA) == C0634Yl.j(this.p) && C0634Yl.g(jA) >= j4.b() && !j4.d.d))) {
            if (!C0634Yl.b(jA, this.p)) {
                J4 j42 = this.j;
                this.l = AbstractC0842bm.d(jA, (C2887xC.k(Math.min(j42.a.t.c(), j42.d())) << 32) | (C2887xC.k(j42.b()) & 4294967295L));
                if (this.d == 3 || (((int) (r12 >> 32)) >= j42.d() && ((int) (4294967295L & r12)) >= j42.b())) {
                    z = false;
                }
                this.k = z;
                this.p = jA;
            }
            return false;
        }
        DV dvE = e(enumC1280gK);
        long jZ = As0.z(jA, this.e, this.d, dvE.c());
        boolean z3 = this.e;
        int i = this.d;
        int i2 = this.f;
        J4 j43 = new J4((N4) dvE, ((z3 || !(i == 2 || i == 4 || i == 5)) && i2 >= 1) ? i2 : 1, i, jZ);
        this.p = jA;
        this.l = AbstractC0842bm.d(jA, (C2887xC.k(j43.b()) & 4294967295L) | (C2887xC.k(j43.d()) << 32));
        if (this.d != 3 && (((int) (r1 >> 32)) < j43.d() || ((int) (r1 & 4294967295L)) < j43.b())) {
            z2 = true;
        }
        this.k = z2;
        this.j = j43;
        return true;
    }

    public final void c() {
        this.j = null;
        this.n = null;
        this.f104o = null;
        this.q = -1;
        this.r = -1;
        this.p = AbstractC0842bm.h(0, 0, 0, 0);
        long j = 0;
        this.l = (j & 4294967295L) | (j << 32);
        this.k = false;
    }

    public final void d(InterfaceC2281qr interfaceC2281qr) {
        long jA;
        InterfaceC2281qr interfaceC2281qr2 = this.i;
        if (interfaceC2281qr != null) {
            int i = AbstractC2512tH.b;
            jA = AbstractC2512tH.a(interfaceC2281qr.e(), interfaceC2281qr.q());
        } else {
            jA = AbstractC2512tH.a;
        }
        if (interfaceC2281qr2 == null) {
            this.i = interfaceC2281qr;
            this.h = jA;
        } else if (interfaceC2281qr == null || this.h != jA) {
            this.i = interfaceC2281qr;
            this.h = jA;
            this.s = (this.s << 2) | 1;
            c();
        }
    }

    public final DV e(EnumC1280gK enumC1280gK) {
        DV n4 = this.n;
        if (n4 == null || enumC1280gK != this.f104o || n4.b()) {
            this.f104o = enumC1280gK;
            String str = this.a;
            C0733af0 c0733af0E = AbstractC2001nt0.E(this.b, enumC1280gK);
            InterfaceC2281qr interfaceC2281qr = this.i;
            InterfaceC2221qA interfaceC2221qA = this.c;
            C0332Mv c0332Mv = C0332Mv.l;
            n4 = new N4(str, c0733af0E, c0332Mv, c0332Mv, interfaceC2221qA, interfaceC2281qr);
        }
        this.n = n4;
        return n4;
    }

    public final String toString() {
        StringBuilder sb = new StringBuilder("ParagraphLayoutCache(paragraph=");
        sb.append(this.j != null ? "<paragraph>" : "null");
        sb.append(", lastDensity=");
        sb.append((Object) AbstractC2512tH.b(this.h));
        sb.append(", history=");
        sb.append(this.s);
        sb.append(", constraints=$)");
        return sb.toString();
    }
}
