package h3;

import com.debridstream.tv.screens.SearchRecommendationsViewModel;
import java.util.List;
import m3.AbstractC2467b;
import w4.C3137A;

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

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

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

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

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C2123h2(SearchRecommendationsViewModel searchRecommendationsViewModel, C2099d2 c2099d2, A4.d dVar) {
        super(2, dVar);
        this.f17998c = searchRecommendationsViewModel;
        this.f17999d = c2099d2;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        C2123h2 c2123h2 = new C2123h2(this.f17998c, this.f17999d, dVar);
        c2123h2.f17997b = obj;
        return c2123h2;
    }

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

    @Override // C4.a
    public final Object invokeSuspend(Object obj) {
        Object objD;
        Y4.c0 c0Var;
        Object value;
        C2105e2 c2105e2;
        String message;
        Object objN;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f17996a;
        x4.y yVar = x4.y.f26065a;
        C3137A c3137a = C3137A.f25453a;
        SearchRecommendationsViewModel searchRecommendationsViewModel = this.f17998c;
        try {
        } catch (Throwable th) {
            objD = AbstractC2467b.d(th);
        }
        if (i6 == 0) {
            AbstractC2467b.l(obj);
            C2105e2 c2105e22 = (C2105e2) ((Y4.c0) searchRecommendationsViewModel._ui).getValue();
            C2099d2 c2099d2 = c2105e22.f17892b;
            String str = c2099d2 != null ? c2099d2.f17848a : null;
            C2099d2 c2099d22 = this.f17999d;
            if (!kotlin.jvm.internal.o.c(str, c2099d22.f17848a) || c2105e22.f17893c.isEmpty()) {
                Y4.H h5 = searchRecommendationsViewModel._ui;
                while (true) {
                    Y4.c0 c0Var2 = (Y4.c0) h5;
                    Object value2 = c0Var2.getValue();
                    Y4.H h6 = h5;
                    if (c0Var2.i(value2, C2105e2.a((C2105e2) value2, null, c2099d22, yVar, true, false, null, false, 2, 1))) {
                        break;
                    }
                    h5 = h6;
                }
                Y2.o oVar = searchRecommendationsViewModel.repository;
                boolean z6 = searchRecommendationsViewModel.kidsCatalogFriendlyOnly;
                this.f17996a = 1;
                objN = T2.n(oVar, c2099d22, 1, z6, this);
                if (objN == aVar) {
                    return aVar;
                }
            }
            return c3137a;
        }
        if (i6 != 1) {
            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
        AbstractC2467b.l(obj);
        objN = obj;
        objD = (Y2.a) objN;
        if (!(objD instanceof w4.m)) {
            Y2.a aVar2 = (Y2.a) objD;
            List list = aVar2.f8714a;
            Y4.H h7 = searchRecommendationsViewModel._ui;
            while (true) {
                Y4.c0 c0Var3 = (Y4.c0) h7;
                Object value3 = c0Var3.getValue();
                List list2 = list;
                if (c0Var3.i(value3, C2105e2.a((C2105e2) value3, null, null, list2, false, false, null, aVar2.f8715b, 2, 19))) {
                    break;
                }
                list = list2;
            }
        }
        Throwable thA = w4.n.a(objD);
        if (thA != null) {
            Y4.H h8 = searchRecommendationsViewModel._ui;
            do {
                c0Var = (Y4.c0) h8;
                value = c0Var.getValue();
                c2105e2 = (C2105e2) value;
                message = thA.getMessage();
                if (message == null) {
                    message = "Failed to load";
                }
            } while (!c0Var.i(value, C2105e2.a(c2105e2, null, null, yVar, false, false, message, false, 0, 147)));
        }
        return c3137a;
    }
}
