import '../../../domain/entities/sequence.dart'; class SequenceState { final List sequences; final List categories; final Map running; // viewerId -> RunningSequence final int? selectedCategoryId; final bool isLoading; final String? error; const SequenceState({ this.sequences = const [], this.categories = const [], this.running = const {}, this.selectedCategoryId, this.isLoading = false, this.error, }); /// Sequences filtered by selected category List get filteredSequences { if (selectedCategoryId == null) return sequences; return sequences .where((s) => s.categoryId == selectedCategoryId) .toList(); } /// Check if a sequence is running on a viewer bool isRunningOnViewer(int viewerId) => running.containsKey(viewerId); /// Get running sequence for a viewer RunningSequence? getRunning(int viewerId) => running[viewerId]; SequenceState copyWith({ List? sequences, List? categories, Map? running, int? selectedCategoryId, bool clearCategory = false, bool? isLoading, String? error, bool clearError = false, }) { return SequenceState( sequences: sequences ?? this.sequences, categories: categories ?? this.categories, running: running ?? this.running, selectedCategoryId: clearCategory ? null : (selectedCategoryId ?? this.selectedCategoryId), isLoading: isLoading ?? this.isLoading, error: clearError ? null : (error ?? this.error), ); } }