package androidx.datastore.core;

import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.CoroutineSingletons;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.internal.Ref$IntRef;
import kotlin.jvm.internal.Ref$ObjectRef;

/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u0000\b\n\u0000\n\u0002\u0018\u0002\n\u0000\u0010\u0002\u001a\u00020\u0001\"\u0004\b\u0000\u0010\u0000H\u008a@"}, d2 = {"T", "Lkd/e;", "<anonymous>"}, k = 3, mv = {1, 8, 0})
@DebugMetadata(c = "androidx.datastore.core.DataStoreImpl$readDataOrHandleCorruption$3", f = "DataStoreImpl.kt", i = {}, l = {387, 388, 390}, m = "invokeSuspend", n = {}, s = {})
final class DataStoreImpl$readDataOrHandleCorruption$3 extends SuspendLambda implements sd.l {
    final /* synthetic */ Ref$ObjectRef<Object> $newData;
    final /* synthetic */ Ref$IntRef $version;
    Object L$0;
    int label;
    final /* synthetic */ n this$0;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public DataStoreImpl$readDataOrHandleCorruption$3(Ref$ObjectRef ref$ObjectRef, n nVar, Ref$IntRef ref$IntRef, Continuation continuation) {
        super(1, continuation);
        this.$newData = ref$ObjectRef;
        this.this$0 = nVar;
        this.$version = ref$IntRef;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Continuation continuation) {
        return new DataStoreImpl$readDataOrHandleCorruption$3(this.$newData, this.this$0, this.$version, continuation);
    }

    @Override // sd.l
    public final Object invoke(Object obj) {
        return ((DataStoreImpl$readDataOrHandleCorruption$3) create((Continuation) obj)).invokeSuspend(kd.e.f29109a);
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Object invokeSuspend(Object obj) {
        Ref$IntRef ref$IntRef;
        Object obj2;
        Ref$ObjectRef<Object> ref$ObjectRef;
        T t10;
        Ref$IntRef ref$IntRef2;
        Object obj3;
        CoroutineSingletons coroutineSingletons = CoroutineSingletons.f29226a;
        int i10 = this.label;
        try {
        } catch (CorruptionException unused) {
            Ref$IntRef ref$IntRef3 = this.$version;
            n nVar = this.this$0;
            Object obj4 = this.$newData.element;
            this.L$0 = ref$IntRef3;
            this.label = 3;
            Object objJ = nVar.j(obj4, true, this);
            if (objJ == coroutineSingletons) {
                return coroutineSingletons;
            }
            ref$IntRef = ref$IntRef3;
            obj2 = objJ;
        }
        if (i10 == 0) {
            kotlin.a.d(obj);
            ref$ObjectRef = this.$newData;
            n nVar2 = this.this$0;
            this.L$0 = ref$ObjectRef;
            this.label = 1;
            Object objI = nVar2.i(this);
            t10 = objI;
            if (objI == coroutineSingletons) {
                return coroutineSingletons;
            }
        } else {
            if (i10 != 1) {
                if (i10 == 2) {
                    ref$IntRef2 = (Ref$IntRef) this.L$0;
                    kotlin.a.d(obj);
                    obj3 = obj;
                    ref$IntRef2.element = ((Number) obj3).intValue();
                    return kd.e.f29109a;
                }
                if (i10 != 3) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                ref$IntRef = (Ref$IntRef) this.L$0;
                kotlin.a.d(obj);
                obj2 = obj;
                ref$IntRef.element = ((Number) obj2).intValue();
                return kd.e.f29109a;
            }
            ref$ObjectRef = (Ref$ObjectRef) this.L$0;
            kotlin.a.d(obj);
            t10 = obj;
        }
        ref$ObjectRef.element = t10;
        ref$IntRef2 = this.$version;
        u uVarG = this.this$0.g();
        this.L$0 = ref$IntRef2;
        this.label = 2;
        Integer numA = ((b0) uVarG).a();
        obj3 = numA;
        if (numA == coroutineSingletons) {
            return coroutineSingletons;
        }
        ref$IntRef2.element = ((Number) obj3).intValue();
        return kd.e.f29109a;
    }
}
