package com.strmr.ps.ui.usercollection;

import com.strmr.ps.data.model.trakt.TraktListItem;
import com.strmr.ps.ui.usercollection.UserCollectionContentViewModel;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.q07;
import defpackage.s38;
import defpackage.vx8;
import defpackage.y41;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.Boxing;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {2, 0, 0})
@DebugMetadata(c = "com.strmr.ps.ui.usercollection.UserCollectionContentViewModel$loadTraktLink$2$2", f = "UserCollectionContentViewModel.kt", i = {}, l = {291}, m = "invokeSuspend", n = {}, s = {})
@vx8
final class ab extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public int a;
    public final /* synthetic */ UserCollectionContentViewModel b;
    public final /* synthetic */ String c;
    public final /* synthetic */ String d;
    public final /* synthetic */ UserCollectionContentViewModel.b e;
    public final /* synthetic */ ArrayList f;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public ab(UserCollectionContentViewModel userCollectionContentViewModel, String str, String str2, UserCollectionContentViewModel.b bVar, ArrayList arrayList, Continuation continuation) {
        super(2, continuation);
        this.b = userCollectionContentViewModel;
        this.c = str;
        this.d = str2;
        this.e = bVar;
        this.f = arrayList;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Object obj, Continuation continuation) {
        return new ab(this.b, this.c, this.d, this.e, this.f, continuation);
    }

    @Override // defpackage.gr3
    public final Object invoke(Object obj, Object obj2) {
        return ((ab) create((ak1) obj, (Continuation) obj2)).invokeSuspend(e6a.a);
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Object invokeSuspend(Object obj) {
        ck1 ck1Var = ck1.a;
        int i = this.a;
        if (i == 0) {
            s38.b(obj);
            UserCollectionContentViewModel userCollectionContentViewModel = this.b;
            String str = this.c;
            String str2 = this.d;
            this.a = 1;
            obj = UserCollectionContentViewModel.d(userCollectionContentViewModel, str, str2, 1, this);
            if (obj == ck1Var) {
                return ck1Var;
            }
        } else {
            if (i != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(obj);
        }
        List list = (List) obj;
        if (list.size() < 20) {
            this.e.j = false;
        }
        if (!list.isEmpty()) {
            this.e.h = 2;
            ArrayList arrayList = this.f;
            synchronized (arrayList) {
                try {
                    List list2 = list;
                    ArrayList arrayList2 = new ArrayList(y41.p(list2, 10));
                    Iterator it = list2.iterator();
                    while (it.hasNext()) {
                        arrayList2.add(new q07((TraktListItem) it.next(), Boxing.boxBoolean(false)));
                    }
                    arrayList.addAll(arrayList2);
                } catch (Throwable th) {
                    throw th;
                }
            }
        }
        list.size();
        return e6a.a;
    }
}
