package V;

import B.h1;
import C0.C0109j;
import I0.AbstractC0303l;
import J0.C0363i;
import J0.InterfaceC0380q0;
import K.AbstractC0454g0;
import K.C0464l0;
import K.C0487x0;
import K.S0;
import K.Y0;
import K.Z0;
import T0.C0590a;
import T0.C0596g;
import T0.C0604o;
import V4.B0;
import a.AbstractC0872a;
import android.content.ClipDescription;
import androidx.compose.runtime.MutableState;
import androidx.compose.runtime.SnapshotStateKt__SnapshotStateKt;
import androidx.compose.runtime.snapshots.Snapshot;
import java.util.ArrayList;
import m3.AbstractC2467b;
import o0.C2631b;
import w4.C3137A;
import x0.InterfaceC3208a;
import x4.AbstractC3252r;

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

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public final C0109j f7079A;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Y0 f7081a;

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public J4.a f7087g;

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public V4.C f7089i;

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

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public InterfaceC3208a f7091k;
    public n0.x l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final MutableState f7092m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final MutableState f7093n;

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

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public T0.N f7095p;

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

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final MutableState f7097r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final MutableState f7098s;

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

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public Z0.y f7100u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public C0109j f7101v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public T0.N f7102w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public final MutableState f7103x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public final T.p f7104y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public final g0 f7105z;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Z0.r f7082b = Z0.f3777a;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public J4.c f7083c = new h1(12);

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final MutableState f7085e = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(new Z0.y((String) null, 0, 7), null, 2, null);

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public Z0.H f7086f = Z0.G.f9073a;

    public i0(Y0 y02) {
        this.f7081a = y02;
        Boolean bool = Boolean.TRUE;
        this.f7092m = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(bool, null, 2, null);
        this.f7093n = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(bool, null, 2, null);
        this.f7094o = 0L;
        this.f7096q = 0L;
        this.f7097r = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(null, null, 2, null);
        this.f7098s = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(null, null, 2, null);
        this.f7099t = -1;
        this.f7100u = new Z0.y((String) null, 0L, 7);
        this.f7103x = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(Boolean.FALSE, null, 2, null);
        T.p pVar = new T.p(18, false);
        pVar.f6346c = Q.m.f5719a;
        this.f7104y = pVar;
        this.f7105z = new g0(this);
        this.f7079A = new C0109j(this);
    }

    public static final w4.k a(i0 i0Var) {
        String str;
        T0.N n6;
        C0596g c0596gO = i0Var.o();
        if (c0596gO == null || (str = c0596gO.f6510b) == null || (n6 = i0Var.f7102w) == null) {
            return null;
        }
        Z0.r rVar = i0Var.f7082b;
        long j4 = n6.f6483a;
        return new w4.k(str, new T0.N(android.support.v4.media.session.b.g(rVar.b((int) (j4 >> 32)), i0Var.f7082b.b((int) (4294967295L & j4)))));
    }

    public static final void b(i0 i0Var, T0.N n6) {
        C0596g c0596gO;
        String str;
        V4.C c6;
        if (n6 == null) {
            i0Var.getClass();
            return;
        }
        C0626u c0626u = i0Var.f7090j;
        if (c0626u == null || (c0596gO = i0Var.o()) == null || (str = c0596gO.f6510b) == null) {
            return;
        }
        Z0.r rVar = i0Var.f7082b;
        long j4 = n6.f6483a;
        long jG = android.support.v4.media.session.b.g(rVar.b((int) (j4 >> 32)), rVar.b((int) (j4 & 4294967295L)));
        if (str.length() <= 0 || T0.N.c(jG) || (c6 = i0Var.f7089i) == null) {
            return;
        }
        V4.E.y(c6, null, null, new e0(c0626u, str, jG, n6, i0Var, rVar, null), 3);
    }

    public static final void c(i0 i0Var, C2631b c2631b) {
        i0Var.f7098s.setValue(c2631b);
    }

    public static final void d(i0 i0Var, K.X x6) {
        i0Var.f7097r.setValue(x6);
    }

    /* JADX WARN: Removed duplicated region for block: B:108:0x01eb  */
    /* JADX WARN: Removed duplicated region for block: B:80:0x0157  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final long e(i0 i0Var, Z0.y yVar, long j4, boolean z6, boolean z7, G0.K k6, boolean z8) {
        S0 s0D;
        char c6;
        long j6;
        int i6;
        char c7;
        long j7;
        A a6;
        int i7;
        A a7;
        boolean z9;
        InterfaceC3208a interfaceC3208a;
        C0631z c0631zI;
        C0631z c0631z;
        C0464l0 c0464l0 = i0Var.f7084d;
        if (c0464l0 == null || (s0D = c0464l0.d()) == null) {
            return T0.N.f6481b;
        }
        Z0.r rVar = i0Var.f7082b;
        long j8 = yVar.f9137b;
        int i8 = T0.N.f6482c;
        int iB = rVar.b((int) (j8 >> 32));
        Z0.r rVar2 = i0Var.f7082b;
        long j9 = yVar.f9137b;
        long jG = android.support.v4.media.session.b.g(iB, rVar2.b((int) (j9 & 4294967295L)));
        int iB2 = s0D.b(j4, false);
        int i9 = (z7 || z6) ? iB2 : (int) (jG >> 32);
        if (!z7 || z6) {
            c6 = ' ';
            j6 = j9;
            i6 = iB2;
        } else {
            c6 = ' ';
            j6 = j9;
            i6 = (int) (jG & 4294967295L);
        }
        C0109j c0109j = i0Var.f7101v;
        int i10 = -1;
        if (z6 || c0109j == null) {
            c7 = c6;
        } else {
            c7 = c6;
            int i11 = i0Var.f7099t;
            if (i11 != -1) {
                i10 = i11;
            }
        }
        T0.L l = s0D.f3742a;
        if (z6) {
            i7 = iB2;
            j7 = 4294967295L;
            a6 = null;
        } else {
            j7 = 4294967295L;
            int i12 = (int) (jG >> c7);
            int i13 = (int) (jG & 4294967295L);
            i7 = iB2;
            a6 = new A(new C0631z(AbstractC0872a.R(l, i12), i12, 1L), new C0631z(AbstractC0872a.R(l, i13), i13, 1L), T0.N.g(jG));
        }
        C0109j c0109j2 = new C0109j(z7, a6, new C0629x(i9, i6, i10, l));
        if (a6 != null && c0109j != null && z7 == c0109j.f606b) {
            C0629x c0629x = (C0629x) c0109j.f608d;
            if (i9 == c0629x.f7177b && i6 == c0629x.f7178c) {
                return j6;
            }
        }
        i0Var.f7101v = c0109j2;
        i0Var.f7099t = i7;
        switch (k6.f1886a) {
            case 12:
                C0629x c0629x2 = (C0629x) c0109j2.f608d;
                a7 = new A(c0629x2.b(c0629x2.f7177b), c0629x2.b(c0629x2.f7178c), c0109j2.d() == EnumC0616j.f7106a);
                break;
            case 13:
                a7 = e4.C.g(c0109j2, B.f6936c);
                break;
            case 14:
                a7 = e4.C.g(c0109j2, B.f6935b);
                break;
            default:
                a7 = (A) c0109j2.f607c;
                if (a7 == null) {
                    a7 = e4.C.g(c0109j2, B.f6936c);
                    break;
                } else {
                    C0629x c0629x3 = (C0629x) c0109j2.f608d;
                    boolean z10 = c0109j2.f606b;
                    C0631z c0631z2 = a7.f6933b;
                    C0631z c0631z3 = a7.f6932a;
                    if (z10) {
                        c0631zI = e4.C.i(c0109j2, c0629x3, c0631z3);
                        c0631z = c0631z2;
                        c0631z2 = c0631z3;
                        c0631z3 = c0631zI;
                    } else {
                        c0631zI = e4.C.i(c0109j2, c0629x3, c0631z2);
                        c0631z = c0631zI;
                    }
                    if (!kotlin.jvm.internal.o.c(c0631zI, c0631z2)) {
                        A a8 = new A(c0631z3, c0631z, c0109j2.d() == EnumC0616j.f7106a || (c0109j2.d() == EnumC0616j.f7108c && c0631z3.f7184b > c0631z.f7184b));
                        C0631z c0631z4 = a8.f6933b;
                        C0631z c0631z5 = a8.f6932a;
                        C0629x c0629x4 = (C0629x) c0109j2.f608d;
                        if (c0631z5.f7185c != c0631z4.f7185c) {
                            boolean z11 = a8.f6934c;
                            if ((z11 ? c0631z5 : c0631z4).f7184b == 0) {
                                if (((T0.L) c0629x4.f7180e).f6471a.f6461a.f6510b.length() != (z11 ? c0631z4 : c0631z5).f7184b) {
                                }
                            }
                            a7 = a8;
                            break;
                        } else if (c0631z5.f7184b == c0631z4.f7184b) {
                            String str = ((T0.L) c0629x4.f7180e).f6471a.f6461a.f6510b;
                            A a9 = (A) c0109j2.f607c;
                            if (a9 == null || str.length() == 0) {
                                a7 = a8;
                            } else {
                                String str2 = ((T0.L) c0629x4.f7180e).f6471a.f6461a.f6510b;
                                int length = str2.length();
                                boolean z12 = c0109j2.f606b;
                                int i14 = c0629x4.f7177b;
                                if (i14 == 0) {
                                    int iJ = AbstractC0454g0.j(0, str2);
                                    a7 = !z12 ? A.a(a8, null, e4.C.q(c0631z4, c0629x4, iJ), false, 1) : A.a(a8, e4.C.q(c0631z5, c0629x4, iJ), null, true, 2);
                                } else if (i14 != length) {
                                    boolean z13 = a9.f6934c;
                                    int iM = z12 ^ z13 ? AbstractC0454g0.m(i14, str2) : AbstractC0454g0.j(i14, str2);
                                    a7 = !z12 ? A.a(a8, null, e4.C.q(c0631z4, c0629x4, iM), z13, 1) : A.a(a8, e4.C.q(c0631z5, c0629x4, iM), null, z13, 2);
                                } else {
                                    int iM2 = AbstractC0454g0.m(length, str2);
                                    a7 = !z12 ? A.a(a8, null, e4.C.q(c0631z4, c0629x4, iM2), true, 1) : A.a(a8, e4.C.q(c0631z5, c0629x4, iM2), null, false, 2);
                                }
                            }
                            break;
                        }
                    }
                }
                break;
        }
        long jG2 = android.support.v4.media.session.b.g(i0Var.f7082b.a(a7.f6932a.f7184b), i0Var.f7082b.a(a7.f6933b.f7184b));
        long j10 = j6;
        if (T0.N.b(jG2, j10)) {
            return j10;
        }
        boolean z14 = T0.N.g(jG2) != T0.N.g(j10) && T0.N.b(android.support.v4.media.session.b.g((int) (jG2 & j7), (int) (jG2 >> c7)), j10);
        boolean z15 = T0.N.c(jG2) && T0.N.c(j10);
        C0596g c0596g = yVar.f9136a;
        if (z8 && c0596g.f6510b.length() > 0 && !z14 && !z15 && (interfaceC3208a = i0Var.f7091k) != null) {
            interfaceC3208a.a(9);
        }
        i0Var.f7083c.invoke(g(c0596g, jG2));
        i0Var.f7102w = new T0.N(jG2);
        if (!z8) {
            i0Var.v(!T0.N.c(jG2));
        }
        C0464l0 c0464l02 = i0Var.f7084d;
        if (c0464l02 != null) {
            c0464l02.f3904q.setValue(Boolean.valueOf(z8));
        }
        C0464l0 c0464l03 = i0Var.f7084d;
        if (c0464l03 != null) {
            c0464l03.f3900m.setValue(Boolean.valueOf(!T0.N.c(jG2) && L4.a.V(i0Var, true)));
        }
        C0464l0 c0464l04 = i0Var.f7084d;
        if (c0464l04 != null) {
            z9 = false;
            c0464l04.f3901n.setValue(Boolean.valueOf(!T0.N.c(jG2) && L4.a.V(i0Var, false)));
        } else {
            z9 = false;
        }
        C0464l0 c0464l05 = i0Var.f7084d;
        if (c0464l05 != null) {
            c0464l05.f3902o.setValue(Boolean.valueOf((T0.N.c(jG2) && L4.a.V(i0Var, true)) ? true : z9));
        }
        return jG2;
    }

    public static Z0.y g(C0596g c0596g, long j4) {
        return new Z0.y(c0596g, j4, (T0.N) null);
    }

    public final B0 f(boolean z6) {
        V4.C c6 = this.f7089i;
        if (c6 != null) {
            return V4.E.y(c6, null, V4.D.f8228d, new a0(this, z6, null), 1);
        }
        return null;
    }

    public final void h() {
        V4.C c6 = this.f7089i;
        if (c6 != null) {
            V4.E.y(c6, null, V4.D.f8228d, new c0(this, null), 1);
        }
    }

    public final void i(C2631b c2631b) {
        if (!T0.N.c(p().f9137b)) {
            C0464l0 c0464l0 = this.f7084d;
            S0 s0D = c0464l0 != null ? c0464l0.d() : null;
            int iE = (c2631b == null || s0D == null) ? T0.N.e(p().f9137b) : this.f7082b.a(s0D.b(c2631b.f21785a, true));
            Z0.y yVarA = Z0.y.a(p(), null, android.support.v4.media.session.b.g(iE, iE), 5);
            this.f7083c.invoke(yVarA);
            this.f7102w = new T0.N(yVarA.f9137b);
        }
        s((c2631b == null || p().f9136a.f6510b.length() <= 0) ? K.Y.f3765a : K.Y.f3767c);
        v(false);
    }

    public final void j(boolean z6) {
        n0.x xVar;
        C0464l0 c0464l0 = this.f7084d;
        if (c0464l0 != null && !c0464l0.b() && (xVar = this.l) != null) {
            n0.x.a(xVar);
        }
        this.f7100u = p();
        v(z6);
        s(K.Y.f3766b);
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final C2631b k() {
        return (C2631b) this.f7098s.getValue();
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final boolean l() {
        return ((Boolean) this.f7092m.getValue()).booleanValue();
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final boolean m() {
        return ((Boolean) this.f7093n.getValue()).booleanValue();
    }

    public final long n(boolean z6) {
        S0 s0D;
        long j4;
        C0464l0 c0464l0 = this.f7084d;
        if (c0464l0 == null || (s0D = c0464l0.d()) == null) {
            return 9205357640488583168L;
        }
        T0.L l = s0D.f3742a;
        C0596g c0596gO = o();
        if (c0596gO == null) {
            return 9205357640488583168L;
        }
        if (!kotlin.jvm.internal.o.c(c0596gO.f6510b, l.f6471a.f6461a.f6510b)) {
            return 9205357640488583168L;
        }
        Z0.y yVarP = p();
        if (z6) {
            long j6 = yVarP.f9137b;
            int i6 = T0.N.f6482c;
            j4 = j6 >> 32;
        } else {
            long j7 = yVarP.f9137b;
            int i7 = T0.N.f6482c;
            j4 = j7 & 4294967295L;
        }
        int iB = this.f7082b.b((int) j4);
        boolean zG = T0.N.g(p().f9137b);
        C0604o c0604o = l.f6472b;
        int iD = c0604o.d(iB);
        if (iD >= c0604o.f6537f) {
            return 9205357640488583168L;
        }
        boolean z7 = l.a(((!z6 || zG) && (z6 || !zG)) ? Math.max(iB + (-1), 0) : iB) == l.g(iB);
        c0604o.l(iB);
        int length = ((C0596g) c0604o.f6532a.f6543b).f6510b.length();
        ArrayList arrayList = c0604o.f6539h;
        T0.r rVar = (T0.r) arrayList.get(iB == length ? AbstractC3252r.A(arrayList) : L4.a.F(iB, arrayList));
        C0590a c0590a = rVar.f6547a;
        int iD2 = rVar.d(iB);
        U0.k kVar = c0590a.f6493d;
        float fH = z7 ? kVar.h(iD2, false) : kVar.i(iD2, false);
        long j8 = l.f6473c;
        return (((long) Float.floatToRawIntBits(L4.a.u(c0604o.b(iD), 0.0f, (int) (j8 & 4294967295L)))) & 4294967295L) | (((long) Float.floatToRawIntBits(L4.a.u(fH, 0.0f, (int) (j8 >> 32)))) << 32);
    }

    public final C0596g o() {
        C0487x0 c0487x0;
        C0464l0 c0464l0 = this.f7084d;
        if (c0464l0 == null || (c0487x0 = c0464l0.f3889a) == null) {
            return null;
        }
        return c0487x0.f4018a;
    }

    public final Z0.y p() {
        return (Z0.y) this.f7085e.getValue();
    }

    public final void q() {
        B0 b02;
        Q.l lVar = (Q.l) this.f7104y.f6345b;
        if (lVar == null || (b02 = lVar.f5717j) == null) {
            return;
        }
        b02.cancel(null);
        lVar.f5717j = null;
    }

    public final void r() {
        V4.C c6 = this.f7089i;
        if (c6 != null) {
            V4.E.y(c6, null, V4.D.f8228d, new f0(this, null), 1);
        }
    }

    public final void s(K.Y y6) {
        C0464l0 c0464l0 = this.f7084d;
        if (c0464l0 != null) {
            if (c0464l0.a() == y6) {
                c0464l0 = null;
            }
            if (c0464l0 != null) {
                c0464l0.f3899k.setValue(y6);
            }
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:12:0x0029, code lost:
    
        if (((java.lang.Boolean) r5.f3904q.getValue()).booleanValue() == false) goto L34;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void t() {
        R.f fVar;
        Snapshot.Companion companion = Snapshot.Companion;
        Snapshot currentThreadSnapshot = companion.getCurrentThreadSnapshot();
        J4.c readObserver = currentThreadSnapshot != null ? currentThreadSnapshot.getReadObserver() : null;
        Snapshot snapshotMakeCurrentNonObservable = companion.makeCurrentNonObservable(currentThreadSnapshot);
        try {
            if (m()) {
                C0464l0 c0464l0 = this.f7084d;
                if (c0464l0 != null) {
                }
                companion.restoreNonObservable(currentThreadSnapshot, snapshotMakeCurrentNonObservable, readObserver);
                T.p pVar = this.f7104y;
                if (((Q.m) pVar.f6346c) == Q.m.f5719a) {
                    A.b.c("ToolbarRequester is not initialized.");
                }
                Q.l lVar = (Q.l) pVar.f6345b;
                if (lVar == null || !lVar.isAttached()) {
                    return;
                }
                B0 b02 = lVar.f5717j;
                if ((b02 == null || !b02.isActive()) && (fVar = (R.f) AbstractC0303l.h(lVar, R.g.f6001b)) != null) {
                    lVar.f5717j = V4.E.y(lVar.getCoroutineScope(), null, V4.D.f8228d, new Q.k(lVar, fVar, null), 1);
                }
            }
        } finally {
            companion.restoreNonObservable(currentThreadSnapshot, snapshotMakeCurrentNonObservable, readObserver);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object u(C4.c cVar) {
        h0 h0Var;
        i0 i0Var;
        if (cVar instanceof h0) {
            h0Var = (h0) cVar;
            int i6 = h0Var.f7078d;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                h0Var.f7078d = i6 - Integer.MIN_VALUE;
            } else {
                h0Var = new h0(this, cVar);
            }
        }
        Object objValueOf = h0Var.f7076b;
        Object obj = B4.a.f492a;
        int i7 = h0Var.f7078d;
        if (i7 == 0) {
            AbstractC2467b.l(objValueOf);
            InterfaceC0380q0 interfaceC0380q0 = this.f7088h;
            if (interfaceC0380q0 != null) {
                h0Var.f7075a = this;
                h0Var.f7078d = 1;
                ClipDescription primaryClipDescription = ((C0363i) interfaceC0380q0).f3026a.f3027a.getPrimaryClipDescription();
                objValueOf = Boolean.valueOf(primaryClipDescription != null && primaryClipDescription.hasMimeType("text/*"));
                if (objValueOf == obj) {
                    return obj;
                }
                i0Var = this;
            }
            return C3137A.f25453a;
        }
        if (i7 != 1) {
            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
        i0Var = h0Var.f7075a;
        AbstractC2467b.l(objValueOf);
        Boolean bool = (Boolean) objValueOf;
        bool.getClass();
        i0Var.f7103x.setValue(bool);
        return C3137A.f25453a;
    }

    public final void v(boolean z6) {
        C0464l0 c0464l0 = this.f7084d;
        if (c0464l0 != null) {
            c0464l0.l.setValue(Boolean.valueOf(z6));
        }
        if (z6) {
            t();
        } else {
            q();
        }
    }
}
