#Requires -Version 7.4

function Format-ExecutionOrder {
    <#
    .SYNOPSIS
    DEPRECATED: No longer called by Invoke-vSEAL. Retained for backward compatibility.
    Plugin summary is now emitted as a plugin.summary structured event.

    .DESCRIPTION
    Takes a pre-sorted array of plugin objects and produces a formatted string array
    showing each plugin's position, priority, and name. Includes a header line and a
    summary line indicating how many plugins will execute out of the total discovered.

    .PARAMETER Plugins
    Array of plugin objects to display. Each object must have Priority and Name properties.
    The array should be pre-sorted by the caller; this function preserves the given order.

    .PARAMETER TotalPlugins
    Total number of plugins discovered (including skipped/disabled), used in the summary line.
    #>
    [CmdletBinding()]
    [OutputType([string[]])]
    param(
        [Parameter(Mandatory)]
        [AllowEmptyCollection()]
        [array]$Plugins,

        [Parameter(Mandatory)]
        [int]$TotalPlugins
    )

    $output = @()

    # Header
    $output += "=== Execution Order ==="

    # Numbered list (already sorted by caller)
    $index = 1
    foreach ($p in $Plugins) {
        $output += "  {0}. [{1}]  {2}" -f $index, $p.Priority, $p.Name
        $index++
    }

    # Summary line
    $output += ""
    $output += "Executing $($Plugins.Count) of $TotalPlugins plugins..."

    return $output
}
