package M2;

import V2.AbstractC0693m0;
import V2.C0654e1;
import V2.C0706p0;
import V2.C0736x;
import V2.C0745z0;
import V2.Q2;
import V2.R2;
import V2.T2;
import V2.z3;
import android.content.Context;
import androidx.compose.runtime.MutableState;
import androidx.compose.runtime.State;
import androidx.media3.exoplayer.ExoPlayer;
import com.debridstream.tv.PlayerViewModel;
import com.debridstream.tv.ProfileViewModel;
import com.debridstream.tv.data.home.HomeMetaItem;
import com.debridstream.tv.screens.SearchViewModel;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import h3.EnumC2129i2;
import h3.F3;
import h3.G3;
import h3.n5;
import java.util.Iterator;
import org.json.JSONException;
import q.AbstractC2771e;
import q.C2756G;
import q.C2757H;
import q.C2799s0;
import w4.C3137A;
import w4.InterfaceC3143e;

/* JADX INFO: renamed from: M2.r0, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final /* synthetic */ class C0543r0 implements J4.a {

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

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

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

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

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

    public /* synthetic */ C0543r0(V4.C c6, MutableState mutableState, String str, String str2) {
        this.f4926a = 6;
        this.f4927b = str;
        this.f4929d = c6;
        this.f4930e = mutableState;
        this.f4928c = str2;
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Override // J4.a
    public final Object invoke() throws JSONException {
        Object obj = null;
        C3137A c3137a = C3137A.f25453a;
        Object obj2 = this.f4930e;
        Object obj3 = this.f4929d;
        Object obj4 = this.f4927b;
        Object obj5 = this.f4928c;
        switch (this.f4926a) {
            case 0:
                Y4.c0 c0Var = z3.f8212a;
                String strA = z3.a((Context) obj4);
                if (strA == null) {
                    strA = "main";
                }
                Y4.c0 c0Var2 = C0706p0.f7996a;
                HomeMetaItem homeMetaItem = (HomeMetaItem) obj5;
                C0706p0.e(homeMetaItem.getTmdbId(), strA, homeMetaItem.getType());
                FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();
                String strC = g3.m.c(homeMetaItem.getTmdbId(), homeMetaItem.getType());
                if (currentUser != null && strC != null) {
                    V4.E.y((V4.C) obj3, c5.d.f13466b, null, new L0(currentUser, strA, strC, null), 2);
                }
                ((MutableState) obj2).setValue(null);
                break;
            case 1:
                q.F0 f0 = AbstractC0693m0.f7892a;
                V2.A0 a02 = ((C0745z0) ((State) obj3).getValue()).f8199a;
                State state = (State) obj2;
                Iterator it = ((T2) state.getValue()).f7543a.iterator();
                while (true) {
                    if (it.hasNext()) {
                        Object next = it.next();
                        if (kotlin.jvm.internal.o.c(((R2) next).f7513a, ((T2) state.getValue()).f7547e)) {
                            obj = next;
                        }
                    }
                }
                R2 r22 = (R2) obj;
                if (a02 != null && r22 != null) {
                    ((ProfileViewModel) obj4).requestProfilePickerAutoSelect(r22.f7513a);
                    ((androidx.navigation.H) obj5).m("profile_selector", new C0736x(8));
                }
                break;
            case 2:
                ExoPlayer exoPlayer = (ExoPlayer) ((MutableState) obj2).getValue();
                PlayerViewModel playerViewModel = (PlayerViewModel) obj5;
                Q2 q22 = (Q2) playerViewModel.getUiState().getValue();
                if (exoPlayer != null && q22.f7502g != null) {
                    long duration = exoPlayer.getDuration();
                    Long lValueOf = duration > 0 ? Long.valueOf(duration) : null;
                    long jLongValue = lValueOf != null ? lValueOf.longValue() : 0L;
                    if (jLongValue > 0) {
                        long currentPosition = exoPlayer.getCurrentPosition();
                        long j4 = currentPosition < 0 ? 0L : currentPosition;
                        a5.c cVar = g3.p.f16541a;
                        Context applicationContext = ((Context) obj4).getApplicationContext();
                        kotlin.jvm.internal.o.g(applicationContext, "getApplicationContext(...)");
                        g3.p.b(applicationContext, playerViewModel, j4, jLongValue, "back_leave_player");
                    }
                }
                ((J4.a) obj3).invoke();
                break;
            case 3:
                String str = (String) ((MutableState) obj2).getValue();
                Boolean bool = (Boolean) ((MutableState) obj5).getValue();
                bool.booleanValue();
                ((J4.f) obj4).invoke(str, bool, (String) ((MutableState) obj3).getValue());
                break;
            case 4:
                int iOrdinal = ((EnumC2129i2) ((MutableState) obj2).getValue()).ordinal();
                n0.x xVar = (n0.x) obj4;
                if (iOrdinal == 2 || iOrdinal == 3) {
                    n0.x.a(xVar);
                } else if (iOrdinal == 4) {
                    ((SearchViewModel) obj5).clearQuery();
                    n0.x.a(xVar);
                } else {
                    ((J4.a) obj3).invoke();
                }
                break;
            case 5:
                MutableState mutableState = (MutableState) obj2;
                if (!((Boolean) mutableState.getValue()).booleanValue()) {
                    MutableState mutableState2 = (MutableState) obj5;
                    if (!((Boolean) mutableState2.getValue()).booleanValue()) {
                        MutableState mutableState3 = (MutableState) obj3;
                        if (!((Boolean) mutableState3.getValue()).booleanValue()) {
                            ((J4.a) obj4).invoke();
                        } else {
                            mutableState3.setValue(Boolean.FALSE);
                        }
                    } else {
                        mutableState2.setValue(Boolean.FALSE);
                    }
                } else {
                    mutableState.setValue(Boolean.FALSE);
                }
                break;
            case 6:
                float f6 = G3.f16846a;
                ((MutableState) obj2).setValue(null);
                V4.E.y((V4.C) obj3, null, null, new F3((String) obj5, (String) obj4, null), 3);
                break;
            case 7:
                ((J4.f) obj4).invoke(((C0654e1) obj5).f7741b, (Integer) obj3, (Integer) obj2);
                break;
            case 8:
                ((J4.c) ((State) obj4).getValue()).invoke((HomeMetaItem) obj5);
                ((MutableState) obj2).setValue(null);
                n5.o((MutableState) obj3, false);
                break;
            default:
                C2757H c2757h = (C2757H) obj5;
                Float f7 = (Float) obj4;
                Float f8 = (Float) obj3;
                if (!f7.equals(c2757h.f23173a) || !f8.equals(c2757h.f23174b)) {
                    c2757h.f23173a = f7;
                    c2757h.f23174b = f8;
                    c2757h.f23176d = new C2799s0((C2756G) obj2, AbstractC2771e.f23306j, f7, f8, null);
                    c2757h.f23180k.f23192b.setValue(Boolean.TRUE);
                    c2757h.f23177e = false;
                    c2757h.f23178f = true;
                }
                break;
        }
        return c3137a;
    }

    public /* synthetic */ C0543r0(PlayerViewModel playerViewModel, Context context, J4.a aVar, MutableState mutableState) {
        this.f4926a = 2;
        this.f4928c = playerViewModel;
        this.f4927b = context;
        this.f4929d = aVar;
        this.f4930e = mutableState;
    }

    public /* synthetic */ C0543r0(HomeMetaItem homeMetaItem, State state, MutableState mutableState, MutableState mutableState2) {
        this.f4926a = 8;
        this.f4928c = homeMetaItem;
        this.f4927b = state;
        this.f4930e = mutableState;
        this.f4929d = mutableState2;
    }

    public /* synthetic */ C0543r0(Object obj, Object obj2, Object obj3, Object obj4, int i6) {
        this.f4926a = i6;
        this.f4927b = obj;
        this.f4928c = obj2;
        this.f4929d = obj3;
        this.f4930e = obj4;
    }

    public /* synthetic */ C0543r0(InterfaceC3143e interfaceC3143e, MutableState mutableState, MutableState mutableState2, MutableState mutableState3, int i6) {
        this.f4926a = i6;
        this.f4927b = interfaceC3143e;
        this.f4930e = mutableState;
        this.f4928c = mutableState2;
        this.f4929d = mutableState3;
    }
}
