package a3;

import D.C0135f;
import M2.C0522k;
import V2.AbstractC0661f3;
import V2.C0636a3;
import V2.O0;
import V2.P2;
import V2.n3;
import a0.C0912k0;
import a0.C0932r0;
import android.content.Context;
import android.os.SystemClock;
import androidx.compose.runtime.Composer;
import androidx.compose.runtime.ComposerKt;
import androidx.compose.runtime.EffectsKt;
import androidx.compose.runtime.ScopeUpdateScope;
import androidx.media3.exoplayer.DecoderReuseEvaluation;
import androidx.media3.exoplayer.RendererCapabilities;
import androidx.media3.extractor.text.ttml.TtmlNode;
import com.debridstream.tv.PlayerViewModel;
import com.debridstream.tv.data.home.HomeMetaItem;
import com.revenuecat.purchases.common.networking.RCHTTPStatusCodes;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import m3.AbstractC2467b;
import okhttp3.OkHttpClient;
import org.json.JSONException;
import w4.C3137A;

/* JADX INFO: renamed from: a3.q, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC0978q {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final w4.p f10754a = m1.g.k(new C0932r0(8));

    public static final void a(String str, String type, Integer num, Integer num2, String title, boolean z6, Composer composer, int i6) {
        Object obj;
        int i7;
        Object obj2;
        boolean z7;
        kotlin.jvm.internal.o.h(type, "type");
        kotlin.jvm.internal.o.h(title, "title");
        Composer composerStartRestartGroup = composer.startRestartGroup(2068312609);
        if ((i6 & 6) == 0) {
            obj = str;
            i7 = (composerStartRestartGroup.changed(obj) ? 4 : 2) | i6;
        } else {
            obj = str;
            i7 = i6;
        }
        if ((i6 & 48) == 0) {
            i7 |= composerStartRestartGroup.changed(type) ? 32 : 16;
        }
        if ((i6 & RendererCapabilities.DECODER_SUPPORT_MASK) == 0) {
            i7 |= composerStartRestartGroup.changed(num) ? 256 : 128;
        }
        if ((i6 & 3072) == 0) {
            obj2 = num2;
            i7 |= composerStartRestartGroup.changed(obj2) ? 2048 : 1024;
        } else {
            obj2 = num2;
        }
        if ((i6 & 24576) == 0) {
            i7 |= composerStartRestartGroup.changed(title) ? 16384 : 8192;
        }
        if ((196608 & i6) == 0) {
            z7 = z6;
            i7 |= composerStartRestartGroup.changed(z7) ? 131072 : androidx.media3.common.C.DEFAULT_BUFFER_SEGMENT_SIZE;
        } else {
            z7 = z6;
        }
        if ((i7 & 74899) == 74898 && composerStartRestartGroup.getSkipping()) {
            composerStartRestartGroup.skipToGroupEnd();
        } else {
            if (ComposerKt.isTraceInProgress()) {
                ComposerKt.traceEventStart(2068312609, i7, -1, "com.debridstream.tv.helpers.DetailsBackgroundScrapeEffect (AutoPlayFlow.kt:700)");
            }
            Object obj3 = obj2;
            int i8 = i7;
            Object[] objArr = {obj, type, num, obj3, title, Boolean.valueOf(z7)};
            composerStartRestartGroup.startReplaceGroup(319735658);
            boolean z8 = ((i8 & 14) == 4) | ((i8 & 112) == 32) | ((i8 & 896) == 256) | ((i8 & 7168) == 2048) | ((458752 & i8) == 131072) | ((57344 & i8) == 16384);
            Object objRememberedValue = composerStartRestartGroup.rememberedValue();
            if (z8 || objRememberedValue == Composer.Companion.getEmpty()) {
                C0966e c0966e = new C0966e(str, type, num, num2, z7, title, null);
                composerStartRestartGroup.updateRememberedValue(c0966e);
                objRememberedValue = c0966e;
            }
            composerStartRestartGroup.endReplaceGroup();
            EffectsKt.LaunchedEffect(objArr, (J4.e) objRememberedValue, composerStartRestartGroup, 0);
            if (ComposerKt.isTraceInProgress()) {
                ComposerKt.traceEventEnd();
            }
        }
        ScopeUpdateScope scopeUpdateScopeEndRestartGroup = composerStartRestartGroup.endRestartGroup();
        if (scopeUpdateScopeEndRestartGroup != null) {
            scopeUpdateScopeEndRestartGroup.updateScope(new C0912k0(str, type, num, num2, title, z6, i6));
        }
    }

    public static final V b(Y key) {
        kotlin.jvm.internal.o.h(key, "key");
        return new V(new C0970i(1, null), new C0135f(key, 24), new C0932r0(9), new C0932r0(10));
    }

    public static final boolean c(C0636a3 c0636a3, Y key) {
        kotlin.jvm.internal.o.h(c0636a3, "<this>");
        kotlin.jvm.internal.o.h(key, "key");
        if (kotlin.jvm.internal.o.c(c0636a3.f7682a, key.f10604a)) {
            String str = c0636a3.f7683b;
            String str2 = key.f10609f;
            if (!kotlin.jvm.internal.o.c(str, str2) || c0636a3.f7686e != key.f10608e) {
                return false;
            }
            if (kotlin.jvm.internal.o.c(str2, "tv")) {
                return kotlin.jvm.internal.o.c(c0636a3.f7684c, key.f10606c) && kotlin.jvm.internal.o.c(c0636a3.f7685d, key.f10607d);
            }
            return true;
        }
        return false;
    }

    /* JADX WARN: Code restructure failed: missing block: B:28:0x00bc, code lost:
    
        if (r1 == r2) goto L29;
     */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0018  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object d(Y y6, String str, C0963b c0963b, N2.r rVar, OkHttpClient okHttpClient, long j4, long j6, C4.c cVar) {
        C0971j c0971j;
        N2.r rVar2;
        C0963b c0963b2;
        OkHttpClient okHttpClient2;
        Y y7;
        if (cVar instanceof C0971j) {
            c0971j = (C0971j) cVar;
            int i6 = c0971j.f10677f;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                c0971j.f10677f = i6 - Integer.MIN_VALUE;
            } else {
                c0971j = new C0971j(cVar);
            }
        }
        C0971j c0971j2 = c0971j;
        Object objD0 = c0971j2.f10676e;
        B4.a aVar = B4.a.f492a;
        int i7 = c0971j2.f10677f;
        if (i7 == 0) {
            AbstractC2467b.l(objD0);
            if (!kotlin.jvm.internal.o.c(y6.f10609f, "tv")) {
                throw new IllegalArgumentException("prefetchTvEpisodeDownloadLink requires type tv");
            }
            AtomicInteger atomicInteger = AbstractC0661f3.f7764a;
            AbstractC0661f3.d(y6.f10606c, y6.f10607d, y6.f10604a, "tv", str, y6.f10608e);
            X x6 = new X(new B.V(y6, 28), j4, j6);
            c0971j2.f10672a = y6;
            c0971j2.f10673b = c0963b;
            rVar2 = rVar;
            c0971j2.f10674c = rVar2;
            c0971j2.f10675d = okHttpClient;
            c0971j2.f10677f = 1;
            Object objJ = j(x6, c0971j2);
            if (objJ != aVar) {
                c0963b2 = c0963b;
                objD0 = objJ;
                okHttpClient2 = okHttpClient;
                y7 = y6;
            }
            return aVar;
        }
        if (i7 != 1) {
            if (i7 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            AbstractC2467b.l(objD0);
            P p6 = (P) objD0;
            String str2 = p6.f10574a;
            if (str2 == null || S4.p.Q0(str2)) {
                return null;
            }
            return p6;
        }
        OkHttpClient okHttpClient3 = c0971j2.f10675d;
        rVar2 = c0971j2.f10674c;
        C0963b c0963b3 = c0971j2.f10673b;
        y7 = c0971j2.f10672a;
        AbstractC2467b.l(objD0);
        okHttpClient2 = okHttpClient3;
        c0963b2 = c0963b3;
        N2.r rVar3 = rVar2;
        List list = (List) objD0;
        if (!list.isEmpty()) {
            Integer num = y7.f10606c;
            Integer num2 = y7.f10607d;
            boolean z6 = y7.f10608e;
            int size = list.size();
            Map map = N2.q.f5245b;
            c0971j2.f10672a = null;
            c0971j2.f10673b = null;
            c0971j2.f10674c = null;
            c0971j2.f10675d = null;
            c0971j2.f10677f = 2;
            objD0 = W.a.d0(list, "tv", num, num2, z6, size, map, c0963b2, rVar3, okHttpClient2, c0971j2);
        }
        return null;
    }

    /* JADX WARN: Removed duplicated region for block: B:79:0x01c7  */
    /* JADX WARN: Removed duplicated region for block: B:82:0x0208  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final J e(Context context, HomeMetaItem item, n3 settingsState, int i6, PlayerViewModel playerViewModel, X2.g gVar, J4.a onPlayNavigate, J4.a onShowWhereToWatch, J4.c onPlayBusy, J4.c cVar, J4.a aVar, Composer composer, int i7, int i8) {
        Composer.Companion companion;
        int i9;
        boolean z6;
        boolean zChanged;
        Object objRememberedValue;
        Composer composer2;
        kotlin.jvm.internal.o.h(context, "context");
        kotlin.jvm.internal.o.h(item, "item");
        kotlin.jvm.internal.o.h(settingsState, "settingsState");
        kotlin.jvm.internal.o.h(playerViewModel, "playerViewModel");
        kotlin.jvm.internal.o.h(onPlayNavigate, "onPlayNavigate");
        kotlin.jvm.internal.o.h(onShowWhereToWatch, "onShowWhereToWatch");
        kotlin.jvm.internal.o.h(onPlayBusy, "onPlayBusy");
        composer.startReplaceGroup(1098179924);
        J4.a aVar2 = (i8 & 1024) != 0 ? null : aVar;
        if (ComposerKt.isTraceInProgress()) {
            ComposerKt.traceEventStart(1098179924, i7, 0, "com.debridstream.tv.helpers.rememberDetailsPlayLauncher (AutoPlayFlow.kt:617)");
        }
        Object objRememberedValue2 = composer.rememberedValue();
        Composer.Companion companion2 = Composer.Companion;
        if (objRememberedValue2 == companion2.getEmpty()) {
            objRememberedValue2 = EffectsKt.createCompositionCoroutineScope(A4.k.f106a, composer);
            composer.updateRememberedValue(objRememberedValue2);
        }
        V4.C c6 = (V4.C) objRememberedValue2;
        composer.startReplaceGroup(1263086083);
        Object objRememberedValue3 = composer.rememberedValue();
        if (objRememberedValue3 == companion2.getEmpty()) {
            objRememberedValue3 = AbstractC0661f3.a();
            composer.updateRememberedValue(objRememberedValue3);
        }
        N2.r rVar = (N2.r) objRememberedValue3;
        composer.endReplaceGroup();
        int i10 = (i7 >> 6) & 14;
        composer.startReplaceGroup(788689470);
        if (ComposerKt.isTraceInProgress()) {
            companion = companion2;
            ComposerKt.traceEventStart(788689470, i10, -1, "com.debridstream.tv.helpers.rememberAutoLinkSelectPreferences (AutoPlayFlow.kt:600)");
        } else {
            companion = companion2;
        }
        composer.startReplaceGroup(860079144);
        O0 o02 = settingsState.f7975e;
        boolean zChanged2 = composer.changed(o02);
        Object objRememberedValue4 = composer.rememberedValue();
        if (zChanged2 || objRememberedValue4 == companion.getEmpty()) {
            kotlin.jvm.internal.o.h(o02, "<this>");
            objRememberedValue4 = new C0963b(o02.f7461b, o02.f7463d, o02.f7462c);
            composer.updateRememberedValue(objRememberedValue4);
        }
        C0963b c0963b = (C0963b) objRememberedValue4;
        composer.endReplaceGroup();
        if (ComposerKt.isTraceInProgress()) {
            ComposerKt.traceEventEnd();
        }
        Object objJ = A0.a.j(composer, 1263090997);
        if (objJ == companion.getEmpty()) {
            objJ = new K();
            composer.updateRememberedValue(objJ);
        }
        K k6 = (K) objJ;
        composer.endReplaceGroup();
        composer.startReplaceGroup(1263094924);
        boolean z7 = true;
        boolean zChanged3 = ((((i7 & 896) ^ RendererCapabilities.DECODER_SUPPORT_MASK) > 256 && composer.changed(settingsState)) || (i7 & RendererCapabilities.DECODER_SUPPORT_MASK) == 256) | composer.changed(context) | composer.changed(item);
        if (((i7 & 7168) ^ 3072) > 2048) {
            i9 = i6;
            if (composer.changed(i9)) {
                z6 = zChanged3;
            }
            boolean zChanged4 = ((((i7 & 3670016) ^ 1572864) <= 1048576 && composer.changed(onPlayNavigate)) || (i7 & 1572864) == 1048576) | z6 | z | composer.changed(playerViewModel) | composer.changed(gVar) | composer.changed(c0963b) | composer.changed(c6) | ((((i7 & 29360128) ^ 12582912) <= 8388608 && composer.changed(onShowWhereToWatch)) || (i7 & 12582912) == 8388608);
            if ((((i7 & 234881024) ^ 100663296) > 67108864 || !composer.changed(onPlayBusy)) && (i7 & 100663296) != 67108864) {
            }
            zChanged = zChanged4 | z7 | composer.changed(cVar) | composer.changed(aVar2);
            objRememberedValue = composer.rememberedValue();
            if (!zChanged || objRememberedValue == companion.getEmpty()) {
                J j4 = new J(new B2.j(22, k6, onPlayBusy), new C0135f(k6, 23), new C0964c(k6, c6, context, item, settingsState, i9, c0963b, rVar, playerViewModel, gVar, cVar, onShowWhereToWatch, onPlayBusy, aVar2, onPlayNavigate));
                composer2 = composer;
                composer2.updateRememberedValue(j4);
                objRememberedValue = j4;
            } else {
                composer2 = composer;
            }
            J j6 = (J) objRememberedValue;
            composer2.endReplaceGroup();
            if (ComposerKt.isTraceInProgress()) {
                ComposerKt.traceEventEnd();
            }
            composer2.endReplaceGroup();
            return j6;
        }
        i9 = i6;
        z6 = zChanged3;
        boolean z8 = (i7 & 3072) == 2048;
        boolean zChanged42 = ((((i7 & 3670016) ^ 1572864) <= 1048576 && composer.changed(onPlayNavigate)) || (i7 & 1572864) == 1048576) | z6 | z8 | composer.changed(playerViewModel) | composer.changed(gVar) | composer.changed(c0963b) | composer.changed(c6) | ((((i7 & 29360128) ^ 12582912) <= 8388608 && composer.changed(onShowWhereToWatch)) || (i7 & 12582912) == 8388608);
        z7 = ((i7 & 234881024) ^ 100663296) > 67108864 ? false : false;
        zChanged = zChanged42 | z7 | composer.changed(cVar) | composer.changed(aVar2);
        objRememberedValue = composer.rememberedValue();
        if (zChanged) {
            J j42 = new J(new B2.j(22, k6, onPlayBusy), new C0135f(k6, 23), new C0964c(k6, c6, context, item, settingsState, i9, c0963b, rVar, playerViewModel, gVar, cVar, onShowWhereToWatch, onPlayBusy, aVar2, onPlayNavigate));
            composer2 = composer;
            composer2.updateRememberedValue(j42);
            objRememberedValue = j42;
        }
        J j62 = (J) objRememberedValue;
        composer2.endReplaceGroup();
        if (ComposerKt.isTraceInProgress()) {
        }
        composer2.endReplaceGroup();
        return j62;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object f(Y y6, String str, C0963b c0963b, N2.r rVar, OkHttpClient okHttpClient, String str2, String str3, long j4, long j6, int i6, C4.c cVar) {
        C0973l c0973l;
        if (cVar instanceof C0973l) {
            c0973l = (C0973l) cVar;
            int i7 = c0973l.f10703b;
            if ((i7 & Integer.MIN_VALUE) != 0) {
                c0973l.f10703b = i7 - Integer.MIN_VALUE;
            } else {
                c0973l = new C0973l(cVar);
            }
        }
        Object obj = c0973l.f10702a;
        B4.a aVar = B4.a.f492a;
        int i8 = c0973l.f10703b;
        if (i8 == 0) {
            AbstractC2467b.l(obj);
            if (!kotlin.jvm.internal.o.c(y6.f10609f, "tv")) {
                throw new IllegalArgumentException("resolveTvEpisodeFromScraperStore requires type tv");
            }
            V vB = b(y6);
            Integer num = y6.f10606c;
            Integer num2 = y6.f10607d;
            boolean z6 = y6.f10608e;
            Map map = N2.q.f5245b;
            U u6 = new U();
            c0973l.f10703b = 1;
            Object objE0 = W.a.e0(vB, "tv", num, num2, z6, i6, j6, j4, map, c0963b, rVar, okHttpClient, str2, str3, u6, null, c0973l, DecoderReuseEvaluation.DISCARD_REASON_AUDIO_BYPASS_POSSIBLE);
            if (objE0 == aVar) {
                return aVar;
            }
            obj = objE0;
        } else {
            if (i8 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            AbstractC2467b.l(obj);
        }
        P p6 = (P) obj;
        String str4 = p6.f10574a;
        if ((str4 == null || S4.p.Q0(str4)) && !p6.f10580g) {
            return null;
        }
        return p6;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:101:0x01e7  */
    /* JADX WARN: Removed duplicated region for block: B:104:0x01ee A[Catch: all -> 0x004a, TryCatch #0 {all -> 0x004a, blocks: (B:13:0x0042, B:131:0x02ca, B:134:0x02da, B:136:0x02e8, B:138:0x02ec, B:140:0x02f4, B:141:0x0300, B:20:0x0075, B:64:0x014d, B:66:0x0151, B:70:0x0166, B:74:0x0178, B:77:0x0199, B:80:0x01a9, B:91:0x01cc, B:94:0x01d4, B:102:0x01e8, B:104:0x01ee, B:108:0x0202, B:112:0x020a, B:114:0x0241, B:116:0x0247, B:118:0x0252, B:120:0x0258, B:122:0x025f, B:127:0x0286, B:113:0x0222, B:96:0x01da, B:98:0x01de, B:83:0x01b5, B:85:0x01bb), top: B:146:0x0030 }] */
    /* JADX WARN: Removed duplicated region for block: B:113:0x0222 A[Catch: all -> 0x004a, TryCatch #0 {all -> 0x004a, blocks: (B:13:0x0042, B:131:0x02ca, B:134:0x02da, B:136:0x02e8, B:138:0x02ec, B:140:0x02f4, B:141:0x0300, B:20:0x0075, B:64:0x014d, B:66:0x0151, B:70:0x0166, B:74:0x0178, B:77:0x0199, B:80:0x01a9, B:91:0x01cc, B:94:0x01d4, B:102:0x01e8, B:104:0x01ee, B:108:0x0202, B:112:0x020a, B:114:0x0241, B:116:0x0247, B:118:0x0252, B:120:0x0258, B:122:0x025f, B:127:0x0286, B:113:0x0222, B:96:0x01da, B:98:0x01de, B:83:0x01b5, B:85:0x01bb), top: B:146:0x0030 }] */
    /* JADX WARN: Removed duplicated region for block: B:116:0x0247 A[Catch: all -> 0x004a, TryCatch #0 {all -> 0x004a, blocks: (B:13:0x0042, B:131:0x02ca, B:134:0x02da, B:136:0x02e8, B:138:0x02ec, B:140:0x02f4, B:141:0x0300, B:20:0x0075, B:64:0x014d, B:66:0x0151, B:70:0x0166, B:74:0x0178, B:77:0x0199, B:80:0x01a9, B:91:0x01cc, B:94:0x01d4, B:102:0x01e8, B:104:0x01ee, B:108:0x0202, B:112:0x020a, B:114:0x0241, B:116:0x0247, B:118:0x0252, B:120:0x0258, B:122:0x025f, B:127:0x0286, B:113:0x0222, B:96:0x01da, B:98:0x01de, B:83:0x01b5, B:85:0x01bb), top: B:146:0x0030 }] */
    /* JADX WARN: Removed duplicated region for block: B:117:0x024f  */
    /* JADX WARN: Removed duplicated region for block: B:120:0x0258 A[Catch: all -> 0x004a, TryCatch #0 {all -> 0x004a, blocks: (B:13:0x0042, B:131:0x02ca, B:134:0x02da, B:136:0x02e8, B:138:0x02ec, B:140:0x02f4, B:141:0x0300, B:20:0x0075, B:64:0x014d, B:66:0x0151, B:70:0x0166, B:74:0x0178, B:77:0x0199, B:80:0x01a9, B:91:0x01cc, B:94:0x01d4, B:102:0x01e8, B:104:0x01ee, B:108:0x0202, B:112:0x020a, B:114:0x0241, B:116:0x0247, B:118:0x0252, B:120:0x0258, B:122:0x025f, B:127:0x0286, B:113:0x0222, B:96:0x01da, B:98:0x01de, B:83:0x01b5, B:85:0x01bb), top: B:146:0x0030 }] */
    /* JADX WARN: Removed duplicated region for block: B:121:0x025e  */
    /* JADX WARN: Removed duplicated region for block: B:124:0x027e  */
    /* JADX WARN: Removed duplicated region for block: B:126:0x0284  */
    /* JADX WARN: Removed duplicated region for block: B:133:0x02d8 A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:141:0x0300 A[Catch: all -> 0x004a, TRY_LEAVE, TryCatch #0 {all -> 0x004a, blocks: (B:13:0x0042, B:131:0x02ca, B:134:0x02da, B:136:0x02e8, B:138:0x02ec, B:140:0x02f4, B:141:0x0300, B:20:0x0075, B:64:0x014d, B:66:0x0151, B:70:0x0166, B:74:0x0178, B:77:0x0199, B:80:0x01a9, B:91:0x01cc, B:94:0x01d4, B:102:0x01e8, B:104:0x01ee, B:108:0x0202, B:112:0x020a, B:114:0x0241, B:116:0x0247, B:118:0x0252, B:120:0x0258, B:122:0x025f, B:127:0x0286, B:113:0x0222, B:96:0x01da, B:98:0x01de, B:83:0x01b5, B:85:0x01bb), top: B:146:0x0030 }] */
    /* JADX WARN: Removed duplicated region for block: B:57:0x00fa  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x001f  */
    /* JADX WARN: Removed duplicated region for block: B:88:0x01c6  */
    /* JADX WARN: Removed duplicated region for block: B:93:0x01d2  */
    /* JADX WARN: Type inference failed for: r1v11 */
    /* JADX WARN: Type inference failed for: r1v30 */
    /* JADX WARN: Type inference failed for: r1v6 */
    /* JADX WARN: Type inference failed for: r1v7 */
    /* JADX WARN: Type inference failed for: r1v8, types: [java.util.List] */
    /* JADX WARN: Type inference failed for: r2v0, types: [X2.g] */
    /* JADX WARN: Type inference failed for: r2v1, types: [J4.c] */
    /* JADX WARN: Type inference failed for: r2v2 */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object g(HomeMetaItem homeMetaItem, n3 settingsState, int i6, C0963b c0963b, N2.r rVar, PlayerViewModel playerViewModel, B2.j jVar, Long l, Integer num, Integer num2, X2.g gVar, J4.c cVar, J4.a aVar, J4.c cVar2, C0965d c0965d, C4.c cVar3) throws Throwable {
        C0974m c0974m;
        String string;
        HomeMetaItem homeMetaItem2;
        boolean z6;
        J4.a aVar2;
        J4.c cVar4;
        Integer num3;
        Integer num4;
        Long l6;
        J4.a aVar3;
        PlayerViewModel playerViewModel2;
        N2.r rVar2;
        C0963b c0963b2;
        X2.g gVar2;
        String str;
        B4.a aVar4;
        int iIntValue;
        int iIntValue2;
        Y y6;
        X2.g gVar3;
        Integer num5;
        long j4;
        Object objH;
        Y y7;
        J4.a aVar5;
        String str2;
        C0636a3 c0636a3;
        ?? r22 = gVar;
        if (cVar3 instanceof C0974m) {
            c0974m = (C0974m) cVar3;
            int i7 = c0974m.f10718q;
            if ((i7 & Integer.MIN_VALUE) != 0) {
                c0974m.f10718q = i7 - Integer.MIN_VALUE;
            } else {
                c0974m = new C0974m(cVar3);
            }
        }
        Object objI = c0974m.f10717p;
        B4.a aVar6 = B4.a.f492a;
        int i8 = c0974m.f10718q;
        x4.y yVar = x4.y.f26065a;
        C3137A c3137a = C3137A.f25453a;
        try {
            if (i8 == 0) {
                AbstractC2467b.l(objI);
                kotlin.jvm.internal.o.h(settingsState, "settingsState");
                if (i6 > 0) {
                    Set setB = settingsState.f7976f.b();
                    if (!setB.isEmpty()) {
                        Map map = N2.q.f5245b;
                        Set set = setB;
                        if (!(set instanceof Collection) || !set.isEmpty()) {
                            Iterator it = set.iterator();
                            while (it.hasNext()) {
                                CharSequence charSequence = (CharSequence) map.get((String) it.next());
                                if (charSequence == null || S4.p.Q0(charSequence)) {
                                }
                            }
                        }
                        ?? r12 = r22 != 0 ? r22.f8588o : 0;
                        if (r12 == 0) {
                            r12 = yVar;
                        }
                        boolean zO0 = W.a.o0(homeMetaItem, r12);
                        cVar2.invoke(Boolean.TRUE);
                        if (r22 != 0) {
                            try {
                                String str3 = r22.f8587n;
                                if (str3 == null || (string = S4.p.o1(str3).toString()) == null || S4.p.Q0(string)) {
                                    string = null;
                                }
                                c0974m.f10706a = homeMetaItem;
                                c0974m.f10707b = c0963b;
                                c0974m.f10708c = rVar;
                                c0974m.f10709d = playerViewModel;
                                c0974m.f10710e = jVar;
                                c0974m.f10711f = l;
                                c0974m.f10712j = num;
                                c0974m.f10713k = num2;
                                c0974m.l = r22;
                                c0974m.f10714m = cVar2;
                                c0974m.f10715n = c0965d;
                                c0974m.f10716o = zO0;
                                c0974m.f10718q = 1;
                                objI = i(string, cVar, 5000L, c0974m);
                                if (objI == aVar6) {
                                    return aVar6;
                                }
                                homeMetaItem2 = homeMetaItem;
                                z6 = zO0;
                                aVar2 = c0965d;
                                cVar4 = cVar2;
                                num3 = num2;
                                num4 = num;
                                l6 = l;
                                aVar3 = jVar;
                                playerViewModel2 = playerViewModel;
                                rVar2 = rVar;
                                c0963b2 = c0963b;
                                gVar2 = gVar;
                            } catch (Throwable th) {
                                th = th;
                                r22 = cVar2;
                                r22.invoke(Boolean.FALSE);
                                throw th;
                            }
                        }
                        str2 = (String) objH;
                        if (!((Boolean) aVar5.invoke()).booleanValue()) {
                            c0636a3 = (C0636a3) AbstractC0661f3.f7767d.getValue();
                            if (c(c0636a3, y7)) {
                                a5.c cVar5 = K2.p.f4116a;
                                K2.p.a("Download link", str2, K2.r.f4127b, j4);
                            }
                        }
                        cVar4.invoke(Boolean.FALSE);
                        return c3137a;
                    }
                }
                aVar.invoke();
                return c3137a;
            }
            if (i8 != 1) {
                if (i8 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y7 = (Y) c0974m.f10708c;
                aVar5 = (J4.a) c0974m.f10707b;
                cVar4 = (J4.c) c0974m.f10706a;
                AbstractC2467b.l(objI);
                objH = objI;
                j4 = 3500;
                str2 = (String) objH;
                if (!((Boolean) aVar5.invoke()).booleanValue() && str2 != null) {
                    c0636a3 = (C0636a3) AbstractC0661f3.f7767d.getValue();
                    if (c(c0636a3, y7) || c0636a3.f7689h || !c0636a3.f7691j.isEmpty()) {
                        a5.c cVar52 = K2.p.f4116a;
                        K2.p.a("Download link", str2, K2.r.f4127b, j4);
                    } else {
                        a5.c cVar6 = K2.p.f4116a;
                        K2.p.a("No sources found", "Addons did not find any sources for this title.", K2.r.f4129d, j4);
                    }
                }
                cVar4.invoke(Boolean.FALSE);
                return c3137a;
            }
            boolean z7 = c0974m.f10716o;
            aVar2 = c0974m.f10715n;
            cVar4 = c0974m.f10714m;
            X2.g gVar4 = c0974m.l;
            Integer num6 = c0974m.f10713k;
            num4 = c0974m.f10712j;
            Long l7 = c0974m.f10711f;
            J4.a aVar7 = c0974m.f10710e;
            PlayerViewModel playerViewModel3 = c0974m.f10709d;
            rVar2 = (N2.r) c0974m.f10708c;
            C0963b c0963b3 = (C0963b) c0974m.f10707b;
            z6 = z7;
            homeMetaItem2 = (HomeMetaItem) c0974m.f10706a;
            AbstractC2467b.l(objI);
            playerViewModel2 = playerViewModel3;
            c0963b2 = c0963b3;
            aVar3 = aVar7;
            l6 = l7;
            num3 = num6;
            gVar2 = gVar4;
            String str4 = (String) objI;
            if (str4 == null) {
                a5.c cVar7 = K2.p.f4116a;
                K2.p.a("IMDb ID not available", "Could not load IMDb metadata for this title. Try again in a moment.", K2.r.f4129d, 3500L);
                cVar4.invoke(Boolean.FALSE);
                return c3137a;
            }
            if (((Boolean) aVar2.invoke()).booleanValue()) {
                cVar4.invoke(Boolean.FALSE);
                return c3137a;
            }
            HomeMetaItem homeMetaItem3 = homeMetaItem2;
            String lowerCase = S4.p.o1(homeMetaItem2.getType()).toString().toLowerCase(Locale.ROOT);
            kotlin.jvm.internal.o.g(lowerCase, "toLowerCase(...)");
            if (S4.p.Q0(lowerCase)) {
                lowerCase = "movie";
            }
            C0636a3 c0636a32 = (C0636a3) AbstractC0661f3.f7767d.getValue();
            if (lowerCase.equals("tv")) {
                if (num4 != null) {
                    str = str4;
                    iIntValue = num4.intValue();
                } else {
                    str = str4;
                    Integer num7 = c0636a32.f7684c;
                    if (num7 == null) {
                        aVar4 = aVar6;
                        iIntValue = 1;
                        if (iIntValue < 1) {
                        }
                        if (lowerCase.equals("tv")) {
                            if (num3 != null) {
                                iIntValue2 = num3.intValue();
                            } else {
                                Integer num8 = c0636a32.f7685d;
                                iIntValue2 = num8 != null ? num8.intValue() : 1;
                            }
                            if (iIntValue2 < 1) {
                            }
                            if (lowerCase.equals("tv")) {
                            }
                            if (lowerCase.equals("tv")) {
                            }
                            AbstractC0661f3.b(num5, !lowerCase.equals("tv") ? new Integer(iIntValue2) : null, str, lowerCase, homeMetaItem3.getTitle(), z6);
                            if (!((Boolean) aVar2.invoke()).booleanValue()) {
                            }
                        } else {
                            iIntValue2 = 1;
                            if (lowerCase.equals("tv")) {
                                y6 = new Y(S4.p.o1(str).toString(), "movie", null, null, z6);
                            } else {
                                String string2 = S4.p.o1(str).toString();
                                int i9 = 1;
                                Integer numValueOf = Integer.valueOf(iIntValue < 1 ? 1 : iIntValue);
                                if (iIntValue2 >= 1) {
                                    i9 = iIntValue2;
                                }
                                boolean z8 = z6;
                                y6 = new Y(string2, "tv", numValueOf, Integer.valueOf(i9), z8);
                                z6 = z8;
                            }
                            if (lowerCase.equals("tv")) {
                                gVar3 = gVar2;
                                num5 = null;
                            } else {
                                gVar3 = gVar2;
                                num5 = new Integer(iIntValue);
                            }
                            AbstractC0661f3.b(num5, !lowerCase.equals("tv") ? new Integer(iIntValue2) : null, str, lowerCase, homeMetaItem3.getTitle(), z6);
                            if (!((Boolean) aVar2.invoke()).booleanValue()) {
                                cVar4.invoke(Boolean.FALSE);
                                return c3137a;
                            }
                            j4 = 3500;
                            V vB = b(y6);
                            U u6 = new U();
                            C0522k c0522k = new C0522k(4, cVar4);
                            c0974m.f10706a = cVar4;
                            c0974m.f10707b = aVar2;
                            c0974m.f10708c = y6;
                            c0974m.f10709d = null;
                            c0974m.f10710e = null;
                            c0974m.f10711f = null;
                            c0974m.f10712j = null;
                            c0974m.f10713k = null;
                            c0974m.l = null;
                            c0974m.f10714m = null;
                            c0974m.f10715n = null;
                            c0974m.f10718q = 2;
                            B4.a aVar8 = aVar4;
                            J4.a aVar9 = aVar2;
                            Y y8 = y6;
                            objH = h(homeMetaItem3, gVar3, yVar, c0963b2, rVar2, playerViewModel2, aVar3, l6, num4, num3, vB, u6, 120000L, c0522k, aVar9, c0974m);
                            if (objH == aVar8) {
                                return aVar8;
                            }
                            y7 = y8;
                            aVar5 = aVar9;
                        }
                        str2 = (String) objH;
                        if (!((Boolean) aVar5.invoke()).booleanValue()) {
                        }
                        cVar4.invoke(Boolean.FALSE);
                        return c3137a;
                    }
                    iIntValue = num7.intValue();
                }
                aVar4 = aVar6;
                if (iIntValue < 1) {
                }
                if (lowerCase.equals("tv")) {
                }
                str2 = (String) objH;
                if (!((Boolean) aVar5.invoke()).booleanValue()) {
                }
                cVar4.invoke(Boolean.FALSE);
                return c3137a;
            }
            str = str4;
            aVar4 = aVar6;
            iIntValue = 1;
            if (lowerCase.equals("tv")) {
            }
            str2 = (String) objH;
            if (!((Boolean) aVar5.invoke()).booleanValue()) {
            }
            cVar4.invoke(Boolean.FALSE);
            return c3137a;
        } catch (Throwable th2) {
            th = th2;
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0023  */
    /* JADX WARN: Removed duplicated region for block: B:82:0x01d4  */
    /* JADX WARN: Removed duplicated region for block: B:83:0x01d9  */
    /* JADX WARN: Removed duplicated region for block: B:85:0x01dc  */
    /* JADX WARN: Type inference failed for: r13v0 */
    /* JADX WARN: Type inference failed for: r13v1 */
    /* JADX WARN: Type inference failed for: r13v18 */
    /* JADX WARN: Type inference failed for: r13v2, types: [java.util.List] */
    /* JADX WARN: Type inference failed for: r13v4, types: [x4.y] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object h(HomeMetaItem homeMetaItem, X2.g gVar, List list, C0963b c0963b, N2.r rVar, PlayerViewModel playerViewModel, J4.a aVar, Long l, Integer num, Integer num2, V v3, U u6, long j4, C0522k c0522k, J4.a aVar2, C4.c cVar) throws JSONException {
        C0975n c0975n;
        Integer num3;
        Integer num4;
        B4.a aVar3;
        String str;
        Integer num5;
        Long l6;
        boolean z6;
        Object obj;
        Integer num6;
        HomeMetaItem homeMetaItem2;
        J4.a aVar4;
        Integer num7;
        Object obj2;
        boolean z7;
        P p6;
        P2 p22;
        String string;
        String str2;
        P2 p23;
        int iIntValue;
        String string2;
        String str3;
        HomeMetaItem homeMetaItem3 = homeMetaItem;
        X2.g gVar2 = gVar;
        PlayerViewModel playerViewModel2 = playerViewModel;
        J4.a aVar5 = aVar;
        J4.a aVar6 = aVar2;
        if (cVar instanceof C0975n) {
            c0975n = (C0975n) cVar;
            int i6 = c0975n.f10731o;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                c0975n.f10731o = i6 - Integer.MIN_VALUE;
            } else {
                c0975n = new C0975n(cVar);
            }
        }
        Object obj3 = c0975n.f10730n;
        B4.a aVar7 = B4.a.f492a;
        int i7 = c0975n.f10731o;
        if (i7 == 0) {
            AbstractC2467b.l(obj3);
            if (v3 == null && list.isEmpty()) {
                return "No cached links available.";
            }
            boolean zC = kotlin.jvm.internal.o.c(homeMetaItem3.getType(), "tv");
            if (zC) {
                int iIntValue2 = num != null ? num.intValue() : 1;
                if (iIntValue2 < 1) {
                    iIntValue2 = 1;
                }
                num3 = new Integer(iIntValue2);
            } else {
                num3 = null;
            }
            if (zC) {
                int iIntValue3 = num2 != null ? num2.intValue() : 1;
                if (iIntValue3 < 1) {
                    iIntValue3 = 1;
                }
                num4 = new Integer(iIntValue3);
            } else {
                num4 = null;
            }
            ?? r13 = gVar2 != null ? gVar2.f8588o : 0;
            if (r13 == 0) {
                r13 = x4.y.f26065a;
            }
            boolean zO0 = W.a.o0(homeMetaItem3, r13);
            if (v3 != null) {
                str = zC ? "tv" : "movie";
                Map map = N2.q.f5245b;
                OkHttpClient okHttpClient = (OkHttpClient) f10754a.getValue();
                c0975n.f10721a = homeMetaItem3;
                c0975n.f10722b = gVar2;
                c0975n.f10723c = playerViewModel2;
                c0975n.f10724d = aVar5;
                c0975n.f10725e = l;
                c0975n.f10726f = c0522k;
                c0975n.f10727j = aVar6;
                c0975n.f10728k = num3;
                c0975n.l = num4;
                c0975n.f10729m = zC;
                c0975n.f10731o = 1;
                C0975n c0975n2 = c0975n;
                aVar3 = aVar7;
                num7 = num3;
                num5 = num4;
                Object objE0 = W.a.e0(v3, str, num7, num5, zO0, 40, 400L, j4, map, c0963b, rVar, okHttpClient, null, null, u6, aVar6, c0975n2, 12288);
                aVar6 = aVar6;
                if (objE0 != aVar3) {
                    l6 = l;
                    obj2 = objE0;
                    z7 = zC;
                    aVar4 = c0522k;
                    p6 = (P) obj2;
                }
            } else {
                C0975n c0975n3 = c0975n;
                aVar3 = aVar7;
                Integer num8 = num3;
                Integer num9 = num4;
                str = zC ? "tv" : "movie";
                int size = list.size();
                Map map2 = N2.q.f5245b;
                OkHttpClient okHttpClient2 = (OkHttpClient) f10754a.getValue();
                c0975n3.f10721a = homeMetaItem3;
                c0975n3.f10722b = gVar2;
                c0975n3.f10723c = playerViewModel2;
                c0975n3.f10724d = aVar5;
                c0975n3.f10725e = l;
                c0975n3.f10726f = c0522k;
                c0975n3.f10727j = aVar6;
                c0975n3.f10728k = num8;
                c0975n3.l = num9;
                c0975n3.f10729m = zC;
                c0975n3.f10731o = 2;
                Object objD0 = W.a.d0(list, str, num8, num9, zO0, size, map2, c0963b, rVar, okHttpClient2, c0975n3);
                num5 = num9;
                if (objD0 != aVar3) {
                    l6 = l;
                    z6 = zC;
                    obj = objD0;
                    num6 = num8;
                    homeMetaItem2 = homeMetaItem;
                    aVar4 = c0522k;
                    p6 = (P) obj;
                    Integer num10 = num6;
                    z7 = z6;
                    homeMetaItem3 = homeMetaItem2;
                    num7 = num10;
                }
            }
            return aVar3;
        }
        if (i7 == 1) {
            boolean z8 = c0975n.f10729m;
            Integer num11 = c0975n.l;
            Integer num12 = c0975n.f10728k;
            J4.a aVar8 = c0975n.f10727j;
            aVar4 = c0975n.f10726f;
            l6 = c0975n.f10725e;
            J4.a aVar9 = c0975n.f10724d;
            PlayerViewModel playerViewModel3 = c0975n.f10723c;
            X2.g gVar3 = c0975n.f10722b;
            HomeMetaItem homeMetaItem4 = c0975n.f10721a;
            AbstractC2467b.l(obj3);
            z7 = z8;
            homeMetaItem3 = homeMetaItem4;
            num7 = num12;
            playerViewModel2 = playerViewModel3;
            num5 = num11;
            gVar2 = gVar3;
            obj2 = obj3;
            aVar6 = aVar8;
            aVar5 = aVar9;
            p6 = (P) obj2;
        } else {
            if (i7 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            z6 = c0975n.f10729m;
            Integer num13 = c0975n.l;
            Integer num14 = c0975n.f10728k;
            J4.a aVar10 = c0975n.f10727j;
            aVar4 = c0975n.f10726f;
            l6 = c0975n.f10725e;
            J4.a aVar11 = c0975n.f10724d;
            PlayerViewModel playerViewModel4 = c0975n.f10723c;
            X2.g gVar4 = c0975n.f10722b;
            homeMetaItem2 = c0975n.f10721a;
            AbstractC2467b.l(obj3);
            num5 = num13;
            gVar2 = gVar4;
            obj = obj3;
            num6 = num14;
            playerViewModel2 = playerViewModel4;
            aVar6 = aVar10;
            aVar5 = aVar11;
            p6 = (P) obj;
            Integer num102 = num6;
            z7 = z6;
            homeMetaItem3 = homeMetaItem2;
            num7 = num102;
        }
        if (((Boolean) aVar6.invoke()).booleanValue()) {
            return null;
        }
        if (!p6.f10580g) {
            String str4 = p6.f10574a;
            if (str4 == null || S4.p.Q0(str4)) {
                return "No download link resolved.";
            }
            String str5 = p6.f10578e;
            String str6 = p6.f10577d;
            if (homeMetaItem3.getTmdbId() > 0) {
                int tmdbId = homeMetaItem3.getTmdbId();
                if (gVar2 == null || (str2 = gVar2.f8587n) == null || (string = S4.p.o1(str2).toString()) == null || !S4.w.A0(string, TtmlNode.TAG_TT, true)) {
                    string = null;
                }
                p22 = new P2(tmdbId, string, z7, num7 != null ? num7.intValue() : 1, num5 != null ? num5.intValue() : 1, null);
            } else {
                p22 = null;
            }
            PlayerViewModel.prepare$default(playerViewModel2, str4, str5, str6, p22, false, l6, homeMetaItem3.getTmdbId() > 0 ? W.b.c0(homeMetaItem3, gVar2) : null, null, false, RCHTTPStatusCodes.BAD_REQUEST, null);
            aVar4.invoke();
            aVar5.invoke();
            return null;
        }
        if (homeMetaItem3.getTmdbId() > 0) {
            int tmdbId2 = homeMetaItem3.getTmdbId();
            if (gVar2 == null || (str3 = gVar2.f8587n) == null || (string2 = S4.p.o1(str3).toString()) == null) {
                iIntValue = 1;
            } else {
                iIntValue = 1;
                if (!S4.w.A0(string2, TtmlNode.TAG_TT, true)) {
                }
                int iIntValue4 = num7 == null ? num7.intValue() : iIntValue;
                if (num5 != null) {
                    iIntValue = num5.intValue();
                }
                p23 = new P2(tmdbId2, string2, z7, iIntValue4, iIntValue, null);
            }
            string2 = null;
            if (num7 == null) {
            }
            if (num5 != null) {
            }
            p23 = new P2(tmdbId2, string2, z7, iIntValue4, iIntValue, null);
        } else {
            p23 = null;
        }
        PlayerViewModel.prepare$default(playerViewModel2, "", null, null, p23, false, l6, homeMetaItem3.getTmdbId() > 0 ? W.b.c0(homeMetaItem3, gVar2) : null, null, true, 128, null);
        aVar4.invoke();
        aVar5.invoke();
        return null;
    }

    /* JADX WARN: Code restructure failed: missing block: B:49:0x00a7, code lost:
    
        if (V4.E.l(100, r0) != r1) goto L17;
     */
    /* JADX WARN: Code restructure failed: missing block: B:52:0x00b2, code lost:
    
        if (r13 == r1) goto L53;
     */
    /* JADX WARN: Removed duplicated region for block: B:34:0x0073  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x0097  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x009a A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:51:0x00aa  */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:49:0x00a7 -> B:17:0x003e). Please report as a decompilation issue!!! */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object i(String str, J4.c cVar, long j4, C4.c cVar2) {
        C0976o c0976o;
        long jElapsedRealtime;
        String string;
        J4.c cVar3;
        long j6;
        String str2;
        String string2;
        String string3;
        if (cVar2 instanceof C0976o) {
            c0976o = (C0976o) cVar2;
            int i6 = c0976o.f10740d;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                c0976o.f10740d = i6 - Integer.MIN_VALUE;
            } else {
                c0976o = new C0976o(cVar2);
            }
        }
        Object objInvoke = c0976o.f10739c;
        B4.a aVar = B4.a.f492a;
        int i7 = c0976o.f10740d;
        if (i7 == 0) {
            AbstractC2467b.l(objInvoke);
            if (str != null && (string = S4.p.o1(str).toString()) != null) {
                if (S4.p.Q0(string)) {
                    string = null;
                }
                if (string != null) {
                    return string;
                }
            }
            if (cVar != null) {
                jElapsedRealtime = SystemClock.elapsedRealtime() + j4;
                if (SystemClock.elapsedRealtime() >= jElapsedRealtime) {
                }
                return aVar;
            }
            return null;
        }
        if (i7 != 1) {
            if (i7 != 2) {
                if (i7 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(objInvoke);
                String str3 = (String) objInvoke;
                if (str3 == null || (string3 = S4.p.o1(str3).toString()) == null || S4.p.Q0(string3)) {
                    return null;
                }
                return string3;
            }
            j6 = c0976o.f10738b;
            cVar3 = c0976o.f10737a;
            AbstractC2467b.l(objInvoke);
            jElapsedRealtime = j6;
            cVar = cVar3;
            if (SystemClock.elapsedRealtime() >= jElapsedRealtime) {
                c0976o.f10737a = cVar;
                c0976o.f10738b = jElapsedRealtime;
                c0976o.f10740d = 1;
                objInvoke = cVar.invoke(c0976o);
                if (objInvoke != aVar) {
                    cVar3 = cVar;
                    j6 = jElapsedRealtime;
                    str2 = (String) objInvoke;
                    if (str2 != null && (string2 = S4.p.o1(str2).toString()) != null) {
                        if (S4.p.Q0(string2)) {
                            string2 = null;
                        }
                        if (string2 != null) {
                            return string2;
                        }
                    }
                    c0976o.f10737a = cVar3;
                    c0976o.f10738b = j6;
                    c0976o.f10740d = 2;
                }
            } else {
                c0976o.f10737a = null;
                c0976o.f10740d = 3;
                objInvoke = cVar.invoke(c0976o);
            }
            return aVar;
        }
        j6 = c0976o.f10738b;
        cVar3 = c0976o.f10737a;
        AbstractC2467b.l(objInvoke);
        str2 = (String) objInvoke;
        if (str2 != null) {
            if (S4.p.Q0(string2)) {
            }
            if (string2 != null) {
            }
        }
        c0976o.f10737a = cVar3;
        c0976o.f10738b = j6;
        c0976o.f10740d = 2;
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object j(X x6, C4.c cVar) {
        C0977p c0977p;
        long j4;
        if (cVar instanceof C0977p) {
            c0977p = (C0977p) cVar;
            int i6 = c0977p.f10752d;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                c0977p.f10752d = i6 - Integer.MIN_VALUE;
            } else {
                c0977p = new C0977p(cVar);
            }
        }
        Object obj = c0977p.f10751c;
        B4.a aVar = B4.a.f492a;
        int i7 = c0977p.f10752d;
        x4.y yVar = x4.y.f26065a;
        if (i7 == 0) {
            AbstractC2467b.l(obj);
            j4 = x6.f10601d + x6.f10599b;
        } else if (i7 == 1) {
            j4 = c0977p.f10750b;
            X x7 = c0977p.f10749a;
            AbstractC2467b.l(obj);
            while (SystemClock.elapsedRealtime() < j4) {
                if (((Boolean) x7.f10603f.invoke()).booleanValue()) {
                    break;
                }
                Object value = AbstractC0661f3.f7767d.getValue();
                if (!((Boolean) x7.f10598a.invoke(value)).booleanValue()) {
                    value = null;
                }
                C0636a3 c0636a3 = (C0636a3) value;
                if (c0636a3 != null) {
                    long j6 = c0636a3.f7692k;
                    if ((j6 > 0 ? SystemClock.elapsedRealtime() - j6 : 0L) >= 0) {
                        break;
                    }
                }
                long jMin = Math.min(x7.f10600c, 100L);
                c0977p.f10749a = x7;
                c0977p.f10750b = j4;
                c0977p.f10752d = 1;
                if (V4.E.l(jMin, c0977p) == aVar) {
                    break;
                }
            }
            x6 = x7;
        } else {
            if (i7 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            j4 = c0977p.f10750b;
            x6 = c0977p.f10749a;
            AbstractC2467b.l(obj);
        }
        do {
            if (SystemClock.elapsedRealtime() >= j4) {
                Object value2 = AbstractC0661f3.f7767d.getValue();
                if (!((Boolean) x6.f10598a.invoke(value2)).booleanValue()) {
                    value2 = null;
                }
                C0636a3 c0636a32 = (C0636a3) value2;
                List list = c0636a32 != null ? c0636a32.f7691j : null;
                if (list == null) {
                    break;
                }
                return list;
            }
            if (!((Boolean) x6.f10603f.invoke()).booleanValue()) {
                C0636a3 c0636a33 = (C0636a3) AbstractC0661f3.f7767d.getValue();
                if (((Boolean) x6.f10598a.invoke(c0636a33)).booleanValue()) {
                    if (!c0636a33.f7691j.isEmpty()) {
                        return c0636a33.f7691j;
                    }
                    if (x6.f10602e && !c0636a33.f7689h) {
                    }
                }
                c0977p.f10749a = x6;
                c0977p.f10750b = j4;
                c0977p.f10752d = 2;
            }
            return yVar;
        } while (V4.E.l(x6.f10600c, c0977p) != aVar);
        return aVar;
    }
}
