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

import com.strmr.ps.data.local.entity.PlaybackProgress;
import com.strmr.ps.data.model.ContentItem;
import com.strmr.ps.data.remote.AddonMetadataClient;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.m02;
import defpackage.m12;
import defpackage.n89;
import defpackage.qm5;
import defpackage.s38;
import defpackage.sc2;
import defpackage.sm5;
import defpackage.u69;
import defpackage.wj0;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.Boxing;
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\u0010\b\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "", "<anonymous>", "(Lak1;)I"}, k = 3, mv = {2, 0, 0})
@DebugMetadata(c = "com.strmr.ps.ui.mobile.details.MobileDetailsViewModel$resolveViaAddonMeta$2", f = "MobileDetailsViewModel.kt", i = {1, 2}, l = {255, 264, 272, 278}, m = "invokeSuspend", n = {"meta", "meta"}, s = {"L$0", "L$0"})
final class ah extends SuspendLambda implements gr3<ak1, Continuation<? super Integer>, Object> {
    public u69 a;
    public int b;
    public final /* synthetic */ ContentItem c;
    public final /* synthetic */ MobileDetailsViewModel d;

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

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

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

    /* JADX WARN: Code restructure failed: missing block: B:48:0x00c4, code lost:
    
        if (r15 == r0) goto L76;
     */
    /* JADX WARN: Code restructure failed: missing block: B:68:0x0112, code lost:
    
        if (r15 == r0) goto L76;
     */
    /* JADX WARN: Code restructure failed: missing block: B:75:0x0136, code lost:
    
        if (defpackage.wj0.f(r15, r4, r14) != r0) goto L77;
     */
    /* JADX WARN: Removed duplicated region for block: B:53:0x00d2  */
    /* JADX WARN: Removed duplicated region for block: B:55:0x00d7  */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws Throwable {
        u69 u69Var;
        int iIntValue;
        String releaseInfo;
        ck1 ck1Var = ck1.a;
        int i = this.b;
        MobileDetailsViewModel mobileDetailsViewModel = this.d;
        ContentItem contentItem = this.c;
        if (i == 0) {
            s38.b(obj);
            String sourceAddonUrl = contentItem.getSourceAddonUrl();
            if (sourceAddonUrl == null) {
                return Boxing.boxInt(0);
            }
            String stremioId = contentItem.getStremioId();
            if (stremioId == null && (stremioId = contentItem.getImdbId()) == null) {
                return Boxing.boxInt(0);
            }
            String stremioType = contentItem.getStremioType();
            if (stremioType == null) {
                stremioType = contentItem.getItemType() == ContentItem.ItemType.TV_SHOW ? "series" : PlaybackProgress.TYPE_MOVIE;
            }
            AddonMetadataClient addonMetadataClient = mobileDetailsViewModel.f;
            this.b = 1;
            obj = addonMetadataClient.a(sourceAddonUrl, stremioType, stremioId, this);
            if (obj != ck1Var) {
            }
            return ck1Var;
        }
        if (i == 1) {
            s38.b(obj);
        } else {
            if (i == 2) {
                u69Var = this.a;
                s38.b(obj);
                iIntValue = ((Number) obj).intValue();
                if (iIntValue <= 0) {
                    return Boxing.boxInt(iIntValue);
                }
                String name = u69Var.getName();
                if (name == null || n89.ab(name)) {
                    u69Var.getClass();
                    m12 m12Var = sc2.a;
                    qm5 qm5Var = sm5.a;
                    ag agVar = new ag(mobileDetailsViewModel, u69Var, null);
                    this.a = null;
                    this.b = 4;
                } else {
                    String name2 = u69Var.getName();
                    Object year = u69Var.getYear();
                    if (year == null || (releaseInfo = year.toString()) == null) {
                        releaseInfo = u69Var.getReleaseInfo();
                    }
                    String str = releaseInfo;
                    ContentItem.ItemType itemType = contentItem.getItemType();
                    this.a = u69Var;
                    this.b = 3;
                    m12 m12Var2 = sc2.a;
                    obj = wj0.f(m02.c, new ai(str, name2, mobileDetailsViewModel, itemType, null), this);
                }
                return ck1Var;
            }
            if (i != 3) {
                if (i != 4) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                return Boxing.boxInt(0);
            }
            u69Var = this.a;
            s38.b(obj);
            int iIntValue2 = ((Number) obj).intValue();
            if (iIntValue2 > 0) {
                return Boxing.boxInt(iIntValue2);
            }
            u69Var.getClass();
            m12 m12Var3 = sc2.a;
            qm5 qm5Var2 = sm5.a;
            ag agVar2 = new ag(mobileDetailsViewModel, u69Var, null);
            this.a = null;
            this.b = 4;
        }
        u69Var = (u69) obj;
        if (u69Var == null) {
            return Boxing.boxInt(0);
        }
        mobileDetailsViewModel.l = u69Var.getVideos();
        if (u69Var.getMoviedbId() == null || u69Var.getMoviedbId().intValue() <= 0) {
            String imdbId = u69Var.getImdbId();
            if (imdbId == null || n89.ab(imdbId)) {
                iIntValue = 0;
            } else {
                String imdbId2 = u69Var.getImdbId();
                ContentItem.ItemType itemType2 = contentItem.getItemType();
                this.a = u69Var;
                this.b = 2;
                m12 m12Var4 = sc2.a;
                obj = wj0.f(m02.c, new af(imdbId2, mobileDetailsViewModel, itemType2, null), this);
            }
        } else {
            iIntValue = u69Var.getMoviedbId().intValue();
        }
        if (iIntValue <= 0) {
        }
    }
}
