using System;
using System.Collections.Generic;
using System.Linq;
using GmRelay.Shared.Features.Sessions.CreateSession.Wizard;
using Telegram.Bot.Types.ReplyMarkups;
namespace GmRelay.Bot.Features.Sessions.CreateSession.Wizard;
///
/// Telegram-side renderer for wizard keyboards. Acts as the adapter
/// between the platform-neutral list
/// produced by and Telegram's
/// . Each
/// becomes its own row (matching the pre-refactor Telegram layout).
/// is currently ignored by Telegram
/// because the platform has no native primary/danger/success button
/// colours.
///
public static class WizardStep
{
public const int MaxTitleLength = WizardStepLimits.MaxTitleLength;
public const int MaxDescriptionLength = WizardStepLimits.MaxDescriptionLength;
public const int MaxSystemLength = WizardStepLimits.MaxSystemLength;
public const int MaxCapacity = WizardStepLimits.MaxCapacity;
public const int MinCapacity = WizardStepLimits.MinCapacity;
public const int MinDurationHours = WizardStepLimits.MinDurationHours;
public const int MaxDurationHours = WizardStepLimits.MaxDurationHours;
///
/// Render the platform-neutral view into a (text, Telegram keyboard)
/// pair. Used by the wizard's surrounding code (router, create
/// handler) when it needs to send a fresh draft message or render
/// the resume/reset menu.
///
public static (string Text, InlineKeyboardMarkup Keyboard) Render(
WizardDraft draft,
WizardPayload payload,
IReadOnlyList? clubs = null)
{
var (text, actions) = WizardStepViewBuilder.Build(draft, payload, clubs);
return (text, ToInlineKeyboard(actions));
}
///
/// Convert a flat list of s into a
/// Telegram keyboard. Each action is placed in its own row to
/// preserve the pre-refactor visual layout.
///
public static InlineKeyboardMarkup ToInlineKeyboard(IReadOnlyList actions)
{
if (actions.Count == 0)
{
return new InlineKeyboardMarkup(Array.Empty());
}
var rows = new InlineKeyboardButton[actions.Count][];
for (var i = 0; i < actions.Count; i++)
{
rows[i] = new[]
{
InlineKeyboardButton.WithCallbackData(actions[i].Label, actions[i].Payload),
};
}
return new InlineKeyboardMarkup(rows);
}
}