package com.strmr.ps.ui.settings.viewmodel;

import com.strmr.ps.data.local.entity.RowConfigEntity;
import com.strmr.ps.data.repository.ScreenConfigRepository;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.re6;
import defpackage.s38;
import java.util.UUID;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
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.settings.viewmodel.RowCustomizationViewModel$addTraktListRow$1", f = "RowCustomizationViewModel.kt", i = {1, 2}, l = {315, 318, 324, 342}, m = "invokeSuspend", n = {"profileSlug", "profileSlug"}, s = {"L$0", "L$0"})
final class b extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public String a;
    public int b;
    public final /* synthetic */ RowCustomizationViewModel c;
    public final /* synthetic */ ScreenConfigRepository.ScreenType d;
    public final /* synthetic */ String e;
    public final /* synthetic */ String f;
    public final /* synthetic */ String i;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public b(RowCustomizationViewModel rowCustomizationViewModel, ScreenConfigRepository.ScreenType screenType, String str, String str2, String str3, Continuation continuation) {
        super(2, continuation);
        this.c = rowCustomizationViewModel;
        this.d = screenType;
        this.e = str;
        this.f = str2;
        this.i = str3;
    }

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

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

    /* JADX WARN: Removed duplicated region for block: B:30:0x006b A[Catch: Exception -> 0x0026, TryCatch #0 {Exception -> 0x0026, blocks: (B:8:0x0022, B:15:0x0033, B:36:0x007f, B:18:0x003c, B:28:0x0067, B:30:0x006b, B:32:0x0073, B:19:0x0042, B:25:0x0055, B:22:0x004b), top: B:42:0x0018 }] */
    /* JADX WARN: Removed duplicated region for block: B:32:0x0073 A[Catch: Exception -> 0x0026, TryCatch #0 {Exception -> 0x0026, blocks: (B:8:0x0022, B:15:0x0033, B:36:0x007f, B:18:0x003c, B:28:0x0067, B:30:0x006b, B:32:0x0073, B:19:0x0042, B:25:0x0055, B:22:0x004b), top: B:42:0x0018 }] */
    /* JADX WARN: Removed duplicated region for block: B:38:0x00e8 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:39:0x00e9 A[RETURN] */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        Object profileSlugForNewRow;
        String str;
        Object objCheckRowLimits;
        String str2;
        Object nextPosition;
        String str3;
        RowCustomizationViewModel rowCustomizationViewModel = this.c;
        re6 re6Var = rowCustomizationViewModel.e;
        ScreenConfigRepository screenConfigRepository = rowCustomizationViewModel.a;
        ck1 ck1Var = ck1.a;
        int i = this.b;
        e6a e6aVar = e6a.a;
        ScreenConfigRepository.ScreenType screenType = this.d;
        try {
            if (i == 0) {
                s38.b(obj);
                this.b = 1;
                profileSlugForNewRow = screenConfigRepository.getProfileSlugForNewRow(this);
                if (profileSlugForNewRow == ck1Var) {
                }
            }
            if (i == 1) {
                s38.b(obj);
                profileSlugForNewRow = obj;
            } else {
                if (i != 2) {
                    if (i != 3) {
                        if (i != 4) {
                            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                        }
                        s38.b(obj);
                        return e6aVar;
                    }
                    String str4 = this.a;
                    s38.b(obj);
                    str3 = str4;
                    nextPosition = obj;
                    int iIntValue = ((Number) nextPosition).intValue();
                    RowConfigEntity rowConfigEntity = new RowConfigEntity(UUID.randomUUID() + "_" + str3, str3, screenType.getKey(), this.e, "trakt_list", null, "portrait", "trakt_list:" + this.f + ":" + this.i, iIntValue, iIntValue, true, false, 20, false, null, null, null, 114688, null);
                    this.a = null;
                    this.b = 4;
                    return screenConfigRepository.insertRow(rowConfigEntity, this) != ck1Var ? ck1Var : e6aVar;
                }
                str = this.a;
                s38.b(obj);
                objCheckRowLimits = obj;
                str2 = (String) objCheckRowLimits;
                if (str2 == null) {
                    re6Var.l("Cannot add list: ".concat(str2));
                    return e6aVar;
                }
                this.a = str;
                this.b = 3;
                nextPosition = screenConfigRepository.getNextPosition(screenType, this);
                if (nextPosition != ck1Var) {
                    str3 = str;
                    int iIntValue2 = ((Number) nextPosition).intValue();
                    RowConfigEntity rowConfigEntity2 = new RowConfigEntity(UUID.randomUUID() + "_" + str3, str3, screenType.getKey(), this.e, "trakt_list", null, "portrait", "trakt_list:" + this.f + ":" + this.i, iIntValue2, iIntValue2, true, false, 20, false, null, null, null, 114688, null);
                    this.a = null;
                    this.b = 4;
                    if (screenConfigRepository.insertRow(rowConfigEntity2, this) != ck1Var) {
                    }
                }
            }
            str = (String) profileSlugForNewRow;
            String key = screenType.getKey();
            this.a = str;
            this.b = 2;
            objCheckRowLimits = screenConfigRepository.checkRowLimits(str, 1, key, this);
            if (objCheckRowLimits != ck1Var) {
                str2 = (String) objCheckRowLimits;
                if (str2 == null) {
                }
            }
        } catch (Exception e) {
            re6Var.l("Failed to add list: " + e.getMessage());
            return e6aVar;
        }
    }
}
