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

import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.maps.android.compose.CameraPositionState;
import java.util.List;
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.CoroutineScope;

/* JADX INFO: compiled from: NearbyScreen.android.kt */
/* JADX INFO: loaded from: classes2.dex */
@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.nearby.NearbyScreen_androidKt$GoogleMaps$2$1", f = "NearbyScreen.android.kt", i = {}, l = {}, m = "invokeSuspend", n = {}, s = {})
final class NearbyScreen_androidKt$GoogleMaps$2$1 extends SuspendLambda implements Function2<CoroutineScope, Continuation<? super Unit>, Object> {
    final /* synthetic */ CameraPositionState $cameraPositionState;
    final /* synthetic */ LatLng $location;
    final /* synthetic */ List<ParadaConDistancia> $paradasCercanas;
    int label;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    NearbyScreen_androidKt$GoogleMaps$2$1(List<ParadaConDistancia> list, LatLng latLng, CameraPositionState cameraPositionState, Continuation<? super NearbyScreen_androidKt$GoogleMaps$2$1> continuation) {
        super(2, continuation);
        this.$paradasCercanas = list;
        this.$location = latLng;
        this.$cameraPositionState = cameraPositionState;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation<Unit> create(Object obj, Continuation<?> continuation) {
        return new NearbyScreen_androidKt$GoogleMaps$2$1(this.$paradasCercanas, this.$location, this.$cameraPositionState, continuation);
    }

    @Override // kotlin.jvm.functions.Function2
    public final Object invoke(CoroutineScope coroutineScope, Continuation<? super Unit> continuation) {
        return ((NearbyScreen_androidKt$GoogleMaps$2$1) create(coroutineScope, 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);
        if (!this.$paradasCercanas.isEmpty()) {
            LatLngBounds.Builder builder = LatLngBounds.builder();
            Intrinsics.checkNotNullExpressionValue(builder, "builder(...)");
            builder.include(this.$location);
            for (ParadaConDistancia paradaConDistancia : this.$paradasCercanas) {
                builder.include(new LatLng(paradaConDistancia.getParada().getPosy(), paradaConDistancia.getParada().getPosx()));
            }
            LatLngBounds latLngBoundsBuild = builder.build();
            Intrinsics.checkNotNullExpressionValue(latLngBoundsBuild, "build(...)");
            CameraPositionState cameraPositionState = this.$cameraPositionState;
            CameraUpdate cameraUpdateNewLatLngBounds = CameraUpdateFactory.newLatLngBounds(latLngBoundsBuild, 100);
            Intrinsics.checkNotNullExpressionValue(cameraUpdateNewLatLngBounds, "newLatLngBounds(...)");
            cameraPositionState.move(cameraUpdateNewLatLngBounds);
        } else {
            CameraPositionState cameraPositionState2 = this.$cameraPositionState;
            CameraUpdate cameraUpdateNewLatLngZoom = CameraUpdateFactory.newLatLngZoom(this.$location, 15.0f);
            Intrinsics.checkNotNullExpressionValue(cameraUpdateNewLatLngZoom, "newLatLngZoom(...)");
            cameraPositionState2.move(cameraUpdateNewLatLngZoom);
        }
        return Unit.INSTANCE;
    }
}