package M2;

import android.content.Context;
import androidx.compose.runtime.MutableState;
import androidx.compose.runtime.State;
import com.debridstream.tv.data.home.HomeMetaItem;
import h3.AbstractC2190s4;
import m3.AbstractC2467b;
import org.json.JSONArray;
import w4.C3137A;

/* JADX INFO: renamed from: M2.i0, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0517i0 extends C4.j implements J4.e {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int f4740a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ boolean f4741b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ Context f4742c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ HomeMetaItem f4743d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ boolean f4744e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final /* synthetic */ State f4745f;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final /* synthetic */ MutableState f4746j;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C0517i0(boolean z6, Context context, HomeMetaItem homeMetaItem, boolean z7, State state, MutableState mutableState, A4.d dVar) {
        super(2, dVar);
        this.f4741b = z6;
        this.f4742c = context;
        this.f4743d = homeMetaItem;
        this.f4744e = z7;
        this.f4745f = state;
        this.f4746j = mutableState;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        return new C0517i0(this.f4741b, this.f4742c, this.f4743d, this.f4744e, this.f4745f, this.f4746j, dVar);
    }

    @Override // J4.e
    public final Object invoke(Object obj, Object obj2) {
        return ((C0517i0) create((V4.C) obj, (A4.d) obj2)).invokeSuspend(C3137A.f25453a);
    }

    /* JADX WARN: Code restructure failed: missing block: B:21:0x004f, code lost:
    
        if (r10 == r0) goto L22;
     */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        boolean zBooleanValue;
        String strConcat;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f4740a;
        MutableState mutableState = this.f4746j;
        boolean z6 = this.f4741b;
        boolean z7 = this.f4744e;
        try {
            if (i6 == 0) {
                AbstractC2467b.l(obj);
                HomeMetaItem homeMetaItem = this.f4743d;
                Context context = this.f4742c;
                if (z6) {
                    State state = this.f4745f;
                    float f6 = AbstractC0535o0.f4860g;
                    JSONArray jSONArray = (JSONArray) state.getValue();
                    this.f4740a = 1;
                    obj = AbstractC2190s4.x(context, homeMetaItem, z7, jSONArray, this);
                    if (obj == aVar) {
                    }
                    zBooleanValue = ((Boolean) obj).booleanValue();
                } else {
                    this.f4740a = 2;
                    obj = AbstractC2190s4.u(context, homeMetaItem, z7, this);
                }
                return aVar;
            }
            if (i6 == 1) {
                AbstractC2467b.l(obj);
                zBooleanValue = ((Boolean) obj).booleanValue();
            } else {
                if (i6 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
                zBooleanValue = ((Boolean) obj).booleanValue();
            }
            float f7 = AbstractC0535o0.f4860g;
            String str = z7 ? "Trakt watchlist" : "watchlist";
            if (zBooleanValue) {
                strConcat = (z6 ? "Removed from " : "Added to ").concat(str);
            } else {
                strConcat = (z6 ? "Failed to remove from " : "Failed to add to ").concat(str);
            }
            a5.c cVar = K2.p.f4116a;
            K2.p.a(strConcat, (10 & 2) != 0 ? "" : "Could not resolve a playable download URL for this link.", zBooleanValue ? K2.r.f4126a : K2.r.f4127b, (10 & 8) != 0 ? androidx.media3.common.C.DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS : 4000L);
            mutableState.setValue(null);
            return C3137A.f25453a;
        } catch (Throwable th) {
            float f8 = AbstractC0535o0.f4860g;
            mutableState.setValue(null);
            throw th;
        }
    }
}
