package H5;

import N1.AbstractC0200c;
import androidx.leanback.widget.C0453a;
import androidx.leanback.widget.C0455b;
import androidx.leanback.widget.I;
import c7.InterfaceC0597e;
import com.facebook.shimmer.ShimmerFrameLayout;
import com.martsnew.domain.type.MediaType;
import com.martsnew.tv.R;
import com.martsnew.tv.ui.home.TvHomeFragment;
import java.util.ArrayList;
import java.util.List;
import k5.C1107g;
import n4.u0;

/* JADX INFO: renamed from: H5.d, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0145d implements InterfaceC0597e {

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

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ TvHomeFragment f3129r;

    public /* synthetic */ C0145d(TvHomeFragment tvHomeFragment, int i) {
        this.f3128q = i;
        this.f3129r = tvHomeFragment;
    }

    @Override // c7.InterfaceC0597e
    public final Object l(Object obj, E6.d dVar) {
        A6.n nVar = A6.n.f457a;
        TvHomeFragment tvHomeFragment = this.f3129r;
        switch (this.f3128q) {
            case u0.f15495q /* 0 */:
                C1107g c1107g = (C1107g) obj;
                if (!c1107g.f13974a.isEmpty()) {
                    int i = TvHomeFragment.f11156O1;
                    ((q) tvHomeFragment.f11159K1.getValue()).o(c1107g.f13974a);
                }
                return nVar;
            case 1:
                List list = (List) obj;
                if (!list.isEmpty()) {
                    int i5 = TvHomeFragment.f11156O1;
                    tvHomeFragment.K0().f17602M.b();
                    ShimmerFrameLayout shimmerFrameLayout = tvHomeFragment.K0().f17602M;
                    P6.g.d(shimmerFrameLayout, "shimmerLayout");
                    shimmerFrameLayout.setVisibility(8);
                    ArrayList arrayList = new ArrayList(B6.m.a0(list));
                    int i8 = 0;
                    for (Object obj2 : list) {
                        int i9 = i8 + 1;
                        if (i8 < 0) {
                            B6.l.Z();
                            throw null;
                        }
                        C0143b c0143b = (C0143b) obj2;
                        MediaType mediaType = c0143b.f3125d;
                        String strU = c0143b.f3122a;
                        if (mediaType != null) {
                            strU = mediaType == MediaType.f11105r ? tvHomeFragment.u(R.string.format_movie, strU) : tvHomeFragment.u(R.string.format_tv_series, strU);
                        }
                        P6.g.b(strU);
                        C0455b c0455b = new C0455b((r) tvHomeFragment.f11162N1.getValue());
                        ArrayList arrayList2 = c0143b.f3123b;
                        if (arrayList2 == null || arrayList2.isEmpty()) {
                            List list2 = c0143b.f3124c;
                            if (list2 != null && !list2.isEmpty()) {
                                c0455b.e(0, list2);
                            }
                        } else {
                            c0455b.e(0, arrayList2);
                        }
                        arrayList.add(new I(i8, new B3.f(4, strU), c0455b));
                        i8 = i9;
                    }
                    tvHomeFragment.f18986B1.e(0, arrayList);
                }
                return nVar;
            case 2:
                List list3 = (List) obj;
                if (!list3.isEmpty()) {
                    ArrayList arrayList3 = new ArrayList(B6.m.a0(list3));
                    int i10 = 0;
                    for (Object obj3 : list3) {
                        int i11 = i10 + 1;
                        if (i10 < 0) {
                            B6.l.Z();
                            throw null;
                        }
                        C0143b c0143b2 = (C0143b) obj3;
                        C0455b c0455b2 = new C0455b((r) tvHomeFragment.f11162N1.getValue());
                        ArrayList arrayList4 = c0143b2.f3123b;
                        if (arrayList4 == null || arrayList4.isEmpty()) {
                            List list4 = c0143b2.f3124c;
                            if (list4 != null && !list4.isEmpty()) {
                                c0455b2.e(0, list4);
                            }
                        } else {
                            c0455b2.e(0, c0143b2.f3123b);
                        }
                        arrayList3.add(new I(i10, new B3.f(4, c0143b2.f3122a), c0455b2));
                        i10 = i11;
                    }
                    int i12 = TvHomeFragment.f11156O1;
                    C0455b c0455b3 = tvHomeFragment.f18986B1;
                    x3.e eVar = new x3.e(5);
                    ArrayList arrayList5 = c0455b3.f8626c;
                    ArrayList arrayList6 = c0455b3.f8627d;
                    arrayList6.clear();
                    arrayList6.addAll(arrayList5);
                    N1.r rVarE = AbstractC0200c.e(new C0453a(c0455b3, arrayList3, eVar));
                    arrayList5.clear();
                    arrayList5.addAll(arrayList3);
                    if (c0455b3.f8628e == null) {
                        c0455b3.f8628e = new P.g(14, c0455b3);
                    }
                    rVarE.a(c0455b3.f8628e);
                    arrayList6.clear();
                }
                return nVar;
            case 3:
                v vVar = (v) obj;
                if (!P6.g.a(vVar, s.f3155a)) {
                    if (vVar instanceof t) {
                        tvHomeFragment.R0(((t) vVar).f3156a);
                    } else {
                        if (!(vVar instanceof u)) {
                            throw new A6.b();
                        }
                        tvHomeFragment.S0(((u) vVar).f3157a);
                    }
                }
                return nVar;
            default:
                int i13 = TvHomeFragment.f11156O1;
                tvHomeFragment.W0(false);
                tvHomeFragment.V0(false);
                tvHomeFragment.U0(true);
                return nVar;
        }
    }
}
