package com.sistemasolton.itranvias.home.presentation.lines;

import androidx.compose.runtime.MutableState;
import androidx.compose.runtime.SnapshotStateKt__SnapshotStateKt;
import androidx.core.view.MotionEventCompat;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelKt;
import com.sistemasolton.itranvias.home.data.remote.dto.infodto.InfoDto;
import com.sistemasolton.itranvias.home.domain.usecase.GetInfoLocalUseCase;
import com.sistemasolton.itranvias.home.domain.usecase.GetInfoUseCase;
import kotlin.Metadata;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.BuildersKt__Builders_commonKt;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.flow.FlowKt;

/* JADX INFO: compiled from: LinesViewModel.kt */
/* JADX INFO: loaded from: classes2.dex */
@Metadata(d1 = {"\u0000,\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0002\n\u0000\b\u0007\u0018\u00002\u00020\u0001B\u0017\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005¢\u0006\u0004\b\u0006\u0010\u0007J\u0006\u0010\u0013\u001a\u00020\u0014R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R+\u0010\n\u001a\u00020\t2\u0006\u0010\b\u001a\u00020\t8F@BX\u0086\u008e\u0002¢\u0006\u0012\n\u0004\b\u000f\u0010\u0010\u001a\u0004\b\u000b\u0010\f\"\u0004\b\r\u0010\u000eR\u0010\u0010\u0011\u001a\u0004\u0018\u00010\u0012X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006\u0015"}, d2 = {"Lcom/sistemasolton/itranvias/home/presentation/lines/LinesViewModel;", "Landroidx/lifecycle/ViewModel;", "getInfoUseCase", "Lcom/sistemasolton/itranvias/home/domain/usecase/GetInfoUseCase;", "getLocalInfoUseCase", "Lcom/sistemasolton/itranvias/home/domain/usecase/GetInfoLocalUseCase;", "<init>", "(Lcom/sistemasolton/itranvias/home/domain/usecase/GetInfoUseCase;Lcom/sistemasolton/itranvias/home/domain/usecase/GetInfoLocalUseCase;)V", "<set-?>", "Lcom/sistemasolton/itranvias/home/presentation/lines/LinesState;", "state", "getState", "()Lcom/sistemasolton/itranvias/home/presentation/lines/LinesState;", "setState", "(Lcom/sistemasolton/itranvias/home/presentation/lines/LinesState;)V", "state$delegate", "Landroidx/compose/runtime/MutableState;", "lastLanguage", "", "loadLocalInfo", "", "composeApp_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
public final class LinesViewModel extends ViewModel {
    public static final int $stable = 8;
    private final GetInfoUseCase getInfoUseCase;
    private final GetInfoLocalUseCase getLocalInfoUseCase;
    private String lastLanguage;

    /* JADX INFO: renamed from: state$delegate, reason: from kotlin metadata */
    private final MutableState state;

    public LinesViewModel(GetInfoUseCase getInfoUseCase, GetInfoLocalUseCase getLocalInfoUseCase) {
        Intrinsics.checkNotNullParameter(getInfoUseCase, "getInfoUseCase");
        Intrinsics.checkNotNullParameter(getLocalInfoUseCase, "getLocalInfoUseCase");
        this.getInfoUseCase = getInfoUseCase;
        this.getLocalInfoUseCase = getLocalInfoUseCase;
        this.state = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(new LinesState(false, false, null, null, 15, null), null, 2, null);
        loadLocalInfo();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void setState(LinesState linesState) {
        this.state.setValue(linesState);
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final LinesState getState() {
        return (LinesState) this.state.getValue();
    }

    /* JADX INFO: renamed from: com.sistemasolton.itranvias.home.presentation.lines.LinesViewModel$loadLocalInfo$1, reason: invalid class name */
    /* JADX INFO: compiled from: LinesViewModel.kt */
    @Metadata(d1 = {"\u0000\n\n\u0000\n\u0002\u0010\u0002\n\u0002\u0018\u0002\u0010\u0000\u001a\u00020\u0001*\u00020\u0002H\n"}, d2 = {"<anonymous>", "", "Lkotlinx/coroutines/CoroutineScope;"}, k = 3, mv = {2, 1, 0}, xi = 48)
    @DebugMetadata(c = "com.sistemasolton.itranvias.home.presentation.lines.LinesViewModel$loadLocalInfo$1", f = "LinesViewModel.kt", i = {}, l = {MotionEventCompat.AXIS_GENERIC_4}, m = "invokeSuspend", n = {}, s = {})
    static final class AnonymousClass1 extends SuspendLambda implements Function2<CoroutineScope, Continuation<? super Unit>, Object> {
        int label;

        AnonymousClass1(Continuation<? super AnonymousClass1> continuation) {
            super(2, continuation);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Continuation<Unit> create(Object obj, Continuation<?> continuation) {
            return LinesViewModel.this.new AnonymousClass1(continuation);
        }

        @Override // kotlin.jvm.functions.Function2
        public final Object invoke(CoroutineScope coroutineScope, Continuation<? super Unit> continuation) {
            return ((AnonymousClass1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Object invokeSuspend(Object obj) throws Throwable {
            Object coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED();
            int i = this.label;
            if (i == 0) {
                ResultKt.throwOnFailure(obj);
                LinesViewModel linesViewModel = LinesViewModel.this;
                linesViewModel.setState(LinesState.copy$default(linesViewModel.getState(), true, false, null, null, 12, null));
                this.label = 1;
                if (FlowKt.collectLatest(LinesViewModel.this.getLocalInfoUseCase.invoke(), new C01181(LinesViewModel.this, null), this) == coroutine_suspended) {
                    return coroutine_suspended;
                }
            } else {
                if (i != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                ResultKt.throwOnFailure(obj);
            }
            return Unit.INSTANCE;
        }

        /* JADX INFO: renamed from: com.sistemasolton.itranvias.home.presentation.lines.LinesViewModel$loadLocalInfo$1$1, reason: invalid class name and collision with other inner class name */
        /* JADX INFO: compiled from: LinesViewModel.kt */
        @Metadata(d1 = {"\u0000\f\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\u0010\u0000\u001a\u00020\u00012\b\u0010\u0002\u001a\u0004\u0018\u00010\u0003H\n"}, d2 = {"<anonymous>", "", "localInfo", "Lcom/sistemasolton/itranvias/home/data/remote/dto/infodto/InfoDto;"}, k = 3, mv = {2, 1, 0}, xi = 48)
        @DebugMetadata(c = "com.sistemasolton.itranvias.home.presentation.lines.LinesViewModel$loadLocalInfo$1$1", f = "LinesViewModel.kt", i = {}, l = {}, m = "invokeSuspend", n = {}, s = {})
        static final class C01181 extends SuspendLambda implements Function2<InfoDto, Continuation<? super Unit>, Object> {
            /* synthetic */ Object L$0;
            int label;
            final /* synthetic */ LinesViewModel this$0;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            C01181(LinesViewModel linesViewModel, Continuation<? super C01181> continuation) {
                super(2, continuation);
                this.this$0 = linesViewModel;
            }

            @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
            public final Continuation<Unit> create(Object obj, Continuation<?> continuation) {
                C01181 c01181 = new C01181(this.this$0, continuation);
                c01181.L$0 = obj;
                return c01181;
            }

            @Override // kotlin.jvm.functions.Function2
            public final Object invoke(InfoDto infoDto, Continuation<? super Unit> continuation) {
                return ((C01181) create(infoDto, continuation)).invokeSuspend(Unit.INSTANCE);
            }

            @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
            public final Object invokeSuspend(Object obj) throws Throwable {
                IntrinsicsKt.getCOROUTINE_SUSPENDED();
                if (this.label != 0) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                ResultKt.throwOnFailure(obj);
                InfoDto infoDto = (InfoDto) this.L$0;
                LinesViewModel linesViewModel = this.this$0;
                linesViewModel.setState(linesViewModel.getState().copy(false, false, infoDto, null));
                return Unit.INSTANCE;
            }
        }
    }

    public final void loadLocalInfo() {
        BuildersKt__Builders_commonKt.launch$default(ViewModelKt.getViewModelScope(this), null, null, new AnonymousClass1(null), 3, null);
    }
}