// 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>
/// Content layer classification for document nodes.
///
/// Replaces separate body/furniture arrays with per-node granularity.
/// </summary>
[JsonConverter(typeof(ContentLayerJsonConverter))]
public enum ContentLayer
{
    /// <summary>
    /// Main document body content.
    /// </summary>
    [JsonPropertyName("body")]
    Body,
    /// <summary>
    /// Page/section header (running header).
    /// </summary>
    [JsonPropertyName("header")]
    Header,
    /// <summary>
    /// Page/section footer (running footer).
    /// </summary>
    [JsonPropertyName("footer")]
    Footer,
    /// <summary>
    /// Footnote content.
    /// </summary>
    [JsonPropertyName("footnote")]
    Footnote,
}


/// <summary>
/// Custom JSON converter for <see cref="ContentLayer"/> that respects explicit variant names.
/// </summary>
internal sealed class ContentLayerJsonConverter : JsonConverter<ContentLayer>
{
    public override ContentLayer Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        var value = reader.GetString();
        return value switch
        {
            "body" => ContentLayer.Body,
            "header" => ContentLayer.Header,
            "footer" => ContentLayer.Footer,
            "footnote" => ContentLayer.Footnote,
            _ => throw new JsonException($"Unknown ContentLayer value: {value}")
        };
    }

    public override void Write(Utf8JsonWriter writer, ContentLayer value, JsonSerializerOptions options)
    {
        var str = value switch
        {
            ContentLayer.Body => "body",
            ContentLayer.Header => "header",
            ContentLayer.Footer => "footer",
            ContentLayer.Footnote => "footnote",
            _ => throw new JsonException($"Unknown ContentLayer value: {value}")
        };
        writer.WriteStringValue(str);
    }
}
