package R5;

import Z6.InterfaceC0382w;
import com.google.android.gms.internal.measurement.C1;
import com.martsnew.domain.model.Episode;
import com.martsnew.domain.model.EpisodeSource;
import com.martsnew.domain.model.Movie;
import com.martsnew.domain.model.Season;
import com.martsnew.domain.model.StreamUrl;
import com.martsnew.domain.type.MediaType;
import java.util.ArrayList;
import java.util.List;
import n4.u0;
import o5.C1374m;
import y5.C1763h;

/* JADX INFO: loaded from: classes.dex */
public final class O extends G6.i implements O6.p {

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public final /* synthetic */ P f6116A;

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public final /* synthetic */ Boolean f6117B;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public Object f6118u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public Object f6119v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public Object f6120w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public Episode f6121x;

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

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public final /* synthetic */ Movie f6123z;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public O(Movie movie, P p3, Boolean bool, E6.d dVar) {
        super(2, dVar);
        this.f6123z = movie;
        this.f6116A = p3;
        this.f6117B = bool;
    }

    @Override // O6.p
    public final Object k(Object obj, Object obj2) {
        return ((O) m((E6.d) obj2, (InterfaceC0382w) obj)).p(A6.n.f457a);
    }

    @Override // G6.a
    public final E6.d m(E6.d dVar, Object obj) {
        return new O(this.f6123z, this.f6116A, this.f6117B, dVar);
    }

    /* JADX WARN: Code restructure failed: missing block: B:54:0x015c, code lost:
    
        if (R5.P.h(r2, r14) == r0) goto L135;
     */
    /* JADX WARN: Code restructure failed: missing block: B:60:0x0176, code lost:
    
        if (r2.f(r15, r14) == r0) goto L135;
     */
    /* JADX WARN: Removed duplicated region for block: B:103:0x027b  */
    /* JADX WARN: Removed duplicated region for block: B:115:0x02cc  */
    /* JADX WARN: Removed duplicated region for block: B:125:0x0321  */
    /* JADX WARN: Removed duplicated region for block: B:133:0x0343  */
    /* JADX WARN: Removed duplicated region for block: B:38:0x00d7  */
    /* JADX WARN: Removed duplicated region for block: B:46:0x0105  */
    /* JADX WARN: Removed duplicated region for block: B:59:0x0167  */
    /* JADX WARN: Removed duplicated region for block: B:68:0x018f  */
    /* JADX WARN: Removed duplicated region for block: B:76:0x01b3  */
    /* JADX WARN: Removed duplicated region for block: B:93:0x0225  */
    @Override // G6.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object p(Object obj) throws Throwable {
        Object objA;
        Object objA2;
        Object obj2;
        Episode episode;
        Object obj3;
        Object obj4;
        Boolean bool;
        P p3;
        Object obj5;
        Throwable thA;
        Throwable thA2;
        Object obj6;
        Episode episode2;
        Object objA3;
        Object objA4;
        Object obj7;
        P p4;
        Throwable thA3;
        Object obj8;
        P p8;
        Throwable thA4;
        Throwable thA5;
        F6.a aVar = F6.a.f2580q;
        int i = this.f6122y;
        Boolean bool2 = this.f6117B;
        A6.n nVar = A6.n.f457a;
        P p9 = this.f6116A;
        C1374m c1374m = p9.f6125e;
        switch (i) {
            case u0.f15495q /* 0 */:
                C1.N(obj);
                Movie movie = this.f6123z;
                long j8 = movie.f11069q;
                if (j8 != -1) {
                    MediaType mediaType = MediaType.f11106s;
                    if (movie.f11076x != mediaType) {
                        this.f6122y = 1;
                        objA2 = p9.f6124d.a(j8, this);
                        if (objA2 != aVar) {
                            obj2 = objA2;
                            if (!(obj2 instanceof A6.i)) {
                                List list = (List) obj2;
                                if (!list.isEmpty()) {
                                    episode = (Episode) B6.k.h0(list);
                                    p9.f6136q = episode;
                                    long j9 = episode.f11023q;
                                    this.f6118u = obj2;
                                    this.f6119v = p9;
                                    this.f6120w = bool2;
                                    this.f6121x = episode;
                                    this.f6122y = 2;
                                    Object objA5 = c1374m.a(j9, this);
                                    if (objA5 != aVar) {
                                        obj3 = obj2;
                                        obj4 = objA5;
                                        bool = bool2;
                                        p3 = p9;
                                        if (!(obj4 instanceof A6.i)) {
                                            EpisodeSource episodeSource = (EpisodeSource) obj4;
                                            p3.f6138s = episodeSource;
                                            p3.f6137r = episodeSource.f11039v;
                                            List listA = episodeSource.a(p3.f6141v);
                                            p3.f6133n = listA;
                                            if (listA.isEmpty()) {
                                                this.f6118u = obj3;
                                                this.f6119v = p3;
                                                this.f6120w = obj4;
                                                this.f6121x = null;
                                                this.f6122y = 3;
                                            } else {
                                                StreamUrl streamUrl = (StreamUrl) B6.k.h0(p3.f6133n);
                                                P6.g.e(streamUrl, "<set-?>");
                                                p3.f6139t = streamUrl;
                                                C1763h c1763h = new C1763h(new A(episodeSource, P6.g.a(bool, Boolean.TRUE) ? new Long(episode.f11031y) : null));
                                                c7.K k8 = p3.f6132m;
                                                k8.getClass();
                                                k8.g(null, c1763h);
                                            }
                                        }
                                        obj5 = obj3;
                                        thA = A6.j.a(obj4);
                                        if (thA != null) {
                                            this.f6118u = obj5;
                                            this.f6119v = obj4;
                                            this.f6120w = null;
                                            this.f6121x = null;
                                            this.f6122y = 4;
                                        }
                                        obj2 = obj5;
                                    }
                                    break;
                                } else {
                                    this.f6118u = obj2;
                                    this.f6122y = 5;
                                    if (P.h(p9, this) != aVar) {
                                    }
                                }
                            }
                            thA2 = A6.j.a(obj2);
                            if (thA2 != null) {
                                this.f6118u = obj2;
                                this.f6119v = null;
                                this.f6120w = null;
                                this.f6121x = null;
                                this.f6122y = 6;
                                if (p9.f(thA2, this) == aVar) {
                                }
                            }
                        }
                    } else {
                        this.f6122y = 7;
                        objA = p9.f6128h.a(j8, mediaType, this);
                        if (objA != aVar) {
                            obj6 = objA;
                            if (!(obj6 instanceof A6.i)) {
                                List<Season> list2 = (List) obj6;
                                p9.f6134o.clear();
                                p9.f6134o.addAll(list2);
                                ArrayList arrayList = p9.f6140u;
                                arrayList.clear();
                                P6.g.e(list2, "<this>");
                                arrayList.addAll(new B6.y(list2));
                                if (bool2.equals(Boolean.TRUE)) {
                                    for (Season season : list2) {
                                        if (season.f11083u) {
                                            for (Episode episode3 : season.f11084v) {
                                                if (episode3.f11022A) {
                                                    p9.f6135p = new Long(season.f11079q);
                                                    p9.f6136q = episode3;
                                                    this.f6118u = p9;
                                                    this.f6119v = episode3;
                                                    this.f6122y = 8;
                                                    objA4 = c1374m.a(episode3.f11023q, this);
                                                    if (objA4 != aVar) {
                                                        obj7 = objA4;
                                                        if (!(obj7 instanceof A6.i)) {
                                                            EpisodeSource episodeSource2 = (EpisodeSource) obj7;
                                                            p9.f6138s = episodeSource2;
                                                            p9.f6137r = episodeSource2.f11039v;
                                                            List listA2 = episodeSource2.a(p9.f6141v);
                                                            p9.f6133n = listA2;
                                                            if (listA2.isEmpty()) {
                                                                this.f6118u = p9;
                                                                this.f6119v = obj7;
                                                                this.f6122y = 9;
                                                                if (P.h(p9, this) != aVar) {
                                                                    p4 = p9;
                                                                    p9 = p4;
                                                                }
                                                            } else {
                                                                StreamUrl streamUrl2 = (StreamUrl) B6.k.h0(p9.f6133n);
                                                                P6.g.e(streamUrl2, "<set-?>");
                                                                p9.f6139t = streamUrl2;
                                                                C1763h c1763h2 = new C1763h(new A(episodeSource2, new Long(episode3.f11031y)));
                                                                c7.K k9 = p9.f6132m;
                                                                k9.getClass();
                                                                k9.g(null, c1763h2);
                                                            }
                                                        }
                                                        thA3 = A6.j.a(obj7);
                                                        if (thA3 != null) {
                                                            this.f6118u = obj7;
                                                            this.f6119v = null;
                                                            this.f6122y = 10;
                                                            if (p9.f(thA3, this) == aVar) {
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    this.f6118u = obj6;
                                    this.f6122y = 14;
                                    if (P.h(p9, this) != aVar) {
                                    }
                                } else {
                                    int size = arrayList.size();
                                    int i5 = 0;
                                    while (i5 < size) {
                                        Object obj9 = arrayList.get(i5);
                                        i5++;
                                        Season season2 = (Season) obj9;
                                        if (!season2.f11084v.isEmpty()) {
                                            episode2 = (Episode) B6.k.h0(season2.f11084v);
                                            p9.f6135p = new Long(season2.f11079q);
                                            p9.f6136q = episode2;
                                            long j10 = episode2.f11023q;
                                            this.f6118u = p9;
                                            this.f6119v = episode2;
                                            this.f6122y = 11;
                                            objA3 = c1374m.a(j10, this);
                                            if (objA3 != aVar) {
                                                Episode episode4 = episode2;
                                                obj8 = objA3;
                                                if (!(obj8 instanceof A6.i)) {
                                                    EpisodeSource episodeSource3 = (EpisodeSource) obj8;
                                                    p9.f6138s = episodeSource3;
                                                    p9.f6137r = episodeSource3.f11039v;
                                                    List listA3 = episodeSource3.a(p9.f6141v);
                                                    p9.f6133n = listA3;
                                                    if (listA3.isEmpty()) {
                                                        this.f6118u = p9;
                                                        this.f6119v = obj8;
                                                        this.f6122y = 12;
                                                        if (P.h(p9, this) != aVar) {
                                                            p8 = p9;
                                                            p9 = p8;
                                                        }
                                                    } else {
                                                        StreamUrl streamUrl3 = (StreamUrl) B6.k.h0(p9.f6133n);
                                                        P6.g.e(streamUrl3, "<set-?>");
                                                        p9.f6139t = streamUrl3;
                                                        C1763h c1763h3 = new C1763h(new A(episodeSource3, new Long(episode4.f11031y)));
                                                        c7.K k10 = p9.f6132m;
                                                        k10.getClass();
                                                        k10.g(null, c1763h3);
                                                    }
                                                }
                                                thA4 = A6.j.a(obj8);
                                                if (thA4 != null) {
                                                    this.f6118u = obj8;
                                                    this.f6119v = null;
                                                    this.f6122y = 13;
                                                    if (p9.f(thA4, this) == aVar) {
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    this.f6118u = obj6;
                                    this.f6122y = 14;
                                    if (P.h(p9, this) != aVar) {
                                    }
                                }
                            }
                            thA5 = A6.j.a(obj6);
                            if (thA5 != null) {
                                this.f6118u = obj6;
                                this.f6122y = 15;
                                if (p9.f(thA5, this) == aVar) {
                                }
                            }
                        }
                    }
                    return aVar;
                }
                return nVar;
            case 1:
                C1.N(obj);
                objA2 = ((A6.j) obj).f449q;
                obj2 = objA2;
                if (!(obj2 instanceof A6.i)) {
                }
                thA2 = A6.j.a(obj2);
                if (thA2 != null) {
                }
                return nVar;
            case 2:
                Episode episode5 = this.f6121x;
                Boolean bool3 = (Boolean) this.f6120w;
                P p10 = (P) this.f6119v;
                obj3 = this.f6118u;
                C1.N(obj);
                obj4 = ((A6.j) obj).f449q;
                episode = episode5;
                bool = bool3;
                p3 = p10;
                if (!(obj4 instanceof A6.i)) {
                }
                obj5 = obj3;
                thA = A6.j.a(obj4);
                if (thA != null) {
                }
                obj2 = obj5;
                thA2 = A6.j.a(obj2);
                if (thA2 != null) {
                }
                return nVar;
            case 3:
                obj4 = this.f6120w;
                p3 = (P) this.f6119v;
                obj5 = this.f6118u;
                C1.N(obj);
                thA = A6.j.a(obj4);
                if (thA != null) {
                }
                obj2 = obj5;
                thA2 = A6.j.a(obj2);
                if (thA2 != null) {
                }
                return nVar;
            case 4:
            case 5:
                obj2 = this.f6118u;
                C1.N(obj);
                thA2 = A6.j.a(obj2);
                if (thA2 != null) {
                }
                return nVar;
            case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                C1.N(obj);
                return nVar;
            case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                C1.N(obj);
                objA = ((A6.j) obj).f449q;
                obj6 = objA;
                if (!(obj6 instanceof A6.i)) {
                }
                thA5 = A6.j.a(obj6);
                if (thA5 != null) {
                }
                return nVar;
            case Z.g.BYTES_FIELD_NUMBER /* 8 */:
                Episode episode6 = (Episode) this.f6119v;
                p9 = (P) this.f6118u;
                C1.N(obj);
                objA4 = ((A6.j) obj).f449q;
                episode3 = episode6;
                obj7 = objA4;
                if (!(obj7 instanceof A6.i)) {
                }
                thA3 = A6.j.a(obj7);
                if (thA3 != null) {
                }
                return nVar;
            case 9:
                obj7 = this.f6119v;
                p4 = (P) this.f6118u;
                C1.N(obj);
                p9 = p4;
                thA3 = A6.j.a(obj7);
                if (thA3 != null) {
                }
                return nVar;
            case 10:
                C1.N(obj);
                return nVar;
            case 11:
                episode2 = (Episode) this.f6119v;
                p9 = (P) this.f6118u;
                C1.N(obj);
                objA3 = ((A6.j) obj).f449q;
                Episode episode42 = episode2;
                obj8 = objA3;
                if (!(obj8 instanceof A6.i)) {
                }
                thA4 = A6.j.a(obj8);
                if (thA4 != null) {
                }
                return nVar;
            case 12:
                obj8 = this.f6119v;
                p8 = (P) this.f6118u;
                C1.N(obj);
                p9 = p8;
                thA4 = A6.j.a(obj8);
                if (thA4 != null) {
                }
                return nVar;
            case 13:
                C1.N(obj);
                return nVar;
            case 14:
                obj6 = this.f6118u;
                C1.N(obj);
                thA5 = A6.j.a(obj6);
                if (thA5 != null) {
                }
                return nVar;
            case 15:
                C1.N(obj);
                return nVar;
            default:
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }
}
