package kotlinx.coroutines.flow;

import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.CoroutineSingletons;
import kotlinx.coroutines.flow.internal.SafeCollector;

/* JADX INFO: loaded from: classes.dex */
public abstract class a implements f {
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @Override // kotlinx.coroutines.flow.f
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object a(g gVar, Continuation continuation) throws Throwable {
        AbstractFlow$collect$1 abstractFlow$collect$1;
        Throwable th;
        SafeCollector safeCollector;
        if (continuation instanceof AbstractFlow$collect$1) {
            abstractFlow$collect$1 = (AbstractFlow$collect$1) continuation;
            int i10 = abstractFlow$collect$1.label;
            if ((i10 & Integer.MIN_VALUE) != 0) {
                abstractFlow$collect$1.label = i10 - Integer.MIN_VALUE;
            } else {
                abstractFlow$collect$1 = new AbstractFlow$collect$1(this, continuation);
            }
        }
        Object obj = abstractFlow$collect$1.result;
        CoroutineSingletons coroutineSingletons = CoroutineSingletons.f29226a;
        int i11 = abstractFlow$collect$1.label;
        kd.e eVar = kd.e.f29109a;
        if (i11 != 0) {
            if (i11 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            safeCollector = (SafeCollector) abstractFlow$collect$1.L$0;
            try {
                kotlin.a.d(obj);
                safeCollector.releaseIntercepted();
                return eVar;
            } catch (Throwable th2) {
                th = th2;
                safeCollector.releaseIntercepted();
                throw th;
            }
        }
        kotlin.a.d(obj);
        SafeCollector safeCollector2 = new SafeCollector(gVar, abstractFlow$collect$1.getContext());
        try {
            abstractFlow$collect$1.L$0 = safeCollector2;
            abstractFlow$collect$1.label = 1;
            Object objInvoke = ((q) this).f29413a.invoke(safeCollector2, abstractFlow$collect$1);
            if (objInvoke != coroutineSingletons) {
                objInvoke = eVar;
            }
            if (objInvoke == coroutineSingletons) {
                return coroutineSingletons;
            }
            safeCollector = safeCollector2;
            safeCollector.releaseIntercepted();
            return eVar;
        } catch (Throwable th3) {
            th = th3;
            safeCollector = safeCollector2;
            safeCollector.releaseIntercepted();
            throw th;
        }
    }
}
