package com.strmr.ps.ui.base;

import android.util.Log;
import com.strmr.ps.data.local.entity.RowConfigEntity;
import com.strmr.ps.data.local.entity.RowConfigExtensionsKt;
import com.strmr.ps.data.model.ContentItem;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.cr4;
import defpackage.e6a;
import defpackage.gf1;
import defpackage.gr3;
import defpackage.ik2;
import defpackage.j43;
import defpackage.k63;
import defpackage.ng6;
import defpackage.s38;
import defpackage.vx8;
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.base.BaseContentViewModel$refreshAfterAuth$1", f = "BaseContentViewModel.kt", i = {1, 1}, l = {706, 881, 723}, m = "invokeSuspend", n = {"configs", "$this$withLock_u24default$iv"}, s = {"L$0", "L$1"})
@vx8
final class p extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public List a;
    public ng6 b;
    public BaseContentViewModel c;
    public int d;
    public final /* synthetic */ BaseContentViewModel e;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public p(BaseContentViewModel baseContentViewModel, Continuation continuation) {
        super(2, continuation);
        this.e = baseContentViewModel;
    }

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

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

    /* JADX WARN: Code restructure failed: missing block: B:33:0x010b, code lost:
    
        if (com.strmr.ps.ui.base.BaseContentViewModel.i(r5, true, r14) != r0) goto L35;
     */
    /* JADX WARN: Removed duplicated region for block: B:22:0x0087 A[Catch: all -> 0x00aa, TryCatch #0 {all -> 0x00aa, blocks: (B:19:0x0076, B:20:0x0081, B:22:0x0087, B:24:0x009d, B:30:0x00dc, B:29:0x00ac, B:31:0x00f0), top: B:39:0x0076 }] */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        List<RowConfigEntity> list;
        ng6 ng6Var;
        BaseContentViewModel baseContentViewModel;
        ck1 ck1Var = ck1.a;
        int i = this.d;
        BaseContentViewModel baseContentViewModel2 = this.e;
        if (i == 0) {
            s38.b(obj);
            baseContentViewModel2.p.l(Boxing.boxBoolean(true));
            baseContentViewModel2.v.l(Boxing.boxBoolean(false));
            baseContentViewModel2.t.l(null);
            j43<List<RowConfigEntity>> rowsForScreen = baseContentViewModel2.a.getRowsForScreen(baseContentViewModel2.d);
            this.d = 1;
            obj = k63.k(rowsForScreen, this);
            if (obj != ck1Var) {
            }
            return ck1Var;
        }
        if (i == 1) {
            s38.b(obj);
        } else {
            if (i != 2) {
                if (i != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                baseContentViewModel2.x.j(Boxing.boxBoolean(true));
                return e6a.a;
            }
            baseContentViewModel = this.c;
            ng6Var = this.b;
            list = this.a;
            s38.b(obj);
            try {
                baseContentViewModel.i.clear();
                for (RowConfigEntity rowConfigEntity : list) {
                    gf1 rowState = RowConfigExtensionsKt.toRowState(rowConfigEntity);
                    if (cr4.b(rowConfigEntity.getRowType(), "trakt_calendar") || cr4.b(rowConfigEntity.getPresentation(), "calendar")) {
                        Log.w("BaseContentVM", "refreshAfterAuth calendar: id=" + rowConfigEntity.getId() + ", presentation='" + rowConfigEntity.getPresentation() + "' → " + rowState.f);
                    }
                    rowState.k.addAll(ContentItem.INSTANCE.createPlaceholders(6));
                    baseContentViewModel.i.add(rowState);
                }
                baseContentViewModel.z = true;
                baseContentViewModel.l.l(ik2.a);
                baseContentViewModel.k();
                ng6Var.c(null);
                this.a = null;
                this.b = null;
                this.c = null;
                this.d = 3;
            } catch (Throwable th) {
                ng6Var.c(null);
                throw th;
            }
        }
        list = (List) obj;
        ng6 ng6Var2 = baseContentViewModel2.j;
        this.a = list;
        this.b = ng6Var2;
        this.c = baseContentViewModel2;
        this.d = 2;
        if (ng6Var2.a(this) != ck1Var) {
            ng6Var = ng6Var2;
            baseContentViewModel = baseContentViewModel2;
            baseContentViewModel.i.clear();
            while (r15.hasNext()) {
            }
            baseContentViewModel.z = true;
            baseContentViewModel.l.l(ik2.a);
            baseContentViewModel.k();
            ng6Var.c(null);
            this.a = null;
            this.b = null;
            this.c = null;
            this.d = 3;
        }
        return ck1Var;
    }
}
