package com.revenuecat.purchases.ui.revenuecatui.components.countdown;

import A4.d;
import B4.a;
import C4.c;
import C4.e;
import C4.j;
import E3.v;
import T4.b;
import V4.C;
import V4.E;
import Y4.InterfaceC0843i;
import Y4.InterfaceC0844j;
import Y4.O;
import Y4.a0;
import androidx.compose.runtime.MutableState;
import androidx.lifecycle.EnumC1108q;
import androidx.lifecycle.InterfaceC1113w;
import java.util.Date;
import m3.AbstractC2467b;
import w4.C3137A;

/* JADX INFO: loaded from: classes3.dex */
@e(c = "com.revenuecat.purchases.ui.revenuecatui.components.countdown.CountdownComponentStateKt$rememberCountdownState$1$1", f = "CountdownComponentState.kt", l = {92}, m = "invokeSuspend")
public final class CountdownComponentStateKt$rememberCountdownState$1$1 extends j implements J4.e {
    final /* synthetic */ MutableState<CountdownTime> $countdownTime$delegate;
    final /* synthetic */ MutableState<Boolean> $isCountingEnabled$delegate;
    final /* synthetic */ InterfaceC1113w $lifecycleOwner;
    final /* synthetic */ Date $targetDate;
    private /* synthetic */ Object L$0;
    int label;

    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.countdown.CountdownComponentStateKt$rememberCountdownState$1$1$1, reason: invalid class name */
    @e(c = "com.revenuecat.purchases.ui.revenuecatui.components.countdown.CountdownComponentStateKt$rememberCountdownState$1$1$1", f = "CountdownComponentState.kt", l = {74}, m = "invokeSuspend")
    public static final class AnonymousClass1 extends j implements J4.e {
        final /* synthetic */ MutableState<Boolean> $isCountingEnabled$delegate;
        final /* synthetic */ InterfaceC1113w $lifecycleOwner;
        int label;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public AnonymousClass1(InterfaceC1113w interfaceC1113w, MutableState<Boolean> mutableState, d dVar) {
            super(2, dVar);
            this.$lifecycleOwner = interfaceC1113w;
            this.$isCountingEnabled$delegate = mutableState;
        }

        @Override // C4.a
        public final d create(Object obj, d dVar) {
            return new AnonymousClass1(this.$lifecycleOwner, this.$isCountingEnabled$delegate, dVar);
        }

        @Override // J4.e
        public final Object invoke(C c6, d dVar) {
            return ((AnonymousClass1) create(c6, dVar)).invokeSuspend(C3137A.f25453a);
        }

        @Override // C4.a
        public final Object invokeSuspend(Object obj) {
            a aVar = a.f492a;
            int i6 = this.label;
            if (i6 == 0) {
                AbstractC2467b.l(obj);
                final a0 currentStateFlow = this.$lifecycleOwner.getLifecycle().getCurrentStateFlow();
                InterfaceC0843i interfaceC0843iJ = O.j(new InterfaceC0843i() { // from class: com.revenuecat.purchases.ui.revenuecatui.components.countdown.CountdownComponentStateKt$rememberCountdownState$1$1$1$invokeSuspend$$inlined$map$1

                    /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.countdown.CountdownComponentStateKt$rememberCountdownState$1$1$1$invokeSuspend$$inlined$map$1$2, reason: invalid class name */
                    public static final class AnonymousClass2<T> implements InterfaceC0844j {
                        final /* synthetic */ InterfaceC0844j $this_unsafeFlow;

                        /* JADX INFO: renamed from: com.revenuecat.purchases.ui.revenuecatui.components.countdown.CountdownComponentStateKt$rememberCountdownState$1$1$1$invokeSuspend$$inlined$map$1$2$1, reason: invalid class name */
                        @e(c = "com.revenuecat.purchases.ui.revenuecatui.components.countdown.CountdownComponentStateKt$rememberCountdownState$1$1$1$invokeSuspend$$inlined$map$1$2", f = "CountdownComponentState.kt", l = {223}, m = "emit")
                        public static final class AnonymousClass1 extends c {
                            Object L$0;
                            int label;
                            /* synthetic */ Object result;

                            public AnonymousClass1(d dVar) {
                                super(dVar);
                            }

                            @Override // C4.a
                            public final Object invokeSuspend(Object obj) {
                                this.result = obj;
                                this.label |= Integer.MIN_VALUE;
                                return AnonymousClass2.this.emit(null, this);
                            }
                        }

                        public AnonymousClass2(InterfaceC0844j interfaceC0844j) {
                            this.$this_unsafeFlow = interfaceC0844j;
                        }

                        /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
                        @Override // Y4.InterfaceC0844j
                        /*
                            Code decompiled incorrectly, please refer to instructions dump.
                        */
                        public final Object emit(Object obj, d dVar) {
                            AnonymousClass1 anonymousClass1;
                            if (dVar instanceof AnonymousClass1) {
                                anonymousClass1 = (AnonymousClass1) dVar;
                                int i6 = anonymousClass1.label;
                                if ((i6 & Integer.MIN_VALUE) != 0) {
                                    anonymousClass1.label = i6 - Integer.MIN_VALUE;
                                } else {
                                    anonymousClass1 = new AnonymousClass1(dVar);
                                }
                            }
                            Object obj2 = anonymousClass1.result;
                            a aVar = a.f492a;
                            int i7 = anonymousClass1.label;
                            if (i7 == 0) {
                                AbstractC2467b.l(obj2);
                                InterfaceC0844j interfaceC0844j = this.$this_unsafeFlow;
                                Boolean boolValueOf = Boolean.valueOf(((EnumC1108q) obj).a(EnumC1108q.f12183d));
                                anonymousClass1.label = 1;
                                if (interfaceC0844j.emit(boolValueOf, anonymousClass1) == aVar) {
                                    return aVar;
                                }
                            } else {
                                if (i7 != 1) {
                                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                                }
                                AbstractC2467b.l(obj2);
                            }
                            return C3137A.f25453a;
                        }
                    }

                    @Override // Y4.InterfaceC0843i
                    public Object collect(InterfaceC0844j interfaceC0844j, d dVar) {
                        Object objCollect = currentStateFlow.collect(new AnonymousClass2(interfaceC0844j), dVar);
                        return objCollect == a.f492a ? objCollect : C3137A.f25453a;
                    }
                });
                final MutableState<Boolean> mutableState = this.$isCountingEnabled$delegate;
                InterfaceC0844j interfaceC0844j = new InterfaceC0844j() { // from class: com.revenuecat.purchases.ui.revenuecatui.components.countdown.CountdownComponentStateKt.rememberCountdownState.1.1.1.2
                    @Override // Y4.InterfaceC0844j
                    public /* bridge */ /* synthetic */ Object emit(Object obj2, d dVar) {
                        return emit(((Boolean) obj2).booleanValue(), dVar);
                    }

                    public final Object emit(boolean z6, d dVar) {
                        CountdownComponentStateKt.rememberCountdownState$lambda$6(mutableState, z6);
                        return C3137A.f25453a;
                    }
                };
                this.label = 1;
                if (interfaceC0843iJ.collect(interfaceC0844j, this) == aVar) {
                    return aVar;
                }
            } else {
                if (i6 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
            }
            return C3137A.f25453a;
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public CountdownComponentStateKt$rememberCountdownState$1$1(Date date, InterfaceC1113w interfaceC1113w, MutableState<Boolean> mutableState, MutableState<CountdownTime> mutableState2, d dVar) {
        super(2, dVar);
        this.$targetDate = date;
        this.$lifecycleOwner = interfaceC1113w;
        this.$isCountingEnabled$delegate = mutableState;
        this.$countdownTime$delegate = mutableState2;
    }

    @Override // C4.a
    public final d create(Object obj, d dVar) {
        CountdownComponentStateKt$rememberCountdownState$1$1 countdownComponentStateKt$rememberCountdownState$1$1 = new CountdownComponentStateKt$rememberCountdownState$1$1(this.$targetDate, this.$lifecycleOwner, this.$isCountingEnabled$delegate, this.$countdownTime$delegate, dVar);
        countdownComponentStateKt$rememberCountdownState$1$1.L$0 = obj;
        return countdownComponentStateKt$rememberCountdownState$1$1;
    }

    @Override // J4.e
    public final Object invoke(C c6, d dVar) {
        return ((CountdownComponentStateKt$rememberCountdownState$1$1) create(c6, dVar)).invokeSuspend(C3137A.f25453a);
    }

    @Override // C4.a
    public final Object invokeSuspend(Object obj) {
        C c6;
        Object obj2;
        a aVar = a.f492a;
        int i6 = this.label;
        if (i6 == 0) {
            AbstractC2467b.l(obj);
            C c7 = (C) this.L$0;
            E.y(c7, null, null, new AnonymousClass1(this.$lifecycleOwner, this.$isCountingEnabled$delegate, null), 3);
            c6 = c7;
        } else {
            if (i6 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            c6 = (C) this.L$0;
            AbstractC2467b.l(obj);
        }
        do {
            boolean zU = E.u(c6.getCoroutineContext());
            obj2 = C3137A.f25453a;
            if (!zU) {
                return obj2;
            }
            long jD = 0;
            if (CountdownComponentStateKt.rememberCountdownState$lambda$5(this.$isCountingEnabled$delegate)) {
                long time = this.$targetDate.getTime() - new Date().getTime();
                if (time <= 0) {
                    this.$countdownTime$delegate.setValue(CountdownTime.Companion.getZERO());
                    return obj2;
                }
                this.$countdownTime$delegate.setValue(CountdownTime.Companion.fromInterval(time));
            }
            T4.a aVar2 = b.f6709b;
            long jI0 = e4.C.i0(1, T4.d.f6716d);
            this.L$0 = c6;
            this.label = 1;
            boolean z6 = jI0 > 0;
            if (z6) {
                jD = b.d(b.g(jI0, e4.C.j0(999999L, T4.d.f6714b)));
            } else if (z6) {
                throw new v();
            }
            Object objL = E.l(jD, this);
            if (objL == a.f492a) {
                obj2 = objL;
            }
        } while (obj2 != aVar);
        return aVar;
    }
}
