package com.strmr.ps.ui.base;

import android.util.Log;
import com.strmr.ps.data.model.trakt.TraktLastActivities;
import com.strmr.ps.data.repository.ContinueWatchingRepository;
import com.strmr.ps.data.repository.TraktSyncRepository;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.e6a;
import defpackage.fx4;
import defpackage.gr3;
import defpackage.m12;
import defpackage.qm5;
import defpackage.rx4;
import defpackage.s38;
import defpackage.sc2;
import defpackage.sm5;
import defpackage.wj0;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {2, 0, 0})
@DebugMetadata(c = "com.strmr.ps.ui.base.BaseContentViewModel$checkForRemoteUpdates$1", f = "BaseContentViewModel.kt", i = {0, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6}, l = {840, 842, 843, 853, 854, 855, 862, 865}, m = "invokeSuspend", n = {"$this$launch", "$this$launch", "activities", "$this$launch", "listsChanged", "collectionJob", "droppedJob", "listsChanged", "cwChanged", "droppedJob", "listsChanged", "cwChanged", "listsChanged", "cwChanged", "listsChanged", "cwChanged"}, s = {"L$0", "L$0", "L$1", "L$0", "Z$0", "L$0", "L$1", "Z$0", "Z$1", "L$0", "Z$0", "Z$1", "Z$0", "Z$1", "Z$0", "Z$1"})
final class i extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public Object a;
    public boolean b;
    public boolean c;
    public int d;
    public /* synthetic */ Object e;
    public final /* synthetic */ BaseContentViewModel f;

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

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

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

    /* JADX WARN: Removed duplicated region for block: B:37:0x0087  */
    /* JADX WARN: Removed duplicated region for block: B:38:0x0089 A[Catch: Exception -> 0x001d, TryCatch #0 {Exception -> 0x001d, blocks: (B:6:0x0019, B:11:0x0024, B:70:0x0147, B:14:0x002d, B:65:0x0135, B:17:0x003a, B:59:0x0121, B:20:0x004b, B:56:0x010f, B:23:0x0056, B:46:0x00b7, B:50:0x00c3, B:52:0x00de, B:26:0x0062, B:42:0x009c, B:29:0x006a, B:35:0x0083, B:38:0x0089, B:32:0x0076), top: B:76:0x000e }] */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00b2  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x00b4  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x00de A[Catch: Exception -> 0x001d, TryCatch #0 {Exception -> 0x001d, blocks: (B:6:0x0019, B:11:0x0024, B:70:0x0147, B:14:0x002d, B:65:0x0135, B:17:0x003a, B:59:0x0121, B:20:0x004b, B:56:0x010f, B:23:0x0056, B:46:0x00b7, B:50:0x00c3, B:52:0x00de, B:26:0x0062, B:42:0x009c, B:29:0x006a, B:35:0x0083, B:38:0x0089, B:32:0x0076), top: B:76:0x000e }] */
    /* JADX WARN: Removed duplicated region for block: B:58:0x0120  */
    /* JADX WARN: Removed duplicated region for block: B:59:0x0121 A[Catch: Exception -> 0x001d, PHI: r2 r4 r5
      0x0121: PHI (r2v10 boolean) = (r2v8 boolean), (r2v11 boolean) binds: [B:57:0x011e, B:17:0x003a] A[DONT_GENERATE, DONT_INLINE]
      0x0121: PHI (r4v16 boolean) = (r4v14 boolean), (r4v17 boolean) binds: [B:57:0x011e, B:17:0x003a] A[DONT_GENERATE, DONT_INLINE]
      0x0121: PHI (r5v5 fx4) = (r5v2 fx4), (r5v7 fx4) binds: [B:57:0x011e, B:17:0x003a] A[DONT_GENERATE, DONT_INLINE], TryCatch #0 {Exception -> 0x001d, blocks: (B:6:0x0019, B:11:0x0024, B:70:0x0147, B:14:0x002d, B:65:0x0135, B:17:0x003a, B:59:0x0121, B:20:0x004b, B:56:0x010f, B:23:0x0056, B:46:0x00b7, B:50:0x00c3, B:52:0x00de, B:26:0x0062, B:42:0x009c, B:29:0x006a, B:35:0x0083, B:38:0x0089, B:32:0x0076), top: B:76:0x000e }] */
    /* JADX WARN: Removed duplicated region for block: B:61:0x0130  */
    /* JADX WARN: Removed duplicated region for block: B:63:0x0132 A[PHI: r4 r13
      0x0132: PHI (r4v18 boolean) = (r4v12 boolean), (r4v20 boolean) binds: [B:51:0x00dc, B:62:0x0131] A[DONT_GENERATE, DONT_INLINE]
      0x0132: PHI (r13v19 boolean) = (r13v14 boolean), (r13v20 boolean) binds: [B:51:0x00dc, B:62:0x0131] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:65:0x0135 A[Catch: Exception -> 0x001d, TryCatch #0 {Exception -> 0x001d, blocks: (B:6:0x0019, B:11:0x0024, B:70:0x0147, B:14:0x002d, B:65:0x0135, B:17:0x003a, B:59:0x0121, B:20:0x004b, B:56:0x010f, B:23:0x0056, B:46:0x00b7, B:50:0x00c3, B:52:0x00de, B:26:0x0062, B:42:0x009c, B:29:0x006a, B:35:0x0083, B:38:0x0089, B:32:0x0076), top: B:76:0x000e }] */
    /* JADX WARN: Removed duplicated region for block: B:70:0x0147 A[Catch: Exception -> 0x001d, PHI: r2 r13
      0x0147: PHI (r2v15 boolean) = (r2v12 boolean), (r2v16 boolean) binds: [B:64:0x0133, B:69:0x0146] A[DONT_GENERATE, DONT_INLINE]
      0x0147: PHI (r13v21 boolean) = (r13v19 boolean), (r13v24 boolean) binds: [B:64:0x0133, B:69:0x0146] A[DONT_GENERATE, DONT_INLINE], TRY_LEAVE, TryCatch #0 {Exception -> 0x001d, blocks: (B:6:0x0019, B:11:0x0024, B:70:0x0147, B:14:0x002d, B:65:0x0135, B:17:0x003a, B:59:0x0121, B:20:0x004b, B:56:0x010f, B:23:0x0056, B:46:0x00b7, B:50:0x00c3, B:52:0x00de, B:26:0x0062, B:42:0x009c, B:29:0x006a, B:35:0x0083, B:38:0x0089, B:32:0x0076), top: B:76:0x000e }] */
    /* JADX WARN: Removed duplicated region for block: B:73:0x015d A[RETURN] */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        ak1 ak1Var;
        TraktLastActivities traktLastActivities;
        TraktLastActivities traktLastActivities2;
        ak1 ak1Var2;
        Object objHasRemoteContinueWatchingChanges;
        boolean z;
        boolean zBooleanValue;
        fx4 fx4VarC;
        boolean z2;
        fx4 fx4Var;
        boolean z3;
        boolean z4;
        qm5 qm5Var;
        e eVar;
        BaseContentViewModel baseContentViewModel = this.f;
        TraktSyncRepository traktSyncRepository = baseContentViewModel.g;
        ck1 ck1Var = ck1.a;
        int i = this.d;
        e6a e6aVar = e6a.a;
        try {
            switch (i) {
                case 0:
                    s38.b(obj);
                    ak1Var = (ak1) this.e;
                    this.e = ak1Var;
                    this.d = 1;
                    obj = traktSyncRepository.getRemoteActivities(this);
                    if (obj != ck1Var) {
                        traktLastActivities = (TraktLastActivities) obj;
                        if (traktLastActivities != null) {
                            return e6aVar;
                        }
                        this.e = ak1Var;
                        this.a = traktLastActivities;
                        this.d = 2;
                        Object objHasRemoteListChanges = traktSyncRepository.hasRemoteListChanges(traktLastActivities, this);
                        if (objHasRemoteListChanges != ck1Var) {
                            ak1 ak1Var3 = ak1Var;
                            traktLastActivities2 = traktLastActivities;
                            obj = objHasRemoteListChanges;
                            ak1Var2 = ak1Var3;
                            boolean zBooleanValue2 = ((Boolean) obj).booleanValue();
                            ContinueWatchingRepository continueWatchingRepository = baseContentViewModel.e;
                            this.e = ak1Var2;
                            this.a = null;
                            this.b = zBooleanValue2;
                            this.d = 3;
                            objHasRemoteContinueWatchingChanges = continueWatchingRepository.hasRemoteContinueWatchingChanges(traktLastActivities2, this);
                            if (objHasRemoteContinueWatchingChanges == ck1Var) {
                                z = zBooleanValue2;
                                obj = objHasRemoteContinueWatchingChanges;
                                zBooleanValue = ((Boolean) obj).booleanValue();
                                if (z && !zBooleanValue) {
                                    return e6aVar;
                                }
                                Log.w("BaseContentVM", "Remote changes detected — lists=" + z + ", cw=" + zBooleanValue);
                                if (z) {
                                    z3 = z;
                                    if (zBooleanValue) {
                                    }
                                } else {
                                    fx4 fx4VarC2 = wj0.c(ak1Var2, null, null, new h(baseContentViewModel, null), 3);
                                    fx4 fx4VarC3 = wj0.c(ak1Var2, null, null, new f(baseContentViewModel, null), 3);
                                    fx4VarC = wj0.c(ak1Var2, null, null, new g(baseContentViewModel, null), 3);
                                    this.e = fx4VarC3;
                                    this.a = fx4VarC;
                                    this.b = z;
                                    this.c = zBooleanValue;
                                    this.d = 4;
                                    if (((rx4) fx4VarC2).u(this) != ck1Var) {
                                        z2 = zBooleanValue;
                                        fx4Var = fx4VarC3;
                                        this.e = fx4VarC;
                                        this.a = null;
                                        this.b = z;
                                        this.c = z2;
                                        this.d = 5;
                                        if (fx4Var.u(this) == ck1Var) {
                                            this.e = null;
                                            this.b = z;
                                            this.c = z2;
                                            this.d = 6;
                                            if (fx4VarC.u(this) == ck1Var) {
                                            }
                                            zBooleanValue = z2;
                                            z3 = z;
                                            if (zBooleanValue) {
                                                m12 m12Var = sc2.a;
                                                qm5Var = sm5.a;
                                                eVar = new e(z3, zBooleanValue, baseContentViewModel, null);
                                                this.e = null;
                                                this.d = 8;
                                                if (wj0.f(qm5Var, eVar, this) != ck1Var) {
                                                }
                                            } else {
                                                this.e = null;
                                                this.b = z3;
                                                this.c = zBooleanValue;
                                                this.d = 7;
                                                if (traktSyncRepository.syncHistoryOnly(this) != ck1Var) {
                                                    z4 = zBooleanValue;
                                                    zBooleanValue = z4;
                                                    m12 m12Var2 = sc2.a;
                                                    qm5Var = sm5.a;
                                                    eVar = new e(z3, zBooleanValue, baseContentViewModel, null);
                                                    this.e = null;
                                                    this.d = 8;
                                                    if (wj0.f(qm5Var, eVar, this) != ck1Var) {
                                                        return e6aVar;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    return ck1Var;
                case 1:
                    ak1Var = (ak1) this.e;
                    s38.b(obj);
                    traktLastActivities = (TraktLastActivities) obj;
                    if (traktLastActivities != null) {
                    }
                    break;
                case 2:
                    traktLastActivities2 = (TraktLastActivities) this.a;
                    ak1Var2 = (ak1) this.e;
                    s38.b(obj);
                    boolean zBooleanValue22 = ((Boolean) obj).booleanValue();
                    ContinueWatchingRepository continueWatchingRepository2 = baseContentViewModel.e;
                    this.e = ak1Var2;
                    this.a = null;
                    this.b = zBooleanValue22;
                    this.d = 3;
                    objHasRemoteContinueWatchingChanges = continueWatchingRepository2.hasRemoteContinueWatchingChanges(traktLastActivities2, this);
                    if (objHasRemoteContinueWatchingChanges == ck1Var) {
                    }
                    break;
                case 3:
                    z = this.b;
                    ak1Var2 = (ak1) this.e;
                    s38.b(obj);
                    zBooleanValue = ((Boolean) obj).booleanValue();
                    if (z) {
                    }
                    Log.w("BaseContentVM", "Remote changes detected — lists=" + z + ", cw=" + zBooleanValue);
                    if (z) {
                    }
                    return ck1Var;
                case 4:
                    z2 = this.c;
                    z = this.b;
                    fx4VarC = (fx4) this.a;
                    fx4Var = (fx4) this.e;
                    s38.b(obj);
                    this.e = fx4VarC;
                    this.a = null;
                    this.b = z;
                    this.c = z2;
                    this.d = 5;
                    if (fx4Var.u(this) == ck1Var) {
                    }
                    return ck1Var;
                case 5:
                    z2 = this.c;
                    z = this.b;
                    fx4VarC = (fx4) this.e;
                    s38.b(obj);
                    this.e = null;
                    this.b = z;
                    this.c = z2;
                    this.d = 6;
                    if (fx4VarC.u(this) == ck1Var) {
                    }
                    zBooleanValue = z2;
                    z3 = z;
                    if (zBooleanValue) {
                    }
                    return ck1Var;
                case 6:
                    z2 = this.c;
                    z = this.b;
                    s38.b(obj);
                    zBooleanValue = z2;
                    z3 = z;
                    if (zBooleanValue) {
                    }
                    return ck1Var;
                case 7:
                    z4 = this.c;
                    z3 = this.b;
                    s38.b(obj);
                    zBooleanValue = z4;
                    m12 m12Var22 = sc2.a;
                    qm5Var = sm5.a;
                    eVar = new e(z3, zBooleanValue, baseContentViewModel, null);
                    this.e = null;
                    this.d = 8;
                    if (wj0.f(qm5Var, eVar, this) != ck1Var) {
                        return ck1Var;
                    }
                    break;
                case 8:
                    s38.b(obj);
                    return e6aVar;
                default:
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
        } catch (Exception e) {
            Log.w("BaseContentViewModel", "Remote update check failed", e);
            return e6aVar;
        }
    }
}
