package g3;

import V2.P2;
import V4.C;
import V4.E;
import V4.N;
import android.content.Context;
import android.os.SystemClock;
import com.debridstream.tv.PlayerViewModel;
import java.util.concurrent.atomic.AtomicBoolean;
import m3.AbstractC2467b;
import w4.C3137A;

/* JADX INFO: loaded from: classes.dex */
public final class o extends C4.j implements J4.e {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public e5.a f16527a;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public P2 f16529c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Context f16530d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public PlayerViewModel f16531e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public long f16532f;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public long f16533j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f16534k;
    public final /* synthetic */ n l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final /* synthetic */ long f16535m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final /* synthetic */ long f16536n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final /* synthetic */ P2 f16537o;

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

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

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public o(n nVar, long j4, long j6, P2 p22, Context context, PlayerViewModel playerViewModel, String str, A4.d dVar) {
        super(2, dVar);
        this.l = nVar;
        this.f16535m = j4;
        this.f16536n = j6;
        this.f16537o = p22;
        this.f16538p = context;
        this.f16539q = playerViewModel;
        this.f16540r = str;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        return new o(this.l, this.f16535m, this.f16536n, this.f16537o, this.f16538p, this.f16539q, this.f16540r, dVar);
    }

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

    /* JADX WARN: Code restructure failed: missing block: B:24:0x0094, code lost:
    
        if (r13 < 5000) goto L59;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:34:0x00b7  */
    /* JADX WARN: Removed duplicated region for block: B:36:0x00ba A[Catch: all -> 0x001c, Exception -> 0x0114, TryCatch #0 {Exception -> 0x0114, blocks: (B:7:0x0017, B:58:0x010a, B:26:0x0098, B:28:0x00a6, B:33:0x00af, B:36:0x00ba, B:41:0x00c3, B:44:0x00ce, B:49:0x00d6, B:51:0x00dd), top: B:64:0x000b }] */
    /* JADX WARN: Removed duplicated region for block: B:42:0x00cb  */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00ce A[Catch: all -> 0x001c, Exception -> 0x0114, TryCatch #0 {Exception -> 0x0114, blocks: (B:7:0x0017, B:58:0x010a, B:26:0x0098, B:28:0x00a6, B:33:0x00af, B:36:0x00ba, B:41:0x00c3, B:44:0x00ce, B:49:0x00d6, B:51:0x00dd), top: B:64:0x000b }] */
    /* JADX WARN: Removed duplicated region for block: B:50:0x00db  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x0104  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x0105  */
    /* JADX WARN: Removed duplicated region for block: B:57:0x0109  */
    /* JADX WARN: Type inference failed for: r2v0, types: [int] */
    /* JADX WARN: Type inference failed for: r2v1 */
    /* JADX WARN: Type inference failed for: r2v10 */
    /* JADX WARN: Type inference failed for: r2v13 */
    /* JADX WARN: Type inference failed for: r2v14 */
    /* JADX WARN: Type inference failed for: r2v15 */
    /* JADX WARN: Type inference failed for: r2v3 */
    /* JADX WARN: Type inference failed for: r2v4 */
    /* JADX WARN: Type inference failed for: r2v7, types: [e5.a] */
    /* JADX WARN: Type inference failed for: r2v8 */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        n nVar;
        long j4;
        long j6;
        P2 p22;
        Context context;
        PlayerViewModel playerViewModel;
        Integer num;
        Integer num2;
        Integer num3;
        Object objH;
        String str;
        B4.a aVar = B4.a.f492a;
        ?? r22 = this.f16534k;
        C3137A c3137a = C3137A.f25453a;
        try {
            if (r22 == 0) {
                AbstractC2467b.l(obj);
                e5.c cVar = p.f16542b;
                nVar = this.l;
                j4 = this.f16535m;
                j6 = this.f16536n;
                p22 = this.f16537o;
                Context context2 = this.f16538p;
                PlayerViewModel playerViewModel2 = this.f16539q;
                this.f16527a = cVar;
                this.f16528b = nVar;
                this.f16529c = p22;
                this.f16530d = context2;
                this.f16531e = playerViewModel2;
                this.f16532f = j4;
                this.f16533j = j6;
                this.f16534k = 1;
                if (cVar.e(this) != aVar) {
                    context = context2;
                    playerViewModel = playerViewModel2;
                    r22 = cVar;
                }
                return aVar;
            }
            if (r22 != 1) {
                if (r22 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                str = (String) this.f16528b;
                e5.a aVar2 = this.f16527a;
                AbstractC2467b.l(obj);
                r22 = aVar2;
                a5.c cVar2 = p.f16541a;
                p.f16543c = str;
                p.f16544d = SystemClock.elapsedRealtime();
                return c3137a;
            }
            j6 = this.f16533j;
            j4 = this.f16532f;
            PlayerViewModel playerViewModel3 = this.f16531e;
            Context context3 = this.f16530d;
            p22 = this.f16529c;
            nVar = (n) this.f16528b;
            e5.a aVar3 = this.f16527a;
            AbstractC2467b.l(obj);
            playerViewModel = playerViewModel3;
            context = context3;
            r22 = aVar3;
            n nVar2 = nVar;
            P2 p23 = p22;
            long j7 = j6;
            long j8 = j4;
            long jElapsedRealtime = SystemClock.elapsedRealtime();
            String strA = p.a(nVar2, j8, j7, p23);
            String str2 = p.f16543c;
            long j9 = p.f16544d;
            if (kotlin.jvm.internal.o.c(str2, strA)) {
                long j10 = jElapsedRealtime - j9;
                if (0 <= j10) {
                }
            }
            kotlin.jvm.internal.o.e(context);
            double d6 = j8 / 1000.0d;
            double d7 = j7 / 1000.0d;
            if (p23 == null) {
                num = null;
                if (p23 == null) {
                    num2 = null;
                    if (p23 != null) {
                        if (!p23.f7480c) {
                            p23 = null;
                        }
                        if (p23 != null) {
                            num3 = p23.f7483f;
                        }
                        AtomicBoolean progressHistoryMarked = playerViewModel.getProgressHistoryMarked();
                        this.f16527a = r22;
                        this.f16528b = strA;
                        this.f16529c = null;
                        this.f16530d = null;
                        this.f16531e = null;
                        this.f16534k = 2;
                        c5.e eVar = N.f8259a;
                        objH = E.H(c5.d.f13466b, new t(nVar2, d6, d7, num, num2, context, playerViewModel, true, progressHistoryMarked, num3, null), this);
                        if (objH == aVar) {
                        }
                        if (objH != aVar) {
                        }
                        return aVar;
                    }
                    num3 = null;
                    AtomicBoolean progressHistoryMarked2 = playerViewModel.getProgressHistoryMarked();
                    this.f16527a = r22;
                    this.f16528b = strA;
                    this.f16529c = null;
                    this.f16530d = null;
                    this.f16531e = null;
                    this.f16534k = 2;
                    c5.e eVar2 = N.f8259a;
                    objH = E.H(c5.d.f13466b, new t(nVar2, d6, d7, num, num2, context, playerViewModel, true, progressHistoryMarked2, num3, null), this);
                    if (objH == aVar) {
                        objH = c3137a;
                    }
                    if (objH != aVar) {
                        str = strA;
                        r22 = r22;
                        a5.c cVar22 = p.f16541a;
                        p.f16543c = str;
                        p.f16544d = SystemClock.elapsedRealtime();
                    }
                    return aVar;
                }
                P2 p24 = p23.f7480c ? p23 : null;
                if (p24 != null) {
                    num2 = new Integer(p24.f7482e);
                }
                if (p23 != null) {
                }
            } else {
                P2 p25 = p23.f7480c ? p23 : null;
                if (p25 != null) {
                    num = new Integer(p25.f7481d);
                }
                if (p23 == null) {
                }
            }
            return c3137a;
        } finally {
            ((e5.c) r22).g(null);
        }
    }
}
