package com.strmr.ps.data.repository;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import androidx.media3.container.NalUnitUtil;
import com.strmr.ps.data.local.dao.RowConfigDao;
import com.strmr.ps.data.local.entity.RowConfigEntity;
import com.strmr.ps.data.local.entity.TraktAccount;
import com.strmr.ps.data.supabase.DeviceManager;
import com.strmr.ps.data.supabase.SettingsSyncManager;
import dagger.Lazy;
import dagger.hilt.android.qualifiers.ApplicationContext;
import defpackage.ak1;
import defpackage.bk1;
import defpackage.ck1;
import defpackage.cr4;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.hn2;
import defpackage.io6;
import defpackage.j43;
import defpackage.jn2;
import defpackage.k12;
import defpackage.k63;
import defpackage.km8;
import defpackage.kp6;
import defpackage.l43;
import defpackage.m02;
import defpackage.m12;
import defpackage.n41;
import defpackage.n89;
import defpackage.pk2;
import defpackage.pq6;
import defpackage.q07;
import defpackage.s38;
import defpackage.sc2;
import defpackage.uz1;
import defpackage.vw2;
import defpackage.vx8;
import defpackage.wj0;
import defpackage.wo5;
import defpackage.y41;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.Boxing;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import okhttp3.internal.http.StatusLine;

/* JADX INFO: loaded from: classes3.dex */
@Singleton
@Metadata(d1 = {"\u0000\u0084\u0001\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0010$\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b+\n\u0002\u0010\"\n\u0002\b\u0014\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0007\u0018\u0000 n2\u00020\u0001:\u0002noBG\b\u0007\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\u0006\u0010\u0005\u001a\u00020\u0004\u0012\u0006\u0010\u0007\u001a\u00020\u0006\u0012\b\b\u0001\u0010\t\u001a\u00020\b\u0012\f\u0010\f\u001a\b\u0012\u0004\u0012\u00020\u000b0\n\u0012\f\u0010\u000e\u001a\b\u0012\u0004\u0012\u00020\r0\n¢\u0006\u0004\b\u000f\u0010\u0010J.\u0010\u0016\u001a\u0004\u0018\u00010\u00112\u0006\u0010\u0012\u001a\u00020\u00112\u0006\u0010\u0014\u001a\u00020\u00132\n\b\u0002\u0010\u0015\u001a\u0004\u0018\u00010\u0011H\u0086@¢\u0006\u0004\b\u0016\u0010\u0017J.\u0010\u001a\u001a\u0004\u0018\u00010\u00112\u0006\u0010\u0012\u001a\u00020\u00112\u0012\u0010\u0019\u001a\u000e\u0012\u0004\u0012\u00020\u0011\u0012\u0004\u0012\u00020\u00130\u0018H\u0086@¢\u0006\u0004\b\u001a\u0010\u001bJ!\u0010!\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020 0\u001f0\u001e2\u0006\u0010\u001d\u001a\u00020\u001c¢\u0006\u0004\b!\u0010\"J!\u0010#\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020 0\u001f0\u001e2\u0006\u0010\u001d\u001a\u00020\u001c¢\u0006\u0004\b#\u0010\"J \u0010(\u001a\u00020'2\u0006\u0010$\u001a\u00020\u00112\u0006\u0010&\u001a\u00020%H\u0086@¢\u0006\u0004\b(\u0010)J \u0010+\u001a\u00020'2\u0006\u0010$\u001a\u00020\u00112\u0006\u0010*\u001a\u00020\u0013H\u0086@¢\u0006\u0004\b+\u0010,J\u0018\u0010-\u001a\u00020'2\u0006\u0010\u001d\u001a\u00020\u001cH\u0086@¢\u0006\u0004\b-\u0010.J\u0010\u0010/\u001a\u00020'H\u0086@¢\u0006\u0004\b/\u00100J\u0018\u00101\u001a\u00020'2\u0006\u0010\u0012\u001a\u00020\u0011H\u0086@¢\u0006\u0004\b1\u00102J\u0018\u00103\u001a\u00020'2\u0006\u0010\u0012\u001a\u00020\u0011H\u0086@¢\u0006\u0004\b3\u00102J\u0018\u00104\u001a\u00020'2\u0006\u0010\u0012\u001a\u00020\u0011H\u0086@¢\u0006\u0004\b4\u00102J\u001a\u00105\u001a\u0004\u0018\u00010 2\u0006\u0010$\u001a\u00020\u0011H\u0086@¢\u0006\u0004\b5\u00102J\u0018\u00107\u001a\u00020'2\u0006\u00106\u001a\u00020 H\u0086@¢\u0006\u0004\b7\u00108J\u0018\u00109\u001a\u00020\u00132\u0006\u0010\u001d\u001a\u00020\u001cH\u0086@¢\u0006\u0004\b9\u0010.J\u0018\u0010:\u001a\u00020'2\u0006\u0010$\u001a\u00020\u0011H\u0086@¢\u0006\u0004\b:\u00102J \u0010=\u001a\u00020%2\u0006\u0010;\u001a\u00020\u00112\u0006\u0010<\u001a\u00020\u0011H\u0086@¢\u0006\u0004\b=\u0010>J(\u0010A\u001a\u00020%2\u0006\u0010\u001d\u001a\u00020\u001c2\u0006\u0010?\u001a\u00020\u00132\u0006\u0010@\u001a\u00020\u0013H\u0086@¢\u0006\u0004\bA\u0010BJ&\u0010D\u001a\u00020%2\u0006\u0010\u001d\u001a\u00020\u001c2\f\u0010C\u001a\b\u0012\u0004\u0012\u00020\u00110\u001fH\u0086@¢\u0006\u0004\bD\u0010EJ\u0018\u0010F\u001a\u00020'2\u0006\u00106\u001a\u00020 H\u0086@¢\u0006\u0004\bF\u00108J\u0018\u0010G\u001a\u00020\u00132\u0006\u0010\u001d\u001a\u00020\u001cH\u0086@¢\u0006\u0004\bG\u0010.J\u0010\u0010H\u001a\u00020\u0011H\u0086@¢\u0006\u0004\bH\u00100J \u0010J\u001a\u00020%2\u0006\u0010$\u001a\u00020\u00112\u0006\u0010I\u001a\u00020\u0011H\u0086@¢\u0006\u0004\bJ\u0010>J \u0010L\u001a\u00020%2\u0006\u0010$\u001a\u00020\u00112\u0006\u0010K\u001a\u00020\u0011H\u0086@¢\u0006\u0004\bL\u0010>J,\u0010O\u001a\u00020%2\u0006\u0010$\u001a\u00020\u00112\b\u0010M\u001a\u0004\u0018\u00010\u00112\b\u0010N\u001a\u0004\u0018\u00010\u0011H\u0086@¢\u0006\u0004\bO\u0010PJ\u0017\u0010Q\u001a\u00020'2\u0006\u0010$\u001a\u00020\u0011H\u0002¢\u0006\u0004\bQ\u0010RJ\u0015\u0010T\u001a\b\u0012\u0004\u0012\u00020\u00110SH\u0002¢\u0006\u0004\bT\u0010UJ\u000f\u0010V\u001a\u00020'H\u0002¢\u0006\u0004\bV\u0010WJ\u0010\u0010X\u001a\u00020\u0011H\u0082@¢\u0006\u0004\bX\u00100J#\u0010Z\u001a\b\u0012\u0004\u0012\u00020 0\u001f2\f\u0010Y\u001a\b\u0012\u0004\u0012\u00020 0\u001fH\u0002¢\u0006\u0004\bZ\u0010[J%\u0010\\\u001a\b\u0012\u0004\u0012\u00020 0\u001f2\u0006\u0010\u0012\u001a\u00020\u00112\u0006\u0010\u001d\u001a\u00020\u001cH\u0002¢\u0006\u0004\b\\\u0010]J\u001d\u0010^\u001a\b\u0012\u0004\u0012\u00020 0\u001f2\u0006\u0010\u0012\u001a\u00020\u0011H\u0002¢\u0006\u0004\b^\u0010_J\u0010\u0010`\u001a\u00020'H\u0082@¢\u0006\u0004\b`\u00100J\u0018\u0010a\u001a\u00020'2\u0006\u0010\u0012\u001a\u00020\u0011H\u0082@¢\u0006\u0004\ba\u00102J\u000f\u0010b\u001a\u00020'H\u0002¢\u0006\u0004\bb\u0010WR\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0003\u0010cR\u0014\u0010\u0005\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0005\u0010dR\u0014\u0010\u0007\u001a\u00020\u00068\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0007\u0010eR\u0014\u0010\t\u001a\u00020\b8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\t\u0010fR\u001a\u0010\f\u001a\b\u0012\u0004\u0012\u00020\u000b0\n8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\f\u0010gR\u001a\u0010\u000e\u001a\b\u0012\u0004\u0012\u00020\r0\n8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u000e\u0010gR\u0014\u0010i\u001a\u00020h8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\bi\u0010jR\u0014\u0010l\u001a\u00020k8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\bl\u0010m¨\u0006p"}, d2 = {"Lcom/strmr/ps/data/repository/ScreenConfigRepository;", "", "Lcom/strmr/ps/data/local/dao/RowConfigDao;", "rowConfigDao", "Lcom/strmr/ps/data/repository/TraktAccountRepository;", "traktAccountRepository", "Lcom/strmr/ps/data/repository/PreferencesRepository;", "preferencesRepository", "Landroid/content/Context;", "context", "Ldagger/Lazy;", "Lcom/strmr/ps/data/supabase/SettingsSyncManager;", "settingsSyncManager", "Lcom/strmr/ps/data/supabase/DeviceManager;", "deviceManager", "<init>", "(Lcom/strmr/ps/data/local/dao/RowConfigDao;Lcom/strmr/ps/data/repository/TraktAccountRepository;Lcom/strmr/ps/data/repository/PreferencesRepository;Landroid/content/Context;Ldagger/Lazy;Ldagger/Lazy;)V", "", "profileSlug", "", "newRowCount", "screenType", "checkRowLimits", "(Ljava/lang/String;ILjava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "", "rowsByScreen", "checkRowLimitsByScreen", "(Ljava/lang/String;Ljava/util/Map;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "Lcom/strmr/ps/data/repository/ScreenConfigRepository$ScreenType;", "screen", "Lj43;", "", "Lcom/strmr/ps/data/local/entity/RowConfigEntity;", "getRowsForScreen", "(Lcom/strmr/ps/data/repository/ScreenConfigRepository$ScreenType;)Lj43;", "getAllRowsForSettings", "rowId", "", "enabled", "Le6a;", "toggleRowVisibility", "(Ljava/lang/String;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;", "newPosition", "reorderRow", "(Ljava/lang/String;ILkotlin/coroutines/Continuation;)Ljava/lang/Object;", "resetScreenToDefaults", "(Lcom/strmr/ps/data/repository/ScreenConfigRepository$ScreenType;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "initializeDefaults", "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "initializeDefaultsForProfile", "(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "syncDeletedDefaultsFromCloudRestore", "deleteRowsForProfile", "getRowById", "row", "updateRow", "(Lcom/strmr/ps/data/local/entity/RowConfigEntity;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "getRowCount", "deleteRow", "rowId1", "rowId2", "swapRowPositions", "(Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "fromIndex", "toIndex", "moveRowToPosition", "(Lcom/strmr/ps/data/repository/ScreenConfigRepository$ScreenType;IILkotlin/coroutines/Continuation;)Ljava/lang/Object;", "orderedIds", "reorderRowsByIds", "(Lcom/strmr/ps/data/repository/ScreenConfigRepository$ScreenType;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "insertRow", "getNextPosition", "getProfileSlugForNewRow", "presentation", "updateRowPresentation", "title", "updateRowTitle", "sortBy", "sortHow", "updateRowSort", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "markDefaultRowDeleted", "(Ljava/lang/String;)V", "", "getDeletedDefaultRowIds", "()Ljava/util/Set;", "clearDeletedDefaultRows", "()V", "getCurrentProfileSlug", "rows", "filterContinueWatchingRows", "(Ljava/util/List;)Ljava/util/List;", "getDefaultRowsForProfile", "(Ljava/lang/String;Lcom/strmr/ps/data/repository/ScreenConfigRepository$ScreenType;)Ljava/util/List;", "getAllDefaultRowsForProfile", "(Ljava/lang/String;)Ljava/util/List;", "backfillTitleResKeys", "insertMissingDefaultRowsForProfile", "triggerCloudSync", "Lcom/strmr/ps/data/local/dao/RowConfigDao;", "Lcom/strmr/ps/data/repository/TraktAccountRepository;", "Lcom/strmr/ps/data/repository/PreferencesRepository;", "Landroid/content/Context;", "Ldagger/Lazy;", "Lak1;", "syncScope", "Lak1;", "Landroid/content/SharedPreferences;", "prefs", "Landroid/content/SharedPreferences;", "Companion", "ScreenType", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public final class ScreenConfigRepository {

    @kp6
    private static final String DEFAULT_PROFILE = "_default";

    @kp6
    private static final String KEY_DELETED_DEFAULT_ROWS = "deleted_default_row_ids";
    public static final int MAX_ROWS_PER_PROFILE = 400;
    public static final int MAX_ROWS_PER_SCREEN = 100;
    public static final int MAX_TOTAL_ROWS = 600;

    @kp6
    private static final String PREFS_NAME = "screen_config_prefs";

    @kp6
    private static final String TAG = "ScreenConfigRepository";

    @kp6
    private final Context context;

    @kp6
    private final Lazy<DeviceManager> deviceManager;

    @kp6
    private final PreferencesRepository preferencesRepository;

    @kp6
    private final SharedPreferences prefs;

    @kp6
    private final RowConfigDao rowConfigDao;

    @kp6
    private final Lazy<SettingsSyncManager> settingsSyncManager;

    @kp6
    private final ak1 syncScope;

    @kp6
    private final TraktAccountRepository traktAccountRepository;

    /* JADX WARN: Failed to restore enum class, 'enum' modifier and super class removed */
    /* JADX WARN: Unknown enum class pattern. Please report as an issue! */
    @Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0010\u0010\n\u0000\n\u0002\u0010\u000e\n\u0002\b\t\b\u0086\u0081\u0002\u0018\u0000 \u000b2\b\u0012\u0004\u0012\u00020\u00000\u0001:\u0001\u000bB\u0011\b\u0002\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0004\b\u0004\u0010\u0005R\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\u0006\u0010\u0007j\u0002\b\bj\u0002\b\tj\u0002\b\n¨\u0006\f"}, d2 = {"Lcom/strmr/ps/data/repository/ScreenConfigRepository$ScreenType;", "", "key", "", "<init>", "(Ljava/lang/String;ILjava/lang/String;)V", "getKey", "()Ljava/lang/String;", "HOME", "MOVIES", "TV_SHOWS", "Companion", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class ScreenType {
        private static final /* synthetic */ hn2 $ENTRIES;
        private static final /* synthetic */ ScreenType[] $VALUES;

        /* JADX INFO: renamed from: Companion, reason: from kotlin metadata */
        @kp6
        public static final Companion INSTANCE;
        public static final ScreenType HOME = new ScreenType("HOME", 0, "home");
        public static final ScreenType MOVIES = new ScreenType("MOVIES", 1, "movies");
        public static final ScreenType TV_SHOWS = new ScreenType("TV_SHOWS", 2, "tvshows");

        @kp6
        private final String key;

        @Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J\u0010\u0010\u0004\u001a\u0004\u0018\u00010\u00052\u0006\u0010\u0006\u001a\u00020\u0007¨\u0006\b"}, d2 = {"Lcom/strmr/ps/data/repository/ScreenConfigRepository$ScreenType$Companion;", "", "<init>", "()V", "fromKey", "Lcom/strmr/ps/data/repository/ScreenConfigRepository$ScreenType;", "key", "", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
        @vx8
        public static final class Companion {
            public /* synthetic */ Companion(uz1 uz1Var) {
                this();
            }

            @pq6
            public final ScreenType fromKey(@kp6 String key) {
                ScreenType next;
                cr4.g(key, "key");
                Iterator<ScreenType> it = ScreenType.getEntries().iterator();
                while (true) {
                    if (!it.hasNext()) {
                        next = null;
                        break;
                    }
                    next = it.next();
                    if (cr4.b(next.getKey(), key)) {
                        break;
                    }
                }
                return next;
            }

            private Companion() {
            }
        }

        private static final /* synthetic */ ScreenType[] $values() {
            return new ScreenType[]{HOME, MOVIES, TV_SHOWS};
        }

        static {
            ScreenType[] screenTypeArr$values = $values();
            $VALUES = screenTypeArr$values;
            $ENTRIES = jn2.a(screenTypeArr$values);
            INSTANCE = new Companion(null);
        }

        private ScreenType(String str, int i, String str2) {
            this.key = str2;
        }

        @kp6
        public static hn2<ScreenType> getEntries() {
            return $ENTRIES;
        }

        public static ScreenType valueOf(String str) {
            return (ScreenType) Enum.valueOf(ScreenType.class, str);
        }

        public static ScreenType[] values() {
            return (ScreenType[]) $VALUES.clone();
        }

        @kp6
        public final String getKey() {
            return this.key;
        }
    }

    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public /* synthetic */ class WhenMappings {
        public static final /* synthetic */ int[] $EnumSwitchMapping$0;

        static {
            int[] iArr = new int[ScreenType.values().length];
            try {
                iArr[ScreenType.HOME.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[ScreenType.MOVIES.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[ScreenType.TV_SHOWS.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            $EnumSwitchMapping$0 = iArr;
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$backfillTitleResKeys$1, reason: invalid class name */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0}, l = {319}, m = "backfillTitleResKeys", n = {"this"}, s = {"L$0"})
    public static final class AnonymousClass1 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public AnonymousClass1(Continuation<? super AnonymousClass1> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.backfillTitleResKeys(this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$checkRowLimits$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 0, 0, 0, 1, 1, 2}, l = {50, 57, 62}, m = "checkRowLimits", n = {"this", "profileSlug", "screenType", "newRowCount", "this", "newRowCount", "newRowCount"}, s = {"L$0", "L$1", "L$2", "I$0", "L$0", "I$0", "I$0"})
    public static final class C03821 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        Object L$2;
        int label;
        /* synthetic */ Object result;

        public C03821(Continuation<? super C03821> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.checkRowLimits(null, 0, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$checkRowLimitsByScreen$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 0, 0, 0, 0, 1, 1, 2}, l = {79, 87, 92}, m = "checkRowLimitsByScreen", n = {"this", "profileSlug", "rowsByScreen", "screen", "count", "this", "totalNew", "totalNew"}, s = {"L$0", "L$1", "L$2", "L$4", "I$0", "L$0", "I$0", "I$0"})
    public static final class C03831 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        Object L$4;
        int label;
        /* synthetic */ Object result;

        public C03831(Continuation<? super C03831> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.checkRowLimitsByScreen(null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$deleteRow$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 0, 1}, l = {420, 426}, m = "deleteRow", n = {"this", "rowId", "this"}, s = {"L$0", "L$1", "L$0"})
    public static final class C03841 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C03841(Continuation<? super C03841> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.deleteRow(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$deleteRowsForProfile$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0}, l = {381}, m = "deleteRowsForProfile", n = {"profileSlug"}, s = {"L$0"})
    public static final class C03851 extends ContinuationImpl {
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C03851(Continuation<? super C03851> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.deleteRowsForProfile(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$getAllRowsForSettings$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(d1 = {"\u0000\u0014\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0004\u001a\u00020\u0003*\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00020\u00010\u0000H\n¢\u0006\u0004\b\u0004\u0010\u0005"}, d2 = {"Ll43;", "", "Lcom/strmr/ps/data/local/entity/RowConfigEntity;", "Le6a;", "<anonymous>", "(Ll43;)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository$getAllRowsForSettings$1", f = "ScreenConfigRepository.kt", i = {0}, l = {193, 194}, m = "invokeSuspend", n = {"$this$flow"}, s = {"L$0"})
    public static final class C03861 extends SuspendLambda implements gr3<l43<? super List<? extends RowConfigEntity>>, Continuation<? super e6a>, Object> {
        final /* synthetic */ ScreenType $screen;
        private /* synthetic */ Object L$0;
        int label;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C03861(ScreenType screenType, Continuation<? super C03861> continuation) {
            super(2, continuation);
            this.$screen = screenType;
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Continuation<e6a> create(Object obj, Continuation<?> continuation) {
            C03861 c03861 = ScreenConfigRepository.this.new C03861(this.$screen, continuation);
            c03861.L$0 = obj;
            return c03861;
        }

        @Override // defpackage.gr3
        public final Object invoke(l43<? super List<RowConfigEntity>> l43Var, Continuation<? super e6a> continuation) {
            return ((C03861) create(l43Var, continuation)).invokeSuspend(e6a.a);
        }

        /* JADX WARN: Code restructure failed: missing block: B:14:0x0057, code lost:
        
            if (r6.collect(r3, r5) == r0) goto L15;
         */
        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Object invokeSuspend(Object obj) {
            final l43 l43Var;
            ck1 ck1Var = ck1.a;
            int i = this.label;
            if (i == 0) {
                s38.b(obj);
                l43Var = (l43) this.L$0;
                ScreenConfigRepository screenConfigRepository = ScreenConfigRepository.this;
                this.L$0 = l43Var;
                this.label = 1;
                obj = screenConfigRepository.getCurrentProfileSlug(this);
                if (obj != ck1Var) {
                }
                return ck1Var;
            }
            if (i != 1) {
                if (i != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                return e6a.a;
            }
            l43Var = (l43) this.L$0;
            s38.b(obj);
            j43<List<RowConfigEntity>> allRowsForProfile = ScreenConfigRepository.this.rowConfigDao.getAllRowsForProfile((String) obj, this.$screen.getKey());
            final ScreenConfigRepository screenConfigRepository2 = ScreenConfigRepository.this;
            l43 l43Var2 = new l43() { // from class: com.strmr.ps.data.repository.ScreenConfigRepository.getAllRowsForSettings.1.1
                @Override // defpackage.l43
                public /* bridge */ /* synthetic */ Object emit(Object obj2, Continuation continuation) {
                    return emit((List<RowConfigEntity>) obj2, (Continuation<? super e6a>) continuation);
                }

                public final Object emit(List<RowConfigEntity> list, Continuation<? super e6a> continuation) {
                    Object objEmit = l43Var.emit(screenConfigRepository2.filterContinueWatchingRows(list), continuation);
                    return objEmit == ck1.a ? objEmit : e6a.a;
                }
            };
            this.L$0 = null;
            this.label = 2;
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$getCurrentProfileSlug$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {}, l = {132}, m = "getCurrentProfileSlug", n = {}, s = {})
    public static final class C03871 extends ContinuationImpl {
        int label;
        /* synthetic */ Object result;

        public C03871(Continuation<? super C03871> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.getCurrentProfileSlug(this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$getNextPosition$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 0}, l = {537, 538}, m = "getNextPosition", n = {"this", "screen"}, s = {"L$0", "L$1"})
    public static final class C03881 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C03881(Continuation<? super C03881> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.getNextPosition(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$getRowCount$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 0}, l = {408, 409}, m = "getRowCount", n = {"this", "screen"}, s = {"L$0", "L$1"})
    public static final class C03891 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C03891(Continuation<? super C03891> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.getRowCount(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$getRowsForScreen$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(d1 = {"\u0000\u0014\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0004\u001a\u00020\u0003*\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00020\u00010\u0000H\n¢\u0006\u0004\b\u0004\u0010\u0005"}, d2 = {"Ll43;", "", "Lcom/strmr/ps/data/local/entity/RowConfigEntity;", "Le6a;", "<anonymous>", "(Ll43;)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository$getRowsForScreen$1", f = "ScreenConfigRepository.kt", i = {0}, l = {143, 145}, m = "invokeSuspend", n = {"$this$flow"}, s = {"L$0"})
    public static final class C03901 extends SuspendLambda implements gr3<l43<? super List<? extends RowConfigEntity>>, Continuation<? super e6a>, Object> {
        final /* synthetic */ ScreenType $screen;
        private /* synthetic */ Object L$0;
        int label;

        /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$getRowsForScreen$1$1, reason: invalid class name and collision with other inner class name */
        @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
        @vx8
        public static final class C01021<T> implements l43 {
            final /* synthetic */ l43<List<RowConfigEntity>> $$this$flow;
            final /* synthetic */ String $profileSlug;
            final /* synthetic */ ScreenType $screen;
            final /* synthetic */ ScreenConfigRepository this$0;

            /* JADX WARN: Multi-variable type inference failed */
            public C01021(String str, ScreenConfigRepository screenConfigRepository, ScreenType screenType, l43<? super List<RowConfigEntity>> l43Var) {
                this.$profileSlug = str;
                this.this$0 = screenConfigRepository;
                this.$screen = screenType;
                this.$$this$flow = l43Var;
            }

            @Override // defpackage.l43
            public /* bridge */ /* synthetic */ Object emit(Object obj, Continuation continuation) {
                return emit((List<RowConfigEntity>) obj, (Continuation<? super e6a>) continuation);
            }

            /* JADX WARN: Removed duplicated region for block: B:38:0x00ce A[PHI: r2 r11 r12
              0x00ce: PHI (r2v7 com.strmr.ps.data.repository.ScreenConfigRepository$getRowsForScreen$1$1<T>) = 
              (r2v5 com.strmr.ps.data.repository.ScreenConfigRepository$getRowsForScreen$1$1<T>)
              (r2v11 com.strmr.ps.data.repository.ScreenConfigRepository$getRowsForScreen$1$1<T>)
             binds: [B:36:0x00cb, B:17:0x003c] A[DONT_GENERATE, DONT_INLINE]
              0x00ce: PHI (r11v7 java.util.List<com.strmr.ps.data.local.entity.RowConfigEntity>) = 
              (r11v1 java.util.List<com.strmr.ps.data.local.entity.RowConfigEntity>)
              (r11v16 java.util.List<com.strmr.ps.data.local.entity.RowConfigEntity>)
             binds: [B:36:0x00cb, B:17:0x003c] A[DONT_GENERATE, DONT_INLINE]
              0x00ce: PHI (r12v18 java.lang.Object) = (r12v10 java.lang.Object), (r12v1 java.lang.Object) binds: [B:36:0x00cb, B:17:0x003c] A[DONT_GENERATE, DONT_INLINE]] */
            /* JADX WARN: Removed duplicated region for block: B:40:0x00d1  */
            /* JADX WARN: Removed duplicated region for block: B:44:0x00e3  */
            /* JADX WARN: Removed duplicated region for block: B:51:0x010b A[RETURN] */
            /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
            /*
                Code decompiled incorrectly, please refer to instructions dump.
            */
            public final Object emit(List<RowConfigEntity> list, Continuation<? super e6a> continuation) {
                ScreenConfigRepository$getRowsForScreen$1$1$emit$1 screenConfigRepository$getRowsForScreen$1$1$emit$1;
                C01021<T> c01021;
                if (continuation instanceof ScreenConfigRepository$getRowsForScreen$1$1$emit$1) {
                    screenConfigRepository$getRowsForScreen$1$1$emit$1 = (ScreenConfigRepository$getRowsForScreen$1$1$emit$1) continuation;
                    int i = screenConfigRepository$getRowsForScreen$1$1$emit$1.label;
                    if ((i & Integer.MIN_VALUE) != 0) {
                        screenConfigRepository$getRowsForScreen$1$1$emit$1.label = i - Integer.MIN_VALUE;
                    } else {
                        screenConfigRepository$getRowsForScreen$1$1$emit$1 = new ScreenConfigRepository$getRowsForScreen$1$1$emit$1(this, continuation);
                    }
                }
                Object rowCountForProfile = screenConfigRepository$getRowsForScreen$1$1$emit$1.result;
                ck1 ck1Var = ck1.a;
                int i2 = screenConfigRepository$getRowsForScreen$1$1$emit$1.label;
                e6a e6aVar = e6a.a;
                if (i2 == 0) {
                    s38.b(rowCountForProfile);
                    if (list.isEmpty() && !cr4.b(this.$profileSlug, ScreenConfigRepository.DEFAULT_PROFILE)) {
                        RowConfigDao rowConfigDao = this.this$0.rowConfigDao;
                        String str = this.$profileSlug;
                        String key = this.$screen.getKey();
                        screenConfigRepository$getRowsForScreen$1$1$emit$1.L$0 = this;
                        screenConfigRepository$getRowsForScreen$1$1$emit$1.L$1 = list;
                        screenConfigRepository$getRowsForScreen$1$1$emit$1.label = 1;
                        rowCountForProfile = rowConfigDao.getRowCountForProfile(str, key, screenConfigRepository$getRowsForScreen$1$1$emit$1);
                        if (rowCountForProfile != ck1Var) {
                            c01021 = this;
                        }
                    }
                    c01021 = this;
                    TraktAccountRepository traktAccountRepository = c01021.this$0.traktAccountRepository;
                    screenConfigRepository$getRowsForScreen$1$1$emit$1.L$0 = c01021;
                    screenConfigRepository$getRowsForScreen$1$1$emit$1.L$1 = list;
                    screenConfigRepository$getRowsForScreen$1$1$emit$1.label = 3;
                    rowCountForProfile = traktAccountRepository.getActiveAccount(screenConfigRepository$getRowsForScreen$1$1$emit$1);
                    if (rowCountForProfile != ck1Var) {
                        if (rowCountForProfile != null) {
                        }
                        ArrayList arrayList = new ArrayList();
                        while (r11.hasNext()) {
                        }
                        List listFilterContinueWatchingRows = c01021.this$0.filterContinueWatchingRows(arrayList);
                        l43<List<RowConfigEntity>> l43Var = c01021.$$this$flow;
                        screenConfigRepository$getRowsForScreen$1$1$emit$1.L$0 = null;
                        screenConfigRepository$getRowsForScreen$1$1$emit$1.L$1 = null;
                        screenConfigRepository$getRowsForScreen$1$1$emit$1.label = 4;
                        if (l43Var.emit(listFilterContinueWatchingRows, screenConfigRepository$getRowsForScreen$1$1$emit$1) != ck1Var) {
                        }
                    }
                }
                if (i2 != 1) {
                    if (i2 == 2) {
                        s38.b(rowCountForProfile);
                        return e6aVar;
                    }
                    if (i2 != 3) {
                        if (i2 == 4) {
                            s38.b(rowCountForProfile);
                        }
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    list = (List) screenConfigRepository$getRowsForScreen$1$1$emit$1.L$1;
                    c01021 = (C01021) screenConfigRepository$getRowsForScreen$1$1$emit$1.L$0;
                    s38.b(rowCountForProfile);
                    boolean z = rowCountForProfile != null;
                    ArrayList arrayList2 = new ArrayList();
                    for (T t : list) {
                        if (!((RowConfigEntity) t).getRequiresAuth() || z) {
                            arrayList2.add(t);
                        }
                    }
                    List listFilterContinueWatchingRows2 = c01021.this$0.filterContinueWatchingRows(arrayList2);
                    l43<List<RowConfigEntity>> l43Var2 = c01021.$$this$flow;
                    screenConfigRepository$getRowsForScreen$1$1$emit$1.L$0 = null;
                    screenConfigRepository$getRowsForScreen$1$1$emit$1.L$1 = null;
                    screenConfigRepository$getRowsForScreen$1$1$emit$1.label = 4;
                    return l43Var2.emit(listFilterContinueWatchingRows2, screenConfigRepository$getRowsForScreen$1$1$emit$1) != ck1Var ? ck1Var : e6aVar;
                }
                list = (List) screenConfigRepository$getRowsForScreen$1$1$emit$1.L$1;
                c01021 = (C01021) screenConfigRepository$getRowsForScreen$1$1$emit$1.L$0;
                s38.b(rowCountForProfile);
                if (((Number) rowCountForProfile).intValue() == 0) {
                    Log.w(ScreenConfigRepository.TAG, n41.o("No rows for profile ", c01021.$profileSlug, " on ", c01021.$screen.getKey(), ", re-initializing defaults"));
                    ScreenConfigRepository screenConfigRepository = c01021.this$0;
                    String str2 = c01021.$profileSlug;
                    screenConfigRepository$getRowsForScreen$1$1$emit$1.L$0 = null;
                    screenConfigRepository$getRowsForScreen$1$1$emit$1.L$1 = null;
                    screenConfigRepository$getRowsForScreen$1$1$emit$1.label = 2;
                    if (screenConfigRepository.initializeDefaultsForProfile(str2, screenConfigRepository$getRowsForScreen$1$1$emit$1) != ck1Var) {
                        return e6aVar;
                    }
                } else {
                    TraktAccountRepository traktAccountRepository2 = c01021.this$0.traktAccountRepository;
                    screenConfigRepository$getRowsForScreen$1$1$emit$1.L$0 = c01021;
                    screenConfigRepository$getRowsForScreen$1$1$emit$1.L$1 = list;
                    screenConfigRepository$getRowsForScreen$1$1$emit$1.label = 3;
                    rowCountForProfile = traktAccountRepository2.getActiveAccount(screenConfigRepository$getRowsForScreen$1$1$emit$1);
                    if (rowCountForProfile != ck1Var) {
                    }
                }
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C03901(ScreenType screenType, Continuation<? super C03901> continuation) {
            super(2, continuation);
            this.$screen = screenType;
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Continuation<e6a> create(Object obj, Continuation<?> continuation) {
            C03901 c03901 = ScreenConfigRepository.this.new C03901(this.$screen, continuation);
            c03901.L$0 = obj;
            return c03901;
        }

        @Override // defpackage.gr3
        public final Object invoke(l43<? super List<RowConfigEntity>> l43Var, Continuation<? super e6a> continuation) {
            return ((C03901) create(l43Var, continuation)).invokeSuspend(e6a.a);
        }

        /* JADX WARN: Code restructure failed: missing block: B:14:0x0059, code lost:
        
            if (r3.collect(r4, r7) == r0) goto L15;
         */
        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Object invokeSuspend(Object obj) {
            l43 l43Var;
            ck1 ck1Var = ck1.a;
            int i = this.label;
            if (i == 0) {
                s38.b(obj);
                l43Var = (l43) this.L$0;
                ScreenConfigRepository screenConfigRepository = ScreenConfigRepository.this;
                this.L$0 = l43Var;
                this.label = 1;
                obj = screenConfigRepository.getCurrentProfileSlug(this);
                if (obj != ck1Var) {
                }
                return ck1Var;
            }
            if (i != 1) {
                if (i != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                return e6a.a;
            }
            l43Var = (l43) this.L$0;
            s38.b(obj);
            String str = (String) obj;
            j43<List<RowConfigEntity>> enabledRowsForProfile = ScreenConfigRepository.this.rowConfigDao.getEnabledRowsForProfile(str, this.$screen.getKey());
            C01021 c01021 = new C01021(str, ScreenConfigRepository.this, this.$screen, l43Var);
            this.L$0 = null;
            this.label = 2;
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$initializeDefaults$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 1, 2, 3}, l = {293, 296, 298, 303, StatusLine.HTTP_PERM_REDIRECT}, m = "initializeDefaults", n = {"this", "this", "this", "this"}, s = {"L$0", "L$0", "L$0", "L$0"})
    public static final class C03911 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C03911(Continuation<? super C03911> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.initializeDefaults(this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$initializeDefaultsForProfile$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 0, 1, 1}, l = {328, 332, 336}, m = "initializeDefaultsForProfile", n = {"this", "profileSlug", "profileSlug", "defaultRows"}, s = {"L$0", "L$1", "L$0", "L$1"})
    public static final class C03921 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C03921(Continuation<? super C03921> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.initializeDefaultsForProfile(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$insertMissingDefaultRowsForProfile$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 0}, l = {366, 372}, m = "insertMissingDefaultRowsForProfile", n = {"this", "profileSlug"}, s = {"L$0", "L$1"})
    public static final class C03931 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C03931(Continuation<? super C03931> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.insertMissingDefaultRowsForProfile(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$insertRow$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0}, l = {527}, m = "insertRow", n = {"this"}, s = {"L$0"})
    public static final class C03941 extends ContinuationImpl {
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C03941(Continuation<? super C03941> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.insertRow(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$moveRowToPosition$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 0, 0, 0, 1, 1, 1, 2}, l = {468, 469, 481}, m = "moveRowToPosition", n = {"this", "screen", "fromIndex", "toIndex", "this", "fromIndex", "toIndex", "this"}, s = {"L$0", "L$1", "I$0", "I$1", "L$0", "I$0", "I$1", "L$0"})
    public static final class C03951 extends ContinuationImpl {
        int I$0;
        int I$1;
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C03951(Continuation<? super C03951> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.moveRowToPosition(null, 0, 0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$reorderRow$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0}, l = {215}, m = "reorderRow", n = {"this"}, s = {"L$0"})
    public static final class C03961 extends ContinuationImpl {
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C03961(Continuation<? super C03961> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.reorderRow(null, 0, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$reorderRowsByIds$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 0, 0, 1, 1, 2}, l = {496, 497, 515}, m = "reorderRowsByIds", n = {"this", "screen", "orderedIds", "this", "orderedIds", "this"}, s = {"L$0", "L$1", "L$2", "L$0", "L$1", "L$0"})
    public static final class C03971 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        int label;
        /* synthetic */ Object result;

        public C03971(Continuation<? super C03971> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.reorderRowsByIds(null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$resetScreenToDefaults$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4}, l = {229, 235, 241, 246, 251}, m = "resetScreenToDefaults", n = {"this", "screen", "this", "screen", "profileSlug", "defaultRows", "this", "screen", "profileSlug", "defaultRows", "this", "screen", "profileSlug", "remainingRowIds", "this"}, s = {"L$0", "L$1", "L$0", "L$1", "L$2", "L$3", "L$0", "L$1", "L$2", "L$3", "L$0", "L$1", "L$2", "L$3", "L$0"})
    public static final class C03981 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        Object L$4;
        int label;
        /* synthetic */ Object result;

        public C03981(Continuation<? super C03981> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.resetScreenToDefaults(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$swapRowPositions$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 0, 0, 1, 1, 1, 2, 2, 2, 3}, l = {438, 444, 451, 452}, m = "swapRowPositions", n = {"this", "rowId1", "rowId2", "this", "rowId2", "row1", "this", "row2", "tempPosition", "this"}, s = {"L$0", "L$1", "L$2", "L$0", "L$1", "L$2", "L$0", "L$1", "I$0", "L$0"})
    public static final class C03991 extends ContinuationImpl {
        int I$0;
        Object L$0;
        Object L$1;
        Object L$2;
        int label;
        /* synthetic */ Object result;

        public C03991(Continuation<? super C03991> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.swapRowPositions(null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$syncDeletedDefaultsFromCloudRestore$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 0}, l = {347}, m = "syncDeletedDefaultsFromCloudRestore", n = {"this", "profileSlug"}, s = {"L$0", "L$1"})
    public static final class C04001 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        int label;
        /* synthetic */ Object result;

        public C04001(Continuation<? super C04001> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.syncDeletedDefaultsFromCloudRestore(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$toggleRowVisibility$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0}, l = {205}, m = "toggleRowVisibility", n = {"this"}, s = {"L$0"})
    public static final class C04011 extends ContinuationImpl {
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C04011(Continuation<? super C04011> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.toggleRowVisibility(null, false, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$triggerCloudSync$1, reason: invalid class name and case insensitive filesystem */
    @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.data.repository.ScreenConfigRepository$triggerCloudSync$1", f = "ScreenConfigRepository.kt", i = {}, l = {612}, m = "invokeSuspend", n = {}, s = {})
    public static final class C04021 extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
        final /* synthetic */ String $accessToken;
        int label;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C04021(String str, Continuation<? super C04021> continuation) {
            super(2, continuation);
            this.$accessToken = str;
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Continuation<e6a> create(Object obj, Continuation<?> continuation) {
            return ScreenConfigRepository.this.new C04021(this.$accessToken, continuation);
        }

        @Override // defpackage.gr3
        public final Object invoke(ak1 ak1Var, Continuation<? super e6a> continuation) {
            return ((C04021) create(ak1Var, continuation)).invokeSuspend(e6a.a);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Object invokeSuspend(Object obj) {
            ck1 ck1Var = ck1.a;
            int i = this.label;
            try {
                if (i == 0) {
                    s38.b(obj);
                    SettingsSyncManager settingsSyncManager = (SettingsSyncManager) ScreenConfigRepository.this.settingsSyncManager.get();
                    this.label = 1;
                    if (settingsSyncManager.l(this) == ck1Var) {
                        return ck1Var;
                    }
                } else {
                    if (i != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    s38.b(obj);
                }
            } catch (Exception e) {
                Log.w(ScreenConfigRepository.TAG, "Row config cloud sync failed", e);
            }
            return e6a.a;
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$updateRow$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0}, l = {398}, m = "updateRow", n = {"this"}, s = {"L$0"})
    public static final class C04031 extends ContinuationImpl {
        Object L$0;
        int label;
        /* synthetic */ Object result;

        public C04031(Continuation<? super C04031> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.updateRow(null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$updateRowPresentation$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 0, 0, 1}, l = {555, 560}, m = "updateRowPresentation", n = {"this", "rowId", "presentation", "this"}, s = {"L$0", "L$1", "L$2", "L$0"})
    public static final class C04041 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        int label;
        /* synthetic */ Object result;

        public C04041(Continuation<? super C04041> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.updateRowPresentation(null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$updateRowSort$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 0, 0, 0, 1}, l = {590, 595}, m = "updateRowSort", n = {"this", "rowId", "sortBy", "sortHow", "this"}, s = {"L$0", "L$1", "L$2", "L$3", "L$0"})
    public static final class C04051 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        Object L$3;
        int label;
        /* synthetic */ Object result;

        public C04051(Continuation<? super C04051> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.updateRowSort(null, null, null, this);
        }
    }

    /* JADX INFO: renamed from: com.strmr.ps.data.repository.ScreenConfigRepository$updateRowTitle$1, reason: invalid class name and case insensitive filesystem */
    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    @DebugMetadata(c = "com.strmr.ps.data.repository.ScreenConfigRepository", f = "ScreenConfigRepository.kt", i = {0, 0, 0, 1}, l = {572, 577}, m = "updateRowTitle", n = {"this", "rowId", "title", "this"}, s = {"L$0", "L$1", "L$2", "L$0"})
    public static final class C04061 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        Object L$2;
        int label;
        /* synthetic */ Object result;

        public C04061(Continuation<? super C04061> continuation) {
            super(continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @pq6
        public final Object invokeSuspend(@kp6 Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return ScreenConfigRepository.this.updateRowTitle(null, null, this);
        }
    }

    @Inject
    public ScreenConfigRepository(@kp6 RowConfigDao rowConfigDao, @kp6 TraktAccountRepository traktAccountRepository, @kp6 PreferencesRepository preferencesRepository, @ApplicationContext @kp6 Context context, @kp6 Lazy<SettingsSyncManager> lazy, @kp6 Lazy<DeviceManager> lazy2) {
        cr4.g(rowConfigDao, "rowConfigDao");
        cr4.g(traktAccountRepository, "traktAccountRepository");
        cr4.g(preferencesRepository, "preferencesRepository");
        cr4.g(context, "context");
        cr4.g(lazy, "settingsSyncManager");
        cr4.g(lazy2, "deviceManager");
        this.rowConfigDao = rowConfigDao;
        this.traktAccountRepository = traktAccountRepository;
        this.preferencesRepository = preferencesRepository;
        this.context = context;
        this.settingsSyncManager = lazy;
        this.deviceManager = lazy2;
        m12 m12Var = sc2.a;
        this.syncScope = bk1.a(m02.c);
        SharedPreferences sharedPreferences = context.getSharedPreferences(PREFS_NAME, 0);
        cr4.f(sharedPreferences, "getSharedPreferences(...)");
        this.prefs = sharedPreferences;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object backfillTitleResKeys(Continuation<? super e6a> continuation) {
        AnonymousClass1 anonymousClass1;
        ScreenConfigRepository screenConfigRepository;
        Iterator it;
        if (continuation instanceof AnonymousClass1) {
            anonymousClass1 = (AnonymousClass1) continuation;
            int i = anonymousClass1.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                anonymousClass1.label = i - Integer.MIN_VALUE;
            } else {
                anonymousClass1 = new AnonymousClass1(continuation);
            }
        }
        Object obj = anonymousClass1.result;
        ck1 ck1Var = ck1.a;
        int i2 = anonymousClass1.label;
        if (i2 == 0) {
            s38.b(obj);
            screenConfigRepository = this;
            it = y41.au(k12.c, y41.au(k12.b, k12.a)).iterator();
        } else {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            it = (Iterator) anonymousClass1.L$1;
            screenConfigRepository = (ScreenConfigRepository) anonymousClass1.L$0;
            s38.b(obj);
        }
        while (it.hasNext()) {
            RowConfigEntity rowConfigEntity = (RowConfigEntity) it.next();
            String titleResKey = rowConfigEntity.getTitleResKey();
            if (titleResKey != null) {
                RowConfigDao rowConfigDao = screenConfigRepository.rowConfigDao;
                String id = rowConfigEntity.getId();
                anonymousClass1.L$0 = screenConfigRepository;
                anonymousClass1.L$1 = it;
                anonymousClass1.label = 1;
                if (rowConfigDao.backfillTitleResKey(id, titleResKey, anonymousClass1) == ck1Var) {
                    return ck1Var;
                }
            }
        }
        return e6a.a;
    }

    public static /* synthetic */ Object checkRowLimits$default(ScreenConfigRepository screenConfigRepository, String str, int i, String str2, Continuation continuation, int i2, Object obj) {
        if ((i2 & 4) != 0) {
            str2 = null;
        }
        return screenConfigRepository.checkRowLimits(str, i, str2, continuation);
    }

    private final void clearDeletedDefaultRows() {
        this.prefs.edit().remove(KEY_DELETED_DEFAULT_ROWS).apply();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final List<RowConfigEntity> filterContinueWatchingRows(List<RowConfigEntity> rows) {
        boolean separateContinueWatching = this.preferencesRepository.getSeparateContinueWatching();
        ArrayList arrayList = new ArrayList();
        for (Object obj : rows) {
            String rowType = ((RowConfigEntity) obj).getRowType();
            int iHashCode = rowType.hashCode();
            boolean z = true;
            if (iHashCode != -1439908533) {
                z = iHashCode != -617583433 ? separateContinueWatching : separateContinueWatching;
            } else if (rowType.equals("continue_watching") && separateContinueWatching) {
                z = false;
            }
            if (z) {
                arrayList.add(obj);
            }
        }
        return arrayList;
    }

    private final List<RowConfigEntity> getAllDefaultRowsForProfile(String profileSlug) {
        ArrayList<RowConfigEntity> arrayList = k12.d;
        ArrayList arrayList2 = new ArrayList(y41.p(arrayList, 10));
        for (RowConfigEntity rowConfigEntity : arrayList) {
            arrayList2.add(RowConfigEntity.copy$default(rowConfigEntity, vw2.l(rowConfigEntity.getId(), "_", profileSlug), profileSlug, null, null, null, null, null, null, 0, 0, false, false, 0, false, null, null, null, 131068, null));
        }
        return arrayList2;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object getCurrentProfileSlug(Continuation<? super String> continuation) {
        C03871 c03871;
        String userSlug;
        if (continuation instanceof C03871) {
            c03871 = (C03871) continuation;
            int i = c03871.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c03871.label = i - Integer.MIN_VALUE;
            } else {
                c03871 = new C03871(continuation);
            }
        }
        Object activeAccount = c03871.result;
        ck1 ck1Var = ck1.a;
        int i2 = c03871.label;
        if (i2 == 0) {
            s38.b(activeAccount);
            TraktAccountRepository traktAccountRepository = this.traktAccountRepository;
            c03871.label = 1;
            activeAccount = traktAccountRepository.getActiveAccount(c03871);
            if (activeAccount == ck1Var) {
                return ck1Var;
            }
        } else {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(activeAccount);
        }
        TraktAccount traktAccount = (TraktAccount) activeAccount;
        return (traktAccount == null || (userSlug = traktAccount.getUserSlug()) == null) ? DEFAULT_PROFILE : userSlug;
    }

    private final List<RowConfigEntity> getDefaultRowsForProfile(String profileSlug, ScreenType screen) {
        List list;
        int i = WhenMappings.$EnumSwitchMapping$0[screen.ordinal()];
        if (i == 1) {
            List list2 = k12.a;
            list = k12.a;
        } else if (i == 2) {
            List list3 = k12.a;
            list = k12.b;
        } else {
            if (i != 3) {
                throw new io6();
            }
            List list4 = k12.a;
            list = k12.c;
        }
        List<RowConfigEntity> list5 = list;
        ArrayList arrayList = new ArrayList(y41.p(list5, 10));
        for (RowConfigEntity rowConfigEntity : list5) {
            arrayList.add(RowConfigEntity.copy$default(rowConfigEntity, vw2.l(rowConfigEntity.getId(), "_", profileSlug), profileSlug, null, null, null, null, null, null, 0, 0, false, false, 0, false, null, null, null, 131068, null));
        }
        return arrayList;
    }

    private final Set<String> getDeletedDefaultRowIds() {
        SharedPreferences sharedPreferences = this.prefs;
        pk2 pk2Var = pk2.a;
        Set<String> stringSet = sharedPreferences.getStringSet(KEY_DELETED_DEFAULT_ROWS, pk2Var);
        return stringSet == null ? pk2Var : stringSet;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object insertMissingDefaultRowsForProfile(String str, Continuation<? super e6a> continuation) {
        C03931 c03931;
        ScreenConfigRepository screenConfigRepository;
        if (continuation instanceof C03931) {
            c03931 = (C03931) continuation;
            int i = c03931.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c03931.label = i - Integer.MIN_VALUE;
            } else {
                c03931 = new C03931(continuation);
            }
        }
        Object allRowIdsForProfile = c03931.result;
        ck1 ck1Var = ck1.a;
        int i2 = c03931.label;
        e6a e6aVar = e6a.a;
        if (i2 == 0) {
            s38.b(allRowIdsForProfile);
            RowConfigDao rowConfigDao = this.rowConfigDao;
            c03931.L$0 = this;
            c03931.L$1 = str;
            c03931.label = 1;
            allRowIdsForProfile = rowConfigDao.getAllRowIdsForProfile(str, c03931);
            if (allRowIdsForProfile != ck1Var) {
                screenConfigRepository = this;
            }
            return ck1Var;
        }
        if (i2 != 1) {
            if (i2 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(allRowIdsForProfile);
            return e6aVar;
        }
        str = (String) c03931.L$1;
        screenConfigRepository = (ScreenConfigRepository) c03931.L$0;
        s38.b(allRowIdsForProfile);
        Set setBr = y41.br((Iterable) allRowIdsForProfile);
        Set<String> deletedDefaultRowIds = screenConfigRepository.getDeletedDefaultRowIds();
        List<RowConfigEntity> allDefaultRowsForProfile = screenConfigRepository.getAllDefaultRowsForProfile(str);
        ArrayList arrayList = new ArrayList();
        for (Object obj : allDefaultRowsForProfile) {
            RowConfigEntity rowConfigEntity = (RowConfigEntity) obj;
            if (!setBr.contains(rowConfigEntity.getId()) && !deletedDefaultRowIds.contains(rowConfigEntity.getId())) {
                arrayList.add(obj);
            }
        }
        if (!arrayList.isEmpty()) {
            arrayList.size();
            ArrayList arrayList2 = new ArrayList(y41.p(arrayList, 10));
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                arrayList2.add(((RowConfigEntity) it.next()).getId());
            }
            arrayList2.toString();
            RowConfigDao rowConfigDao2 = screenConfigRepository.rowConfigDao;
            c03931.L$0 = null;
            c03931.L$1 = null;
            c03931.label = 2;
            if (rowConfigDao2.insertAll(arrayList, c03931) == ck1Var) {
                return ck1Var;
            }
        }
        return e6aVar;
    }

    private final void markDefaultRowDeleted(String rowId) {
        SharedPreferences sharedPreferences = this.prefs;
        Set<String> set = pk2.a;
        Set<String> stringSet = sharedPreferences.getStringSet(KEY_DELETED_DEFAULT_ROWS, set);
        if (stringSet != null) {
            set = stringSet;
        }
        this.prefs.edit().putStringSet(KEY_DELETED_DEFAULT_ROWS, km8.g(set, rowId)).apply();
    }

    private final void triggerCloudSync() {
        String strE = this.deviceManager.get().e();
        if (strE == null) {
            return;
        }
        wj0.c(this.syncScope, null, null, new C04021(strE, null), 3);
    }

    /* JADX WARN: Code restructure failed: missing block: B:44:0x00e6, code lost:
    
        if (r12 == r1) goto L45;
     */
    /* JADX WARN: Removed duplicated region for block: B:38:0x00c5  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x00d1  */
    /* JADX WARN: Removed duplicated region for block: B:43:0x00da  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object checkRowLimits(@kp6 String str, int i, @pq6 String str2, @kp6 Continuation<? super String> continuation) {
        C03821 c03821;
        int i2;
        ScreenConfigRepository screenConfigRepository;
        ScreenConfigRepository screenConfigRepository2;
        int i3;
        String strName;
        int iIntValue;
        if (continuation instanceof C03821) {
            c03821 = (C03821) continuation;
            int i4 = c03821.label;
            if ((i4 & Integer.MIN_VALUE) != 0) {
                c03821.label = i4 - Integer.MIN_VALUE;
            } else {
                c03821 = new C03821(continuation);
            }
        }
        Object rowCountForProfile = c03821.result;
        ck1 ck1Var = ck1.a;
        int i5 = c03821.label;
        if (i5 == 0) {
            s38.b(rowCountForProfile);
            if (str2 != null) {
                RowConfigDao rowConfigDao = this.rowConfigDao;
                c03821.L$0 = this;
                c03821.L$1 = str;
                c03821.L$2 = str2;
                c03821.I$0 = i;
                c03821.label = 1;
                rowCountForProfile = rowConfigDao.getRowCountForProfile(str, str2, c03821);
                if (rowCountForProfile != ck1Var) {
                    screenConfigRepository2 = this;
                }
                return ck1Var;
            }
            i2 = i;
            screenConfigRepository = this;
            RowConfigDao rowConfigDao2 = screenConfigRepository.rowConfigDao;
            c03821.L$0 = screenConfigRepository;
            c03821.L$1 = null;
            c03821.L$2 = null;
            c03821.I$0 = i2;
            c03821.label = 2;
            rowCountForProfile = rowConfigDao2.getRowCountForProfileTotal(str, c03821);
            if (rowCountForProfile != ck1Var) {
                i3 = i2;
                iIntValue = ((Number) rowCountForProfile).intValue() + i3;
                if (iIntValue <= 400) {
                }
            }
            return ck1Var;
        }
        if (i5 == 1) {
            i = c03821.I$0;
            str2 = (String) c03821.L$2;
            str = (String) c03821.L$1;
            screenConfigRepository2 = (ScreenConfigRepository) c03821.L$0;
            s38.b(rowCountForProfile);
        } else {
            if (i5 != 2) {
                if (i5 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                i3 = c03821.I$0;
                s38.b(rowCountForProfile);
                int iIntValue2 = ((Number) rowCountForProfile).intValue() + i3;
                if (iIntValue2 > 600) {
                    return n41.i(iIntValue2, "Total rows would be ", " (limit: 600). Remove some rows first.");
                }
                return null;
            }
            i3 = c03821.I$0;
            screenConfigRepository = (ScreenConfigRepository) c03821.L$0;
            s38.b(rowCountForProfile);
            iIntValue = ((Number) rowCountForProfile).intValue() + i3;
            if (iIntValue <= 400) {
                return n41.i(iIntValue, "Profile would have ", " rows (limit: 400). Remove some rows first.");
            }
            RowConfigDao rowConfigDao3 = screenConfigRepository.rowConfigDao;
            c03821.L$0 = null;
            c03821.I$0 = i3;
            c03821.label = 3;
            rowCountForProfile = rowConfigDao3.getTotalRowCount(c03821);
        }
        int iIntValue3 = ((Number) rowCountForProfile).intValue();
        if (iIntValue3 + i > 100) {
            ScreenType screenTypeFromKey = ScreenType.INSTANCE.fromKey(str2);
            if (screenTypeFromKey != null && (strName = screenTypeFromKey.name()) != null) {
                str2 = n89.an(strName, "_", " ");
            }
            return str2 + " page already has " + iIntValue3 + " rows (limit: 100). Remove some rows first.";
        }
        i2 = i;
        screenConfigRepository = screenConfigRepository2;
        RowConfigDao rowConfigDao22 = screenConfigRepository.rowConfigDao;
        c03821.L$0 = screenConfigRepository;
        c03821.L$1 = null;
        c03821.L$2 = null;
        c03821.I$0 = i2;
        c03821.label = 2;
        rowCountForProfile = rowConfigDao22.getRowCountForProfileTotal(str, c03821);
        if (rowCountForProfile != ck1Var) {
        }
        return ck1Var;
    }

    /* JADX WARN: Code restructure failed: missing block: B:48:0x0149, code lost:
    
        if (r14 == r1) goto L49;
     */
    /* JADX WARN: Removed duplicated region for block: B:21:0x0078  */
    /* JADX WARN: Removed duplicated region for block: B:27:0x00b8  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x00e8  */
    /* JADX WARN: Removed duplicated region for block: B:35:0x00ed  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x0134  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x013d  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:24:0x00a6 -> B:25:0x00ad). Please report as a decompilation issue!!! */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object checkRowLimitsByScreen(@kp6 String str, @kp6 Map<String, Integer> map, @kp6 Continuation<? super String> continuation) {
        C03831 c03831;
        Iterator<Map.Entry<String, Integer>> it;
        ScreenConfigRepository screenConfigRepository;
        ScreenConfigRepository screenConfigRepository2;
        int i;
        String strName;
        int iIntValue;
        if (continuation instanceof C03831) {
            c03831 = (C03831) continuation;
            int i2 = c03831.label;
            if ((i2 & Integer.MIN_VALUE) != 0) {
                c03831.label = i2 - Integer.MIN_VALUE;
            } else {
                c03831 = new C03831(continuation);
            }
        }
        Object totalRowCount = c03831.result;
        ck1 ck1Var = ck1.a;
        int i3 = c03831.label;
        if (i3 == 0) {
            s38.b(totalRowCount);
            it = map.entrySet().iterator();
            screenConfigRepository = this;
            if (it.hasNext()) {
            }
            return ck1Var;
        }
        if (i3 == 1) {
            int i4 = c03831.I$0;
            String str2 = (String) c03831.L$4;
            Iterator<Map.Entry<String, Integer>> it2 = (Iterator) c03831.L$3;
            Map<String, Integer> map2 = (Map) c03831.L$2;
            String str3 = (String) c03831.L$1;
            ScreenConfigRepository screenConfigRepository3 = (ScreenConfigRepository) c03831.L$0;
            s38.b(totalRowCount);
            String strAn = str2;
            map = map2;
            Iterator<Map.Entry<String, Integer>> it3 = it2;
            C03831 c038312 = c03831;
            ScreenConfigRepository screenConfigRepository4 = screenConfigRepository3;
            Object rowCountForProfile = totalRowCount;
            int iIntValue2 = ((Number) rowCountForProfile).intValue() + i4;
            if (iIntValue2 <= 100) {
                ScreenType screenTypeFromKey = ScreenType.INSTANCE.fromKey(strAn);
                if (screenTypeFromKey != null && (strName = screenTypeFromKey.name()) != null) {
                    strAn = n89.an(strName, "_", " ");
                }
                return strAn + " page would have " + iIntValue2 + " rows (limit: 100). Remove some rows first.";
            }
            screenConfigRepository = screenConfigRepository4;
            c03831 = c038312;
            it = it3;
            str = str3;
            if (it.hasNext()) {
                Collection<Integer> collectionValues = map.values();
                cr4.g(collectionValues, "<this>");
                Iterator<T> it4 = collectionValues.iterator();
                int iIntValue3 = 0;
                while (it4.hasNext()) {
                    iIntValue3 += ((Number) it4.next()).intValue();
                }
                RowConfigDao rowConfigDao = screenConfigRepository.rowConfigDao;
                c03831.L$0 = screenConfigRepository;
                c03831.L$1 = null;
                c03831.L$2 = null;
                c03831.L$3 = null;
                c03831.L$4 = null;
                c03831.I$0 = iIntValue3;
                c03831.label = 2;
                Object rowCountForProfileTotal = rowConfigDao.getRowCountForProfileTotal(str, c03831);
                if (rowCountForProfileTotal != ck1Var) {
                    screenConfigRepository2 = screenConfigRepository;
                    totalRowCount = rowCountForProfileTotal;
                    i = iIntValue3;
                    iIntValue = ((Number) totalRowCount).intValue() + i;
                    if (iIntValue <= 400) {
                    }
                }
            } else {
                Map.Entry<String, Integer> next = it.next();
                String key = next.getKey();
                int iIntValue4 = next.getValue().intValue();
                RowConfigDao rowConfigDao2 = screenConfigRepository.rowConfigDao;
                c03831.L$0 = screenConfigRepository;
                c03831.L$1 = str;
                c03831.L$2 = map;
                c03831.L$3 = it;
                c03831.L$4 = key;
                c03831.I$0 = iIntValue4;
                c03831.label = 1;
                rowCountForProfile = rowConfigDao2.getRowCountForProfile(str, key, c03831);
                if (rowCountForProfile != ck1Var) {
                    str3 = str;
                    i4 = iIntValue4;
                    it3 = it;
                    c038312 = c03831;
                    screenConfigRepository4 = screenConfigRepository;
                    strAn = key;
                    int iIntValue22 = ((Number) rowCountForProfile).intValue() + i4;
                    if (iIntValue22 <= 100) {
                    }
                }
            }
            return ck1Var;
        }
        if (i3 != 2) {
            if (i3 != 3) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            i = c03831.I$0;
            s38.b(totalRowCount);
            int iIntValue5 = ((Number) totalRowCount).intValue() + i;
            if (iIntValue5 > 600) {
                return n41.i(iIntValue5, "Total rows would be ", " (limit: 600). Remove some rows first.");
            }
            return null;
        }
        i = c03831.I$0;
        screenConfigRepository2 = (ScreenConfigRepository) c03831.L$0;
        s38.b(totalRowCount);
        iIntValue = ((Number) totalRowCount).intValue() + i;
        if (iIntValue <= 400) {
            return n41.i(iIntValue, "Profile would have ", " rows (limit: 400). Remove some rows first.");
        }
        RowConfigDao rowConfigDao3 = screenConfigRepository2.rowConfigDao;
        c03831.L$0 = null;
        c03831.I$0 = i;
        c03831.label = 3;
        totalRowCount = rowConfigDao3.getTotalRowCount(c03831);
    }

    /* JADX WARN: Code restructure failed: missing block: B:32:0x009a, code lost:
    
        if (r2.deleteNonSystemRow(r8, r0) == r1) goto L33;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object deleteRow(@kp6 String str, @kp6 Continuation<? super e6a> continuation) {
        C03841 c03841;
        Object obj;
        String str2;
        ScreenConfigRepository screenConfigRepository;
        if (continuation instanceof C03841) {
            c03841 = (C03841) continuation;
            int i = c03841.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c03841.label = i - Integer.MIN_VALUE;
            } else {
                c03841 = new C03841(continuation);
            }
        }
        Object obj2 = c03841.result;
        ck1 ck1Var = ck1.a;
        int i2 = c03841.label;
        if (i2 == 0) {
            s38.b(obj2);
            c03841.L$0 = this;
            c03841.L$1 = str;
            c03841.label = 1;
            Object currentProfileSlug = getCurrentProfileSlug(c03841);
            if (currentProfileSlug != ck1Var) {
                obj = currentProfileSlug;
                str2 = str;
                screenConfigRepository = this;
            }
            return ck1Var;
        }
        if (i2 != 1) {
            if (i2 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            screenConfigRepository = (ScreenConfigRepository) c03841.L$0;
            s38.b(obj2);
            screenConfigRepository.triggerCloudSync();
            return e6a.a;
        }
        String str3 = (String) c03841.L$1;
        ScreenConfigRepository screenConfigRepository2 = (ScreenConfigRepository) c03841.L$0;
        s38.b(obj2);
        str2 = str3;
        screenConfigRepository = screenConfigRepository2;
        obj = obj2;
        List<RowConfigEntity> allDefaultRowsForProfile = screenConfigRepository.getAllDefaultRowsForProfile((String) obj);
        if (!(allDefaultRowsForProfile instanceof Collection) || !allDefaultRowsForProfile.isEmpty()) {
            Iterator<T> it = allDefaultRowsForProfile.iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                if (cr4.b(((RowConfigEntity) it.next()).getId(), str2)) {
                    screenConfigRepository.markDefaultRowDeleted(str2);
                    break;
                }
            }
        }
        RowConfigDao rowConfigDao = screenConfigRepository.rowConfigDao;
        c03841.L$0 = screenConfigRepository;
        c03841.L$1 = null;
        c03841.label = 2;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object deleteRowsForProfile(@kp6 String str, @kp6 Continuation<? super e6a> continuation) {
        C03851 c03851;
        if (continuation instanceof C03851) {
            c03851 = (C03851) continuation;
            int i = c03851.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c03851.label = i - Integer.MIN_VALUE;
            } else {
                c03851 = new C03851(continuation);
            }
        }
        Object obj = c03851.result;
        ck1 ck1Var = ck1.a;
        int i2 = c03851.label;
        if (i2 == 0) {
            s38.b(obj);
            RowConfigDao rowConfigDao = this.rowConfigDao;
            c03851.L$0 = str;
            c03851.label = 1;
            if (rowConfigDao.deleteAllRowsForProfile(str, c03851) == ck1Var) {
                return ck1Var;
            }
        } else {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(obj);
        }
        return e6a.a;
    }

    @kp6
    public final j43<List<RowConfigEntity>> getAllRowsForSettings(@kp6 ScreenType screen) {
        cr4.g(screen, "screen");
        return k63.n(new C03861(screen, null));
    }

    /* JADX WARN: Code restructure failed: missing block: B:21:0x0066, code lost:
    
        if (r8 == r1) goto L22;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object getNextPosition(@kp6 ScreenType screenType, @kp6 Continuation<? super Integer> continuation) {
        C03881 c03881;
        ScreenConfigRepository screenConfigRepository;
        if (continuation instanceof C03881) {
            c03881 = (C03881) continuation;
            int i = c03881.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c03881.label = i - Integer.MIN_VALUE;
            } else {
                c03881 = new C03881(continuation);
            }
        }
        Object currentProfileSlug = c03881.result;
        ck1 ck1Var = ck1.a;
        int i2 = c03881.label;
        Integer num = null;
        if (i2 == 0) {
            s38.b(currentProfileSlug);
            c03881.L$0 = this;
            c03881.L$1 = screenType;
            c03881.label = 1;
            currentProfileSlug = getCurrentProfileSlug(c03881);
            if (currentProfileSlug != ck1Var) {
                screenConfigRepository = this;
            }
            return ck1Var;
        }
        if (i2 != 1) {
            if (i2 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(currentProfileSlug);
            Iterator it = ((List) currentProfileSlug).iterator();
            if (it.hasNext()) {
                Integer numBoxInt = Boxing.boxInt(((RowConfigEntity) it.next()).getPosition());
                loop0: while (true) {
                    num = numBoxInt;
                    while (it.hasNext()) {
                        numBoxInt = Boxing.boxInt(((RowConfigEntity) it.next()).getPosition());
                        if (num.compareTo(numBoxInt) < 0) {
                            break;
                        }
                    }
                }
            }
            return Boxing.boxInt((num != null ? num.intValue() : -1) + 1);
        }
        screenType = (ScreenType) c03881.L$1;
        screenConfigRepository = (ScreenConfigRepository) c03881.L$0;
        s38.b(currentProfileSlug);
        j43<List<RowConfigEntity>> allRowsForProfile = screenConfigRepository.rowConfigDao.getAllRowsForProfile((String) currentProfileSlug, screenType.getKey());
        c03881.L$0 = null;
        c03881.L$1 = null;
        c03881.label = 2;
        currentProfileSlug = k63.k(allRowsForProfile, c03881);
    }

    @pq6
    public final Object getProfileSlugForNewRow(@kp6 Continuation<? super String> continuation) {
        return getCurrentProfileSlug(continuation);
    }

    @pq6
    public final Object getRowById(@kp6 String str, @kp6 Continuation<? super RowConfigEntity> continuation) {
        return this.rowConfigDao.getRowById(str, continuation);
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object getRowCount(@kp6 ScreenType screenType, @kp6 Continuation<? super Integer> continuation) {
        C03891 c03891;
        ScreenConfigRepository screenConfigRepository;
        if (continuation instanceof C03891) {
            c03891 = (C03891) continuation;
            int i = c03891.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c03891.label = i - Integer.MIN_VALUE;
            } else {
                c03891 = new C03891(continuation);
            }
        }
        Object currentProfileSlug = c03891.result;
        ck1 ck1Var = ck1.a;
        int i2 = c03891.label;
        if (i2 == 0) {
            s38.b(currentProfileSlug);
            c03891.L$0 = this;
            c03891.L$1 = screenType;
            c03891.label = 1;
            currentProfileSlug = getCurrentProfileSlug(c03891);
            if (currentProfileSlug != ck1Var) {
                screenConfigRepository = this;
            }
        }
        if (i2 != 1) {
            if (i2 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(currentProfileSlug);
            return currentProfileSlug;
        }
        screenType = (ScreenType) c03891.L$1;
        screenConfigRepository = (ScreenConfigRepository) c03891.L$0;
        s38.b(currentProfileSlug);
        RowConfigDao rowConfigDao = screenConfigRepository.rowConfigDao;
        String key = screenType.getKey();
        c03891.L$0 = null;
        c03891.L$1 = null;
        c03891.label = 2;
        Object rowCountForProfile = rowConfigDao.getRowCountForProfile((String) currentProfileSlug, key, c03891);
        return rowCountForProfile == ck1Var ? ck1Var : rowCountForProfile;
    }

    @kp6
    public final j43<List<RowConfigEntity>> getRowsForScreen(@kp6 ScreenType screen) {
        cr4.g(screen, "screen");
        return k63.n(new C03901(screen, null));
    }

    /* JADX WARN: Code restructure failed: missing block: B:27:0x007e, code lost:
    
        if (r11 == r1) goto L41;
     */
    /* JADX WARN: Code restructure failed: missing block: B:40:0x00bf, code lost:
    
        if (r2.backfillTitleResKeys(r0) == r1) goto L41;
     */
    /* JADX WARN: Removed duplicated region for block: B:32:0x0090  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x00a7 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object initializeDefaults(@kp6 Continuation<? super e6a> continuation) {
        C03911 c03911;
        ScreenConfigRepository screenConfigRepository;
        Iterator it;
        ScreenConfigRepository screenConfigRepository2;
        ScreenConfigRepository screenConfigRepository3;
        if (continuation instanceof C03911) {
            c03911 = (C03911) continuation;
            int i = c03911.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c03911.label = i - Integer.MIN_VALUE;
            } else {
                c03911 = new C03911(continuation);
            }
        }
        Object allAccountsSync = c03911.result;
        ck1 ck1Var = ck1.a;
        int i2 = c03911.label;
        if (i2 == 0) {
            s38.b(allAccountsSync);
            c03911.L$0 = this;
            c03911.label = 1;
            if (initializeDefaultsForProfile(DEFAULT_PROFILE, c03911) != ck1Var) {
                screenConfigRepository = this;
            }
            return ck1Var;
        }
        if (i2 == 1) {
            screenConfigRepository = (ScreenConfigRepository) c03911.L$0;
            s38.b(allAccountsSync);
        } else {
            if (i2 == 2) {
                screenConfigRepository = (ScreenConfigRepository) c03911.L$0;
                s38.b(allAccountsSync);
                ScreenConfigRepository screenConfigRepository4 = screenConfigRepository;
                it = ((List) allAccountsSync).iterator();
                screenConfigRepository2 = screenConfigRepository4;
                while (true) {
                    if (it.hasNext()) {
                    }
                }
                return ck1Var;
            }
            if (i2 == 3) {
                it = (Iterator) c03911.L$1;
                ScreenConfigRepository screenConfigRepository5 = (ScreenConfigRepository) c03911.L$0;
                s38.b(allAccountsSync);
                screenConfigRepository2 = screenConfigRepository5;
                while (true) {
                    if (it.hasNext()) {
                        RowConfigDao rowConfigDao = screenConfigRepository2.rowConfigDao;
                        c03911.L$0 = screenConfigRepository2;
                        c03911.L$1 = null;
                        c03911.label = 4;
                        if (rowConfigDao.fixTraktListAuthRequirement(c03911) != ck1Var) {
                            screenConfigRepository3 = screenConfigRepository2;
                        }
                    } else {
                        String userSlug = ((TraktAccount) it.next()).getUserSlug();
                        c03911.L$0 = screenConfigRepository2;
                        c03911.L$1 = it;
                        c03911.label = 3;
                        if (screenConfigRepository2.initializeDefaultsForProfile(userSlug, c03911) == ck1Var) {
                            break;
                        }
                    }
                }
                return ck1Var;
            }
            if (i2 != 4) {
                if (i2 != 5) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(allAccountsSync);
                return e6a.a;
            }
            screenConfigRepository3 = (ScreenConfigRepository) c03911.L$0;
            s38.b(allAccountsSync);
            c03911.L$0 = null;
            c03911.label = 5;
        }
        TraktAccountRepository traktAccountRepository = screenConfigRepository.traktAccountRepository;
        c03911.L$0 = screenConfigRepository;
        c03911.label = 2;
        allAccountsSync = traktAccountRepository.getAllAccountsSync(c03911);
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object initializeDefaultsForProfile(@kp6 String str, @kp6 Continuation<? super e6a> continuation) {
        C03921 c03921;
        ScreenConfigRepository screenConfigRepository;
        List<RowConfigEntity> list;
        if (continuation instanceof C03921) {
            c03921 = (C03921) continuation;
            int i = c03921.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c03921.label = i - Integer.MIN_VALUE;
            } else {
                c03921 = new C03921(continuation);
            }
        }
        Object rowCountForProfile = c03921.result;
        ck1 ck1Var = ck1.a;
        int i2 = c03921.label;
        e6a e6aVar = e6a.a;
        if (i2 == 0) {
            s38.b(rowCountForProfile);
            RowConfigDao rowConfigDao = this.rowConfigDao;
            String key = ScreenType.HOME.getKey();
            c03921.L$0 = this;
            c03921.L$1 = str;
            c03921.label = 1;
            rowCountForProfile = rowConfigDao.getRowCountForProfile(str, key, c03921);
            if (rowCountForProfile != ck1Var) {
                screenConfigRepository = this;
            }
            return ck1Var;
        }
        if (i2 != 1) {
            if (i2 != 2) {
                if (i2 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(rowCountForProfile);
                return e6aVar;
            }
            list = (List) c03921.L$1;
            s38.b(rowCountForProfile);
            list.size();
            return e6aVar;
        }
        str = (String) c03921.L$1;
        screenConfigRepository = (ScreenConfigRepository) c03921.L$0;
        s38.b(rowCountForProfile);
        if (((Number) rowCountForProfile).intValue() == 0) {
            List<RowConfigEntity> allDefaultRowsForProfile = screenConfigRepository.getAllDefaultRowsForProfile(str);
            RowConfigDao rowConfigDao2 = screenConfigRepository.rowConfigDao;
            c03921.L$0 = str;
            c03921.L$1 = allDefaultRowsForProfile;
            c03921.label = 2;
            if (rowConfigDao2.insertAll(allDefaultRowsForProfile, c03921) != ck1Var) {
                list = allDefaultRowsForProfile;
                list.size();
                return e6aVar;
            }
        } else {
            c03921.L$0 = null;
            c03921.L$1 = null;
            c03921.label = 3;
            if (screenConfigRepository.insertMissingDefaultRowsForProfile(str, c03921) != ck1Var) {
                return e6aVar;
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object insertRow(@kp6 RowConfigEntity rowConfigEntity, @kp6 Continuation<? super e6a> continuation) {
        C03941 c03941;
        ScreenConfigRepository screenConfigRepository;
        if (continuation instanceof C03941) {
            c03941 = (C03941) continuation;
            int i = c03941.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c03941.label = i - Integer.MIN_VALUE;
            } else {
                c03941 = new C03941(continuation);
            }
        }
        Object obj = c03941.result;
        ck1 ck1Var = ck1.a;
        int i2 = c03941.label;
        if (i2 == 0) {
            s38.b(obj);
            RowConfigDao rowConfigDao = this.rowConfigDao;
            c03941.L$0 = this;
            c03941.label = 1;
            if (rowConfigDao.insert(rowConfigEntity, c03941) == ck1Var) {
                return ck1Var;
            }
            screenConfigRepository = this;
        } else {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            screenConfigRepository = (ScreenConfigRepository) c03941.L$0;
            s38.b(obj);
        }
        screenConfigRepository.triggerCloudSync();
        return e6a.a;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object moveRowToPosition(@kp6 ScreenType screenType, int i, int i2, @kp6 Continuation<? super Boolean> continuation) {
        C03951 c03951;
        ScreenConfigRepository screenConfigRepository;
        int i3;
        ScreenConfigRepository screenConfigRepository2;
        ArrayList arrayListBp;
        ScreenConfigRepository screenConfigRepository3;
        if (continuation instanceof C03951) {
            c03951 = (C03951) continuation;
            int i4 = c03951.label;
            if ((i4 & Integer.MIN_VALUE) != 0) {
                c03951.label = i4 - Integer.MIN_VALUE;
            } else {
                c03951 = new C03951(continuation);
            }
        }
        Object currentProfileSlug = c03951.result;
        ck1 ck1Var = ck1.a;
        int i5 = c03951.label;
        if (i5 == 0) {
            s38.b(currentProfileSlug);
            if (i == i2) {
                return Boxing.boxBoolean(true);
            }
            c03951.L$0 = this;
            c03951.L$1 = screenType;
            c03951.I$0 = i;
            c03951.I$1 = i2;
            c03951.label = 1;
            currentProfileSlug = getCurrentProfileSlug(c03951);
            if (currentProfileSlug != ck1Var) {
                screenConfigRepository = this;
            }
            return ck1Var;
        }
        if (i5 != 1) {
            if (i5 != 2) {
                if (i5 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                screenConfigRepository3 = (ScreenConfigRepository) c03951.L$0;
                s38.b(currentProfileSlug);
                screenConfigRepository3.triggerCloudSync();
                return Boxing.boxBoolean(true);
            }
            i3 = c03951.I$1;
            i = c03951.I$0;
            screenConfigRepository2 = (ScreenConfigRepository) c03951.L$0;
            s38.b(currentProfileSlug);
            arrayListBp = y41.bp((Collection) currentProfileSlug);
            int i6 = 0;
            if (i >= 0 || i >= arrayListBp.size() || i3 < 0 || i3 >= arrayListBp.size()) {
                int size = arrayListBp.size();
                StringBuilder sbR = vw2.r("moveRowToPosition: Invalid indices from=", i, " to=", " size=", i3);
                sbR.append(size);
                Log.w(TAG, sbR.toString());
                return Boxing.boxBoolean(false);
            }
            arrayListBp.add(i3, (RowConfigEntity) arrayListBp.remove(i));
            ArrayList arrayList = new ArrayList(y41.p(arrayListBp, 10));
            for (Object obj : arrayListBp) {
                int i7 = i6 + 1;
                if (i6 < 0) {
                    y41.bm();
                    throw null;
                }
                arrayList.add(new q07(((RowConfigEntity) obj).getId(), Boxing.boxInt(i6)));
                i6 = i7;
            }
            RowConfigDao rowConfigDao = screenConfigRepository2.rowConfigDao;
            c03951.L$0 = screenConfigRepository2;
            c03951.label = 3;
            if (rowConfigDao.updateMultiplePositions(arrayList, c03951) != ck1Var) {
                screenConfigRepository3 = screenConfigRepository2;
                screenConfigRepository3.triggerCloudSync();
                return Boxing.boxBoolean(true);
            }
            return ck1Var;
        }
        i2 = c03951.I$1;
        i = c03951.I$0;
        screenType = (ScreenType) c03951.L$1;
        screenConfigRepository = (ScreenConfigRepository) c03951.L$0;
        s38.b(currentProfileSlug);
        RowConfigDao rowConfigDao2 = screenConfigRepository.rowConfigDao;
        String key = screenType.getKey();
        c03951.L$0 = screenConfigRepository;
        c03951.L$1 = null;
        c03951.I$0 = i;
        c03951.I$1 = i2;
        c03951.label = 2;
        currentProfileSlug = rowConfigDao2.getAllRowsForProfileSync((String) currentProfileSlug, key, c03951);
        if (currentProfileSlug != ck1Var) {
            i3 = i2;
            screenConfigRepository2 = screenConfigRepository;
            arrayListBp = y41.bp((Collection) currentProfileSlug);
            int i62 = 0;
            if (i >= 0) {
            }
            int size2 = arrayListBp.size();
            StringBuilder sbR2 = vw2.r("moveRowToPosition: Invalid indices from=", i, " to=", " size=", i3);
            sbR2.append(size2);
            Log.w(TAG, sbR2.toString());
            return Boxing.boxBoolean(false);
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object reorderRow(@kp6 String str, int i, @kp6 Continuation<? super e6a> continuation) {
        C03961 c03961;
        ScreenConfigRepository screenConfigRepository;
        if (continuation instanceof C03961) {
            c03961 = (C03961) continuation;
            int i2 = c03961.label;
            if ((i2 & Integer.MIN_VALUE) != 0) {
                c03961.label = i2 - Integer.MIN_VALUE;
            } else {
                c03961 = new C03961(continuation);
            }
        }
        Object obj = c03961.result;
        ck1 ck1Var = ck1.a;
        int i3 = c03961.label;
        if (i3 == 0) {
            s38.b(obj);
            RowConfigDao rowConfigDao = this.rowConfigDao;
            c03961.L$0 = this;
            c03961.label = 1;
            if (rowConfigDao.updateRowPosition(str, i, c03961) == ck1Var) {
                return ck1Var;
            }
            screenConfigRepository = this;
        } else {
            if (i3 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            screenConfigRepository = (ScreenConfigRepository) c03961.L$0;
            s38.b(obj);
        }
        screenConfigRepository.triggerCloudSync();
        return e6a.a;
    }

    /* JADX WARN: Removed duplicated region for block: B:28:0x0098  */
    /* JADX WARN: Removed duplicated region for block: B:32:0x00a8 A[LOOP:0: B:30:0x00a2->B:32:0x00a8, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:36:0x00c9  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x00ea  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x011e  */
    /* JADX WARN: Removed duplicated region for block: B:56:0x014d  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object reorderRowsByIds(@kp6 ScreenType screenType, @kp6 List<String> list, @kp6 Continuation<? super Boolean> continuation) {
        C03971 c03971;
        ScreenConfigRepository screenConfigRepository;
        List<String> list2;
        ScreenConfigRepository screenConfigRepository2;
        int iH;
        Iterator<T> it;
        ArrayList arrayList;
        RowConfigDao rowConfigDao;
        ScreenConfigRepository screenConfigRepository3;
        if (continuation instanceof C03971) {
            c03971 = (C03971) continuation;
            int i = c03971.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c03971.label = i - Integer.MIN_VALUE;
            } else {
                c03971 = new C03971(continuation);
            }
        }
        Object currentProfileSlug = c03971.result;
        ck1 ck1Var = ck1.a;
        int i2 = c03971.label;
        if (i2 == 0) {
            s38.b(currentProfileSlug);
            c03971.L$0 = this;
            c03971.L$1 = screenType;
            c03971.L$2 = list;
            c03971.label = 1;
            currentProfileSlug = getCurrentProfileSlug(c03971);
            if (currentProfileSlug != ck1Var) {
                screenConfigRepository = this;
            }
            return ck1Var;
        }
        if (i2 != 1) {
            if (i2 != 2) {
                if (i2 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                screenConfigRepository3 = (ScreenConfigRepository) c03971.L$0;
                s38.b(currentProfileSlug);
                screenConfigRepository3.triggerCloudSync();
                return Boxing.boxBoolean(true);
            }
            list2 = (List) c03971.L$1;
            screenConfigRepository2 = (ScreenConfigRepository) c03971.L$0;
            s38.b(currentProfileSlug);
            List list3 = (List) currentProfileSlug;
            iH = wo5.h(y41.p(list3, 10));
            if (iH < 16) {
                iH = 16;
            }
            LinkedHashMap linkedHashMap = new LinkedHashMap(iH);
            for (Object obj : list3) {
                linkedHashMap.put(((RowConfigEntity) obj).getId(), obj);
            }
            ArrayList arrayList2 = new ArrayList();
            it = list2.iterator();
            while (it.hasNext()) {
                RowConfigEntity rowConfigEntity = (RowConfigEntity) linkedHashMap.get((String) it.next());
                if (rowConfigEntity != null) {
                    arrayList2.add(rowConfigEntity);
                }
            }
            ArrayList arrayList3 = new ArrayList();
            for (Object obj2 : list3) {
                if (!list2.contains(((RowConfigEntity) obj2).getId())) {
                    arrayList3.add(obj2);
                }
            }
            ArrayList arrayList4 = new ArrayList();
            arrayList4.addAll(arrayList2);
            arrayList4.addAll(arrayList3);
            arrayList = new ArrayList(y41.p(arrayList4, 10));
            int i3 = 0;
            for (Object obj3 : arrayList4) {
                int i4 = i3 + 1;
                if (i3 < 0) {
                    y41.bm();
                    throw null;
                }
                arrayList.add(new q07(((RowConfigEntity) obj3).getId(), Boxing.boxInt(i3)));
                i3 = i4;
            }
            rowConfigDao = screenConfigRepository2.rowConfigDao;
            c03971.L$0 = screenConfigRepository2;
            c03971.L$1 = null;
            c03971.label = 3;
            if (rowConfigDao.updateMultiplePositions(arrayList, c03971) != ck1Var) {
                screenConfigRepository3 = screenConfigRepository2;
                screenConfigRepository3.triggerCloudSync();
                return Boxing.boxBoolean(true);
            }
            return ck1Var;
        }
        list = (List) c03971.L$2;
        screenType = (ScreenType) c03971.L$1;
        screenConfigRepository = (ScreenConfigRepository) c03971.L$0;
        s38.b(currentProfileSlug);
        RowConfigDao rowConfigDao2 = screenConfigRepository.rowConfigDao;
        String key = screenType.getKey();
        c03971.L$0 = screenConfigRepository;
        c03971.L$1 = list;
        c03971.L$2 = null;
        c03971.label = 2;
        currentProfileSlug = rowConfigDao2.getAllRowsForProfileSync((String) currentProfileSlug, key, c03971);
        if (currentProfileSlug != ck1Var) {
            list2 = list;
            screenConfigRepository2 = screenConfigRepository;
            List list32 = (List) currentProfileSlug;
            iH = wo5.h(y41.p(list32, 10));
            if (iH < 16) {
            }
            LinkedHashMap linkedHashMap2 = new LinkedHashMap(iH);
            while (r4.hasNext()) {
            }
            ArrayList arrayList22 = new ArrayList();
            it = list2.iterator();
            while (it.hasNext()) {
            }
            ArrayList arrayList32 = new ArrayList();
            while (r13.hasNext()) {
            }
            ArrayList arrayList42 = new ArrayList();
            arrayList42.addAll(arrayList22);
            arrayList42.addAll(arrayList32);
            arrayList = new ArrayList(y41.p(arrayList42, 10));
            int i32 = 0;
            while (r11.hasNext()) {
            }
            rowConfigDao = screenConfigRepository2.rowConfigDao;
            c03971.L$0 = screenConfigRepository2;
            c03971.L$1 = null;
            c03971.label = 3;
            if (rowConfigDao.updateMultiplePositions(arrayList, c03971) != ck1Var) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:33:0x00de  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x00f4  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x0119 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object resetScreenToDefaults(@kp6 ScreenType screenType, @kp6 Continuation<? super e6a> continuation) {
        C03981 c03981;
        ScreenConfigRepository screenConfigRepository;
        ScreenType screenType2;
        List<RowConfigEntity> list;
        ScreenConfigRepository screenConfigRepository2;
        String str;
        ScreenType screenType3;
        ScreenConfigRepository screenConfigRepository3;
        Iterator<RowConfigEntity> it;
        Set set;
        ScreenType screenType4;
        String str2;
        ScreenConfigRepository screenConfigRepository4;
        if (continuation instanceof C03981) {
            c03981 = (C03981) continuation;
            int i = c03981.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c03981.label = i - Integer.MIN_VALUE;
            } else {
                c03981 = new C03981(continuation);
            }
        }
        Object currentProfileSlug = c03981.result;
        ck1 ck1Var = ck1.a;
        int i2 = c03981.label;
        if (i2 == 0) {
            s38.b(currentProfileSlug);
            c03981.L$0 = this;
            c03981.L$1 = screenType;
            c03981.label = 1;
            currentProfileSlug = getCurrentProfileSlug(c03981);
            if (currentProfileSlug != ck1Var) {
                screenConfigRepository = this;
            }
            return ck1Var;
        }
        if (i2 != 1) {
            if (i2 == 2) {
                list = (List) c03981.L$3;
                str = (String) c03981.L$2;
                screenType2 = (ScreenType) c03981.L$1;
                screenConfigRepository2 = (ScreenConfigRepository) c03981.L$0;
                s38.b(currentProfileSlug);
                screenConfigRepository2.clearDeletedDefaultRows();
                RowConfigDao rowConfigDao = screenConfigRepository2.rowConfigDao;
                String key = screenType2.getKey();
                c03981.L$0 = screenConfigRepository2;
                c03981.L$1 = screenType2;
                c03981.L$2 = str;
                c03981.L$3 = list;
                c03981.label = 3;
                currentProfileSlug = rowConfigDao.getRowIdsForProfile(str, key, c03981);
                if (currentProfileSlug != ck1Var) {
                    screenType3 = screenType2;
                    screenConfigRepository3 = screenConfigRepository2;
                    Set setBr = y41.br((Iterable) currentProfileSlug);
                    it = list.iterator();
                    String str3 = str;
                    set = setBr;
                    screenType4 = screenType3;
                    str2 = str3;
                    while (true) {
                        if (it.hasNext()) {
                        }
                    }
                }
                return ck1Var;
            }
            if (i2 == 3) {
                list = (List) c03981.L$3;
                str = (String) c03981.L$2;
                screenType3 = (ScreenType) c03981.L$1;
                screenConfigRepository3 = (ScreenConfigRepository) c03981.L$0;
                s38.b(currentProfileSlug);
                Set setBr2 = y41.br((Iterable) currentProfileSlug);
                it = list.iterator();
                String str32 = str;
                set = setBr2;
                screenType4 = screenType3;
                str2 = str32;
                while (true) {
                    if (it.hasNext()) {
                    }
                }
                return ck1Var;
            }
            if (i2 != 4) {
                if (i2 != 5) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                screenConfigRepository4 = (ScreenConfigRepository) c03981.L$0;
                s38.b(currentProfileSlug);
                screenConfigRepository4.triggerCloudSync();
                return e6a.a;
            }
            it = (Iterator) c03981.L$4;
            set = (Set) c03981.L$3;
            str2 = (String) c03981.L$2;
            ScreenType screenType5 = (ScreenType) c03981.L$1;
            ScreenConfigRepository screenConfigRepository5 = (ScreenConfigRepository) c03981.L$0;
            s38.b(currentProfileSlug);
            screenType4 = screenType5;
            screenConfigRepository3 = screenConfigRepository5;
            while (true) {
                if (it.hasNext()) {
                    RowConfigEntity next = it.next();
                    if (!set.contains(next.getId())) {
                        RowConfigDao rowConfigDao2 = screenConfigRepository3.rowConfigDao;
                        c03981.L$0 = screenConfigRepository3;
                        c03981.L$1 = screenType4;
                        c03981.L$2 = str2;
                        c03981.L$3 = set;
                        c03981.L$4 = it;
                        c03981.label = 4;
                        if (rowConfigDao2.insert(next, c03981) == ck1Var) {
                            break;
                        }
                    }
                } else {
                    RowConfigDao rowConfigDao3 = screenConfigRepository3.rowConfigDao;
                    String key2 = screenType4.getKey();
                    c03981.L$0 = screenConfigRepository3;
                    c03981.L$1 = null;
                    c03981.L$2 = null;
                    c03981.L$3 = null;
                    c03981.L$4 = null;
                    c03981.label = 5;
                    if (rowConfigDao3.resetProfileScreenPositionsAndEnabled(str2, key2, c03981) != ck1Var) {
                        screenConfigRepository4 = screenConfigRepository3;
                    }
                }
            }
            return ck1Var;
        }
        screenType = (ScreenType) c03981.L$1;
        screenConfigRepository = (ScreenConfigRepository) c03981.L$0;
        s38.b(currentProfileSlug);
        String str4 = (String) currentProfileSlug;
        List<RowConfigEntity> defaultRowsForProfile = screenConfigRepository.getDefaultRowsForProfile(str4, screenType);
        RowConfigDao rowConfigDao4 = screenConfigRepository.rowConfigDao;
        String key3 = screenType.getKey();
        c03981.L$0 = screenConfigRepository;
        c03981.L$1 = screenType;
        c03981.L$2 = str4;
        c03981.L$3 = defaultRowsForProfile;
        c03981.label = 2;
        if (rowConfigDao4.deleteAllNonSystemRowsForProfile(str4, key3, c03981) != ck1Var) {
            screenType2 = screenType;
            list = defaultRowsForProfile;
            screenConfigRepository2 = screenConfigRepository;
            str = str4;
            screenConfigRepository2.clearDeletedDefaultRows();
            RowConfigDao rowConfigDao5 = screenConfigRepository2.rowConfigDao;
            String key4 = screenType2.getKey();
            c03981.L$0 = screenConfigRepository2;
            c03981.L$1 = screenType2;
            c03981.L$2 = str;
            c03981.L$3 = list;
            c03981.label = 3;
            currentProfileSlug = rowConfigDao5.getRowIdsForProfile(str, key4, c03981);
            if (currentProfileSlug != ck1Var) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Code restructure failed: missing block: B:41:0x0101, code lost:
    
        if (r2.updateRowPosition(r14, r13, r0) != r1) goto L43;
     */
    /* JADX WARN: Removed duplicated region for block: B:35:0x00bc  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x00d2  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object swapRowPositions(@kp6 String str, @kp6 String str2, @kp6 Continuation<? super Boolean> continuation) {
        C03991 c03991;
        ScreenConfigRepository screenConfigRepository;
        RowConfigEntity rowConfigEntity;
        RowConfigEntity rowConfigEntity2;
        int position;
        ScreenConfigRepository screenConfigRepository2;
        if (continuation instanceof C03991) {
            c03991 = (C03991) continuation;
            int i = c03991.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c03991.label = i - Integer.MIN_VALUE;
            } else {
                c03991 = new C03991(continuation);
            }
        }
        Object rowById = c03991.result;
        ck1 ck1Var = ck1.a;
        int i2 = c03991.label;
        if (i2 == 0) {
            s38.b(rowById);
            RowConfigDao rowConfigDao = this.rowConfigDao;
            c03991.L$0 = this;
            c03991.L$1 = str;
            c03991.L$2 = str2;
            c03991.label = 1;
            rowById = rowConfigDao.getRowById(str, c03991);
            if (rowById != ck1Var) {
                screenConfigRepository = this;
            }
            return ck1Var;
        }
        if (i2 == 1) {
            str2 = (String) c03991.L$2;
            str = (String) c03991.L$1;
            screenConfigRepository = (ScreenConfigRepository) c03991.L$0;
            s38.b(rowById);
        } else {
            if (i2 == 2) {
                rowConfigEntity = (RowConfigEntity) c03991.L$2;
                str2 = (String) c03991.L$1;
                screenConfigRepository = (ScreenConfigRepository) c03991.L$0;
                s38.b(rowById);
                rowConfigEntity2 = (RowConfigEntity) rowById;
                if (rowConfigEntity2 != null) {
                    Log.w(TAG, "swapRowPositions: Row2 not found: " + str2);
                    return Boxing.boxBoolean(false);
                }
                position = rowConfigEntity.getPosition();
                RowConfigDao rowConfigDao2 = screenConfigRepository.rowConfigDao;
                String id = rowConfigEntity.getId();
                int position2 = rowConfigEntity2.getPosition();
                c03991.L$0 = screenConfigRepository;
                c03991.L$1 = rowConfigEntity2;
                c03991.L$2 = null;
                c03991.I$0 = position;
                c03991.label = 3;
                if (rowConfigDao2.updateRowPosition(id, position2, c03991) != ck1Var) {
                    screenConfigRepository2 = screenConfigRepository;
                    RowConfigDao rowConfigDao3 = screenConfigRepository2.rowConfigDao;
                    String id2 = rowConfigEntity2.getId();
                    c03991.L$0 = screenConfigRepository2;
                    c03991.L$1 = null;
                    c03991.label = 4;
                }
                return ck1Var;
            }
            if (i2 != 3) {
                if (i2 != 4) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                screenConfigRepository2 = (ScreenConfigRepository) c03991.L$0;
                s38.b(rowById);
                screenConfigRepository2.triggerCloudSync();
                return Boxing.boxBoolean(true);
            }
            int i3 = c03991.I$0;
            RowConfigEntity rowConfigEntity3 = (RowConfigEntity) c03991.L$1;
            screenConfigRepository = (ScreenConfigRepository) c03991.L$0;
            s38.b(rowById);
            rowConfigEntity2 = rowConfigEntity3;
            position = i3;
            screenConfigRepository2 = screenConfigRepository;
            RowConfigDao rowConfigDao32 = screenConfigRepository2.rowConfigDao;
            String id22 = rowConfigEntity2.getId();
            c03991.L$0 = screenConfigRepository2;
            c03991.L$1 = null;
            c03991.label = 4;
        }
        RowConfigEntity rowConfigEntity4 = (RowConfigEntity) rowById;
        if (rowConfigEntity4 == null) {
            Log.w(TAG, "swapRowPositions: Row1 not found: " + str);
            return Boxing.boxBoolean(false);
        }
        RowConfigDao rowConfigDao4 = screenConfigRepository.rowConfigDao;
        c03991.L$0 = screenConfigRepository;
        c03991.L$1 = str2;
        c03991.L$2 = rowConfigEntity4;
        c03991.label = 2;
        Object rowById2 = rowConfigDao4.getRowById(str2, c03991);
        if (rowById2 != ck1Var) {
            rowById = rowById2;
            rowConfigEntity = rowConfigEntity4;
            rowConfigEntity2 = (RowConfigEntity) rowById;
            if (rowConfigEntity2 != null) {
            }
        }
        return ck1Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object syncDeletedDefaultsFromCloudRestore(@kp6 String str, @kp6 Continuation<? super e6a> continuation) {
        C04001 c04001;
        ScreenConfigRepository screenConfigRepository;
        if (continuation instanceof C04001) {
            c04001 = (C04001) continuation;
            int i = c04001.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04001.label = i - Integer.MIN_VALUE;
            } else {
                c04001 = new C04001(continuation);
            }
        }
        Object allRowIdsForProfile = c04001.result;
        ck1 ck1Var = ck1.a;
        int i2 = c04001.label;
        if (i2 == 0) {
            s38.b(allRowIdsForProfile);
            RowConfigDao rowConfigDao = this.rowConfigDao;
            c04001.L$0 = this;
            c04001.L$1 = str;
            c04001.label = 1;
            allRowIdsForProfile = rowConfigDao.getAllRowIdsForProfile(str, c04001);
            if (allRowIdsForProfile == ck1Var) {
                return ck1Var;
            }
            screenConfigRepository = this;
        } else {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            str = (String) c04001.L$1;
            screenConfigRepository = (ScreenConfigRepository) c04001.L$0;
            s38.b(allRowIdsForProfile);
        }
        Set setBr = y41.br((Iterable) allRowIdsForProfile);
        List<RowConfigEntity> allDefaultRowsForProfile = screenConfigRepository.getAllDefaultRowsForProfile(str);
        ArrayList arrayList = new ArrayList();
        for (Object obj : allDefaultRowsForProfile) {
            if (!setBr.contains(((RowConfigEntity) obj).getId())) {
                arrayList.add(obj);
            }
        }
        ArrayList arrayList2 = new ArrayList(y41.p(arrayList, 10));
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            arrayList2.add(((RowConfigEntity) it.next()).getId());
        }
        Set setBr2 = y41.br(arrayList2);
        if (!setBr2.isEmpty()) {
            SharedPreferences sharedPreferences = screenConfigRepository.prefs;
            Set<String> set = pk2.a;
            Set<String> stringSet = sharedPreferences.getStringSet(KEY_DELETED_DEFAULT_ROWS, set);
            if (stringSet != null) {
                set = stringSet;
            }
            screenConfigRepository.prefs.edit().putStringSet(KEY_DELETED_DEFAULT_ROWS, km8.f(set, setBr2)).apply();
            setBr2.size();
        }
        return e6a.a;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object toggleRowVisibility(@kp6 String str, boolean z, @kp6 Continuation<? super e6a> continuation) {
        C04011 c04011;
        ScreenConfigRepository screenConfigRepository;
        if (continuation instanceof C04011) {
            c04011 = (C04011) continuation;
            int i = c04011.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04011.label = i - Integer.MIN_VALUE;
            } else {
                c04011 = new C04011(continuation);
            }
        }
        Object obj = c04011.result;
        ck1 ck1Var = ck1.a;
        int i2 = c04011.label;
        if (i2 == 0) {
            s38.b(obj);
            RowConfigDao rowConfigDao = this.rowConfigDao;
            c04011.L$0 = this;
            c04011.label = 1;
            if (rowConfigDao.setRowEnabled(str, z, c04011) == ck1Var) {
                return ck1Var;
            }
            screenConfigRepository = this;
        } else {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            screenConfigRepository = (ScreenConfigRepository) c04011.L$0;
            s38.b(obj);
        }
        screenConfigRepository.triggerCloudSync();
        return e6a.a;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object updateRow(@kp6 RowConfigEntity rowConfigEntity, @kp6 Continuation<? super e6a> continuation) {
        C04031 c04031;
        ScreenConfigRepository screenConfigRepository;
        if (continuation instanceof C04031) {
            c04031 = (C04031) continuation;
            int i = c04031.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04031.label = i - Integer.MIN_VALUE;
            } else {
                c04031 = new C04031(continuation);
            }
        }
        Object obj = c04031.result;
        ck1 ck1Var = ck1.a;
        int i2 = c04031.label;
        if (i2 == 0) {
            s38.b(obj);
            RowConfigDao rowConfigDao = this.rowConfigDao;
            c04031.L$0 = this;
            c04031.label = 1;
            if (rowConfigDao.updateRow(rowConfigEntity, c04031) == ck1Var) {
                return ck1Var;
            }
            screenConfigRepository = this;
        } else {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            screenConfigRepository = (ScreenConfigRepository) c04031.L$0;
            s38.b(obj);
        }
        screenConfigRepository.triggerCloudSync();
        return e6a.a;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0019  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object updateRowPresentation(@kp6 String str, @kp6 String str2, @kp6 Continuation<? super Boolean> continuation) {
        C04041 c04041;
        String str3;
        Object obj;
        ScreenConfigRepository screenConfigRepository;
        ScreenConfigRepository screenConfigRepository2;
        String str4 = str;
        if (continuation instanceof C04041) {
            c04041 = (C04041) continuation;
            int i = c04041.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04041.label = i - Integer.MIN_VALUE;
            } else {
                c04041 = new C04041(continuation);
            }
        }
        Object obj2 = c04041.result;
        ck1 ck1Var = ck1.a;
        int i2 = c04041.label;
        if (i2 == 0) {
            s38.b(obj2);
            RowConfigDao rowConfigDao = this.rowConfigDao;
            c04041.L$0 = this;
            c04041.L$1 = str4;
            c04041.L$2 = str2;
            c04041.label = 1;
            Object rowById = rowConfigDao.getRowById(str4, c04041);
            if (rowById != ck1Var) {
                str3 = str2;
                obj = rowById;
                screenConfigRepository = this;
            }
            return ck1Var;
        }
        if (i2 != 1) {
            if (i2 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            screenConfigRepository2 = (ScreenConfigRepository) c04041.L$0;
            s38.b(obj2);
            screenConfigRepository2.triggerCloudSync();
            return Boxing.boxBoolean(true);
        }
        String str5 = (String) c04041.L$2;
        String str6 = (String) c04041.L$1;
        ScreenConfigRepository screenConfigRepository3 = (ScreenConfigRepository) c04041.L$0;
        s38.b(obj2);
        str3 = str5;
        str4 = str6;
        obj = obj2;
        screenConfigRepository = screenConfigRepository3;
        RowConfigEntity rowConfigEntity = (RowConfigEntity) obj;
        if (rowConfigEntity == null) {
            Log.w(TAG, "updateRowPresentation: Row not found: " + str4);
            return Boxing.boxBoolean(false);
        }
        RowConfigDao rowConfigDao2 = screenConfigRepository.rowConfigDao;
        RowConfigEntity rowConfigEntityCopy$default = RowConfigEntity.copy$default(rowConfigEntity, null, null, null, null, null, null, str3, null, 0, 0, false, false, 0, false, null, null, null, 131007, null);
        c04041.L$0 = screenConfigRepository;
        c04041.L$1 = null;
        c04041.L$2 = null;
        c04041.label = 2;
        if (rowConfigDao2.updateRow(rowConfigEntityCopy$default, c04041) != ck1Var) {
            screenConfigRepository2 = screenConfigRepository;
            screenConfigRepository2.triggerCloudSync();
            return Boxing.boxBoolean(true);
        }
        return ck1Var;
    }

    /* JADX WARN: Code restructure failed: missing block: B:25:0x009c, code lost:
    
        if (r2.updateSort(r9, r10, r11, r0) == r1) goto L26;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object updateRowSort(@kp6 String str, @pq6 String str2, @pq6 String str3, @kp6 Continuation<? super Boolean> continuation) {
        C04051 c04051;
        Object obj;
        String str4;
        String str5;
        String str6;
        ScreenConfigRepository screenConfigRepository;
        if (continuation instanceof C04051) {
            c04051 = (C04051) continuation;
            int i = c04051.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04051.label = i - Integer.MIN_VALUE;
            } else {
                c04051 = new C04051(continuation);
            }
        }
        Object obj2 = c04051.result;
        ck1 ck1Var = ck1.a;
        int i2 = c04051.label;
        if (i2 == 0) {
            s38.b(obj2);
            RowConfigDao rowConfigDao = this.rowConfigDao;
            c04051.L$0 = this;
            c04051.L$1 = str;
            c04051.L$2 = str2;
            c04051.L$3 = str3;
            c04051.label = 1;
            Object rowById = rowConfigDao.getRowById(str, c04051);
            if (rowById != ck1Var) {
                obj = rowById;
                str4 = str3;
                str5 = str2;
                str6 = str;
                screenConfigRepository = this;
            }
            return ck1Var;
        }
        if (i2 != 1) {
            if (i2 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            screenConfigRepository = (ScreenConfigRepository) c04051.L$0;
            s38.b(obj2);
            screenConfigRepository.triggerCloudSync();
            return Boxing.boxBoolean(true);
        }
        String str7 = (String) c04051.L$3;
        String str8 = (String) c04051.L$2;
        String str9 = (String) c04051.L$1;
        ScreenConfigRepository screenConfigRepository2 = (ScreenConfigRepository) c04051.L$0;
        s38.b(obj2);
        str6 = str9;
        screenConfigRepository = screenConfigRepository2;
        obj = obj2;
        str4 = str7;
        str5 = str8;
        if (((RowConfigEntity) obj) == null) {
            Log.w(TAG, "updateRowSort: Row not found: " + str6);
            return Boxing.boxBoolean(false);
        }
        RowConfigDao rowConfigDao2 = screenConfigRepository.rowConfigDao;
        c04051.L$0 = screenConfigRepository;
        c04051.L$1 = null;
        c04051.L$2 = null;
        c04051.L$3 = null;
        c04051.label = 2;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0019  */
    @pq6
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object updateRowTitle(@kp6 String str, @kp6 String str2, @kp6 Continuation<? super Boolean> continuation) {
        C04061 c04061;
        String str3;
        Object obj;
        ScreenConfigRepository screenConfigRepository;
        ScreenConfigRepository screenConfigRepository2;
        String str4 = str;
        if (continuation instanceof C04061) {
            c04061 = (C04061) continuation;
            int i = c04061.label;
            if ((i & Integer.MIN_VALUE) != 0) {
                c04061.label = i - Integer.MIN_VALUE;
            } else {
                c04061 = new C04061(continuation);
            }
        }
        Object obj2 = c04061.result;
        ck1 ck1Var = ck1.a;
        int i2 = c04061.label;
        if (i2 == 0) {
            s38.b(obj2);
            RowConfigDao rowConfigDao = this.rowConfigDao;
            c04061.L$0 = this;
            c04061.L$1 = str4;
            c04061.L$2 = str2;
            c04061.label = 1;
            Object rowById = rowConfigDao.getRowById(str4, c04061);
            if (rowById != ck1Var) {
                str3 = str2;
                obj = rowById;
                screenConfigRepository = this;
            }
            return ck1Var;
        }
        if (i2 != 1) {
            if (i2 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            screenConfigRepository2 = (ScreenConfigRepository) c04061.L$0;
            s38.b(obj2);
            screenConfigRepository2.triggerCloudSync();
            return Boxing.boxBoolean(true);
        }
        String str5 = (String) c04061.L$2;
        String str6 = (String) c04061.L$1;
        ScreenConfigRepository screenConfigRepository3 = (ScreenConfigRepository) c04061.L$0;
        s38.b(obj2);
        str3 = str5;
        str4 = str6;
        obj = obj2;
        screenConfigRepository = screenConfigRepository3;
        RowConfigEntity rowConfigEntity = (RowConfigEntity) obj;
        if (rowConfigEntity == null) {
            Log.w(TAG, "updateRowTitle: Row not found: " + str4);
            return Boxing.boxBoolean(false);
        }
        RowConfigDao rowConfigDao2 = screenConfigRepository.rowConfigDao;
        RowConfigEntity rowConfigEntityCopy$default = RowConfigEntity.copy$default(rowConfigEntity, null, null, null, str3, null, null, null, null, 0, 0, false, false, 0, false, null, null, null, 131063, null);
        c04061.L$0 = screenConfigRepository;
        c04061.L$1 = null;
        c04061.L$2 = null;
        c04061.label = 2;
        if (rowConfigDao2.updateRow(rowConfigEntityCopy$default, c04061) != ck1Var) {
            screenConfigRepository2 = screenConfigRepository;
            screenConfigRepository2.triggerCloudSync();
            return Boxing.boxBoolean(true);
        }
        return ck1Var;
    }
}
