// 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>
/// Which table structure recognition model to use.
///
/// Controls the model used for table cell detection within layout-detected
/// table regions. Wire format is snake_case in all serializers (JSON, TOML,
/// YAML).
/// </summary>
[JsonConverter(typeof(TableModelJsonConverter))]
public enum TableModel
{
    /// <summary>
    /// TATR (Table Transformer) -- default, 30MB, DETR-based row/column detection.
    /// </summary>
    [JsonPropertyName("tatr")]
    Tatr,
    /// <summary>
    /// SLANeXT wired variant -- 365MB, optimized for bordered tables.
    /// </summary>
    [JsonPropertyName("slanet_wired")]
    SlanetWired,
    /// <summary>
    /// SLANeXT wireless variant -- 365MB, optimized for borderless tables.
    /// </summary>
    [JsonPropertyName("slanet_wireless")]
    SlanetWireless,
    /// <summary>
    /// SLANet-plus -- 7.78MB, lightweight general-purpose.
    /// </summary>
    [JsonPropertyName("slanet_plus")]
    SlanetPlus,
    /// <summary>
    /// Classifier-routed SLANeXT: auto-select wired/wireless per table.
    /// Uses PP-LCNet classifier (6.78MB) + both SLANeXT variants (730MB total).
    /// </summary>
    [JsonPropertyName("slanet_auto")]
    SlanetAuto,
    /// <summary>
    /// Disable table structure model inference entirely; use heuristic path only.
    /// </summary>
    [JsonPropertyName("disabled")]
    Disabled,
}


/// <summary>
/// Custom JSON converter for <see cref="TableModel"/> that respects explicit variant names.
/// </summary>
internal sealed class TableModelJsonConverter : JsonConverter<TableModel>
{
    public override TableModel Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        var value = reader.GetString();
        return value switch
        {
            "tatr" => TableModel.Tatr,
            "slanet_wired" => TableModel.SlanetWired,
            "slanet_wireless" => TableModel.SlanetWireless,
            "slanet_plus" => TableModel.SlanetPlus,
            "slanet_auto" => TableModel.SlanetAuto,
            "disabled" => TableModel.Disabled,
            _ => throw new JsonException($"Unknown TableModel value: {value}")
        };
    }

    public override void Write(Utf8JsonWriter writer, TableModel value, JsonSerializerOptions options)
    {
        var str = value switch
        {
            TableModel.Tatr => "tatr",
            TableModel.SlanetWired => "slanet_wired",
            TableModel.SlanetWireless => "slanet_wireless",
            TableModel.SlanetPlus => "slanet_plus",
            TableModel.SlanetAuto => "slanet_auto",
            TableModel.Disabled => "disabled",
            _ => throw new JsonException($"Unknown TableModel value: {value}")
        };
        writer.WriteStringValue(str);
    }
}
