// This file is auto-generated by alef. DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
#nullable enable

using System;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Kreuzberg;
/// <summary>
/// Type of list detection.
/// </summary>
[JsonConverter(typeof(ListTypeJsonConverter))]
public enum ListType
{
    /// <summary>
    /// Bullet points (-, *, •, etc.)
    /// </summary>
    [JsonPropertyName("bullet")]
    Bullet,
    /// <summary>
    /// Numbered lists (1., 2., etc.)
    /// </summary>
    [JsonPropertyName("numbered")]
    Numbered,
    /// <summary>
    /// Lettered lists (a., b., A., B., etc.)
    /// </summary>
    [JsonPropertyName("lettered")]
    Lettered,
    /// <summary>
    /// Indented items
    /// </summary>
    [JsonPropertyName("indented")]
    Indented,
}


/// <summary>
/// Custom JSON converter for <see cref="ListType"/> that respects explicit variant names.
/// </summary>
internal sealed class ListTypeJsonConverter : JsonConverter<ListType>
{
    public override ListType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        var value = reader.GetString();
        return value switch
        {
            "bullet" => ListType.Bullet,
            "numbered" => ListType.Numbered,
            "lettered" => ListType.Lettered,
            "indented" => ListType.Indented,
            _ => throw new JsonException($"Unknown ListType value: {value}")
        };
    }

    public override void Write(Utf8JsonWriter writer, ListType value, JsonSerializerOptions options)
    {
        var str = value switch
        {
            ListType.Bullet => "bullet",
            ListType.Numbered => "numbered",
            ListType.Lettered => "lettered",
            ListType.Indented => "indented",
            _ => throw new JsonException($"Unknown ListType value: {value}")
        };
        writer.WriteStringValue(str);
    }
}
