// PRE-GENERATED (design session). Pure logic: apply an AI EqDelta onto an EqState.
using DansoriEQ.Core.Eq;

namespace DansoriEQ.Core.Ai;

public static class EqDeltaApplier
{
    /// <summary>
    /// Builds the new EqState from the AI's delta. The prompt asks the model to return the
    /// COMPLETE desired band set (plus a safe preamp), so we take filters as the target state.
    /// `Replace` is informational here; both paths rebuild from the returned filters.
    /// </summary>
    public static EqState Apply(EqState current, EqDelta delta)
    {
        var s = new EqState { PreampDb = delta.PreampDb };
        foreach (var df in delta.Filters)
            s.Filters.Add(new Filter
            {
                Type = FilterTypeExtensions.FromApoToken(df.Type),
                Fc = df.Fc,
                GainDb = df.Gain,
                Q = df.Q,
                Enabled = df.Enabled
            });
        return s;
    }
}
