import 'package:freezed_annotation/freezed_annotation.dart';

part 'nextcloud_capabilities_state.freezed.dart';
part 'nextcloud_capabilities_state.g.dart';

/// Hydrated snapshot of the user's Nextcloud `files_sharing` capabilities.
/// Mirrors the fields the sharing UI gates on; see
/// `NextcloudSharingCapabilities` for the per-field meaning.
@freezed
abstract class NextcloudCapabilitiesState with _$NextcloudCapabilitiesState {
  const factory NextcloudCapabilitiesState({
    @Default(false) bool apiEnabled,
    @Default(false) bool publicEnabled,
    @Default(false) bool publicMultipleLinks,
    @Default(false) bool publicUploadEnabled,
    @Default(false) bool publicPasswordEnforced,
    @Default(false) bool publicExpireEnabled,
    int? publicExpireDays,
    @Default(false) bool publicExpireEnforced,
    @Default(false) bool groupEnabled,
    @Default(false) bool resharing,
    int? passwordMinLength,
    @Default(false) bool passwordEnforceUpperLower,
    @Default(false) bool passwordEnforceNumeric,
    @Default(false) bool passwordEnforceSpecial,
    // Whether a capability response (or a definitive failure) has been observed
    // at least once this session.
    @Default(false) bool loaded,
  }) = _NextcloudCapabilitiesState;

  factory NextcloudCapabilitiesState.fromJson(Map<String, Object?> json) =>
      _$NextcloudCapabilitiesStateFromJson(json);
}
