package androidx.lifecycle;

import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import org.jetbrains.annotations.NotNull;

/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u00000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0007\b\u0000\u0018\u00002\u00020\u00012\u00020\u0002B\u0017\u0012\u0006\u0010\u000b\u001a\u00020\n\u0012\u0006\u0010\u0010\u001a\u00020\u000f¢\u0006\u0004\b\u0014\u0010\u0015J\u0006\u0010\u0004\u001a\u00020\u0003J\u0018\u0010\t\u001a\u00020\u00032\u0006\u0010\u0006\u001a\u00020\u00052\u0006\u0010\b\u001a\u00020\u0007H\u0016R\u001a\u0010\u000b\u001a\u00020\n8\u0010X\u0090\u0004¢\u0006\f\n\u0004\b\u000b\u0010\f\u001a\u0004\b\r\u0010\u000eR\u001a\u0010\u0010\u001a\u00020\u000f8\u0016X\u0096\u0004¢\u0006\f\n\u0004\b\u0010\u0010\u0011\u001a\u0004\b\u0012\u0010\u0013¨\u0006\u0016"}, d2 = {"Landroidx/lifecycle/LifecycleCoroutineScopeImpl;", "Landroidx/lifecycle/LifecycleCoroutineScope;", "Landroidx/lifecycle/LifecycleEventObserver;", "Lkd/e;", "register", "Landroidx/lifecycle/p;", "source", "Landroidx/lifecycle/Lifecycle$Event;", "event", "onStateChanged", "Landroidx/lifecycle/l;", "lifecycle", "Landroidx/lifecycle/l;", "getLifecycle$lifecycle_common", "()Landroidx/lifecycle/l;", "Lkotlin/coroutines/h;", "coroutineContext", "Lkotlin/coroutines/h;", "getCoroutineContext", "()Lkotlin/coroutines/h;", "<init>", "(Landroidx/lifecycle/l;Lkotlin/coroutines/h;)V", "lifecycle-common"}, k = 1, mv = {1, 8, 0})
public final class LifecycleCoroutineScopeImpl extends LifecycleCoroutineScope implements LifecycleEventObserver {

    @NotNull
    private final kotlin.coroutines.h coroutineContext;

    @NotNull
    private final l lifecycle;

    /* JADX INFO: renamed from: androidx.lifecycle.LifecycleCoroutineScopeImpl$register$1, reason: invalid class name */
    @Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\u008a@"}, d2 = {"Lkotlinx/coroutines/x;", "Lkd/e;", "<anonymous>"}, k = 3, mv = {1, 8, 0})
    @DebugMetadata(c = "androidx.lifecycle.LifecycleCoroutineScopeImpl$register$1", f = "Lifecycle.kt", i = {}, l = {}, m = "invokeSuspend", n = {}, s = {})
    public static final class AnonymousClass1 extends SuspendLambda implements Function2 {
        private /* synthetic */ Object L$0;
        int label;

        public AnonymousClass1(Continuation continuation) {
            super(2, continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Continuation create(Object obj, Continuation continuation) {
            AnonymousClass1 anonymousClass1 = LifecycleCoroutineScopeImpl.this.new AnonymousClass1(continuation);
            anonymousClass1.L$0 = obj;
            return anonymousClass1;
        }

        @Override // kotlin.jvm.functions.Function2
        public final Object invoke(Object obj, Object obj2) {
            AnonymousClass1 anonymousClass1 = (AnonymousClass1) create((kotlinx.coroutines.x) obj, (Continuation) obj2);
            kd.e eVar = kd.e.f29109a;
            anonymousClass1.invokeSuspend(eVar);
            return eVar;
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Object invokeSuspend(Object obj) {
            if (this.label != 0) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            kotlin.a.d(obj);
            kotlinx.coroutines.x xVar = (kotlinx.coroutines.x) this.L$0;
            if (((r) LifecycleCoroutineScopeImpl.this.getLifecycle()).f2692c.compareTo(Lifecycle$State.f2632b) >= 0) {
                LifecycleCoroutineScopeImpl.this.getLifecycle().a(LifecycleCoroutineScopeImpl.this);
            } else {
                kotlinx.coroutines.y.d(xVar.getCoroutineContext(), null);
            }
            return kd.e.f29109a;
        }
    }

    public LifecycleCoroutineScopeImpl(@NotNull l lVar, @NotNull kotlin.coroutines.h hVar) {
        nb.g.i(lVar, "lifecycle");
        nb.g.i(hVar, "coroutineContext");
        this.lifecycle = lVar;
        this.coroutineContext = hVar;
        if (((r) getLifecycle()).f2692c == Lifecycle$State.f2631a) {
            kotlinx.coroutines.y.d(getCoroutineContext(), null);
        }
    }

    @Override // kotlinx.coroutines.x
    @NotNull
    public kotlin.coroutines.h getCoroutineContext() {
        return this.coroutineContext;
    }

    @Override // androidx.lifecycle.LifecycleCoroutineScope
    @NotNull
    /* JADX INFO: renamed from: getLifecycle$lifecycle_common, reason: from getter */
    public l getLifecycle() {
        return this.lifecycle;
    }

    @Override // androidx.lifecycle.LifecycleEventObserver
    public void onStateChanged(@NotNull p pVar, @NotNull Lifecycle$Event lifecycle$Event) {
        nb.g.i(pVar, "source");
        nb.g.i(lifecycle$Event, "event");
        if (((r) getLifecycle()).f2692c.compareTo(Lifecycle$State.f2631a) <= 0) {
            getLifecycle().b(this);
            kotlinx.coroutines.y.d(getCoroutineContext(), null);
        }
    }

    public final void register() {
        be.d dVar = kotlinx.coroutines.h0.f29440a;
        hb.a.k0(this, ((ae.d) kotlinx.coroutines.internal.n.f29483a).f453f, new AnonymousClass1(null), 2);
    }
}
