package com.strmr.ps.ui.mobile.details;

import android.util.Log;
import androidx.media3.exoplayer.upstream.CmcdData;
import com.strmr.ps.data.model.tmdb.TMDBCast;
import com.strmr.ps.data.model.tmdb.TMDBCredits;
import com.strmr.ps.data.model.tmdb.TMDBExternalIds;
import com.strmr.ps.data.model.tmdb.TMDBGenre;
import com.strmr.ps.data.model.tmdb.TMDBSeason;
import com.strmr.ps.data.model.tmdb.TMDBShowDetails;
import com.strmr.ps.data.model.trakt.TraktShowProgress;
import com.strmr.ps.data.remote.RateLimiter;
import com.strmr.ps.data.remote.api.TMDBApiService;
import com.strmr.ps.data.repository.ScreenConfigRepository;
import defpackage.ak1;
import defpackage.bk1;
import defpackage.ck1;
import defpackage.cr4;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.ik2;
import defpackage.j26;
import defpackage.k26;
import defpackage.l24;
import defpackage.m12;
import defpackage.n89;
import defpackage.qm5;
import defpackage.r22;
import defpackage.s38;
import defpackage.sc2;
import defpackage.sm5;
import defpackage.vx8;
import defpackage.wj0;
import defpackage.y41;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CancellationException;
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\u0004\u0018\u00010\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.mobile.details.MobileDetailsViewModel$loadShowDetails$2", f = "MobileDetailsViewModel.kt", i = {0, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5}, l = {377, 378, ScreenConfigRepository.MAX_ROWS_PER_PROFILE, 427, 428, 429, 439, 473}, m = "invokeSuspend", n = {"$this$withContext", "$this$withContext", "$this$withContext", "showDetails", "cast", "trailerKey", "seasons", "imdbId", "showDetails", "cast", "trailerKey", "seasons", "imdbId", "similarItems", "yearRange", "traktPlaybackDeferred", "localProgressDeferred", "showDetails", "cast", "trailerKey", "seasons", "imdbId", "similarItems", "yearRange", "localProgressDeferred", "traktShowProgress", "showDetails", "cast", "trailerKey", "seasons", "imdbId", "similarItems", "yearRange", "traktShowProgress", "traktPlaybackProgress"}, s = {"L$0", "L$0", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8", "L$0", "L$1", "L$2", "L$3", "L$4", "L$5", "L$6", "L$7", "L$8"})
@vx8
final class ad extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public Object a;
    public Object b;
    public Object c;
    public Object d;
    public Object e;
    public String f;
    public Object i;
    public Object j;
    public int k;
    public /* synthetic */ Object l;
    public final /* synthetic */ MobileDetailsViewModel m;
    public final /* synthetic */ int n;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public ad(MobileDetailsViewModel mobileDetailsViewModel, int i, Continuation continuation) {
        super(2, continuation);
        this.m = mobileDetailsViewModel;
        this.n = i;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Object obj, Continuation continuation) {
        ad adVar = new ad(this.m, this.n, continuation);
        adVar.l = obj;
        return adVar;
    }

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

    /* JADX WARN: Code restructure failed: missing block: B:149:0x039f, code lost:
    
        if (defpackage.wj0.f(r0, r1, r33) == r7) goto L150;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:103:0x0222 A[Catch: CancellationException -> 0x002b, Exception -> 0x01d2, TryCatch #0 {CancellationException -> 0x002b, blocks: (B:7:0x001f, B:146:0x0372, B:14:0x0050, B:129:0x02e3, B:130:0x02f7, B:132:0x02fd, B:136:0x031d, B:138:0x0323, B:141:0x032d, B:143:0x0347, B:17:0x007f, B:126:0x02c4, B:20:0x00ae, B:123:0x02a5, B:23:0x00d1, B:68:0x01ae, B:71:0x01b9, B:73:0x01c0, B:75:0x01c6, B:82:0x01d8, B:84:0x01de, B:95:0x01fc, B:97:0x0202, B:99:0x0208, B:101:0x021e, B:103:0x0222, B:105:0x0229, B:108:0x0234, B:109:0x0238, B:111:0x023e, B:117:0x0261, B:119:0x0264, B:92:0x01f1, B:94:0x01f7, B:26:0x00df, B:38:0x0118, B:41:0x0122, B:43:0x0128, B:45:0x013b, B:47:0x0145, B:48:0x0150, B:50:0x0156, B:52:0x0164, B:58:0x0174, B:59:0x0178, B:60:0x0181, B:62:0x0187, B:64:0x018d, B:29:0x00ea, B:35:0x0104, B:32:0x00f6), top: B:154:0x000f }] */
    /* JADX WARN: Removed duplicated region for block: B:115:0x0251  */
    /* JADX WARN: Removed duplicated region for block: B:121:0x029a  */
    /* JADX WARN: Removed duplicated region for block: B:122:0x029c  */
    /* JADX WARN: Removed duplicated region for block: B:125:0x02c2  */
    /* JADX WARN: Removed duplicated region for block: B:126:0x02c4 A[Catch: CancellationException -> 0x002b, Exception -> 0x0319, PHI: r0 r1 r2 r4 r5 r6 r8 r9 r10 r11 r12
      0x02c4: PHI (r0v29 r22) = (r0v26 r22), (r0v33 r22) binds: [B:124:0x02c0, B:18:0x0082] A[DONT_GENERATE, DONT_INLINE]
      0x02c4: PHI (r1v22 java.lang.Object) = (r1v19 java.lang.Object), (r1v26 java.lang.Object) binds: [B:124:0x02c0, B:18:0x0082] A[DONT_GENERATE, DONT_INLINE]
      0x02c4: PHI (r2v15 java.lang.String) = (r2v13 java.lang.String), (r2v16 java.lang.String) binds: [B:124:0x02c0, B:18:0x0082] A[DONT_GENERATE, DONT_INLINE]
      0x02c4: PHI (r4v11 java.util.List) = (r4v8 java.util.List), (r4v13 java.util.List) binds: [B:124:0x02c0, B:18:0x0082] A[DONT_GENERATE, DONT_INLINE]
      0x02c4: PHI (r5v16 java.lang.String) = (r5v13 java.lang.String), (r5v18 java.lang.String) binds: [B:124:0x02c0, B:18:0x0082] A[DONT_GENERATE, DONT_INLINE]
      0x02c4: PHI (r6v7 java.util.List) = (r6v4 java.util.List), (r6v9 java.util.List) binds: [B:124:0x02c0, B:18:0x0082] A[DONT_GENERATE, DONT_INLINE]
      0x02c4: PHI (r8v20 java.lang.String) = (r8v17 java.lang.String), (r8v22 java.lang.String) binds: [B:124:0x02c0, B:18:0x0082] A[DONT_GENERATE, DONT_INLINE]
      0x02c4: PHI (r9v8 java.util.List) = (r9v5 java.util.List), (r9v10 java.util.List) binds: [B:124:0x02c0, B:18:0x0082] A[DONT_GENERATE, DONT_INLINE]
      0x02c4: PHI (r10v17 com.strmr.ps.data.model.trakt.TraktShowProgress) = (r10v13 com.strmr.ps.data.model.trakt.TraktShowProgress), (r10v20 com.strmr.ps.data.model.trakt.TraktShowProgress) binds: [B:124:0x02c0, B:18:0x0082] A[DONT_GENERATE, DONT_INLINE]
      0x02c4: PHI (r11v15 java.lang.String) = (r11v32 java.lang.String), (r11v18 java.lang.String) binds: [B:124:0x02c0, B:18:0x0082] A[DONT_GENERATE, DONT_INLINE]
      0x02c4: PHI (r12v20 com.strmr.ps.data.model.tmdb.TMDBShowDetails) = (r12v18 com.strmr.ps.data.model.tmdb.TMDBShowDetails), (r12v21 com.strmr.ps.data.model.tmdb.TMDBShowDetails) binds: [B:124:0x02c0, B:18:0x0082] A[DONT_GENERATE, DONT_INLINE], TryCatch #0 {CancellationException -> 0x002b, blocks: (B:7:0x001f, B:146:0x0372, B:14:0x0050, B:129:0x02e3, B:130:0x02f7, B:132:0x02fd, B:136:0x031d, B:138:0x0323, B:141:0x032d, B:143:0x0347, B:17:0x007f, B:126:0x02c4, B:20:0x00ae, B:123:0x02a5, B:23:0x00d1, B:68:0x01ae, B:71:0x01b9, B:73:0x01c0, B:75:0x01c6, B:82:0x01d8, B:84:0x01de, B:95:0x01fc, B:97:0x0202, B:99:0x0208, B:101:0x021e, B:103:0x0222, B:105:0x0229, B:108:0x0234, B:109:0x0238, B:111:0x023e, B:117:0x0261, B:119:0x0264, B:92:0x01f1, B:94:0x01f7, B:26:0x00df, B:38:0x0118, B:41:0x0122, B:43:0x0128, B:45:0x013b, B:47:0x0145, B:48:0x0150, B:50:0x0156, B:52:0x0164, B:58:0x0174, B:59:0x0178, B:60:0x0181, B:62:0x0187, B:64:0x018d, B:29:0x00ea, B:35:0x0104, B:32:0x00f6), top: B:154:0x000f }] */
    /* JADX WARN: Removed duplicated region for block: B:128:0x02e1  */
    /* JADX WARN: Removed duplicated region for block: B:132:0x02fd A[Catch: CancellationException -> 0x002b, Exception -> 0x0319, TryCatch #0 {CancellationException -> 0x002b, blocks: (B:7:0x001f, B:146:0x0372, B:14:0x0050, B:129:0x02e3, B:130:0x02f7, B:132:0x02fd, B:136:0x031d, B:138:0x0323, B:141:0x032d, B:143:0x0347, B:17:0x007f, B:126:0x02c4, B:20:0x00ae, B:123:0x02a5, B:23:0x00d1, B:68:0x01ae, B:71:0x01b9, B:73:0x01c0, B:75:0x01c6, B:82:0x01d8, B:84:0x01de, B:95:0x01fc, B:97:0x0202, B:99:0x0208, B:101:0x021e, B:103:0x0222, B:105:0x0229, B:108:0x0234, B:109:0x0238, B:111:0x023e, B:117:0x0261, B:119:0x0264, B:92:0x01f1, B:94:0x01f7, B:26:0x00df, B:38:0x0118, B:41:0x0122, B:43:0x0128, B:45:0x013b, B:47:0x0145, B:48:0x0150, B:50:0x0156, B:52:0x0164, B:58:0x0174, B:59:0x0178, B:60:0x0181, B:62:0x0187, B:64:0x018d, B:29:0x00ea, B:35:0x0104, B:32:0x00f6), top: B:154:0x000f }] */
    /* JADX WARN: Removed duplicated region for block: B:135:0x031b  */
    /* JADX WARN: Removed duplicated region for block: B:138:0x0323 A[Catch: CancellationException -> 0x002b, Exception -> 0x0319, TryCatch #0 {CancellationException -> 0x002b, blocks: (B:7:0x001f, B:146:0x0372, B:14:0x0050, B:129:0x02e3, B:130:0x02f7, B:132:0x02fd, B:136:0x031d, B:138:0x0323, B:141:0x032d, B:143:0x0347, B:17:0x007f, B:126:0x02c4, B:20:0x00ae, B:123:0x02a5, B:23:0x00d1, B:68:0x01ae, B:71:0x01b9, B:73:0x01c0, B:75:0x01c6, B:82:0x01d8, B:84:0x01de, B:95:0x01fc, B:97:0x0202, B:99:0x0208, B:101:0x021e, B:103:0x0222, B:105:0x0229, B:108:0x0234, B:109:0x0238, B:111:0x023e, B:117:0x0261, B:119:0x0264, B:92:0x01f1, B:94:0x01f7, B:26:0x00df, B:38:0x0118, B:41:0x0122, B:43:0x0128, B:45:0x013b, B:47:0x0145, B:48:0x0150, B:50:0x0156, B:52:0x0164, B:58:0x0174, B:59:0x0178, B:60:0x0181, B:62:0x0187, B:64:0x018d, B:29:0x00ea, B:35:0x0104, B:32:0x00f6), top: B:154:0x000f }] */
    /* JADX WARN: Removed duplicated region for block: B:139:0x032a  */
    /* JADX WARN: Removed duplicated region for block: B:141:0x032d A[Catch: CancellationException -> 0x002b, Exception -> 0x0319, TryCatch #0 {CancellationException -> 0x002b, blocks: (B:7:0x001f, B:146:0x0372, B:14:0x0050, B:129:0x02e3, B:130:0x02f7, B:132:0x02fd, B:136:0x031d, B:138:0x0323, B:141:0x032d, B:143:0x0347, B:17:0x007f, B:126:0x02c4, B:20:0x00ae, B:123:0x02a5, B:23:0x00d1, B:68:0x01ae, B:71:0x01b9, B:73:0x01c0, B:75:0x01c6, B:82:0x01d8, B:84:0x01de, B:95:0x01fc, B:97:0x0202, B:99:0x0208, B:101:0x021e, B:103:0x0222, B:105:0x0229, B:108:0x0234, B:109:0x0238, B:111:0x023e, B:117:0x0261, B:119:0x0264, B:92:0x01f1, B:94:0x01f7, B:26:0x00df, B:38:0x0118, B:41:0x0122, B:43:0x0128, B:45:0x013b, B:47:0x0145, B:48:0x0150, B:50:0x0156, B:52:0x0164, B:58:0x0174, B:59:0x0178, B:60:0x0181, B:62:0x0187, B:64:0x018d, B:29:0x00ea, B:35:0x0104, B:32:0x00f6), top: B:154:0x000f }] */
    /* JADX WARN: Removed duplicated region for block: B:142:0x0345  */
    /* JADX WARN: Removed duplicated region for block: B:145:0x0371  */
    /* JADX WARN: Removed duplicated region for block: B:157:0x01c6 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:37:0x0116  */
    /* JADX WARN: Removed duplicated region for block: B:38:0x0118 A[Catch: Exception -> 0x0027, CancellationException -> 0x002b, PHI: r0 r14
      0x0118: PHI (r0v15 java.lang.Object) = (r0v12 java.lang.Object), (r0v19 java.lang.Object) binds: [B:36:0x0114, B:27:0x00e2] A[DONT_GENERATE, DONT_INLINE]
      0x0118: PHI (r14v1 ak1) = (r14v0 ak1), (r14v2 ak1) binds: [B:36:0x0114, B:27:0x00e2] A[DONT_GENERATE, DONT_INLINE], TRY_LEAVE, TryCatch #0 {CancellationException -> 0x002b, blocks: (B:7:0x001f, B:146:0x0372, B:14:0x0050, B:129:0x02e3, B:130:0x02f7, B:132:0x02fd, B:136:0x031d, B:138:0x0323, B:141:0x032d, B:143:0x0347, B:17:0x007f, B:126:0x02c4, B:20:0x00ae, B:123:0x02a5, B:23:0x00d1, B:68:0x01ae, B:71:0x01b9, B:73:0x01c0, B:75:0x01c6, B:82:0x01d8, B:84:0x01de, B:95:0x01fc, B:97:0x0202, B:99:0x0208, B:101:0x021e, B:103:0x0222, B:105:0x0229, B:108:0x0234, B:109:0x0238, B:111:0x023e, B:117:0x0261, B:119:0x0264, B:92:0x01f1, B:94:0x01f7, B:26:0x00df, B:38:0x0118, B:41:0x0122, B:43:0x0128, B:45:0x013b, B:47:0x0145, B:48:0x0150, B:50:0x0156, B:52:0x0164, B:58:0x0174, B:59:0x0178, B:60:0x0181, B:62:0x0187, B:64:0x018d, B:29:0x00ea, B:35:0x0104, B:32:0x00f6), top: B:154:0x000f }] */
    /* JADX WARN: Removed duplicated region for block: B:47:0x0145 A[Catch: Exception -> 0x0027, CancellationException -> 0x002b, TryCatch #0 {CancellationException -> 0x002b, blocks: (B:7:0x001f, B:146:0x0372, B:14:0x0050, B:129:0x02e3, B:130:0x02f7, B:132:0x02fd, B:136:0x031d, B:138:0x0323, B:141:0x032d, B:143:0x0347, B:17:0x007f, B:126:0x02c4, B:20:0x00ae, B:123:0x02a5, B:23:0x00d1, B:68:0x01ae, B:71:0x01b9, B:73:0x01c0, B:75:0x01c6, B:82:0x01d8, B:84:0x01de, B:95:0x01fc, B:97:0x0202, B:99:0x0208, B:101:0x021e, B:103:0x0222, B:105:0x0229, B:108:0x0234, B:109:0x0238, B:111:0x023e, B:117:0x0261, B:119:0x0264, B:92:0x01f1, B:94:0x01f7, B:26:0x00df, B:38:0x0118, B:41:0x0122, B:43:0x0128, B:45:0x013b, B:47:0x0145, B:48:0x0150, B:50:0x0156, B:52:0x0164, B:58:0x0174, B:59:0x0178, B:60:0x0181, B:62:0x0187, B:64:0x018d, B:29:0x00ea, B:35:0x0104, B:32:0x00f6), top: B:154:0x000f }] */
    /* JADX WARN: Removed duplicated region for block: B:62:0x0187 A[Catch: Exception -> 0x0027, CancellationException -> 0x002b, TryCatch #0 {CancellationException -> 0x002b, blocks: (B:7:0x001f, B:146:0x0372, B:14:0x0050, B:129:0x02e3, B:130:0x02f7, B:132:0x02fd, B:136:0x031d, B:138:0x0323, B:141:0x032d, B:143:0x0347, B:17:0x007f, B:126:0x02c4, B:20:0x00ae, B:123:0x02a5, B:23:0x00d1, B:68:0x01ae, B:71:0x01b9, B:73:0x01c0, B:75:0x01c6, B:82:0x01d8, B:84:0x01de, B:95:0x01fc, B:97:0x0202, B:99:0x0208, B:101:0x021e, B:103:0x0222, B:105:0x0229, B:108:0x0234, B:109:0x0238, B:111:0x023e, B:117:0x0261, B:119:0x0264, B:92:0x01f1, B:94:0x01f7, B:26:0x00df, B:38:0x0118, B:41:0x0122, B:43:0x0128, B:45:0x013b, B:47:0x0145, B:48:0x0150, B:50:0x0156, B:52:0x0164, B:58:0x0174, B:59:0x0178, B:60:0x0181, B:62:0x0187, B:64:0x018d, B:29:0x00ea, B:35:0x0104, B:32:0x00f6), top: B:154:0x000f }] */
    /* JADX WARN: Removed duplicated region for block: B:63:0x018c  */
    /* JADX WARN: Removed duplicated region for block: B:66:0x01a6  */
    /* JADX WARN: Removed duplicated region for block: B:67:0x01a8  */
    /* JADX WARN: Removed duplicated region for block: B:71:0x01b9 A[Catch: Exception -> 0x0027, CancellationException -> 0x002b, TRY_ENTER, TryCatch #0 {CancellationException -> 0x002b, blocks: (B:7:0x001f, B:146:0x0372, B:14:0x0050, B:129:0x02e3, B:130:0x02f7, B:132:0x02fd, B:136:0x031d, B:138:0x0323, B:141:0x032d, B:143:0x0347, B:17:0x007f, B:126:0x02c4, B:20:0x00ae, B:123:0x02a5, B:23:0x00d1, B:68:0x01ae, B:71:0x01b9, B:73:0x01c0, B:75:0x01c6, B:82:0x01d8, B:84:0x01de, B:95:0x01fc, B:97:0x0202, B:99:0x0208, B:101:0x021e, B:103:0x0222, B:105:0x0229, B:108:0x0234, B:109:0x0238, B:111:0x023e, B:117:0x0261, B:119:0x0264, B:92:0x01f1, B:94:0x01f7, B:26:0x00df, B:38:0x0118, B:41:0x0122, B:43:0x0128, B:45:0x013b, B:47:0x0145, B:48:0x0150, B:50:0x0156, B:52:0x0164, B:58:0x0174, B:59:0x0178, B:60:0x0181, B:62:0x0187, B:64:0x018d, B:29:0x00ea, B:35:0x0104, B:32:0x00f6), top: B:154:0x000f }] */
    /* JADX WARN: Removed duplicated region for block: B:72:0x01be  */
    /* JADX WARN: Removed duplicated region for block: B:82:0x01d8 A[Catch: CancellationException -> 0x002b, Exception -> 0x01d2, TryCatch #0 {CancellationException -> 0x002b, blocks: (B:7:0x001f, B:146:0x0372, B:14:0x0050, B:129:0x02e3, B:130:0x02f7, B:132:0x02fd, B:136:0x031d, B:138:0x0323, B:141:0x032d, B:143:0x0347, B:17:0x007f, B:126:0x02c4, B:20:0x00ae, B:123:0x02a5, B:23:0x00d1, B:68:0x01ae, B:71:0x01b9, B:73:0x01c0, B:75:0x01c6, B:82:0x01d8, B:84:0x01de, B:95:0x01fc, B:97:0x0202, B:99:0x0208, B:101:0x021e, B:103:0x0222, B:105:0x0229, B:108:0x0234, B:109:0x0238, B:111:0x023e, B:117:0x0261, B:119:0x0264, B:92:0x01f1, B:94:0x01f7, B:26:0x00df, B:38:0x0118, B:41:0x0122, B:43:0x0128, B:45:0x013b, B:47:0x0145, B:48:0x0150, B:50:0x0156, B:52:0x0164, B:58:0x0174, B:59:0x0178, B:60:0x0181, B:62:0x0187, B:64:0x018d, B:29:0x00ea, B:35:0x0104, B:32:0x00f6), top: B:154:0x000f }] */
    /* JADX WARN: Removed duplicated region for block: B:94:0x01f7 A[Catch: CancellationException -> 0x002b, Exception -> 0x01d2, TryCatch #0 {CancellationException -> 0x002b, blocks: (B:7:0x001f, B:146:0x0372, B:14:0x0050, B:129:0x02e3, B:130:0x02f7, B:132:0x02fd, B:136:0x031d, B:138:0x0323, B:141:0x032d, B:143:0x0347, B:17:0x007f, B:126:0x02c4, B:20:0x00ae, B:123:0x02a5, B:23:0x00d1, B:68:0x01ae, B:71:0x01b9, B:73:0x01c0, B:75:0x01c6, B:82:0x01d8, B:84:0x01de, B:95:0x01fc, B:97:0x0202, B:99:0x0208, B:101:0x021e, B:103:0x0222, B:105:0x0229, B:108:0x0234, B:109:0x0238, B:111:0x023e, B:117:0x0261, B:119:0x0264, B:92:0x01f1, B:94:0x01f7, B:26:0x00df, B:38:0x0118, B:41:0x0122, B:43:0x0128, B:45:0x013b, B:47:0x0145, B:48:0x0150, B:50:0x0156, B:52:0x0164, B:58:0x0174, B:59:0x0178, B:60:0x0181, B:62:0x0187, B:64:0x018d, B:29:0x00ea, B:35:0x0104, B:32:0x00f6), top: B:154:0x000f }] */
    /* JADX WARN: Removed duplicated region for block: B:97:0x0202 A[Catch: CancellationException -> 0x002b, Exception -> 0x01d2, TryCatch #0 {CancellationException -> 0x002b, blocks: (B:7:0x001f, B:146:0x0372, B:14:0x0050, B:129:0x02e3, B:130:0x02f7, B:132:0x02fd, B:136:0x031d, B:138:0x0323, B:141:0x032d, B:143:0x0347, B:17:0x007f, B:126:0x02c4, B:20:0x00ae, B:123:0x02a5, B:23:0x00d1, B:68:0x01ae, B:71:0x01b9, B:73:0x01c0, B:75:0x01c6, B:82:0x01d8, B:84:0x01de, B:95:0x01fc, B:97:0x0202, B:99:0x0208, B:101:0x021e, B:103:0x0222, B:105:0x0229, B:108:0x0234, B:109:0x0238, B:111:0x023e, B:117:0x0261, B:119:0x0264, B:92:0x01f1, B:94:0x01f7, B:26:0x00df, B:38:0x0118, B:41:0x0122, B:43:0x0128, B:45:0x013b, B:47:0x0145, B:48:0x0150, B:50:0x0156, B:52:0x0164, B:58:0x0174, B:59:0x0178, B:60:0x0181, B:62:0x0187, B:64:0x018d, B:29:0x00ea, B:35:0x0104, B:32:0x00f6), top: B:154:0x000f }] */
    /* JADX WARN: Type inference failed for: r0v36 */
    /* JADX WARN: Type inference failed for: r0v37, types: [java.lang.Number] */
    /* JADX WARN: Type inference failed for: r0v59 */
    /* JADX WARN: Type inference failed for: r11v0 */
    /* JADX WARN: Type inference failed for: r11v1, types: [java.lang.Object, java.lang.String, kotlin.coroutines.Continuation] */
    /* JADX WARN: Type inference failed for: r11v29 */
    /* JADX WARN: Type inference failed for: r11v5 */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws Throwable {
        ?? r11;
        ak1 ak1Var;
        ak1 ak1Var2;
        Object showDetails$default;
        TMDBShowDetails tMDBShowDetails;
        List<TMDBSeason> seasons;
        String imdbId;
        Object objC;
        List list;
        List list2;
        String str;
        List<TMDBCast> cast;
        List list3;
        String strBb;
        String status;
        boolean z;
        String lastAirDate;
        Integer num;
        String str2;
        Object objAb;
        String str3;
        String str4;
        TMDBShowDetails tMDBShowDetails2;
        r22 r22Var;
        List list4;
        r22 r22Var2;
        List list5;
        List list6;
        boolean z2;
        TMDBShowDetails tMDBShowDetails3;
        List list7;
        String str5;
        List list8;
        String str6;
        Integer numB;
        String str7;
        String str8;
        TraktShowProgress traktShowProgress;
        Object objAb2;
        String str9;
        Map map;
        Object objAb3;
        Object objF;
        String str10;
        int i = this.n;
        ck1 ck1Var = ck1.a;
        int i2 = this.k;
        MobileDetailsViewModel mobileDetailsViewModel = this.m;
        try {
            try {
            } catch (CancellationException e) {
                throw e;
            }
        } catch (Exception e2) {
            e = e2;
            r11 = 0;
        }
        switch (i2) {
            case 0:
                s38.b(obj);
                ak1Var = (ak1) this.l;
                RateLimiter rateLimiter = mobileDetailsViewModel.c;
                this.l = ak1Var;
                this.k = 1;
                if (rateLimiter.a(this) != ck1Var) {
                    ak1Var2 = ak1Var;
                    TMDBApiService tMDBApiService = mobileDetailsViewModel.a;
                    int i3 = this.n;
                    this.l = ak1Var2;
                    this.k = 2;
                    showDetails$default = TMDBApiService.DefaultImpls.getShowDetails$default(tMDBApiService, i3, null, this, 2, null);
                    if (showDetails$default == ck1Var) {
                        tMDBShowDetails = (TMDBShowDetails) showDetails$default;
                        TMDBCredits credits = tMDBShowDetails.getCredits();
                        List listBj = ik2.a;
                        List listBk = (credits != null || (cast = credits.getCast()) == null) ? listBj : y41.bk(y41.bj(new j26(), cast), 8);
                        String trailerKey = tMDBShowDetails.getTrailerKey();
                        seasons = tMDBShowDetails.getSeasons();
                        if (seasons != null) {
                            ArrayList arrayList = new ArrayList();
                            for (Object obj2 : seasons) {
                                Integer seasonNumber = ((TMDBSeason) obj2).getSeasonNumber();
                                if ((seasonNumber != null ? seasonNumber.intValue() : 0) > 0) {
                                    arrayList.add(obj2);
                                }
                            }
                            listBj = y41.bj(new k26(), arrayList);
                        }
                        TMDBExternalIds externalIds = tMDBShowDetails.getExternalIds();
                        imdbId = externalIds == null ? externalIds.getImdbId() : null;
                        this.l = ak1Var2;
                        this.a = tMDBShowDetails;
                        this.b = listBk;
                        this.c = trailerKey;
                        this.d = listBj;
                        this.e = imdbId;
                        this.k = 3;
                        objC = bk1.c(new p(imdbId, mobileDetailsViewModel, null), this);
                        if (objC == ck1Var) {
                            list = listBk;
                            list2 = listBj;
                            str = trailerKey;
                            list3 = (List) objC;
                            String firstAirDate = tMDBShowDetails.getFirstAirDate();
                            String strBb2 = "";
                            strBb = firstAirDate == null ? n89.bb(4, firstAirDate) : "";
                            status = tMDBShowDetails.getStatus();
                            try {
                                if (status != null) {
                                    try {
                                        z = status.equalsIgnoreCase("Ended");
                                        if (!z) {
                                            String status2 = tMDBShowDetails.getStatus();
                                            if (!(status2 != null && status2.equalsIgnoreCase("Canceled"))) {
                                                strBb2 = "Present";
                                                String str11 = strBb2;
                                                String str12 = (!n89.ab(strBb) || n89.ab(str11)) ? strBb : strBb + " - " + str11;
                                                num = mobileDetailsViewModel.i;
                                                if (num != null) {
                                                    List list9 = list2;
                                                    if (!(list9 instanceof Collection) || !list9.isEmpty()) {
                                                        Iterator it = list9.iterator();
                                                        while (it.hasNext()) {
                                                            if (cr4.b(((TMDBSeason) it.next()).getSeasonNumber(), num)) {
                                                                z2 = true;
                                                                if (z2) {
                                                                    tMDBShowDetails3 = tMDBShowDetails;
                                                                    list7 = list2;
                                                                    str5 = str;
                                                                    list8 = list;
                                                                    str6 = str12;
                                                                    numB = num;
                                                                    str7 = null;
                                                                    String str13 = imdbId;
                                                                    List<TMDBGenre> genres = tMDBShowDetails3.getGenres();
                                                                    String strAi = genres == null ? y41.ai(genres, ", ", null, null, new l24(16), 30) : str7;
                                                                    List<Integer> episodeRunTime = tMDBShowDetails3.getEpisodeRunTime();
                                                                    ?? r0 = episodeRunTime == null ? (Integer) y41.ab(episodeRunTime) : str7;
                                                                    String str14 = r0 == 0 ? r0.intValue() + CmcdData.OBJECT_TYPE_MANIFEST : str7;
                                                                    m12 m12Var = sc2.a;
                                                                    qm5 qm5Var = sm5.a;
                                                                    y yVar = new y(mobileDetailsViewModel, list8, list3, str5, list7, this.n, str13, str6, tMDBShowDetails3, strAi, str14, numB, null);
                                                                    this.l = str7;
                                                                    this.a = str7;
                                                                    this.b = str7;
                                                                    this.c = str7;
                                                                    this.d = str7;
                                                                    this.e = str7;
                                                                    this.f = str7;
                                                                    this.i = str7;
                                                                    this.j = str7;
                                                                    this.k = 7;
                                                                    objF = wj0.f(qm5Var, yVar, this);
                                                                    str2 = str7;
                                                                    if (objF == ck1Var) {
                                                                    }
                                                                    return (e6a) objF;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    z2 = false;
                                                    if (z2) {
                                                    }
                                                }
                                                str2 = null;
                                                str8 = null;
                                                r22 r22VarA = wj0.a(ak1Var2, null, new ac(mobileDetailsViewModel, i, null), 3);
                                                r22 r22VarA2 = wj0.a(ak1Var2, null, new ab(mobileDetailsViewModel, i, null), 3);
                                                r22 r22VarA3 = wj0.a(ak1Var2, null, new aa(mobileDetailsViewModel, i, null), 3);
                                                this.l = tMDBShowDetails;
                                                this.a = list;
                                                this.b = str;
                                                this.c = list2;
                                                this.d = imdbId;
                                                this.e = list3;
                                                this.f = str12;
                                                this.i = r22VarA2;
                                                this.j = r22VarA3;
                                                this.k = 4;
                                                objAb = r22VarA.ab(this);
                                                if (objAb == ck1Var) {
                                                    String str15 = str12;
                                                    str3 = str;
                                                    str4 = str15;
                                                    tMDBShowDetails2 = tMDBShowDetails;
                                                    r22Var = r22VarA3;
                                                    list4 = list2;
                                                    r22Var2 = r22VarA2;
                                                    list5 = list;
                                                    list6 = list3;
                                                    traktShowProgress = (TraktShowProgress) objAb;
                                                    this.l = tMDBShowDetails2;
                                                    this.a = list5;
                                                    this.b = str3;
                                                    this.c = list4;
                                                    this.d = imdbId;
                                                    this.e = list6;
                                                    this.f = str4;
                                                    this.i = r22Var;
                                                    this.j = traktShowProgress;
                                                    this.k = 5;
                                                    objAb2 = r22Var2.ab(this);
                                                    str9 = str8;
                                                    if (objAb2 == ck1Var) {
                                                        map = (Map) objAb2;
                                                        this.l = tMDBShowDetails2;
                                                        this.a = list5;
                                                        this.b = str3;
                                                        this.c = list4;
                                                        this.d = imdbId;
                                                        this.e = list6;
                                                        this.f = str4;
                                                        this.i = traktShowProgress;
                                                        this.j = map;
                                                        this.k = 6;
                                                        objAb3 = r22Var.ab(this);
                                                        str10 = str9;
                                                        if (objAb3 == ck1Var) {
                                                        }
                                                        numB = MobileDetailsViewModel.b(mobileDetailsViewModel, list4, (List) objAb3, traktShowProgress, map);
                                                        str6 = str4;
                                                        list3 = list6;
                                                        list7 = list4;
                                                        str5 = str3;
                                                        list8 = list5;
                                                        tMDBShowDetails3 = tMDBShowDetails2;
                                                        str7 = str10;
                                                        String str132 = imdbId;
                                                        List<TMDBGenre> genres2 = tMDBShowDetails3.getGenres();
                                                        if (genres2 == null) {
                                                        }
                                                        List<Integer> episodeRunTime2 = tMDBShowDetails3.getEpisodeRunTime();
                                                        if (episodeRunTime2 == null) {
                                                        }
                                                        if (r0 == 0) {
                                                        }
                                                        m12 m12Var2 = sc2.a;
                                                        qm5 qm5Var2 = sm5.a;
                                                        y yVar2 = new y(mobileDetailsViewModel, list8, list3, str5, list7, this.n, str132, str6, tMDBShowDetails3, strAi, str14, numB, null);
                                                        this.l = str7;
                                                        this.a = str7;
                                                        this.b = str7;
                                                        this.c = str7;
                                                        this.d = str7;
                                                        this.e = str7;
                                                        this.f = str7;
                                                        this.i = str7;
                                                        this.j = str7;
                                                        this.k = 7;
                                                        objF = wj0.f(qm5Var2, yVar2, this);
                                                        str2 = str7;
                                                        if (objF == ck1Var) {
                                                        }
                                                        return (e6a) objF;
                                                    }
                                                }
                                            }
                                        }
                                        lastAirDate = tMDBShowDetails.getLastAirDate();
                                        if (lastAirDate != null) {
                                            strBb2 = n89.bb(4, lastAirDate);
                                        }
                                        String str112 = strBb2;
                                        if (n89.ab(strBb)) {
                                        }
                                        num = mobileDetailsViewModel.i;
                                        if (num != null) {
                                        }
                                        str2 = null;
                                        str8 = null;
                                        r22 r22VarA4 = wj0.a(ak1Var2, null, new ac(mobileDetailsViewModel, i, null), 3);
                                        r22 r22VarA22 = wj0.a(ak1Var2, null, new ab(mobileDetailsViewModel, i, null), 3);
                                        r22 r22VarA32 = wj0.a(ak1Var2, null, new aa(mobileDetailsViewModel, i, null), 3);
                                        this.l = tMDBShowDetails;
                                        this.a = list;
                                        this.b = str;
                                        this.c = list2;
                                        this.d = imdbId;
                                        this.e = list3;
                                        this.f = str12;
                                        this.i = r22VarA22;
                                        this.j = r22VarA32;
                                        this.k = 4;
                                        objAb = r22VarA4.ab(this);
                                        if (objAb == ck1Var) {
                                        }
                                    } catch (Exception e3) {
                                        e = e3;
                                        r11 = 0;
                                        Log.e("MobileDetailsViewModel", "Error loading show details", e);
                                        m12 m12Var3 = sc2.a;
                                        qm5 qm5Var3 = sm5.a;
                                        z zVar = new z(mobileDetailsViewModel, r11);
                                        this.l = r11;
                                        this.a = r11;
                                        this.b = r11;
                                        this.c = r11;
                                        this.d = r11;
                                        this.e = r11;
                                        this.f = r11;
                                        this.i = r11;
                                        this.j = r11;
                                        this.k = 8;
                                        break;
                                    }
                                }
                                r22 r22VarA42 = wj0.a(ak1Var2, null, new ac(mobileDetailsViewModel, i, null), 3);
                                r22 r22VarA222 = wj0.a(ak1Var2, null, new ab(mobileDetailsViewModel, i, null), 3);
                                r22 r22VarA322 = wj0.a(ak1Var2, null, new aa(mobileDetailsViewModel, i, null), 3);
                                this.l = tMDBShowDetails;
                                this.a = list;
                                this.b = str;
                                this.c = list2;
                                this.d = imdbId;
                                this.e = list3;
                                this.f = str12;
                                this.i = r22VarA222;
                                this.j = r22VarA322;
                                this.k = 4;
                                objAb = r22VarA42.ab(this);
                                if (objAb == ck1Var) {
                                }
                            } catch (Exception e4) {
                                e = e4;
                                r11 = str2;
                                Log.e("MobileDetailsViewModel", "Error loading show details", e);
                                m12 m12Var32 = sc2.a;
                                qm5 qm5Var32 = sm5.a;
                                z zVar2 = new z(mobileDetailsViewModel, r11);
                                this.l = r11;
                                this.a = r11;
                                this.b = r11;
                                this.c = r11;
                                this.d = r11;
                                this.e = r11;
                                this.f = r11;
                                this.i = r11;
                                this.j = r11;
                                this.k = 8;
                                break;
                            }
                            if (!z) {
                            }
                            lastAirDate = tMDBShowDetails.getLastAirDate();
                            if (lastAirDate != null) {
                            }
                            String str1122 = strBb2;
                            if (n89.ab(strBb)) {
                            }
                            num = mobileDetailsViewModel.i;
                            if (num != null) {
                            }
                            str2 = null;
                            str8 = null;
                        }
                    }
                }
                return ck1Var;
            case 1:
                ak1Var = (ak1) this.l;
                s38.b(obj);
                ak1Var2 = ak1Var;
                TMDBApiService tMDBApiService2 = mobileDetailsViewModel.a;
                int i32 = this.n;
                this.l = ak1Var2;
                this.k = 2;
                showDetails$default = TMDBApiService.DefaultImpls.getShowDetails$default(tMDBApiService2, i32, null, this, 2, null);
                if (showDetails$default == ck1Var) {
                }
                return ck1Var;
            case 2:
                ak1 ak1Var3 = (ak1) this.l;
                s38.b(obj);
                ak1Var2 = ak1Var3;
                showDetails$default = obj;
                tMDBShowDetails = (TMDBShowDetails) showDetails$default;
                TMDBCredits credits2 = tMDBShowDetails.getCredits();
                List listBj2 = ik2.a;
                if (credits2 != null) {
                }
                String trailerKey2 = tMDBShowDetails.getTrailerKey();
                seasons = tMDBShowDetails.getSeasons();
                if (seasons != null) {
                }
                TMDBExternalIds externalIds2 = tMDBShowDetails.getExternalIds();
                if (externalIds2 == null) {
                }
                this.l = ak1Var2;
                this.a = tMDBShowDetails;
                this.b = listBk;
                this.c = trailerKey2;
                this.d = listBj2;
                this.e = imdbId;
                this.k = 3;
                objC = bk1.c(new p(imdbId, mobileDetailsViewModel, null), this);
                if (objC == ck1Var) {
                }
                break;
            case 3:
                String str16 = (String) this.e;
                list2 = (List) this.d;
                str = (String) this.c;
                list = (List) this.b;
                TMDBShowDetails tMDBShowDetails4 = (TMDBShowDetails) this.a;
                ak1Var2 = (ak1) this.l;
                s38.b(obj);
                imdbId = str16;
                tMDBShowDetails = tMDBShowDetails4;
                objC = obj;
                list3 = (List) objC;
                String firstAirDate2 = tMDBShowDetails.getFirstAirDate();
                String strBb22 = "";
                if (firstAirDate2 == null) {
                }
                status = tMDBShowDetails.getStatus();
                if (status != null) {
                }
                if (!z) {
                }
                lastAirDate = tMDBShowDetails.getLastAirDate();
                if (lastAirDate != null) {
                }
                String str11222 = strBb22;
                if (n89.ab(strBb)) {
                }
                num = mobileDetailsViewModel.i;
                if (num != null) {
                }
                str2 = null;
                str8 = null;
                r22 r22VarA422 = wj0.a(ak1Var2, null, new ac(mobileDetailsViewModel, i, null), 3);
                r22 r22VarA2222 = wj0.a(ak1Var2, null, new ab(mobileDetailsViewModel, i, null), 3);
                r22 r22VarA3222 = wj0.a(ak1Var2, null, new aa(mobileDetailsViewModel, i, null), 3);
                this.l = tMDBShowDetails;
                this.a = list;
                this.b = str;
                this.c = list2;
                this.d = imdbId;
                this.e = list3;
                this.f = str12;
                this.i = r22VarA2222;
                this.j = r22VarA3222;
                this.k = 4;
                objAb = r22VarA422.ab(this);
                if (objAb == ck1Var) {
                }
                break;
            case 4:
                r22Var = (r22) this.j;
                r22Var2 = (r22) this.i;
                str4 = this.f;
                list6 = (List) this.e;
                imdbId = (String) this.d;
                list4 = (List) this.c;
                str3 = (String) this.b;
                List list10 = (List) this.a;
                TMDBShowDetails tMDBShowDetails5 = (TMDBShowDetails) this.l;
                s38.b(obj);
                tMDBShowDetails2 = tMDBShowDetails5;
                str8 = null;
                list5 = list10;
                objAb = obj;
                traktShowProgress = (TraktShowProgress) objAb;
                this.l = tMDBShowDetails2;
                this.a = list5;
                this.b = str3;
                this.c = list4;
                this.d = imdbId;
                this.e = list6;
                this.f = str4;
                this.i = r22Var;
                this.j = traktShowProgress;
                this.k = 5;
                objAb2 = r22Var2.ab(this);
                str9 = str8;
                if (objAb2 == ck1Var) {
                }
                return ck1Var;
            case 5:
                TraktShowProgress traktShowProgress2 = (TraktShowProgress) this.j;
                r22 r22Var3 = (r22) this.i;
                str4 = this.f;
                list6 = (List) this.e;
                imdbId = (String) this.d;
                list4 = (List) this.c;
                str3 = (String) this.b;
                List list11 = (List) this.a;
                TMDBShowDetails tMDBShowDetails6 = (TMDBShowDetails) this.l;
                s38.b(obj);
                tMDBShowDetails2 = tMDBShowDetails6;
                str9 = null;
                list5 = list11;
                traktShowProgress = traktShowProgress2;
                r22Var = r22Var3;
                objAb2 = obj;
                map = (Map) objAb2;
                this.l = tMDBShowDetails2;
                this.a = list5;
                this.b = str3;
                this.c = list4;
                this.d = imdbId;
                this.e = list6;
                this.f = str4;
                this.i = traktShowProgress;
                this.j = map;
                this.k = 6;
                objAb3 = r22Var.ab(this);
                str10 = str9;
                if (objAb3 == ck1Var) {
                }
                numB = MobileDetailsViewModel.b(mobileDetailsViewModel, list4, (List) objAb3, traktShowProgress, map);
                str6 = str4;
                list3 = list6;
                list7 = list4;
                str5 = str3;
                list8 = list5;
                tMDBShowDetails3 = tMDBShowDetails2;
                str7 = str10;
                String str1322 = imdbId;
                List<TMDBGenre> genres22 = tMDBShowDetails3.getGenres();
                if (genres22 == null) {
                }
                List<Integer> episodeRunTime22 = tMDBShowDetails3.getEpisodeRunTime();
                if (episodeRunTime22 == null) {
                }
                if (r0 == 0) {
                }
                m12 m12Var22 = sc2.a;
                qm5 qm5Var22 = sm5.a;
                y yVar22 = new y(mobileDetailsViewModel, list8, list3, str5, list7, this.n, str1322, str6, tMDBShowDetails3, strAi, str14, numB, null);
                this.l = str7;
                this.a = str7;
                this.b = str7;
                this.c = str7;
                this.d = str7;
                this.e = str7;
                this.f = str7;
                this.i = str7;
                this.j = str7;
                this.k = 7;
                objF = wj0.f(qm5Var22, yVar22, this);
                str2 = str7;
                if (objF == ck1Var) {
                }
                return (e6a) objF;
            case 6:
                Map map2 = (Map) this.j;
                TraktShowProgress traktShowProgress3 = (TraktShowProgress) this.i;
                str4 = this.f;
                list6 = (List) this.e;
                imdbId = (String) this.d;
                list4 = (List) this.c;
                str3 = (String) this.b;
                List list12 = (List) this.a;
                TMDBShowDetails tMDBShowDetails7 = (TMDBShowDetails) this.l;
                s38.b(obj);
                tMDBShowDetails2 = tMDBShowDetails7;
                str10 = null;
                list5 = list12;
                traktShowProgress = traktShowProgress3;
                map = map2;
                objAb3 = obj;
                numB = MobileDetailsViewModel.b(mobileDetailsViewModel, list4, (List) objAb3, traktShowProgress, map);
                str6 = str4;
                list3 = list6;
                list7 = list4;
                str5 = str3;
                list8 = list5;
                tMDBShowDetails3 = tMDBShowDetails2;
                str7 = str10;
                String str13222 = imdbId;
                List<TMDBGenre> genres222 = tMDBShowDetails3.getGenres();
                if (genres222 == null) {
                }
                List<Integer> episodeRunTime222 = tMDBShowDetails3.getEpisodeRunTime();
                if (episodeRunTime222 == null) {
                }
                if (r0 == 0) {
                }
                m12 m12Var222 = sc2.a;
                qm5 qm5Var222 = sm5.a;
                y yVar222 = new y(mobileDetailsViewModel, list8, list3, str5, list7, this.n, str13222, str6, tMDBShowDetails3, strAi, str14, numB, null);
                this.l = str7;
                this.a = str7;
                this.b = str7;
                this.c = str7;
                this.d = str7;
                this.e = str7;
                this.f = str7;
                this.i = str7;
                this.j = str7;
                this.k = 7;
                objF = wj0.f(qm5Var222, yVar222, this);
                str2 = str7;
                if (objF == ck1Var) {
                }
                return (e6a) objF;
            case 7:
                s38.b(obj);
                objF = obj;
                str2 = null;
                return (e6a) objF;
            case 8:
                s38.b(obj);
                return e6a.a;
            default:
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }
}
