using System.Collections.Generic;

namespace EventsAppQuest.Web.Application
{
    /// <summary>
    /// Store em memória: gargalos marcados como resolvidos (mock). Não persiste.
    /// </summary>
    public static class ResolvedBottleneckStore
    {
        private static readonly HashSet<string> ResolvedIds = new HashSet<string>();

        public static void MarkResolved(string bottleneckId)
        {
            if (!string.IsNullOrEmpty(bottleneckId))
                ResolvedIds.Add(bottleneckId);
        }

        public static void MarkUnresolved(string bottleneckId)
        {
            if (!string.IsNullOrEmpty(bottleneckId))
                ResolvedIds.Remove(bottleneckId);
        }

        public static bool IsResolved(string bottleneckId) => !string.IsNullOrEmpty(bottleneckId) && ResolvedIds.Contains(bottleneckId);

        public static void ClearResolvedForCycle(string cycleId)
        {
            if (string.IsNullOrEmpty(cycleId)) return;
            var toRemove = new List<string>();
            foreach (var id in ResolvedIds)
                if (id.StartsWith(cycleId + "_"))
                    toRemove.Add(id);
            foreach (var id in toRemove)
                ResolvedIds.Remove(id);
        }

        public static void ClearAllResolved() => ResolvedIds.Clear();
    }
}
