package com.amplifyframework.api.aws;

import com.amplifyframework.AmplifyException;
import com.amplifyframework.core.Consumer;
import com.amplifyframework.core.NullableConsumer;
import com.amplifyframework.core.model.Model;
import kotlin.Metadata;
import rm.n0;
import tp.m0;

@kotlin.coroutines.jvm.internal.f(c = "com.amplifyframework.api.aws.ApiLazyModelReference$fetchModel$2", f = "ApiLazyModelReference.kt", l = {77}, m = "invokeSuspend")
@Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\u0010\u0004\u001a\u00020\u0003\"\b\b\u0000\u0010\u0001*\u00020\u0000*\u00020\u0002H\u008a@"}, d2 = {"Lcom/amplifyframework/core/model/Model;", "M", "Ltp/m0;", "Lrm/n0;", "<anonymous>"}, k = 3, mv = {1, 9, 0})
/* loaded from: classes4.dex */
final class ApiLazyModelReference$fetchModel$2 extends kotlin.coroutines.jvm.internal.l implements dn.p {
    final /* synthetic */ Consumer<AmplifyException> $onError;
    final /* synthetic */ NullableConsumer<M> $onSuccess;
    int label;
    final /* synthetic */ ApiLazyModelReference<M> this$0;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public ApiLazyModelReference$fetchModel$2(ApiLazyModelReference<M> apiLazyModelReference, NullableConsumer<M> nullableConsumer, Consumer<AmplifyException> consumer, vm.d<? super ApiLazyModelReference$fetchModel$2> dVar) {
        super(2, dVar);
        this.this$0 = apiLazyModelReference;
        this.$onSuccess = nullableConsumer;
        this.$onError = consumer;
    }

    @Override // kotlin.coroutines.jvm.internal.a
    public final vm.d<n0> create(Object obj, vm.d<?> dVar) {
        return new ApiLazyModelReference$fetchModel$2(this.this$0, this.$onSuccess, this.$onError, dVar);
    }

    @Override // kotlin.coroutines.jvm.internal.a
    public final Object invokeSuspend(Object obj) {
        Object f10;
        f10 = wm.d.f();
        int i10 = this.label;
        try {
            if (i10 == 0) {
                rm.y.b(obj);
                ApiLazyModelReference<M> apiLazyModelReference = this.this$0;
                this.label = 1;
                obj = apiLazyModelReference.fetchInternal(this);
                if (obj == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            this.$onSuccess.accept((Model) obj);
        } catch (AmplifyException e10) {
            this.$onError.accept(e10);
        }
        return n0.f34904a;
    }

    @Override // dn.p
    public final Object invoke(m0 m0Var, vm.d<? super n0> dVar) {
        return ((ApiLazyModelReference$fetchModel$2) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
    }
}
