package defpackage;

import com.strmr.ps.data.remote.model.premiumize.PremiumizeTokenResponse;
import com.strmr.ps.data.repository.PremiumizeRepository;
import defpackage.q38;
import java.io.IOException;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {2, 0, 0})
@DebugMetadata(c = "com.strmr.ps.ui.settings.fragments.AccountsFragment$pollForPremiumizeToken$1", f = "AccountsFragment.kt", i = {0, 0, 0, 3, 3, 3}, l = {1097, 1102, 1108, 1118, 1122}, m = "invokeSuspend", n = {"$this$launch", "expiresAt", "pollDelay", "$this$launch", "expiresAt", "pollDelay"}, s = {"L$0", "J$0", "J$1", "L$0", "J$0", "J$1"})
final class k5 extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public long a;
    public long b;
    public int c;
    public /* synthetic */ Object d;
    public final /* synthetic */ int e;
    public final /* synthetic */ int f;
    public final /* synthetic */ a4 i;
    public final /* synthetic */ String j;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public k5(int i, int i2, a4 a4Var, String str, Continuation continuation) {
        super(2, continuation);
        this.e = i;
        this.f = i2;
        this.i = a4Var;
        this.j = str;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Object obj, Continuation continuation) {
        k5 k5Var = new k5(this.e, this.f, this.i, this.j, continuation);
        k5Var.d = obj;
        return k5Var;
    }

    @Override // defpackage.gr3
    public final Object invoke(Object obj, Object obj2) {
        return ((k5) create((ak1) obj, (Continuation) obj2)).invokeSuspend(e6a.a);
    }

    /* JADX WARN: Code restructure failed: missing block: B:45:0x00cf, code lost:
    
        if (defpackage.h32.a(r11, r18) == r1) goto L50;
     */
    /* JADX WARN: Removed duplicated region for block: B:25:0x006e  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x00a9  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x00af  */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00c3  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x00e7 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:51:0x00e8 A[RETURN] */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:45:0x00cf -> B:47:0x00d2). Please report as a decompilation issue!!! */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws IOException {
        ak1 ak1Var;
        long jCurrentTimeMillis;
        long j;
        Object objM115pollForTokengIAlus;
        Throwable thA;
        PremiumizeTokenResponse premiumizeTokenResponse;
        qm5 qm5Var;
        j5 j5Var;
        ck1 ck1Var = ck1.a;
        int i = this.c;
        int i2 = 1;
        e6a e6aVar = e6a.a;
        a4 a4Var = this.i;
        if (i == 0) {
            s38.b(obj);
            ak1Var = (ak1) this.d;
            jCurrentTimeMillis = (((long) this.e) * 1000) + System.currentTimeMillis();
            int i3 = this.f;
            if (i3 < 5) {
                i3 = 5;
            }
            j = ((long) i3) * 1000;
            if (bk1.d(ak1Var)) {
            }
            m12 m12Var = sc2.a;
            qm5Var = sm5.a;
            j5Var = new j5(a4Var, null);
            this.d = null;
            this.c = 5;
            if (wj0.f(qm5Var, j5Var, this) == ck1Var) {
            }
        } else {
            if (i != 1) {
                if (i == 2) {
                    s38.b(obj);
                    return e6aVar;
                }
                if (i == 3) {
                    s38.b(obj);
                    return e6aVar;
                }
                if (i != 4) {
                    if (i != 5) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    s38.b(obj);
                    return e6aVar;
                }
                j = this.b;
                jCurrentTimeMillis = this.a;
                ak1Var = (ak1) this.d;
                s38.b(obj);
                i2 = 1;
                if (bk1.d(ak1Var) || System.currentTimeMillis() >= jCurrentTimeMillis) {
                    m12 m12Var2 = sc2.a;
                    qm5Var = sm5.a;
                    j5Var = new j5(a4Var, null);
                    this.d = null;
                    this.c = 5;
                    if (wj0.f(qm5Var, j5Var, this) == ck1Var) {
                        return e6aVar;
                    }
                } else {
                    PremiumizeRepository premiumizeRepositoryV = a4Var.v();
                    this.d = ak1Var;
                    this.a = jCurrentTimeMillis;
                    this.b = j;
                    this.c = i2;
                    objM115pollForTokengIAlus = premiumizeRepositoryV.m115pollForTokengIAlus(this.j, this);
                    if (objM115pollForTokengIAlus != ck1Var) {
                        if (!(objM115pollForTokengIAlus instanceof q38.b) || (premiumizeTokenResponse = (PremiumizeTokenResponse) objM115pollForTokengIAlus) == null || premiumizeTokenResponse.getAccessToken() == null) {
                            thA = q38.a(objM115pollForTokengIAlus);
                            if (thA == null) {
                                m12 m12Var3 = sc2.a;
                                qm5 qm5Var2 = sm5.a;
                                i5 i5Var = new i5(a4Var, thA, null);
                                this.d = null;
                                this.c = 3;
                                if (wj0.f(qm5Var2, i5Var, this) == ck1Var) {
                                }
                            } else {
                                this.d = ak1Var;
                                this.a = jCurrentTimeMillis;
                                this.b = j;
                                this.c = 4;
                            }
                        } else {
                            String accessToken = premiumizeTokenResponse.getAccessToken();
                            this.d = null;
                            this.c = 2;
                            if (a4.m(a4Var, accessToken, this) == ck1Var) {
                            }
                        }
                    }
                }
                return ck1Var;
            }
            j = this.b;
            jCurrentTimeMillis = this.a;
            ak1Var = (ak1) this.d;
            s38.b(obj);
            objM115pollForTokengIAlus = ((q38) obj).a;
            if (objM115pollForTokengIAlus instanceof q38.b) {
                thA = q38.a(objM115pollForTokengIAlus);
                if (thA == null) {
                }
                return ck1Var;
            }
            if (bk1.d(ak1Var)) {
            }
            m12 m12Var22 = sc2.a;
            qm5Var = sm5.a;
            j5Var = new j5(a4Var, null);
            this.d = null;
            this.c = 5;
            if (wj0.f(qm5Var, j5Var, this) == ck1Var) {
                return ck1Var;
            }
        }
    }
}
