package com.strmr.ps.ui.networkcontent;

import android.util.Log;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.ik2;
import defpackage.qo9;
import defpackage.re6;
import defpackage.s38;
import defpackage.y41;
import defpackage.zw8;
import java.util.List;
import java.util.concurrent.CancellationException;
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.networkcontent.NetworkContentViewModel$loadInitial$1", f = "NetworkContentViewModel.kt", i = {}, l = {207}, m = "invokeSuspend", n = {}, s = {})
final class n extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public int a;
    public final /* synthetic */ NetworkContentViewModel b;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public n(NetworkContentViewModel networkContentViewModel, Continuation continuation) {
        super(2, continuation);
        this.b = networkContentViewModel;
    }

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

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

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Object invokeSuspend(Object obj) {
        NetworkContentViewModel networkContentViewModel = this.b;
        re6 re6Var = networkContentViewModel.h;
        re6 re6Var2 = networkContentViewModel.j;
        re6 re6Var3 = networkContentViewModel.l;
        ck1 ck1Var = ck1.a;
        int i = this.a;
        ik2 ik2Var = ik2.a;
        try {
            try {
                if (i == 0) {
                    s38.b(obj);
                    re6Var2.l(Boxing.boxBoolean(true));
                    re6Var3.l(null);
                    m mVar = new m(networkContentViewModel, null);
                    this.a = 1;
                    obj = qo9.c(30000L, mVar, this);
                    if (obj == ck1Var) {
                        return ck1Var;
                    }
                } else {
                    if (i != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    s38.b(obj);
                }
                List listA = (List) obj;
                if (listA == null) {
                    Log.w("NetworkContentVM", "Network content loading timed out after 30000ms");
                    re6Var3.l("Loading timed out. Tap to retry.");
                    re6Var.l(ik2Var);
                } else if (listA.isEmpty()) {
                    re6Var3.l("No content found");
                    re6Var.l(ik2Var);
                } else {
                    String str = networkContentViewModel.aa;
                    if (str != null) {
                        List list = zw8.a;
                        String str2 = networkContentViewModel.ab;
                        if (str2 == null) {
                            str2 = "asc";
                        }
                        listA = zw8.a(str, str2, listA);
                    }
                    re6Var.l(listA);
                    networkContentViewModel.n.l(y41.ab(listA));
                    re6Var3.l(null);
                }
            } catch (CancellationException e) {
                throw e;
            } catch (Exception e2) {
                Log.e("NetworkContentVM", "Error loading network content", e2);
                String message = e2.getMessage();
                if (message == null) {
                    message = "Unable to load content";
                }
                re6Var3.l(message);
                re6Var.l(ik2Var);
            }
            return e6a.a;
        } finally {
            re6Var2.l(Boxing.boxBoolean(false));
        }
    }
}
