using System.Windows;
using DragonISO.App.ViewModels;

namespace DragonISO.App.Views;

/// <summary>
/// Per-participant ISO override editor. Modal dialog opened from the gear
/// affordance on each participant row. The dialog is a thin shell over
/// <see cref="IsoOverrideDialogViewModel"/> â€” it owns no business logic; it
/// just wires <see cref="IsoOverrideDialogViewModel.RequestClose"/> to
/// <see cref="Window.Close"/> so Apply / Clear / Cancel can dismiss the
/// dialog without taking a Window dependency on the VM.
/// </summary>
public partial class IsoOverrideDialog : Window
{
    public IsoOverrideDialog()
    {
        InitializeComponent();
    }

    public IsoOverrideDialog(IsoOverrideDialogViewModel vm) : this()
    {
        DataContext = vm;
        vm.RequestClose = () =>
        {
            // Idempotent â€” Window.Close after the window has closed is a no-op.
            if (IsLoaded) Close();
        };
    }
}
