package defpackage;

import com.strmr.ps.data.local.entity.AllDebridAccount;
import com.strmr.ps.data.repository.AllDebridRepository;
import defpackage.q38;
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$pollForAllDebridApiKey$1", f = "AccountsFragment.kt", i = {0, 0, 0, 5, 5, 5}, l = {1534, 1539, 1545, 1552, 1564, 1574, 1578}, 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 e5 extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public Object a;
    public long b;
    public long c;
    public int d;
    public /* synthetic */ Object e;
    public final /* synthetic */ int f;
    public final /* synthetic */ a4 i;
    public final /* synthetic */ String j;
    public final /* synthetic */ String k;

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

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

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

    /* JADX WARN: Code restructure failed: missing block: B:52:0x0117, code lost:
    
        if (defpackage.h32.a(r6, r13) == r0) goto L56;
     */
    /* JADX WARN: Removed duplicated region for block: B:21:0x0071  */
    /* JADX WARN: Removed duplicated region for block: B:36:0x00b2  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x00d2 A[PHI: r1 r4
      0x00d2: PHI (r1v6 java.lang.Object) = (r1v7 java.lang.Object), (r1v8 java.lang.Object) binds: [B:40:0x00d1, B:35:0x00b0] A[DONT_GENERATE, DONT_INLINE]
      0x00d2: PHI (r4v3 a4) = (r4v4 a4), (r4v5 a4) binds: [B:40:0x00d1, B:35:0x00b0] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:43:0x00d8  */
    /* JADX WARN: Removed duplicated region for block: B:46:0x00ef  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x00f5  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x010a  */
    /* JADX WARN: Removed duplicated region for block: B:56:0x012e A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:57:0x012f A[RETURN] */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:52:0x0117 -> B:9:0x0024). 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) {
        ak1 ak1Var;
        long jCurrentTimeMillis;
        long j;
        ak1 ak1Var2;
        Object obj2;
        Object objM77saveApiKeygIAlus;
        Object obj3;
        a4 a4Var;
        Throwable thA;
        Throwable thA2;
        String str;
        qm5 qm5Var;
        d5 d5Var;
        ck1 ck1Var = ck1.a;
        int i = this.d;
        e6a e6aVar = e6a.a;
        a4 a4Var2 = this.i;
        switch (i) {
            case 0:
                s38.b(obj);
                ak1Var = (ak1) this.e;
                jCurrentTimeMillis = (((long) this.f) * 1000) + System.currentTimeMillis();
                j = 5000;
                if (bk1.d(ak1Var) || System.currentTimeMillis() >= jCurrentTimeMillis) {
                    m12 m12Var = sc2.a;
                    qm5Var = sm5.a;
                    d5Var = new d5(a4Var2, null);
                    this.e = null;
                    this.d = 7;
                    if (wj0.f(qm5Var, d5Var, this) == ck1Var) {
                        return e6aVar;
                    }
                } else {
                    AllDebridRepository allDebridRepositoryR = a4Var2.r();
                    this.e = ak1Var;
                    this.b = jCurrentTimeMillis;
                    this.c = j;
                    this.d = 1;
                    Object objM72pollForApiKey0E7RQCE = allDebridRepositoryR.m72pollForApiKey0E7RQCE(this.j, this.k, this);
                    if (objM72pollForApiKey0E7RQCE != ck1Var) {
                        ak1Var2 = ak1Var;
                        obj2 = objM72pollForApiKey0E7RQCE;
                        if (!(obj2 instanceof q38.b) || (str = (String) obj2) == null) {
                            thA2 = q38.a(obj2);
                            if (thA2 != null) {
                                this.e = ak1Var2;
                                this.b = jCurrentTimeMillis;
                                this.c = j;
                                this.d = 6;
                                break;
                            } else {
                                m12 m12Var2 = sc2.a;
                                qm5 qm5Var2 = sm5.a;
                                c5 c5Var = new c5(a4Var2, thA2, null);
                                this.e = null;
                                this.d = 5;
                                if (wj0.f(qm5Var2, c5Var, this) == ck1Var) {
                                }
                            }
                        } else {
                            AllDebridRepository allDebridRepositoryR2 = a4Var2.r();
                            this.e = a4Var2;
                            this.d = 2;
                            objM77saveApiKeygIAlus = allDebridRepositoryR2.m77saveApiKeygIAlus(str, this);
                            if (objM77saveApiKeygIAlus != ck1Var) {
                                obj3 = objM77saveApiKeygIAlus;
                                if (!(obj3 instanceof q38.b)) {
                                    thA = q38.a(obj3);
                                    if (thA != null) {
                                    }
                                    return e6aVar;
                                }
                                a4Var2.ad = (AllDebridAccount) obj3;
                                a4Var2.aj = true;
                                m12 m12Var3 = sc2.a;
                                qm5 qm5Var3 = sm5.a;
                                a5 a5Var = new a5(a4Var2, null);
                                this.e = a4Var2;
                                this.a = obj3;
                                this.d = 3;
                                if (wj0.f(qm5Var3, a5Var, this) != ck1Var) {
                                    a4Var = a4Var2;
                                    a4Var2 = a4Var;
                                    thA = q38.a(obj3);
                                    if (thA != null) {
                                        m12 m12Var4 = sc2.a;
                                        qm5 qm5Var4 = sm5.a;
                                        b5 b5Var = new b5(a4Var2, thA, null);
                                        this.e = obj3;
                                        this.a = null;
                                        this.d = 4;
                                        if (wj0.f(qm5Var4, b5Var, this) == ck1Var) {
                                        }
                                    }
                                    return e6aVar;
                                }
                            }
                        }
                    }
                }
                return ck1Var;
            case 1:
                j = this.c;
                jCurrentTimeMillis = this.b;
                ak1Var2 = (ak1) this.e;
                s38.b(obj);
                obj2 = ((q38) obj).a;
                if (obj2 instanceof q38.b) {
                    thA2 = q38.a(obj2);
                    if (thA2 != null) {
                    }
                    return ck1Var;
                }
                if (bk1.d(ak1Var)) {
                }
                m12 m12Var5 = sc2.a;
                qm5Var = sm5.a;
                d5Var = new d5(a4Var2, null);
                this.e = null;
                this.d = 7;
                if (wj0.f(qm5Var, d5Var, this) == ck1Var) {
                    return ck1Var;
                }
                break;
            case 2:
                a4Var2 = (a4) this.e;
                s38.b(obj);
                objM77saveApiKeygIAlus = ((q38) obj).a;
                obj3 = objM77saveApiKeygIAlus;
                if (!(obj3 instanceof q38.b)) {
                }
                return ck1Var;
            case 3:
                obj3 = this.a;
                a4Var = (a4) this.e;
                s38.b(obj);
                a4Var2 = a4Var;
                thA = q38.a(obj3);
                if (thA != null) {
                }
                return e6aVar;
            case 4:
                s38.b(obj);
                return e6aVar;
            case 5:
                s38.b(obj);
                return e6aVar;
            case 6:
                j = this.c;
                jCurrentTimeMillis = this.b;
                ak1Var2 = (ak1) this.e;
                s38.b(obj);
                ak1Var = ak1Var2;
                if (bk1.d(ak1Var)) {
                }
                m12 m12Var52 = sc2.a;
                qm5Var = sm5.a;
                d5Var = new d5(a4Var2, null);
                this.e = null;
                this.d = 7;
                if (wj0.f(qm5Var, d5Var, this) == ck1Var) {
                }
                break;
            case 7:
                s38.b(obj);
                return e6aVar;
            default:
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }
}
