package kotlinx.coroutines.flow.internal;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes3.dex */
@kotlin.Metadata(d1 = {"\u0000\n\n\u0000\n\u0002\u0010\u0002\n\u0002\u0018\u0002\u0010\u0000\u001a\u00020\u0001*\u00020\u0002H\n"}, d2 = {"<anonymous>", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "Lkotlinx/coroutines/CoroutineScope;"}, k = 3, mv = {2, 1, 0}, xi = 48)
@kotlin.coroutines.jvm.internal.DebugMetadata(c = "kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3", f = "Merge.kt", l = {23}, m = "invokeSuspend")
final class ChannelFlowTransformLatest$flowCollect$3 extends kotlin.coroutines.jvm.internal.SuspendLambda implements kotlin.jvm.functions.Function2<kotlinx.coroutines.CoroutineScope, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object> {
    int n;
    private /* synthetic */ java.lang.Object o;
    final /* synthetic */ kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest p;
    final /* synthetic */ kotlinx.coroutines.flow.FlowCollector q;

    /* JADX INFO: renamed from: kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1, reason: invalid class name */
    /* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
    @kotlin.Metadata(k = 3, mv = {2, 1, 0}, xi = 48)
    static final class AnonymousClass1<T> implements kotlinx.coroutines.flow.FlowCollector {
        final /* synthetic */ kotlin.jvm.internal.Ref.ObjectRef a;
        final /* synthetic */ kotlinx.coroutines.CoroutineScope b;
        final /* synthetic */ kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest c;
        final /* synthetic */ kotlinx.coroutines.flow.FlowCollector d;

        /* JADX INFO: renamed from: kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2, reason: invalid class name */
        /* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
        @kotlin.Metadata(d1 = {"\u0000\n\n\u0000\n\u0002\u0010\u0002\n\u0002\u0018\u0002\u0010\u0000\u001a\u00020\u0001*\u00020\u0002H\n"}, d2 = {"<anonymous>", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "Lkotlinx/coroutines/CoroutineScope;"}, k = 3, mv = {2, 1, 0}, xi = 48)
        @kotlin.coroutines.jvm.internal.DebugMetadata(c = "kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2", f = "Merge.kt", l = {30}, m = "invokeSuspend")
        static final class AnonymousClass2 extends kotlin.coroutines.jvm.internal.SuspendLambda implements kotlin.jvm.functions.Function2<kotlinx.coroutines.CoroutineScope, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object> {
            int n;
            final /* synthetic */ kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest o;
            final /* synthetic */ kotlinx.coroutines.flow.FlowCollector p;
            final /* synthetic */ java.lang.Object q;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            AnonymousClass2(kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest channelFlowTransformLatest, kotlinx.coroutines.flow.FlowCollector flowCollector, java.lang.Object obj, kotlin.coroutines.Continuation continuation) {
                super(2, continuation);
                this.o = channelFlowTransformLatest;
                this.p = flowCollector;
                this.q = obj;
            }

            public final kotlin.coroutines.Continuation create(java.lang.Object obj, kotlin.coroutines.Continuation continuation) {
                return new kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.AnonymousClass1.AnonymousClass2(this.o, this.p, this.q, continuation);
            }

            public final java.lang.Object invokeSuspend(java.lang.Object obj) {
                java.lang.Object objG = kotlin.coroutines.intrinsics.IntrinsicsKt.g();
                int i = this.n;
                if (i == 0) {
                    kotlin.ResultKt.b(obj);
                    kotlin.jvm.functions.Function3 function3 = this.o.transform;
                    kotlinx.coroutines.flow.FlowCollector flowCollector = this.p;
                    java.lang.Object obj2 = this.q;
                    this.n = 1;
                    if (function3.invoke(flowCollector, obj2, this) == objG) {
                        return objG;
                    }
                } else {
                    if (i != 1) {
                        throw new java.lang.IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    kotlin.ResultKt.b(obj);
                }
                return kotlin.Unit.a;
            }

            public final java.lang.Object invoke(kotlinx.coroutines.CoroutineScope coroutineScope, kotlin.coroutines.Continuation continuation) {
                return create(coroutineScope, continuation).invokeSuspend(kotlin.Unit.a);
            }
        }

        AnonymousClass1(kotlin.jvm.internal.Ref.ObjectRef objectRef, kotlinx.coroutines.CoroutineScope coroutineScope, kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest channelFlowTransformLatest, kotlinx.coroutines.flow.FlowCollector flowCollector) {
            this.a = objectRef;
            this.b = coroutineScope;
            this.c = channelFlowTransformLatest;
            this.d = flowCollector;
        }

        /* JADX WARN: Code duplicated, block: B:7:0x0013  */
        @Override // kotlinx.coroutines.flow.FlowCollector
        public final java.lang.Object emit(java.lang.Object obj, kotlin.coroutines.Continuation continuation) {
            kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$emit$1 channelFlowTransformLatest$flowCollect$3$1$emit$1;
            if (continuation instanceof kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$emit$1) {
                channelFlowTransformLatest$flowCollect$3$1$emit$1 = (kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$emit$1) continuation;
                int i = channelFlowTransformLatest$flowCollect$3$1$emit$1.s;
                if ((i & Integer.MIN_VALUE) != 0) {
                    channelFlowTransformLatest$flowCollect$3$1$emit$1.s = i - Integer.MIN_VALUE;
                } else {
                    channelFlowTransformLatest$flowCollect$3$1$emit$1 = new kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$emit$1(this, continuation);
                }
            } else {
                channelFlowTransformLatest$flowCollect$3$1$emit$1 = new kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$emit$1(this, continuation);
            }
            java.lang.Object obj2 = channelFlowTransformLatest$flowCollect$3$1$emit$1.q;
            java.lang.Object objG = kotlin.coroutines.intrinsics.IntrinsicsKt.g();
            int i2 = channelFlowTransformLatest$flowCollect$3$1$emit$1.s;
            if (i2 == 0) {
                kotlin.ResultKt.b(obj2);
                kotlinx.coroutines.Job job = (kotlinx.coroutines.Job) this.a.a;
                if (job != null) {
                    job.e(new kotlinx.coroutines.flow.internal.ChildCancelledException());
                    channelFlowTransformLatest$flowCollect$3$1$emit$1.n = this;
                    channelFlowTransformLatest$flowCollect$3$1$emit$1.o = obj;
                    channelFlowTransformLatest$flowCollect$3$1$emit$1.p = job;
                    channelFlowTransformLatest$flowCollect$3$1$emit$1.s = 1;
                    if (job.F1(channelFlowTransformLatest$flowCollect$3$1$emit$1) == objG) {
                        return objG;
                    }
                }
            } else {
                if (i2 != 1) {
                    throw new java.lang.IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                obj = channelFlowTransformLatest$flowCollect$3$1$emit$1.o;
                this = (kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.AnonymousClass1) channelFlowTransformLatest$flowCollect$3$1$emit$1.n;
                kotlin.ResultKt.b(obj2);
            }
            this.a.a = kotlinx.coroutines.BuildersKt.d(this.b, (kotlin.coroutines.CoroutineContext) null, kotlinx.coroutines.CoroutineStart.UNDISPATCHED, new kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.AnonymousClass1.AnonymousClass2(this.c, this.d, obj, null), 1, (java.lang.Object) null);
            return kotlin.Unit.a;
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    ChannelFlowTransformLatest$flowCollect$3(kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest channelFlowTransformLatest, kotlinx.coroutines.flow.FlowCollector flowCollector, kotlin.coroutines.Continuation continuation) {
        super(2, continuation);
        this.p = channelFlowTransformLatest;
        this.q = flowCollector;
    }

    public final kotlin.coroutines.Continuation create(java.lang.Object obj, kotlin.coroutines.Continuation continuation) {
        kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3 channelFlowTransformLatest$flowCollect$3 = new kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3(this.p, this.q, continuation);
        channelFlowTransformLatest$flowCollect$3.o = obj;
        return channelFlowTransformLatest$flowCollect$3;
    }

    public final java.lang.Object invokeSuspend(java.lang.Object obj) {
        java.lang.Object objG = kotlin.coroutines.intrinsics.IntrinsicsKt.g();
        int i = this.n;
        if (i == 0) {
            kotlin.ResultKt.b(obj);
            kotlinx.coroutines.CoroutineScope coroutineScope = (kotlinx.coroutines.CoroutineScope) this.o;
            kotlin.jvm.internal.Ref.ObjectRef objectRef = new kotlin.jvm.internal.Ref.ObjectRef();
            kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest channelFlowTransformLatest = this.p;
            kotlinx.coroutines.flow.Flow flow = channelFlowTransformLatest.flow;
            kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.AnonymousClass1 anonymousClass1 = new kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3.AnonymousClass1(objectRef, coroutineScope, channelFlowTransformLatest, this.q);
            this.n = 1;
            if (flow.a(anonymousClass1, this) == objG) {
                return objG;
            }
        } else {
            if (i != 1) {
                throw new java.lang.IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            kotlin.ResultKt.b(obj);
        }
        return kotlin.Unit.a;
    }

    public final java.lang.Object invoke(kotlinx.coroutines.CoroutineScope coroutineScope, kotlin.coroutines.Continuation continuation) {
        return create(coroutineScope, continuation).invokeSuspend(kotlin.Unit.a);
    }
}
