using System;
using System.Collections.Generic;

namespace EventsAppQuest.Web.Application
{
    /// <summary>
    /// Armazenamento em memória de alertas marcados como resolvidos (mock). Por AlertId.
    /// </summary>
    public static class ResolvedCycleAlertStore
    {
        private static readonly HashSet<string> ResolvedIds = new HashSet<string>();
        private static readonly object Lock = new object();

        public static void MarkResolved(string alertId)
        {
            if (string.IsNullOrEmpty(alertId)) return;
            lock (Lock)
                ResolvedIds.Add(alertId);
        }

        public static void MarkUnresolved(string alertId)
        {
            if (string.IsNullOrEmpty(alertId)) return;
            lock (Lock)
                ResolvedIds.Remove(alertId);
        }

        public static bool IsResolved(string alertId)
        {
            if (string.IsNullOrEmpty(alertId)) return false;
            lock (Lock)
                return ResolvedIds.Contains(alertId);
        }

        public static void ClearResolvedForCycle(string cycleId)
        {
            if (string.IsNullOrEmpty(cycleId)) return;
            lock (Lock)
                ResolvedIds.RemoveWhere(id => id != null && id.StartsWith(cycleId + "_", StringComparison.Ordinal));
        }

        public static void ClearAllResolved()
        {
            lock (Lock)
                ResolvedIds.Clear();
        }
    }
}
