// 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>
/// OCR backend types.
/// </summary>
[JsonConverter(typeof(OcrBackendTypeJsonConverter))]
public enum OcrBackendType
{
    /// <summary>
    /// Tesseract OCR (native Rust binding)
    /// </summary>
    [JsonPropertyName("tesseract")]
    Tesseract,
    /// <summary>
    /// EasyOCR (Python-based, via FFI)
    /// </summary>
    [JsonPropertyName("easyocr")]
    EasyOcr,
    /// <summary>
    /// PaddleOCR (Python-based, via FFI)
    /// </summary>
    [JsonPropertyName("paddleocr")]
    PaddleOcr,
    /// <summary>
    /// Custom/third-party OCR backend
    /// </summary>
    [JsonPropertyName("custom")]
    Custom,
}


/// <summary>
/// Custom JSON converter for <see cref="OcrBackendType"/> that respects explicit variant names.
/// </summary>
internal sealed class OcrBackendTypeJsonConverter : JsonConverter<OcrBackendType>
{
    public override OcrBackendType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        var value = reader.GetString();
        return value switch
        {
            "tesseract" => OcrBackendType.Tesseract,
            "easyocr" => OcrBackendType.EasyOcr,
            "paddleocr" => OcrBackendType.PaddleOcr,
            "custom" => OcrBackendType.Custom,
            _ => throw new JsonException($"Unknown OcrBackendType value: {value}")
        };
    }

    public override void Write(Utf8JsonWriter writer, OcrBackendType value, JsonSerializerOptions options)
    {
        var str = value switch
        {
            OcrBackendType.Tesseract => "tesseract",
            OcrBackendType.EasyOcr => "easyocr",
            OcrBackendType.PaddleOcr => "paddleocr",
            OcrBackendType.Custom => "custom",
            _ => throw new JsonException($"Unknown OcrBackendType value: {value}")
        };
        writer.WriteStringValue(str);
    }
}
