package com.strmr.ps.ui.details;

import com.strmr.ps.data.local.dao.EpisodeWatchStatusDao;
import com.strmr.ps.data.local.entity.EpisodeWatchStatus;
import com.strmr.ps.data.model.ContentItem;
import com.strmr.ps.data.model.trakt.TraktShowProgress;
import com.strmr.ps.data.repository.TraktSyncRepository;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.cr4;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.hx9;
import defpackage.s38;
import defpackage.vx8;
import defpackage.y41;
import java.util.ArrayList;
import java.util.Map;
import java.util.Set;
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 \n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010$\n\u0002\u0010\u000e\n\u0002\u0010\u0007\n\u0002\u0010\"\n\u0002\b\u0002\u0010\u0007\u001a(\u0012\u0006\u0012\u0004\u0018\u00010\u0002\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00020\u0004\u0012\u0004\u0012\u00020\u00050\u0003\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00040\u00060\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0007\u0010\b"}, d2 = {"Lak1;", "Lhx9;", "Lcom/strmr/ps/data/model/trakt/TraktShowProgress;", "", "", "", "", "<anonymous>", "(Lak1;)Lhx9;"}, k = 3, mv = {2, 0, 0})
@DebugMetadata(c = "com.strmr.ps.ui.details.DetailsFragment$onResume$1$1$2", f = "DetailsFragment.kt", i = {1, 2, 2}, l = {691, 692, 695}, m = "invokeSuspend", n = {"progress", "progress", "playback"}, s = {"L$0", "L$0", "L$1"})
@vx8
final class v extends SuspendLambda implements gr3<ak1, Continuation<? super hx9<? extends TraktShowProgress, ? extends Map<String, ? extends Float>, ? extends Set<? extends String>>>, Object> {
    public TraktShowProgress a;
    public Map b;
    public int c;
    public final /* synthetic */ DetailsFragment d;
    public final /* synthetic */ ContentItem e;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public v(ContentItem contentItem, DetailsFragment detailsFragment, Continuation continuation) {
        super(2, continuation);
        this.d = detailsFragment;
        this.e = contentItem;
    }

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

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

    /* JADX WARN: Removed duplicated region for block: B:21:0x0061  */
    /* JADX WARN: Removed duplicated region for block: B:28:0x008e A[LOOP:0: B:26:0x0088->B:28:0x008e, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:31:0x00c0  */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        TraktShowProgress traktShowProgress;
        EpisodeWatchStatusDao episodeWatchStatusDao;
        Map map;
        ck1 ck1Var = ck1.a;
        int i = this.c;
        ContentItem contentItem = this.e;
        DetailsFragment detailsFragment = this.d;
        if (i == 0) {
            s38.b(obj);
            TraktSyncRepository traktSyncRepositoryV = detailsFragment.v();
            int tmdbId = contentItem.getTmdbId();
            this.c = 1;
            obj = traktSyncRepositoryV.getShowProgress(tmdbId, this);
            if (obj != ck1Var) {
            }
            return ck1Var;
        }
        if (i != 1) {
            if (i != 2) {
                if (i != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                map = this.b;
                traktShowProgress = this.a;
                s38.b(obj);
                Iterable<EpisodeWatchStatus> iterable = (Iterable) obj;
                ArrayList arrayList = new ArrayList(y41.p(iterable, 10));
                for (EpisodeWatchStatus episodeWatchStatus : iterable) {
                    arrayList.add("S" + episodeWatchStatus.getSeason() + "E" + episodeWatchStatus.getEpisode());
                }
                return new hx9(traktShowProgress, map, y41.br(arrayList));
            }
            traktShowProgress = this.a;
            s38.b(obj);
            Map map2 = (Map) obj;
            episodeWatchStatusDao = detailsFragment.bg;
            if (episodeWatchStatusDao != null) {
                cr4.n("episodeWatchStatusDao");
                throw null;
            }
            int tmdbId2 = contentItem.getTmdbId();
            this.a = traktShowProgress;
            this.b = map2;
            this.c = 3;
            Object watchedEpisodes = episodeWatchStatusDao.getWatchedEpisodes(tmdbId2, this);
            if (watchedEpisodes != ck1Var) {
                map = map2;
                obj = watchedEpisodes;
                Iterable<EpisodeWatchStatus> iterable2 = (Iterable) obj;
                ArrayList arrayList2 = new ArrayList(y41.p(iterable2, 10));
                while (r9.hasNext()) {
                }
                return new hx9(traktShowProgress, map, y41.br(arrayList2));
            }
            return ck1Var;
        }
        s38.b(obj);
        TraktShowProgress traktShowProgress2 = (TraktShowProgress) obj;
        TraktSyncRepository traktSyncRepositoryV2 = detailsFragment.v();
        int tmdbId3 = contentItem.getTmdbId();
        this.a = traktShowProgress2;
        this.c = 2;
        Object episodePlaybackProgress = traktSyncRepositoryV2.getEpisodePlaybackProgress(tmdbId3, this);
        if (episodePlaybackProgress != ck1Var) {
            traktShowProgress = traktShowProgress2;
            obj = episodePlaybackProgress;
            Map map22 = (Map) obj;
            episodeWatchStatusDao = detailsFragment.bg;
            if (episodeWatchStatusDao != null) {
            }
        }
        return ck1Var;
    }
}
