using System.Text.Json.Serialization;

namespace Nalu.Web.Models;

[JsonConverter(typeof(JsonStringEnumConverter))]
public enum ReplyType
{
    Answer,
    Question,
    CounterProposal,
    Confirmation,
    Rejection,
    OffTopic,
    Greeting,
    Handoff,
    Cancel,
    Unclear
}

public record ReplyResponse
{
    [JsonPropertyName("obtained")]
    public bool Obtained { get; init; }

    [JsonPropertyName("reply_type")]
    public ReplyType? ReplyType { get; init; }

    [JsonPropertyName("extracted_value")]
    public string? ExtractedValue { get; init; }

    /// "quantity" | "amount" | "date" | "text" | "boolean" | null
    [JsonPropertyName("value_type")]
    public string? ValueType { get; init; }

    [JsonPropertyName("extracted_meaning")]
    public string? ExtractedMeaning { get; init; }

    /// 0.0 – 1.0 float (validate_reply exposes raw confidence — it's a premium endpoint)
    [JsonPropertyName("confidence")]
    public double Confidence { get; init; }

    [JsonPropertyName("needs_clarification")]
    public bool NeedsClarification { get; init; }

    [JsonPropertyName("suggestion_to_agent")]
    public string? SuggestionToAgent { get; init; }

    [JsonPropertyName("has_suggestion")]
    public bool HasSuggestion => SuggestionToAgent is not null;
}
