// 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>
/// Types of inline elements in Djot.
/// </summary>
[JsonConverter(typeof(InlineTypeJsonConverter))]
public enum InlineType
{
    [JsonPropertyName("text")]
    Text,
    [JsonPropertyName("strong")]
    Strong,
    [JsonPropertyName("emphasis")]
    Emphasis,
    [JsonPropertyName("highlight")]
    Highlight,
    [JsonPropertyName("subscript")]
    Subscript,
    [JsonPropertyName("superscript")]
    Superscript,
    [JsonPropertyName("insert")]
    Insert,
    [JsonPropertyName("delete")]
    Delete,
    [JsonPropertyName("code")]
    Code,
    [JsonPropertyName("link")]
    Link,
    [JsonPropertyName("image")]
    Image,
    [JsonPropertyName("span")]
    Span,
    [JsonPropertyName("math")]
    Math,
    [JsonPropertyName("raw_inline")]
    RawInline,
    [JsonPropertyName("footnote_ref")]
    FootnoteRef,
    [JsonPropertyName("symbol")]
    Symbol,
}


/// <summary>
/// Custom JSON converter for <see cref="InlineType"/> that respects explicit variant names.
/// </summary>
internal sealed class InlineTypeJsonConverter : JsonConverter<InlineType>
{
    public override InlineType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        var value = reader.GetString();
        return value switch
        {
            "text" => InlineType.Text,
            "strong" => InlineType.Strong,
            "emphasis" => InlineType.Emphasis,
            "highlight" => InlineType.Highlight,
            "subscript" => InlineType.Subscript,
            "superscript" => InlineType.Superscript,
            "insert" => InlineType.Insert,
            "delete" => InlineType.Delete,
            "code" => InlineType.Code,
            "link" => InlineType.Link,
            "image" => InlineType.Image,
            "span" => InlineType.Span,
            "math" => InlineType.Math,
            "raw_inline" => InlineType.RawInline,
            "footnote_ref" => InlineType.FootnoteRef,
            "symbol" => InlineType.Symbol,
            _ => throw new JsonException($"Unknown InlineType value: {value}")
        };
    }

    public override void Write(Utf8JsonWriter writer, InlineType value, JsonSerializerOptions options)
    {
        var str = value switch
        {
            InlineType.Text => "text",
            InlineType.Strong => "strong",
            InlineType.Emphasis => "emphasis",
            InlineType.Highlight => "highlight",
            InlineType.Subscript => "subscript",
            InlineType.Superscript => "superscript",
            InlineType.Insert => "insert",
            InlineType.Delete => "delete",
            InlineType.Code => "code",
            InlineType.Link => "link",
            InlineType.Image => "image",
            InlineType.Span => "span",
            InlineType.Math => "math",
            InlineType.RawInline => "raw_inline",
            InlineType.FootnoteRef => "footnote_ref",
            InlineType.Symbol => "symbol",
            _ => throw new JsonException($"Unknown InlineType value: {value}")
        };
        writer.WriteStringValue(str);
    }
}
