// PRE-GENERATED (design session). Preview/dry-run writer used when APO is NOT installed.
// Lets the whole EQ chain run offline-of-APO and writes the generated config to a preview
// file so you can verify exactly what WOULD be applied.
using System;
using System.IO;
using DansoriEQ.Core.Apo;

namespace DansoriEQ.App.Apo;

public sealed class NullApoWriter : IApoWriter
{
    private readonly string _previewPath;

    public NullApoWriter()
    {
        var dir = Path.Combine(
            Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "DansoriEQ");
        Directory.CreateDirectory(dir);
        _previewPath = Path.Combine(dir, "preview_apo_config.txt");
    }

    public bool IsLive => false;
    public string TargetPath => _previewPath;
    public string? LastConfig { get; private set; }

    public void Apply(string apoConfigText)
    {
        LastConfig = apoConfigText;
        try { File.WriteAllText(_previewPath, apoConfigText); } catch { /* preview only */ }
    }
}
