// Version: 1.0.0 | Created: 2026-04-01 // Sealed auth state hierarchy. // All auth transitions are expressed as one of these states — no raw booleans. import 'package:freezed_annotation/freezed_annotation.dart'; part 'auth_state.freezed.dart'; /// Represents every possible authentication state in the app. @freezed sealed class AuthState with _$AuthState { /// App has just launched; trying to restore session from storage. const factory AuthState.initial() = AuthInitial; /// A login or session-restore attempt is in progress. const factory AuthState.loading() = AuthLoading; /// User is authenticated. Holds the Matrix user ID and access token. const factory AuthState.authenticated({ required String userId, required String accessToken, required String deviceId, }) = AuthAuthenticated; /// User is not authenticated. /// [failure] is null on first launch; non-null after a failed attempt. const factory AuthState.unauthenticated({String? failure}) = AuthUnauthenticated; }