// SPDX-FileCopyrightText: 2026 FocusFlow contributors
// SPDX-License-Identifier: AGPL-3.0-only

part of '../quick_capture.dart';

/// Result of a quick-capture request.
///
/// The result always carries a [task], even on validation failure, so the UI can
/// preserve the user's input and show what needs to be fixed. When scheduling
/// was attempted, [schedulingResult] exposes the lower-level engine notices and
/// changes for debugging or timeline updates.
class QuickCaptureResult {
  /// Creates a `QuickCaptureResult` instance with the values required by its invariants.
  /// Callers should pass already-normalized scheduler data because validation and defaulting belong at the model or service boundary, not in arbitrary UI code.
  QuickCaptureResult({
    required this.task,
    required this.status,
    this.schedulingResult,
    List<String> messages = const <String>[],
  }) : messages = List<String>.unmodifiable(messages);

  /// Captured task, scheduled or unscheduled depending on [status].
  final Task task;

  /// High-level outcome of the capture attempt.
  final QuickCaptureStatus status;

  /// Detailed scheduling output when immediate placement was attempted.
  final SchedulingResult? schedulingResult;

  /// Human-readable validation or scheduling messages.
  final List<String> messages;

  /// Convenience check for UI branches that only care whether capture succeeded.
  bool get isValid => status != QuickCaptureStatus.validationError;
}
