package V2;

import com.debridstream.tv.CollectionHubViewModel;
import com.debridstream.tv.HomeUiState;
import java.util.ArrayList;
import java.util.List;
import m3.AbstractC2467b;
import w4.C3137A;
import x4.AbstractC3251q;

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

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ CollectionHubViewModel f7528b;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public S0(CollectionHubViewModel collectionHubViewModel, A4.d dVar) {
        super(2, dVar);
        this.f7528b = collectionHubViewModel;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        return new S0(this.f7528b, dVar);
    }

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

    @Override // C4.a
    public final Object invokeSuspend(Object obj) throws Throwable {
        B4.a aVar = B4.a.f492a;
        int i6 = this.f7527a;
        CollectionHubViewModel collectionHubViewModel = this.f7528b;
        if (i6 == 0) {
            AbstractC2467b.l(obj);
            E1 e12 = E1.f7299a;
            String str = collectionHubViewModel.categoryJsonUrl;
            this.f7527a = 1;
            obj = e12.b(str, this);
            if (obj == aVar) {
                return aVar;
            }
        } else {
            if (i6 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            AbstractC2467b.l(obj);
        }
        ArrayList arrayList = new ArrayList();
        for (Object obj2 : (Iterable) obj) {
            AbstractC0742y1 abstractC0742y1 = (AbstractC0742y1) obj2;
            if (!(abstractC0742y1 instanceof C0726u1) && !(abstractC0742y1 instanceof C0718s1)) {
                arrayList.add(obj2);
            }
        }
        List listY0 = AbstractC3251q.y0(AbstractC0696m3.q(arrayList), 15);
        collectionHubViewModel.configs = listY0;
        if (listY0.isEmpty()) {
            Y4.H h5 = collectionHubViewModel._uiState;
            HomeUiState homeUiState = new HomeUiState(x4.y.f26065a, false, "Could not load collection");
            Y4.c0 c0Var = (Y4.c0) h5;
            c0Var.getClass();
            c0Var.k(null, homeUiState);
        } else {
            ((Y4.c0) collectionHubViewModel._uiState).j(collectionHubViewModel.shellState(listY0));
            collectionHubViewModel.requestSectionsAround(0, 3);
        }
        return C3137A.f25453a;
    }
}
