<?php

declare(strict_types=1);

namespace Drupal\ffmpeg_media\ValueObject;

use Drupal\media\MediaInterface;

/**
 * Immutable request data for a single output execution run.
 */
final readonly class OutputExecutionRequest {

  /**
   * Constructs an OutputExecutionRequest object.
   *
   * @param \Drupal\media\MediaInterface $media
   *   Media entity being converted.
   * @param string $sourcePath
   *   Resolved local source file path.
   * @param \Drupal\ffmpeg_media\ValueObject\ConversionContext $context
   *   Formatter and field context for the conversion.
   * @param \Drupal\ffmpeg_media\ValueObject\VideoInfo $videoInfo
   *   Probed source media metadata.
   * @param int $mediaId
   *   Numeric media entity ID.
   * @param bool $synchronous
   *   Whether conversion is running synchronously.
   * @param string $correlationId
   *   Correlation ID used for tracing logs and sub-operations.
   * @param string $resolvedProfileId
   *   Conversion profile ID used for this execution.
   * @param array<int, \Drupal\ffmpeg_media\ValueObject\ProfileOutput> $enabledOutputs
   *   Outputs enabled for this run.
   * @param \Drupal\ffmpeg_media\ValueObject\OutputExecutionPlan $executionPlan
   *   Typed execution metadata for the current run.
   */
  public function __construct(
    public MediaInterface $media,
    public string $sourcePath,
    public ConversionContext $context,
    public VideoInfo $videoInfo,
    public int $mediaId,
    public bool $synchronous,
    public string $correlationId,
    public string $resolvedProfileId,
    public array $enabledOutputs,
    public OutputExecutionPlan $executionPlan,
  ) {
    if ($sourcePath === '') {
      throw new \InvalidArgumentException('Source path cannot be empty.');
    }
    if ($mediaId <= 0) {
      throw new \InvalidArgumentException('Media ID must be greater than zero.');
    }
    if ($correlationId === '') {
      throw new \InvalidArgumentException('Correlation ID cannot be empty.');
    }
    if ($resolvedProfileId === '') {
      throw new \InvalidArgumentException('Resolved profile ID cannot be empty.');
    }
  }

}
