package V2;

import V4.C0772m;
import a.AbstractC0872a;
import com.debridstream.tv.AuthViewModel;
import com.revenuecat.purchases.Purchases;
import m3.AbstractC2467b;
import w4.C3137A;

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

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

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

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public G0(AuthViewModel authViewModel, A4.d dVar) {
        super(2, dVar);
        this.f7332c = authViewModel;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        G0 g0 = new G0(this.f7332c, dVar);
        g0.f7331b = obj;
        return g0;
    }

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

    /* JADX WARN: Code restructure failed: missing block: B:23:0x0065, code lost:
    
        if (r2.refreshStartupStateForAuthenticatedUser(r18) == r0) goto L24;
     */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        Object objD;
        Y4.c0 c0Var;
        Object value;
        C0745z0 c0745z0;
        String message;
        AuthViewModel authViewModel;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f7330a;
        C3137A c3137a = C3137A.f25453a;
        AuthViewModel authViewModel2 = this.f7332c;
        try {
        } catch (Throwable th) {
            objD = AbstractC2467b.d(th);
        }
        if (i6 == 0) {
            AbstractC2467b.l(obj);
            Purchases.Companion companion = Purchases.Companion;
            if (companion.isConfigured()) {
                this.f7331b = authViewModel2;
                this.f7330a = 1;
                C0772m c0772m = new C0772m(1, AbstractC0872a.V(this));
                c0772m.s();
                companion.getSharedInstance().restorePurchases(new C0733w0(c0772m, 1));
                if (c0772m.r() == aVar) {
                    return aVar;
                }
            }
            authViewModel = authViewModel2;
        } else {
            if (i6 != 1) {
                if (i6 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
                objD = c3137a;
                Throwable thA = w4.n.a(objD);
                if (thA != null) {
                    Y4.H h5 = authViewModel2._uiState;
                    do {
                        c0Var = (Y4.c0) h5;
                        value = c0Var.getValue();
                        c0745z0 = (C0745z0) value;
                        message = thA.getMessage();
                        if (message == null) {
                            message = "Could not restore purchases";
                        }
                    } while (!c0Var.i(value, C0745z0.a(c0745z0, null, null, false, false, false, "", message, null, false, 0, 911)));
                }
                return c3137a;
            }
            authViewModel = (AuthViewModel) this.f7331b;
            AbstractC2467b.l(obj);
        }
        this.f7331b = null;
        this.f7330a = 2;
    }
}
