using System;

namespace GmRelay.Bot.Features.Sessions.CreateSession.Wizard;

public static class WizardCallbackData
{
    public const string Prefix = "wizard";

    public static string Choice(string step, string choice) => $"{Prefix}:{step}:{choice}";
    public static string Back() => $"{Prefix}:back";
    public static string Cancel() => $"{Prefix}:cancel";
    public static string Create() => $"{Prefix}:create";

    public static bool TryParse(string? data, out string action, out string step, out string choice)
    {
        action = step = choice = string.Empty;
        if (string.IsNullOrEmpty(data)) return false;
        var parts = data.Split(':', 3);
        if (parts.Length < 2 || parts[0] != Prefix) return false;
        action = parts[1];
        step = parts.Length >= 3 ? parts[1] : string.Empty;
        choice = parts.Length >= 3 ? parts[2] : string.Empty;
        return true;
    }
}
