package r0;

import androidx.compose.ui.platform.a1;
import androidx.compose.ui.platform.q2;
import androidx.compose.ui.platform.s2;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import l0.l1;
import l0.p1;
import q2.m0;
import q2.n0;
import r1.g;
import w2.b1;
import w2.q0;
import w2.r0;
import y0.q1;
import y0.s3;

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

    /* renamed from: a, reason: collision with root package name */
    private final l1 f34154a;

    /* renamed from: b, reason: collision with root package name */
    private w2.h0 f34155b = p1.d();

    /* renamed from: c, reason: collision with root package name */
    private dn.l f34156c = d.f34180p;

    /* renamed from: d, reason: collision with root package name */
    private l0.z f34157d;

    /* renamed from: e, reason: collision with root package name */
    private final q1 f34158e;

    /* renamed from: f, reason: collision with root package name */
    private b1 f34159f;

    /* renamed from: g, reason: collision with root package name */
    private a1 f34160g;

    /* renamed from: h, reason: collision with root package name */
    private q2 f34161h;

    /* renamed from: i, reason: collision with root package name */
    private z1.a f34162i;

    /* renamed from: j, reason: collision with root package name */
    private androidx.compose.ui.focus.m f34163j;

    /* renamed from: k, reason: collision with root package name */
    private final q1 f34164k;

    /* renamed from: l, reason: collision with root package name */
    private final q1 f34165l;

    /* renamed from: m, reason: collision with root package name */
    private long f34166m;

    /* renamed from: n, reason: collision with root package name */
    private Integer f34167n;

    /* renamed from: o, reason: collision with root package name */
    private long f34168o;

    /* renamed from: p, reason: collision with root package name */
    private final q1 f34169p;

    /* renamed from: q, reason: collision with root package name */
    private final q1 f34170q;

    /* renamed from: r, reason: collision with root package name */
    private int f34171r;

    /* renamed from: s, reason: collision with root package name */
    private q0 f34172s;

    /* renamed from: t, reason: collision with root package name */
    private w f34173t;

    /* renamed from: u, reason: collision with root package name */
    private final l0.l0 f34174u;

    /* renamed from: v, reason: collision with root package name */
    private final r0.h f34175v;

    /* loaded from: classes.dex */
    public static final class a implements l0.l0 {
        a() {
        }

        @Override // l0.l0
        public void a(long j10) {
        }

        @Override // l0.l0
        public void b(long j10) {
            l0.a1 j11;
            long a10 = v.a(f0.this.G(true));
            l0.z L = f0.this.L();
            if (L == null || (j11 = L.j()) == null) {
                return;
            }
            long k10 = j11.k(a10);
            f0.this.f34166m = k10;
            f0.this.W(r1.g.d(k10));
            f0.this.f34168o = r1.g.f34318b.c();
            f0.this.Y(l0.m.Cursor);
            f0.this.m0(false);
        }

        @Override // l0.l0
        public void c() {
            f0.this.Y(null);
            f0.this.W(null);
        }

        @Override // l0.l0
        public void d(long j10) {
            l0.a1 j11;
            z1.a H;
            f0 f0Var = f0.this;
            f0Var.f34168o = r1.g.r(f0Var.f34168o, j10);
            l0.z L = f0.this.L();
            if (L == null || (j11 = L.j()) == null) {
                return;
            }
            f0 f0Var2 = f0.this;
            f0Var2.W(r1.g.d(r1.g.r(f0Var2.f34166m, f0Var2.f34168o)));
            w2.h0 J = f0Var2.J();
            r1.g A = f0Var2.A();
            kotlin.jvm.internal.t.d(A);
            int a10 = J.a(l0.a1.e(j11, A.v(), false, 2, null));
            long b10 = n0.b(a10, a10);
            if (m0.g(b10, f0Var2.O().g())) {
                return;
            }
            l0.z L2 = f0Var2.L();
            boolean z10 = false;
            if (L2 != null && !L2.y()) {
                z10 = true;
            }
            if (!z10 && (H = f0Var2.H()) != null) {
                H.a(z1.b.f53144a.b());
            }
            f0Var2.K().invoke(f0Var2.q(f0Var2.O().e(), b10));
        }

        @Override // l0.l0
        public void onCancel() {
        }

        @Override // l0.l0
        public void onStop() {
            f0.this.Y(null);
            f0.this.W(null);
        }
    }

    /* loaded from: classes.dex */
    public static final class b implements l0.l0 {

        /* renamed from: b, reason: collision with root package name */
        final /* synthetic */ boolean f34178b;

        b(boolean z10) {
            this.f34178b = z10;
        }

        @Override // l0.l0
        public void a(long j10) {
            l0.a1 j11;
            f0.this.Y(this.f34178b ? l0.m.SelectionStart : l0.m.SelectionEnd);
            long a10 = v.a(f0.this.G(this.f34178b));
            l0.z L = f0.this.L();
            if (L == null || (j11 = L.j()) == null) {
                return;
            }
            long k10 = j11.k(a10);
            f0.this.f34166m = k10;
            f0.this.W(r1.g.d(k10));
            f0.this.f34168o = r1.g.f34318b.c();
            f0.this.f34171r = -1;
            l0.z L2 = f0.this.L();
            if (L2 != null) {
                L2.D(true);
            }
            f0.this.m0(false);
        }

        @Override // l0.l0
        public void b(long j10) {
        }

        @Override // l0.l0
        public void c() {
            f0.this.Y(null);
            f0.this.W(null);
            f0.this.m0(true);
        }

        @Override // l0.l0
        public void d(long j10) {
            f0 f0Var = f0.this;
            f0Var.f34168o = r1.g.r(f0Var.f34168o, j10);
            f0 f0Var2 = f0.this;
            f0Var2.W(r1.g.d(r1.g.r(f0Var2.f34166m, f0.this.f34168o)));
            f0 f0Var3 = f0.this;
            q0 O = f0Var3.O();
            r1.g A = f0.this.A();
            kotlin.jvm.internal.t.d(A);
            f0Var3.n0(O, A.v(), false, this.f34178b, q.f34237a.k(), true);
            f0.this.m0(false);
        }

        @Override // l0.l0
        public void onCancel() {
        }

        @Override // l0.l0
        public void onStop() {
            f0.this.Y(null);
            f0.this.W(null);
            f0.this.m0(true);
        }
    }

    /* loaded from: classes.dex */
    public static final class c implements r0.h {
        c() {
        }

        @Override // r0.h
        public boolean a(long j10) {
            l0.z L;
            if (f0.this.E()) {
                if (!(f0.this.O().h().length() == 0) && (L = f0.this.L()) != null && L.j() != null) {
                    f(f0.this.O(), j10, false, q.f34237a.l());
                    return true;
                }
            }
            return false;
        }

        @Override // r0.h
        public boolean b(long j10, q qVar) {
            l0.z L;
            if (f0.this.E()) {
                if (!(f0.this.O().h().length() == 0) && (L = f0.this.L()) != null && L.j() != null) {
                    androidx.compose.ui.focus.m F = f0.this.F();
                    if (F != null) {
                        F.f();
                    }
                    f0.this.f34166m = j10;
                    f0.this.f34171r = -1;
                    f0.w(f0.this, false, 1, null);
                    f(f0.this.O(), f0.this.f34166m, true, qVar);
                    return true;
                }
            }
            return false;
        }

        @Override // r0.h
        public boolean c(long j10, q qVar) {
            l0.z L;
            if (f0.this.E()) {
                if (!(f0.this.O().h().length() == 0) && (L = f0.this.L()) != null && L.j() != null) {
                    f(f0.this.O(), j10, false, qVar);
                    return true;
                }
            }
            return false;
        }

        @Override // r0.h
        public void d() {
        }

        @Override // r0.h
        public boolean e(long j10) {
            l0.z L = f0.this.L();
            if (L == null || L.j() == null || !f0.this.E()) {
                return false;
            }
            f0.this.f34171r = -1;
            f(f0.this.O(), j10, false, q.f34237a.l());
            return true;
        }

        public final void f(q0 q0Var, long j10, boolean z10, q qVar) {
            f0.this.c0(m0.h(f0.this.n0(q0Var, j10, z10, false, qVar, false)) ? l0.n.Cursor : l0.n.Selection);
        }
    }

    /* loaded from: classes.dex */
    static final class d extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final d f34180p = new d();

        d() {
            super(1);
        }

        public final void a(q0 q0Var) {
        }

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

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class e extends kotlin.jvm.internal.v implements dn.a {
        e() {
            super(0);
        }

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

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m404invoke() {
            f0.p(f0.this, false, 1, null);
            f0.this.R();
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class f extends kotlin.jvm.internal.v implements dn.a {
        f() {
            super(0);
        }

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

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m405invoke() {
            f0.this.s();
            f0.this.R();
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class g extends kotlin.jvm.internal.v implements dn.a {
        g() {
            super(0);
        }

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

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m406invoke() {
            f0.this.T();
            f0.this.R();
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class h extends kotlin.jvm.internal.v implements dn.a {
        h() {
            super(0);
        }

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

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m407invoke() {
            f0.this.U();
        }
    }

    /* loaded from: classes.dex */
    public static final class i implements l0.l0 {
        i() {
        }

        private final void e() {
            f0.this.Y(null);
            f0.this.W(null);
            f0.this.m0(true);
            f0.this.f34167n = null;
            boolean h10 = m0.h(f0.this.O().g());
            f0.this.c0(h10 ? l0.n.Cursor : l0.n.Selection);
            l0.z L = f0.this.L();
            if (L != null) {
                L.M(!h10 && g0.c(f0.this, true));
            }
            l0.z L2 = f0.this.L();
            if (L2 != null) {
                L2.L(!h10 && g0.c(f0.this, false));
            }
            l0.z L3 = f0.this.L();
            if (L3 == null) {
                return;
            }
            L3.J(h10 && g0.c(f0.this, true));
        }

        @Override // l0.l0
        public void a(long j10) {
        }

        @Override // l0.l0
        public void b(long j10) {
            l0.a1 j11;
            l0.a1 j12;
            if (f0.this.E() && f0.this.C() == null) {
                f0.this.Y(l0.m.SelectionEnd);
                f0.this.f34171r = -1;
                f0.this.R();
                l0.z L = f0.this.L();
                if ((L == null || (j12 = L.j()) == null || !j12.g(j10)) ? false : true) {
                    if (f0.this.O().h().length() == 0) {
                        return;
                    }
                    f0.this.v(false);
                    f0 f0Var = f0.this;
                    f0.this.f34167n = Integer.valueOf(m0.n(f0Var.n0(q0.d(f0Var.O(), null, m0.f33348b.a(), null, 5, null), j10, true, false, q.f34237a.n(), true)));
                } else {
                    l0.z L2 = f0.this.L();
                    if (L2 != null && (j11 = L2.j()) != null) {
                        f0 f0Var2 = f0.this;
                        int a10 = f0Var2.J().a(l0.a1.e(j11, j10, false, 2, null));
                        q0 q10 = f0Var2.q(f0Var2.O().e(), n0.b(a10, a10));
                        f0Var2.v(false);
                        z1.a H = f0Var2.H();
                        if (H != null) {
                            H.a(z1.b.f53144a.b());
                        }
                        f0Var2.K().invoke(q10);
                    }
                }
                f0.this.c0(l0.n.None);
                f0.this.f34166m = j10;
                f0 f0Var3 = f0.this;
                f0Var3.W(r1.g.d(f0Var3.f34166m));
                f0.this.f34168o = r1.g.f34318b.c();
            }
        }

        @Override // l0.l0
        public void c() {
        }

        @Override // l0.l0
        public void d(long j10) {
            l0.a1 j11;
            long n02;
            if (f0.this.E()) {
                if (f0.this.O().h().length() == 0) {
                    return;
                }
                f0 f0Var = f0.this;
                f0Var.f34168o = r1.g.r(f0Var.f34168o, j10);
                l0.z L = f0.this.L();
                if (L != null && (j11 = L.j()) != null) {
                    f0 f0Var2 = f0.this;
                    f0Var2.W(r1.g.d(r1.g.r(f0Var2.f34166m, f0Var2.f34168o)));
                    if (f0Var2.f34167n == null) {
                        r1.g A = f0Var2.A();
                        kotlin.jvm.internal.t.d(A);
                        if (!j11.g(A.v())) {
                            int a10 = f0Var2.J().a(l0.a1.e(j11, f0Var2.f34166m, false, 2, null));
                            w2.h0 J = f0Var2.J();
                            r1.g A2 = f0Var2.A();
                            kotlin.jvm.internal.t.d(A2);
                            q l10 = a10 == J.a(l0.a1.e(j11, A2.v(), false, 2, null)) ? q.f34237a.l() : q.f34237a.n();
                            q0 O = f0Var2.O();
                            r1.g A3 = f0Var2.A();
                            kotlin.jvm.internal.t.d(A3);
                            n02 = f0Var2.n0(O, A3.v(), false, false, l10, true);
                            m0.b(n02);
                        }
                    }
                    Integer num = f0Var2.f34167n;
                    int intValue = num != null ? num.intValue() : j11.d(f0Var2.f34166m, false);
                    r1.g A4 = f0Var2.A();
                    kotlin.jvm.internal.t.d(A4);
                    int d10 = j11.d(A4.v(), false);
                    if (f0Var2.f34167n == null && intValue == d10) {
                        return;
                    }
                    q0 O2 = f0Var2.O();
                    r1.g A5 = f0Var2.A();
                    kotlin.jvm.internal.t.d(A5);
                    n02 = f0Var2.n0(O2, A5.v(), false, false, q.f34237a.n(), true);
                    m0.b(n02);
                }
                f0.this.m0(false);
            }
        }

        @Override // l0.l0
        public void onCancel() {
            e();
        }

        @Override // l0.l0
        public void onStop() {
            e();
        }
    }

    public f0(l1 l1Var) {
        q1 d10;
        q1 d11;
        q1 d12;
        q1 d13;
        q1 d14;
        this.f34154a = l1Var;
        d10 = s3.d(new q0((String) null, 0L, (m0) null, 7, (kotlin.jvm.internal.k) null), null, 2, null);
        this.f34158e = d10;
        this.f34159f = b1.f40732a.c();
        Boolean bool = Boolean.TRUE;
        d11 = s3.d(bool, null, 2, null);
        this.f34164k = d11;
        d12 = s3.d(bool, null, 2, null);
        this.f34165l = d12;
        g.a aVar = r1.g.f34318b;
        this.f34166m = aVar.c();
        this.f34168o = aVar.c();
        d13 = s3.d(null, null, 2, null);
        this.f34169p = d13;
        d14 = s3.d(null, null, 2, null);
        this.f34170q = d14;
        this.f34171r = -1;
        this.f34172s = new q0((String) null, 0L, (m0) null, 7, (kotlin.jvm.internal.k) null);
        this.f34174u = new i();
        this.f34175v = new c();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void W(r1.g gVar) {
        this.f34170q.setValue(gVar);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void Y(l0.m mVar) {
        this.f34169p.setValue(mVar);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void c0(l0.n nVar) {
        l0.z zVar = this.f34157d;
        if (zVar != null) {
            if (zVar.d() == nVar) {
                zVar = null;
            }
            if (zVar != null) {
                zVar.B(nVar);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void m0(boolean z10) {
        l0.z zVar = this.f34157d;
        if (zVar != null) {
            zVar.K(z10);
        }
        if (z10) {
            l0();
        } else {
            R();
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final long n0(q0 q0Var, long j10, boolean z10, boolean z11, q qVar, boolean z12) {
        l0.a1 j11;
        z1.a aVar;
        int i10;
        l0.z zVar = this.f34157d;
        if (zVar == null || (j11 = zVar.j()) == null) {
            return m0.f33348b.a();
        }
        long b10 = n0.b(this.f34155b.b(m0.n(q0Var.g())), this.f34155b.b(m0.i(q0Var.g())));
        boolean z13 = false;
        int d10 = j11.d(j10, false);
        int n10 = (z11 || z10) ? d10 : m0.n(b10);
        int i11 = (!z11 || z10) ? d10 : m0.i(b10);
        w wVar = this.f34173t;
        int i12 = -1;
        if (!z10 && wVar != null && (i10 = this.f34171r) != -1) {
            i12 = i10;
        }
        w c10 = x.c(j11.f(), n10, i11, i12, b10, z10, z11);
        if (!c10.g(wVar)) {
            return q0Var.g();
        }
        this.f34173t = c10;
        this.f34171r = d10;
        k a10 = qVar.a(c10);
        long b11 = n0.b(this.f34155b.a(a10.e().c()), this.f34155b.a(a10.c().c()));
        if (m0.g(b11, q0Var.g())) {
            return q0Var.g();
        }
        boolean z14 = m0.m(b11) != m0.m(q0Var.g()) && m0.g(n0.b(m0.i(b11), m0.n(b11)), q0Var.g());
        boolean z15 = m0.h(b11) && m0.h(q0Var.g());
        if (z12) {
            if ((q0Var.h().length() > 0) && !z14 && !z15 && (aVar = this.f34162i) != null) {
                aVar.a(z1.b.f53144a.b());
            }
        }
        this.f34156c.invoke(q(q0Var.e(), b11));
        if (!z12) {
            m0(!m0.h(b11));
        }
        l0.z zVar2 = this.f34157d;
        if (zVar2 != null) {
            zVar2.D(z12);
        }
        l0.z zVar3 = this.f34157d;
        if (zVar3 != null) {
            zVar3.M(!m0.h(b11) && g0.c(this, true));
        }
        l0.z zVar4 = this.f34157d;
        if (zVar4 != null) {
            zVar4.L(!m0.h(b11) && g0.c(this, false));
        }
        l0.z zVar5 = this.f34157d;
        if (zVar5 != null) {
            if (m0.h(b11) && g0.c(this, true)) {
                z13 = true;
            }
            zVar5.J(z13);
        }
        return b11;
    }

    public static /* synthetic */ void p(f0 f0Var, boolean z10, int i10, Object obj) {
        if ((i10 & 1) != 0) {
            z10 = true;
        }
        f0Var.o(z10);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final q0 q(q2.d dVar, long j10) {
        return new q0(dVar, j10, (m0) null, 4, (kotlin.jvm.internal.k) null);
    }

    public static /* synthetic */ void u(f0 f0Var, r1.g gVar, int i10, Object obj) {
        if ((i10 & 1) != 0) {
            gVar = null;
        }
        f0Var.t(gVar);
    }

    public static /* synthetic */ void w(f0 f0Var, boolean z10, int i10, Object obj) {
        if ((i10 & 1) != 0) {
            z10 = true;
        }
        f0Var.v(z10);
    }

    private final r1.i z() {
        float f10;
        h2.s i10;
        q2.j0 f11;
        r1.i e10;
        h2.s i11;
        q2.j0 f12;
        r1.i e11;
        h2.s i12;
        h2.s i13;
        l0.z zVar = this.f34157d;
        if (zVar != null) {
            if (!(!zVar.z())) {
                zVar = null;
            }
            if (zVar != null) {
                int b10 = this.f34155b.b(m0.n(O().g()));
                int b11 = this.f34155b.b(m0.i(O().g()));
                l0.z zVar2 = this.f34157d;
                long c10 = (zVar2 == null || (i13 = zVar2.i()) == null) ? r1.g.f34318b.c() : i13.r0(G(true));
                l0.z zVar3 = this.f34157d;
                long c11 = (zVar3 == null || (i12 = zVar3.i()) == null) ? r1.g.f34318b.c() : i12.r0(G(false));
                l0.z zVar4 = this.f34157d;
                float f13 = BitmapDescriptorFactory.HUE_RED;
                if (zVar4 == null || (i11 = zVar4.i()) == null) {
                    f10 = 0.0f;
                } else {
                    l0.a1 j10 = zVar.j();
                    f10 = r1.g.n(i11.r0(r1.h.a(BitmapDescriptorFactory.HUE_RED, (j10 == null || (f12 = j10.f()) == null || (e11 = f12.e(b10)) == null) ? 0.0f : e11.l())));
                }
                l0.z zVar5 = this.f34157d;
                if (zVar5 != null && (i10 = zVar5.i()) != null) {
                    l0.a1 j11 = zVar.j();
                    f13 = r1.g.n(i10.r0(r1.h.a(BitmapDescriptorFactory.HUE_RED, (j11 == null || (f11 = j11.f()) == null || (e10 = f11.e(b11)) == null) ? 0.0f : e10.l())));
                }
                return new r1.i(Math.min(r1.g.m(c10), r1.g.m(c11)), Math.min(f10, f13), Math.max(r1.g.m(c10), r1.g.m(c11)), Math.max(r1.g.n(c10), r1.g.n(c11)) + (c3.h.t(25) * zVar.v().a().getDensity()));
            }
        }
        return r1.i.f34323e.a();
    }

    public final r1.g A() {
        return (r1.g) this.f34170q.getValue();
    }

    public final long B(c3.d dVar) {
        int k10;
        int b10 = this.f34155b.b(m0.n(O().g()));
        l0.z zVar = this.f34157d;
        l0.a1 j10 = zVar != null ? zVar.j() : null;
        kotlin.jvm.internal.t.d(j10);
        q2.j0 f10 = j10.f();
        k10 = jn.o.k(b10, 0, f10.l().j().length());
        r1.i e10 = f10.e(k10);
        return r1.h.a(e10.i() + (dVar.L0(l0.m0.b()) / 2), e10.e());
    }

    public final l0.m C() {
        return (l0.m) this.f34169p.getValue();
    }

    public final boolean D() {
        return ((Boolean) this.f34164k.getValue()).booleanValue();
    }

    public final boolean E() {
        return ((Boolean) this.f34165l.getValue()).booleanValue();
    }

    public final androidx.compose.ui.focus.m F() {
        return this.f34163j;
    }

    public final long G(boolean z10) {
        l0.a1 j10;
        q2.j0 f10;
        l0.z zVar = this.f34157d;
        if (zVar == null || (j10 = zVar.j()) == null || (f10 = j10.f()) == null) {
            return r1.g.f34318b.b();
        }
        q2.d N = N();
        if (N == null) {
            return r1.g.f34318b.b();
        }
        if (!kotlin.jvm.internal.t.b(N.j(), f10.l().j().j())) {
            return r1.g.f34318b.b();
        }
        long g10 = O().g();
        return l0.b(f10, this.f34155b.b(z10 ? m0.n(g10) : m0.i(g10)), z10, m0.m(O().g()));
    }

    public final z1.a H() {
        return this.f34162i;
    }

    public final r0.h I() {
        return this.f34175v;
    }

    public final w2.h0 J() {
        return this.f34155b;
    }

    public final dn.l K() {
        return this.f34156c;
    }

    public final l0.z L() {
        return this.f34157d;
    }

    public final l0.l0 M() {
        return this.f34174u;
    }

    public final q2.d N() {
        l0.j0 v10;
        l0.z zVar = this.f34157d;
        if (zVar == null || (v10 = zVar.v()) == null) {
            return null;
        }
        return v10.k();
    }

    public final q0 O() {
        return (q0) this.f34158e.getValue();
    }

    public final b1 P() {
        return this.f34159f;
    }

    public final l0.l0 Q(boolean z10) {
        return new b(z10);
    }

    public final void R() {
        q2 q2Var;
        q2 q2Var2 = this.f34161h;
        if ((q2Var2 != null ? q2Var2.getStatus() : null) != s2.Shown || (q2Var = this.f34161h) == null) {
            return;
        }
        q2Var.b();
    }

    public final boolean S() {
        return !kotlin.jvm.internal.t.b(this.f34172s.h(), O().h());
    }

    public final void T() {
        q2.d a10;
        a1 a1Var = this.f34160g;
        if (a1Var == null || (a10 = a1Var.a()) == null) {
            return;
        }
        q2.d p10 = r0.c(O(), O().h().length()).p(a10).p(r0.b(O(), O().h().length()));
        int l10 = m0.l(O().g()) + a10.length();
        this.f34156c.invoke(q(p10, n0.b(l10, l10)));
        c0(l0.n.None);
        l1 l1Var = this.f34154a;
        if (l1Var != null) {
            l1Var.a();
        }
    }

    public final void U() {
        q0 q10 = q(O().e(), n0.b(0, O().h().length()));
        this.f34156c.invoke(q10);
        this.f34172s = q0.d(this.f34172s, null, q10.g(), null, 5, null);
        v(true);
    }

    public final void V(a1 a1Var) {
        this.f34160g = a1Var;
    }

    public final void X(long j10) {
        l0.z zVar = this.f34157d;
        if (zVar != null) {
            zVar.A(j10);
        }
        l0.z zVar2 = this.f34157d;
        if (zVar2 != null) {
            zVar2.I(m0.f33348b.a());
        }
        if (m0.h(j10)) {
            return;
        }
        x();
    }

    public final void Z(boolean z10) {
        this.f34164k.setValue(Boolean.valueOf(z10));
    }

    public final void a0(boolean z10) {
        this.f34165l.setValue(Boolean.valueOf(z10));
    }

    public final void b0(androidx.compose.ui.focus.m mVar) {
        this.f34163j = mVar;
    }

    public final void d0(z1.a aVar) {
        this.f34162i = aVar;
    }

    public final void e0(w2.h0 h0Var) {
        this.f34155b = h0Var;
    }

    public final void f0(dn.l lVar) {
        this.f34156c = lVar;
    }

    public final void g0(long j10) {
        l0.z zVar = this.f34157d;
        if (zVar != null) {
            zVar.I(j10);
        }
        l0.z zVar2 = this.f34157d;
        if (zVar2 != null) {
            zVar2.A(m0.f33348b.a());
        }
        if (m0.h(j10)) {
            return;
        }
        x();
    }

    public final void h0(l0.z zVar) {
        this.f34157d = zVar;
    }

    public final void i0(q2 q2Var) {
        this.f34161h = q2Var;
    }

    public final void j0(q0 q0Var) {
        this.f34158e.setValue(q0Var);
    }

    public final void k0(b1 b1Var) {
        this.f34159f = b1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:29:0x008a  */
    /* JADX WARN: Removed duplicated region for block: B:32:0x0094  */
    /* JADX WARN: Removed duplicated region for block: B:35:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void l0() {
        g gVar;
        q2 q2Var;
        if (!E()) {
            return;
        }
        l0.z zVar = this.f34157d;
        if ((zVar == null || zVar.y()) ? false : true) {
            return;
        }
        boolean z10 = this.f34159f instanceof w2.j0;
        e eVar = (m0.h(O().g()) || z10) ? null : new e();
        f fVar = (m0.h(O().g()) || !D() || z10) ? null : new f();
        if (D()) {
            a1 a1Var = this.f34160g;
            if (a1Var != null && a1Var.b()) {
                gVar = new g();
                h hVar = m0.j(O().g()) != O().h().length() ? new h() : null;
                q2Var = this.f34161h;
                if (q2Var == null) {
                    q2Var.a(z(), eVar, gVar, fVar, hVar);
                    return;
                }
                return;
            }
        }
        gVar = null;
        h hVar2 = m0.j(O().g()) != O().h().length() ? new h() : null;
        q2Var = this.f34161h;
        if (q2Var == null) {
        }
    }

    public final void n() {
        l0.z zVar = this.f34157d;
        if (zVar != null) {
            zVar.A(m0.f33348b.a());
        }
        l0.z zVar2 = this.f34157d;
        if (zVar2 == null) {
            return;
        }
        zVar2.I(m0.f33348b.a());
    }

    public final void o(boolean z10) {
        if (m0.h(O().g())) {
            return;
        }
        a1 a1Var = this.f34160g;
        if (a1Var != null) {
            a1Var.c(r0.a(O()));
        }
        if (z10) {
            int k10 = m0.k(O().g());
            this.f34156c.invoke(q(O().e(), n0.b(k10, k10)));
            c0(l0.n.None);
        }
    }

    public final l0.l0 r() {
        return new a();
    }

    public final void s() {
        if (m0.h(O().g())) {
            return;
        }
        a1 a1Var = this.f34160g;
        if (a1Var != null) {
            a1Var.c(r0.a(O()));
        }
        q2.d p10 = r0.c(O(), O().h().length()).p(r0.b(O(), O().h().length()));
        int l10 = m0.l(O().g());
        this.f34156c.invoke(q(p10, n0.b(l10, l10)));
        c0(l0.n.None);
        l1 l1Var = this.f34154a;
        if (l1Var != null) {
            l1Var.a();
        }
    }

    public final void t(r1.g gVar) {
        l0.n nVar;
        if (!m0.h(O().g())) {
            l0.z zVar = this.f34157d;
            l0.a1 j10 = zVar != null ? zVar.j() : null;
            this.f34156c.invoke(q0.d(O(), null, n0.a((gVar == null || j10 == null) ? m0.k(O().g()) : this.f34155b.a(l0.a1.e(j10, gVar.v(), false, 2, null))), null, 5, null));
        }
        if (gVar != null) {
            if (O().h().length() > 0) {
                nVar = l0.n.Cursor;
                c0(nVar);
                m0(false);
            }
        }
        nVar = l0.n.None;
        c0(nVar);
        m0(false);
    }

    public final void v(boolean z10) {
        androidx.compose.ui.focus.m mVar;
        l0.z zVar = this.f34157d;
        boolean z11 = false;
        if (zVar != null && !zVar.e()) {
            z11 = true;
        }
        if (z11 && (mVar = this.f34163j) != null) {
            mVar.f();
        }
        this.f34172s = O();
        m0(z10);
        c0(l0.n.Selection);
    }

    public final void x() {
        m0(false);
        c0(l0.n.None);
    }

    public final a1 y() {
        return this.f34160g;
    }
}
