package H;

import C0.C0104e;
import I0.AbstractC0300j0;
import V4.C;
import V4.C0772m;
import a.AbstractC0872a;
import androidx.compose.runtime.collection.MutableVector;
import c0.C1217r;
import java.util.concurrent.CancellationException;
import m3.AbstractC2467b;
import o0.C2632c;
import w4.C3137A;
import x.C3144a;
import x.C3162g;
import x.C3171j;

/* JADX INFO: loaded from: classes.dex */
public final class g extends C4.j implements J4.e {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ j f2079b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ AbstractC0300j0 f2080c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ C0104e f2081d;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public g(j jVar, AbstractC0300j0 abstractC0300j0, C0104e c0104e, A4.d dVar) {
        super(2, dVar);
        this.f2079b = jVar;
        this.f2080c = abstractC0300j0;
        this.f2081d = c0104e;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        return new g(this.f2079b, this.f2080c, this.f2081d, dVar);
    }

    @Override // J4.e
    public final Object invoke(Object obj, Object obj2) {
        return ((g) create((C) obj, (A4.d) obj2)).invokeSuspend(C3137A.f25453a);
    }

    /* JADX WARN: Removed duplicated region for block: B:36:0x00ce  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x00dc  */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        Object objR;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f2078a;
        C3137A c3137a = C3137A.f25453a;
        if (i6 != 0) {
            if (i6 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            AbstractC2467b.l(obj);
            return c3137a;
        }
        AbstractC2467b.l(obj);
        j jVar = this.f2079b;
        C3171j c3171j = jVar.f2090a;
        f fVar = new f(jVar, this.f2080c, this.f2081d);
        this.f2078a = 1;
        c3171j.getClass();
        C2632c c2632c = (C2632c) fVar.invoke();
        if (c2632c == null || C3171j.u0(c3171j, c2632c, 0L, 0L, 3)) {
            objR = c3137a;
        } else {
            C0772m c0772m = new C0772m(1, AbstractC0872a.V(this));
            c0772m.s();
            C3162g c3162g = new C3162g(fVar, c0772m);
            C3144a c3144a = c3171j.f25839f;
            c3144a.getClass();
            C2632c c2632c2 = (C2632c) fVar.invoke();
            if (c2632c2 == null) {
                c0772m.resumeWith(c3137a);
            } else {
                c0772m.u(new C1217r(27, c3144a, c3162g));
                MutableVector mutableVector = c3144a.f25742a;
                P4.g gVarL0 = L4.a.l0(0, mutableVector.getSize());
                int i7 = gVarL0.f5676a;
                int i8 = gVarL0.f5677b;
                if (i7 <= i8) {
                    while (true) {
                        C2632c c2632c3 = (C2632c) ((C3162g) mutableVector.content[i8]).f25784a.invoke();
                        if (c2632c3 != null) {
                            C2632c c2632cE = c2632c2.e(c2632c3);
                            if (c2632cE.equals(c2632c2)) {
                                mutableVector.add(i8 + 1, c3162g);
                                break;
                            }
                            if (!c2632cE.equals(c2632c3)) {
                                CancellationException cancellationException = new CancellationException("bringIntoView call interrupted by a newer, non-overlapping call");
                                int size = mutableVector.getSize() - 1;
                                if (size <= i8) {
                                    while (true) {
                                        ((C3162g) mutableVector.content[i8]).f25785b.i(cancellationException);
                                        if (size == i8) {
                                            break;
                                        }
                                        size++;
                                    }
                                }
                            }
                        }
                        if (i8 == i7) {
                            break;
                        }
                        i8--;
                    }
                    mutableVector.add(0, c3162g);
                    if (!c3171j.l) {
                        c3171j.v0(0L);
                    }
                } else {
                    mutableVector.add(0, c3162g);
                    if (!c3171j.l) {
                    }
                }
            }
            objR = c0772m.r();
            if (objR != B4.a.f492a) {
            }
        }
        return objR == aVar ? aVar : c3137a;
    }
}
