package androidx.compose.foundation.text.modifiers;

import b3.j;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.firebase.crashlytics.internal.metadata.UserMetadata;
import dn.l;
import h2.d0;
import h2.f0;
import h2.n;
import h2.o;
import h2.p0;
import j2.b0;
import j2.e0;
import j2.r;
import j2.s;
import j2.s1;
import j2.t1;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import kotlin.jvm.internal.k;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import l1.i;
import o2.u;
import q0.g;
import q0.h;
import q2.i0;
import q2.o0;
import rm.n0;
import s1.a0;
import s1.g0;
import s1.j0;
import s1.p1;
import s1.y;
import v2.i;

/* loaded from: classes.dex */
public final class b extends i.c implements b0, r, s1 {
    private q2.d C;
    private o0 D;
    private i.b E;
    private l F;
    private int G;
    private boolean H;
    private int I;
    private int J;
    private List K;
    private l L;
    private g M;
    private j0 N;
    private l O;
    private Map P;
    private q0.e Q;
    private l R;
    private a S;

    /* renamed from: androidx.compose.foundation.text.modifiers.b$b, reason: collision with other inner class name */
    /* loaded from: classes.dex */
    static final class C0056b extends v implements l {
        C0056b() {
            super(1);
        }

        /* JADX WARN: Removed duplicated region for block: B:10:0x00bb  */
        /* JADX WARN: Removed duplicated region for block: B:14:0x00bd  */
        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Boolean invoke(List list) {
            q2.j0 j0Var;
            o0 J;
            q2.j0 b10 = b.this.q2().b();
            if (b10 != null) {
                q2.d j10 = b10.l().j();
                o0 o0Var = b.this.D;
                j0 j0Var2 = b.this.N;
                J = o0Var.J((r58 & 1) != 0 ? g0.f35254b.f() : j0Var2 != null ? j0Var2.a() : g0.f35254b.f(), (r58 & 2) != 0 ? c3.v.f7436b.a() : 0L, (r58 & 4) != 0 ? null : null, (r58 & 8) != 0 ? null : null, (r58 & 16) != 0 ? null : null, (r58 & 32) != 0 ? null : null, (r58 & 64) != 0 ? null : null, (r58 & 128) != 0 ? c3.v.f7436b.a() : 0L, (r58 & 256) != 0 ? null : null, (r58 & 512) != 0 ? null : null, (r58 & UserMetadata.MAX_ATTRIBUTE_SIZE) != 0 ? null : null, (r58 & 2048) != 0 ? g0.f35254b.f() : 0L, (r58 & 4096) != 0 ? null : null, (r58 & UserMetadata.MAX_INTERNAL_KEY_SIZE) != 0 ? null : null, (r58 & 16384) != 0 ? null : null, (r58 & 32768) != 0 ? j.f6691b.g() : 0, (r58 & 65536) != 0 ? b3.l.f6705b.f() : 0, (r58 & 131072) != 0 ? c3.v.f7436b.a() : 0L, (r58 & 262144) != 0 ? null : null, (r58 & 524288) != 0 ? null : null, (r58 & 1048576) != 0 ? b3.f.f6656b.b() : 0, (r58 & 2097152) != 0 ? b3.e.f6651b.c() : 0, (r58 & 4194304) != 0 ? null : null, (r58 & 8388608) != 0 ? null : null);
                j0Var = q2.j0.b(b10, new i0(j10, J, b10.l().g(), b10.l().e(), b10.l().h(), b10.l().f(), b10.l().b(), b10.l().d(), b10.l().c(), b10.l().a(), (k) null), 0L, 2, null);
                if (j0Var != null) {
                    list.add(j0Var);
                    return Boolean.valueOf(j0Var == null);
                }
            }
            j0Var = null;
            return Boolean.valueOf(j0Var == null);
        }
    }

    /* loaded from: classes.dex */
    static final class c extends v implements l {
        c() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Boolean invoke(q2.d dVar) {
            b.this.z2(dVar);
            b.this.t2();
            return Boolean.TRUE;
        }
    }

    /* loaded from: classes.dex */
    static final class d extends v implements l {
        d() {
            super(1);
        }

        public final Boolean a(boolean z10) {
            if (b.this.s2() == null) {
                return Boolean.FALSE;
            }
            l lVar = b.this.O;
            if (lVar != null) {
                a s22 = b.this.s2();
                t.d(s22);
                lVar.invoke(s22);
            }
            a s23 = b.this.s2();
            if (s23 != null) {
                s23.f(z10);
            }
            b.this.t2();
            return Boolean.TRUE;
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            return a(((Boolean) obj).booleanValue());
        }
    }

    /* loaded from: classes.dex */
    static final class e extends v implements dn.a {
        e() {
            super(0);
        }

        @Override // dn.a
        public final Boolean invoke() {
            b.this.n2();
            b.this.t2();
            return Boolean.TRUE;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class f extends v implements l {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ p0 f2079p;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        f(p0 p0Var) {
            super(1);
            this.f2079p = p0Var;
        }

        public final void a(p0.a aVar) {
            p0.a.h(aVar, this.f2079p, 0, 0, BitmapDescriptorFactory.HUE_RED, 4, null);
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            a((p0.a) obj);
            return n0.f34904a;
        }
    }

    public /* synthetic */ b(q2.d dVar, o0 o0Var, i.b bVar, l lVar, int i10, boolean z10, int i11, int i12, List list, l lVar2, g gVar, j0 j0Var, l lVar3, k kVar) {
        this(dVar, o0Var, bVar, lVar, i10, z10, i11, i12, list, lVar2, gVar, j0Var, lVar3);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final q0.e q2() {
        if (this.Q == null) {
            this.Q = new q0.e(this.C, this.D, this.E, this.G, this.H, this.I, this.J, this.K, null);
        }
        q0.e eVar = this.Q;
        t.d(eVar);
        return eVar;
    }

    private final q0.e r2(c3.d dVar) {
        q0.e a10;
        a aVar = this.S;
        if (aVar != null && aVar.d() && (a10 = aVar.a()) != null) {
            a10.k(dVar);
            return a10;
        }
        q0.e q22 = q2();
        q22.k(dVar);
        return q22;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void t2() {
        t1.b(this);
        e0.b(this);
        s.a(this);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final boolean z2(q2.d dVar) {
        n0 n0Var;
        a aVar = this.S;
        if (aVar == null) {
            a aVar2 = new a(this.C, dVar, false, null, 12, null);
            q0.e eVar = new q0.e(dVar, this.D, this.E, this.G, this.H, this.I, this.J, this.K, null);
            eVar.k(q2().a());
            aVar2.e(eVar);
            this.S = aVar2;
            return true;
        }
        if (t.b(dVar, aVar.c())) {
            return false;
        }
        aVar.g(dVar);
        q0.e a10 = aVar.a();
        if (a10 != null) {
            a10.n(dVar, this.D, this.E, this.G, this.H, this.I, this.J, this.K);
            n0Var = n0.f34904a;
        } else {
            n0Var = null;
        }
        return n0Var != null;
    }

    public final boolean A2(l lVar, l lVar2, g gVar, l lVar3) {
        boolean z10;
        if (this.F != lVar) {
            this.F = lVar;
            z10 = true;
        } else {
            z10 = false;
        }
        if (this.L != lVar2) {
            this.L = lVar2;
            z10 = true;
        }
        if (!t.b(this.M, gVar)) {
            this.M = gVar;
            z10 = true;
        }
        if (this.O == lVar3) {
            return z10;
        }
        this.O = lVar3;
        return true;
    }

    @Override // j2.s1
    public void B0(u uVar) {
        l lVar = this.R;
        if (lVar == null) {
            lVar = new C0056b();
            this.R = lVar;
        }
        o2.s.m0(uVar, this.C);
        a aVar = this.S;
        if (aVar != null) {
            o2.s.q0(uVar, aVar.c());
            o2.s.j0(uVar, aVar.d());
        }
        o2.s.r0(uVar, null, new c(), 1, null);
        o2.s.w0(uVar, null, new d(), 1, null);
        o2.s.d(uVar, null, new e(), 1, null);
        o2.s.r(uVar, null, lVar, 1, null);
    }

    public final boolean B2(j0 j0Var, o0 o0Var) {
        boolean z10 = !t.b(j0Var, this.N);
        this.N = j0Var;
        return z10 || !o0Var.F(this.D);
    }

    public final boolean C2(o0 o0Var, List list, int i10, int i11, boolean z10, i.b bVar, int i12) {
        boolean z11 = !this.D.G(o0Var);
        this.D = o0Var;
        if (!t.b(this.K, list)) {
            this.K = list;
            z11 = true;
        }
        if (this.J != i10) {
            this.J = i10;
            z11 = true;
        }
        if (this.I != i11) {
            this.I = i11;
            z11 = true;
        }
        if (this.H != z10) {
            this.H = z10;
            z11 = true;
        }
        if (!t.b(this.E, bVar)) {
            this.E = bVar;
            z11 = true;
        }
        if (b3.t.e(this.G, i12)) {
            return z11;
        }
        this.G = i12;
        return true;
    }

    public final boolean D2(q2.d dVar) {
        boolean z10 = true;
        boolean z11 = !t.b(this.C.j(), dVar.j());
        boolean z12 = !t.b(this.C.g(), dVar.g());
        boolean z13 = !t.b(this.C.e(), dVar.e());
        boolean z14 = !this.C.m(dVar);
        if (!z11 && !z12 && !z13 && !z14) {
            z10 = false;
        }
        if (z10) {
            this.C = dVar;
        }
        if (z11) {
            n2();
        }
        return z10;
    }

    @Override // j2.b0
    public int I(o oVar, n nVar, int i10) {
        return r2(oVar).i(oVar.getLayoutDirection());
    }

    @Override // j2.b0
    public f0 h(h2.g0 g0Var, d0 d0Var, long j10) {
        q0.e r22 = r2(g0Var);
        boolean f10 = r22.f(j10, g0Var.getLayoutDirection());
        q2.j0 c10 = r22.c();
        c10.w().j().c();
        if (f10) {
            e0.a(this);
            l lVar = this.F;
            if (lVar != null) {
                lVar.invoke(c10);
            }
            g gVar = this.M;
            if (gVar != null) {
                gVar.g(c10);
            }
            Map map = this.P;
            if (map == null) {
                map = new LinkedHashMap(2);
            }
            map.put(h2.b.a(), Integer.valueOf(Math.round(c10.h())));
            map.put(h2.b.b(), Integer.valueOf(Math.round(c10.k())));
            this.P = map;
        }
        l lVar2 = this.L;
        if (lVar2 != null) {
            lVar2.invoke(c10.A());
        }
        p0 Y = d0Var.Y(c3.b.f7403b.b(c3.r.g(c10.B()), c3.r.g(c10.B()), c3.r.f(c10.B()), c3.r.f(c10.B())));
        int g10 = c3.r.g(c10.B());
        int f11 = c3.r.f(c10.B());
        Map map2 = this.P;
        t.d(map2);
        return g0Var.e0(g10, f11, map2, new f(Y));
    }

    public final void n2() {
        this.S = null;
    }

    public final void o2(boolean z10, boolean z11, boolean z12, boolean z13) {
        if (z11 || z12 || z13) {
            q2().n(this.C, this.D, this.E, this.G, this.H, this.I, this.J, this.K);
        }
        if (O1()) {
            if (z11 || (z10 && this.R != null)) {
                t1.b(this);
            }
            if (z11 || z12 || z13) {
                e0.b(this);
                s.a(this);
            }
            if (z10) {
                s.a(this);
            }
        }
    }

    @Override // j2.b0
    public int p(o oVar, n nVar, int i10) {
        return r2(oVar).d(i10, oVar.getLayoutDirection());
    }

    public final void p2(u1.c cVar) {
        r(cVar);
    }

    @Override // j2.r
    public void r(u1.c cVar) {
        if (O1()) {
            g gVar = this.M;
            if (gVar != null) {
                gVar.a(cVar);
            }
            a0 i10 = cVar.Q0().i();
            q2.j0 c10 = r2(cVar).c();
            q2.j w10 = c10.w();
            boolean z10 = true;
            boolean z11 = c10.i() && !b3.t.e(this.G, b3.t.f6735a.c());
            if (z11) {
                r1.i b10 = r1.j.b(r1.g.f34318b.c(), r1.n.a(c3.r.g(c10.B()), c3.r.f(c10.B())));
                i10.n();
                a0.m(i10, b10, 0, 2, null);
            }
            try {
                b3.k A = this.D.A();
                if (A == null) {
                    A = b3.k.f6700b.c();
                }
                b3.k kVar = A;
                p1 x10 = this.D.x();
                if (x10 == null) {
                    x10 = p1.f35307d.a();
                }
                p1 p1Var = x10;
                u1.g i11 = this.D.i();
                if (i11 == null) {
                    i11 = u1.j.f36769a;
                }
                u1.g gVar2 = i11;
                y g10 = this.D.g();
                if (g10 != null) {
                    w10.E(i10, g10, (r17 & 4) != 0 ? Float.NaN : this.D.d(), (r17 & 8) != 0 ? null : p1Var, (r17 & 16) != 0 ? null : kVar, (r17 & 32) != 0 ? null : gVar2, (r17 & 64) != 0 ? u1.f.f36765k.a() : 0);
                } else {
                    j0 j0Var = this.N;
                    long a10 = j0Var != null ? j0Var.a() : g0.f35254b.f();
                    if (!(a10 != 16)) {
                        a10 = (this.D.h() > 16L ? 1 : (this.D.h() == 16L ? 0 : -1)) != 0 ? this.D.h() : g0.f35254b.a();
                    }
                    w10.C(i10, (r14 & 2) != 0 ? g0.f35254b.f() : a10, (r14 & 4) != 0 ? null : p1Var, (r14 & 8) != 0 ? null : kVar, (r14 & 16) == 0 ? gVar2 : null, (r14 & 32) != 0 ? u1.f.f36765k.a() : 0);
                }
                a aVar = this.S;
                if (!(aVar != null && aVar.d() ? false : h.a(this.C))) {
                    List list = this.K;
                    if (list != null && !list.isEmpty()) {
                        z10 = false;
                    }
                    if (z10) {
                        return;
                    }
                }
                cVar.z1();
            } finally {
                if (z11) {
                    i10.x();
                }
            }
        }
    }

    @Override // j2.b0
    public int s(o oVar, n nVar, int i10) {
        return r2(oVar).d(i10, oVar.getLayoutDirection());
    }

    public final a s2() {
        return this.S;
    }

    public final int u2(o oVar, n nVar, int i10) {
        return p(oVar, nVar, i10);
    }

    public final int v2(o oVar, n nVar, int i10) {
        return x(oVar, nVar, i10);
    }

    public final f0 w2(h2.g0 g0Var, d0 d0Var, long j10) {
        return h(g0Var, d0Var, j10);
    }

    @Override // j2.b0
    public int x(o oVar, n nVar, int i10) {
        return r2(oVar).h(oVar.getLayoutDirection());
    }

    public final int x2(o oVar, n nVar, int i10) {
        return s(oVar, nVar, i10);
    }

    public final int y2(o oVar, n nVar, int i10) {
        return I(oVar, nVar, i10);
    }

    private b(q2.d dVar, o0 o0Var, i.b bVar, l lVar, int i10, boolean z10, int i11, int i12, List list, l lVar2, g gVar, j0 j0Var, l lVar3) {
        this.C = dVar;
        this.D = o0Var;
        this.E = bVar;
        this.F = lVar;
        this.G = i10;
        this.H = z10;
        this.I = i11;
        this.J = i12;
        this.K = list;
        this.L = lVar2;
        this.M = gVar;
        this.N = j0Var;
        this.O = lVar3;
    }

    /* loaded from: classes.dex */
    public static final class a {

        /* renamed from: a, reason: collision with root package name */
        private final q2.d f2071a;

        /* renamed from: b, reason: collision with root package name */
        private q2.d f2072b;

        /* renamed from: c, reason: collision with root package name */
        private boolean f2073c;

        /* renamed from: d, reason: collision with root package name */
        private q0.e f2074d;

        public a(q2.d dVar, q2.d dVar2, boolean z10, q0.e eVar) {
            this.f2071a = dVar;
            this.f2072b = dVar2;
            this.f2073c = z10;
            this.f2074d = eVar;
        }

        public final q0.e a() {
            return this.f2074d;
        }

        public final q2.d b() {
            return this.f2071a;
        }

        public final q2.d c() {
            return this.f2072b;
        }

        public final boolean d() {
            return this.f2073c;
        }

        public final void e(q0.e eVar) {
            this.f2074d = eVar;
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof a)) {
                return false;
            }
            a aVar = (a) obj;
            return t.b(this.f2071a, aVar.f2071a) && t.b(this.f2072b, aVar.f2072b) && this.f2073c == aVar.f2073c && t.b(this.f2074d, aVar.f2074d);
        }

        public final void f(boolean z10) {
            this.f2073c = z10;
        }

        public final void g(q2.d dVar) {
            this.f2072b = dVar;
        }

        public int hashCode() {
            int hashCode = ((((this.f2071a.hashCode() * 31) + this.f2072b.hashCode()) * 31) + Boolean.hashCode(this.f2073c)) * 31;
            q0.e eVar = this.f2074d;
            return hashCode + (eVar == null ? 0 : eVar.hashCode());
        }

        public String toString() {
            return "TextSubstitutionValue(original=" + ((Object) this.f2071a) + ", substitution=" + ((Object) this.f2072b) + ", isShowingSubstitution=" + this.f2073c + ", layoutCache=" + this.f2074d + ')';
        }

        public /* synthetic */ a(q2.d dVar, q2.d dVar2, boolean z10, q0.e eVar, int i10, k kVar) {
            this(dVar, dVar2, (i10 & 4) != 0 ? false : z10, (i10 & 8) != 0 ? null : eVar);
        }
    }
}
