package com.sistemasolton.itranvias.home.data.remote.dto.mapasdto;

import java.util.ArrayList;
import java.util.List;
import kotlin.Metadata;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.serialization.KSerializer;
import kotlinx.serialization.builtins.BuiltinSerializersKt;
import kotlinx.serialization.descriptors.SerialDescriptor;
import kotlinx.serialization.encoding.Decoder;
import kotlinx.serialization.encoding.Encoder;
import kotlinx.serialization.json.JsonArray;
import kotlinx.serialization.json.JsonDecoder;
import kotlinx.serialization.json.JsonElement;
import kotlinx.serialization.json.JsonEncoder;
import kotlinx.serialization.json.JsonObject;

/* JADX INFO: compiled from: MapasDto.kt */
/* JADX INFO: loaded from: classes2.dex */
@Metadata(d1 = {"\u00000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\bÇ\u0002\u0018\u00002\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00030\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0004\u0010\u0005J\u0016\u0010\n\u001a\b\u0012\u0004\u0012\u00020\u00030\u00022\u0006\u0010\u000b\u001a\u00020\fH\u0016J\u001e\u0010\r\u001a\u00020\u000e2\u0006\u0010\u000f\u001a\u00020\u00102\f\u0010\u0011\u001a\b\u0012\u0004\u0012\u00020\u00030\u0002H\u0016R\u0014\u0010\u0006\u001a\u00020\u0007X\u0096\u0004¢\u0006\b\n\u0000\u001a\u0004\b\b\u0010\t¨\u0006\u0012"}, d2 = {"Lcom/sistemasolton/itranvias/home/data/remote/dto/mapasdto/IgnoreEmptyListSerializer;", "Lkotlinx/serialization/KSerializer;", "", "Lcom/sistemasolton/itranvias/home/data/remote/dto/mapasdto/MapaDto;", "<init>", "()V", "descriptor", "Lkotlinx/serialization/descriptors/SerialDescriptor;", "getDescriptor", "()Lkotlinx/serialization/descriptors/SerialDescriptor;", "deserialize", "decoder", "Lkotlinx/serialization/encoding/Decoder;", "serialize", "", "encoder", "Lkotlinx/serialization/encoding/Encoder;", "value", "composeApp_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
public final class IgnoreEmptyListSerializer implements KSerializer<List<? extends MapaDto>> {
    public static final IgnoreEmptyListSerializer INSTANCE = new IgnoreEmptyListSerializer();
    private static final SerialDescriptor descriptor = BuiltinSerializersKt.ListSerializer(MapaDto.INSTANCE.serializer()).getDescriptor();
    public static final int $stable = 8;

    private IgnoreEmptyListSerializer() {
    }

    @Override // kotlinx.serialization.KSerializer, kotlinx.serialization.SerializationStrategy, kotlinx.serialization.DeserializationStrategy
    public SerialDescriptor getDescriptor() {
        return descriptor;
    }

    @Override // kotlinx.serialization.DeserializationStrategy
    public List<MapaDto> deserialize(Decoder decoder) {
        Intrinsics.checkNotNullParameter(decoder, "decoder");
        JsonDecoder jsonDecoder = decoder instanceof JsonDecoder ? (JsonDecoder) decoder : null;
        if (jsonDecoder == null) {
            throw new IllegalStateException("Solo JSON".toString());
        }
        Object objDecodeJsonElement = jsonDecoder.decodeJsonElement();
        if (!(objDecodeJsonElement instanceof JsonArray)) {
            return CollectionsKt.emptyList();
        }
        ArrayList arrayList = new ArrayList();
        for (JsonElement jsonElement : (Iterable) objDecodeJsonElement) {
            MapaDto mapaDto = jsonElement instanceof JsonObject ? (MapaDto) jsonDecoder.getJson().decodeFromJsonElement(MapaDto.INSTANCE.serializer(), jsonElement) : null;
            if (mapaDto != null) {
                arrayList.add(mapaDto);
            }
        }
        return arrayList;
    }

    @Override // kotlinx.serialization.SerializationStrategy
    public void serialize(Encoder encoder, List<MapaDto> value) {
        Intrinsics.checkNotNullParameter(encoder, "encoder");
        Intrinsics.checkNotNullParameter(value, "value");
        JsonEncoder jsonEncoder = encoder instanceof JsonEncoder ? (JsonEncoder) encoder : null;
        if (jsonEncoder == null) {
            throw new IllegalStateException("Solo JSON".toString());
        }
        jsonEncoder.encodeSerializableValue(BuiltinSerializersKt.ListSerializer(MapaDto.INSTANCE.serializer()), value);
    }
}