package h3;

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

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

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

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

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

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

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

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C2131i4(Context context, HomeMetaItem homeMetaItem, boolean z6, State state, State state2, A4.d dVar) {
        super(2, dVar);
        this.f18058b = context;
        this.f18059c = homeMetaItem;
        this.f18060d = z6;
        this.f18061e = state;
        this.f18062f = state2;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        return new C2131i4(this.f18058b, this.f18059c, this.f18060d, this.f18061e, this.f18062f, dVar);
    }

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

    /* JADX WARN: Code restructure failed: missing block: B:13:0x0043, code lost:
    
        if (r8 == r0) goto L18;
     */
    /* JADX WARN: Code restructure failed: missing block: B:17:0x0053, code lost:
    
        if (r8 == r0) goto L18;
     */
    /* JADX WARN: Removed duplicated region for block: B:25:0x0071  */
    /* JADX WARN: Removed duplicated region for block: B:29:0x0084  */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        boolean zBooleanValue;
        String str;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f18057a;
        State state = this.f18061e;
        boolean z6 = this.f18060d;
        if (i6 == 0) {
            AbstractC2467b.l(obj);
            float f6 = AbstractC2190s4.f18484a;
            boolean zBooleanValue2 = ((Boolean) state.getValue()).booleanValue();
            HomeMetaItem homeMetaItem = this.f18059c;
            Context context = this.f18058b;
            if (zBooleanValue2) {
                JSONArray jSONArray = (JSONArray) this.f18062f.getValue();
                this.f18057a = 1;
                obj = AbstractC2190s4.x(context, homeMetaItem, z6, jSONArray, this);
            } else {
                this.f18057a = 2;
                obj = AbstractC2190s4.u(context, homeMetaItem, z6, 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();
        }
        if (!zBooleanValue) {
            float f7 = AbstractC2190s4.f18484a;
            if (((Boolean) state.getValue()).booleanValue() && z6) {
                str = "Failed to remove from Trakt watchlist";
            } else if (!zBooleanValue) {
                float f8 = AbstractC2190s4.f18484a;
                if (((Boolean) state.getValue()).booleanValue()) {
                    str = "Failed to remove from watchlist";
                } else if (!zBooleanValue && z6) {
                    str = "Failed to add to Trakt watchlist";
                } else if (zBooleanValue) {
                    float f9 = AbstractC2190s4.f18484a;
                    str = (((Boolean) state.getValue()).booleanValue() && z6) ? "Removed from Trakt watchlist" : ((Boolean) state.getValue()).booleanValue() ? "Removed from watchlist" : z6 ? "Added to Trakt watchlist" : "Added to watchlist";
                } else {
                    str = "Failed to add to watchlist";
                }
            }
        }
        a5.c cVar = K2.p.f4116a;
        K2.p.a(str, (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);
        return C3137A.f25453a;
    }
}
