package com.amplifyframework.api.aws;

import com.amplifyframework.AmplifyException;
import com.amplifyframework.core.Consumer;
import com.amplifyframework.core.model.LazyModelList;
import com.amplifyframework.core.model.ModelPage;
import com.amplifyframework.core.model.PaginationToken;
import kotlin.Metadata;
import rm.n0;
import tp.m0;

@kotlin.coroutines.jvm.internal.f(c = "com.amplifyframework.api.aws.ApiLazyModelList$fetchPage$3", f = "ApiModelListTypes.kt", l = {85}, 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\"\n\b\u0000\u0010\u0001 \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 ApiLazyModelList$fetchPage$3 extends kotlin.coroutines.jvm.internal.l implements dn.p {
    final /* synthetic */ Consumer<AmplifyException> $onError;
    final /* synthetic */ Consumer<ModelPage<M>> $onSuccess;
    final /* synthetic */ PaginationToken $paginationToken;
    int label;
    final /* synthetic */ ApiLazyModelList<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) */
    /* JADX WARN: Multi-variable type inference failed */
    public ApiLazyModelList$fetchPage$3(ApiLazyModelList<? extends M> apiLazyModelList, PaginationToken paginationToken, Consumer<ModelPage<M>> consumer, Consumer<AmplifyException> consumer2, vm.d<? super ApiLazyModelList$fetchPage$3> dVar) {
        super(2, dVar);
        this.this$0 = apiLazyModelList;
        this.$paginationToken = paginationToken;
        this.$onSuccess = consumer;
        this.$onError = consumer2;
    }

    @Override // kotlin.coroutines.jvm.internal.a
    public final vm.d<n0> create(Object obj, vm.d<?> dVar) {
        return new ApiLazyModelList$fetchPage$3(this.this$0, this.$paginationToken, 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);
                LazyModelList lazyModelList = this.this$0;
                PaginationToken paginationToken = this.$paginationToken;
                this.label = 1;
                obj = lazyModelList.fetchPage(paginationToken, 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((ModelPage) 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 ((ApiLazyModelList$fetchPage$3) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
    }
}
