package androidx.lifecycle;

import V4.C0772m;
import V4.InterfaceC0765i0;
import a.AbstractC0872a;
import b2.C1191c;
import m3.AbstractC2467b;
import w4.C3137A;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public kotlin.jvm.internal.C f12120a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public kotlin.jvm.internal.C f12121b;

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ r f12124e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final /* synthetic */ EnumC1108q f12125f;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final /* synthetic */ V4.C f12126j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final /* synthetic */ C1191c f12127k;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public O(r rVar, EnumC1108q enumC1108q, V4.C c6, C1191c c1191c, A4.d dVar) {
        super(2, dVar);
        this.f12124e = rVar;
        this.f12125f = enumC1108q;
        this.f12126j = c6;
        this.f12127k = c1191c;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        return new O(this.f12124e, this.f12125f, this.f12126j, this.f12127k, dVar);
    }

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

    /* JADX WARN: Removed duplicated region for block: B:29:0x008f A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:30:0x0090  */
    /* JADX WARN: Removed duplicated region for block: B:33:0x0097  */
    /* JADX WARN: Removed duplicated region for block: B:36:0x00a0  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x00ad  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x00b6  */
    /* JADX WARN: Removed duplicated region for block: B:51:? A[SYNTHETIC] */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws Throwable {
        kotlin.jvm.internal.C c6;
        Throwable th;
        kotlin.jvm.internal.C c7;
        EnumC1107p enumC1107p;
        EnumC1107p enumC1107p2;
        InterfaceC0765i0 interfaceC0765i0;
        InterfaceC1111u interfaceC1111u;
        InterfaceC0765i0 interfaceC0765i02;
        InterfaceC1111u interfaceC1111u2;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f12123d;
        C3137A c3137a = C3137A.f25453a;
        r rVar = this.f12124e;
        if (i6 == 0) {
            AbstractC2467b.l(obj);
            if (rVar.getCurrentState() != EnumC1108q.f12180a) {
                kotlin.jvm.internal.C c8 = new kotlin.jvm.internal.C();
                c6 = new kotlin.jvm.internal.C();
                try {
                    EnumC1108q state = this.f12125f;
                    V4.C c9 = this.f12126j;
                    C1191c c1191c = this.f12127k;
                    this.f12120a = c8;
                    this.f12121b = c6;
                    this.f12122c = c9;
                    this.f12123d = 1;
                    C0772m c0772m = new C0772m(1, AbstractC0872a.V(this));
                    c0772m.s();
                    EnumC1107p.Companion.getClass();
                    kotlin.jvm.internal.o.h(state, "state");
                    int iOrdinal = state.ordinal();
                    if (iOrdinal == 2) {
                        enumC1107p = EnumC1107p.ON_CREATE;
                    } else if (iOrdinal == 3) {
                        enumC1107p = EnumC1107p.ON_START;
                    } else if (iOrdinal != 4) {
                        enumC1107p2 = null;
                        N n6 = new N(enumC1107p2, c8, c9, C1105n.a(state), c0772m, e5.d.a(), c1191c);
                        c6.f20115a = n6;
                        rVar.addObserver(n6);
                        if (c0772m.r() != aVar) {
                            return aVar;
                        }
                        c7 = c8;
                        interfaceC0765i02 = (InterfaceC0765i0) c7.f20115a;
                        if (interfaceC0765i02 != null) {
                        }
                        interfaceC1111u2 = (InterfaceC1111u) c6.f20115a;
                        if (interfaceC1111u2 != null) {
                        }
                    } else {
                        enumC1107p = EnumC1107p.ON_RESUME;
                    }
                    enumC1107p2 = enumC1107p;
                    N n62 = new N(enumC1107p2, c8, c9, C1105n.a(state), c0772m, e5.d.a(), c1191c);
                    c6.f20115a = n62;
                    rVar.addObserver(n62);
                    if (c0772m.r() != aVar) {
                    }
                } catch (Throwable th2) {
                    th = th2;
                    c7 = c8;
                    interfaceC0765i0 = (InterfaceC0765i0) c7.f20115a;
                    if (interfaceC0765i0 != null) {
                        interfaceC0765i0.cancel(null);
                    }
                    interfaceC1111u = (InterfaceC1111u) c6.f20115a;
                    if (interfaceC1111u != null) {
                        throw th;
                    }
                    rVar.removeObserver(interfaceC1111u);
                    throw th;
                }
            }
        } else {
            if (i6 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            c6 = this.f12121b;
            c7 = this.f12120a;
            try {
                AbstractC2467b.l(obj);
                interfaceC0765i02 = (InterfaceC0765i0) c7.f20115a;
                if (interfaceC0765i02 != null) {
                    interfaceC0765i02.cancel(null);
                }
                interfaceC1111u2 = (InterfaceC1111u) c6.f20115a;
                if (interfaceC1111u2 != null) {
                    rVar.removeObserver(interfaceC1111u2);
                }
            } catch (Throwable th3) {
                th = th3;
                interfaceC0765i0 = (InterfaceC0765i0) c7.f20115a;
                if (interfaceC0765i0 != null) {
                }
                interfaceC1111u = (InterfaceC1111u) c6.f20115a;
                if (interfaceC1111u != null) {
                }
            }
        }
        return c3137a;
    }
}
