using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using GsaEditor.Core.Models;

namespace GsaEditor.ViewModels;

/// <summary>
/// Represents a node in the archive tree view.
/// Can be a folder (with children) or a leaf file node (with an associated <see cref="GsaEntry"/>).
/// </summary>
public partial class EntryTreeNodeViewModel : ViewModelBase
{
    [ObservableProperty]
    private string _name = string.Empty;

    [ObservableProperty]
    private bool _isExpanded;

    /// <summary>
    /// Full relative path of this node within the archive (using '/' separator).
    /// </summary>
    public string FullPath { get; set; } = string.Empty;

    /// <summary>
    /// Whether this node represents a folder (true) or a file (false).
    /// </summary>
    public bool IsFolder { get; set; }

    /// <summary>
    /// Whether this node represents a file.
    /// </summary>
    public bool IsFile => !IsFolder;

    /// <summary>
    /// The archive entry this node represents. Null for folder nodes.
    /// </summary>
    public GsaEntry? Entry { get; set; }

    /// <summary>
    /// Child nodes (sub-folders and files within this folder).
    /// </summary>
    public ObservableCollection<EntryTreeNodeViewModel> Children { get; } = new();
}
