class PermissionOption {
  String id;
  String title;
  bool isChecked;
  bool isHighlighted;
  List<PermissionOption> subOptions;

  PermissionOption({
    required this.id,
    required this.title,
    this.isChecked = false,
    this.isHighlighted = false,
    this.subOptions = const [],
  });

  factory PermissionOption.fromJson(Map<String, dynamic> json) {
    return PermissionOption(
      id: json['id'] ?? '',
      title: json['title'] != null
          ? json['title'].toString().toLowerCase().replaceAll("_", " ")
          : '',
      isChecked: json['isChecked'] ?? false,
      isHighlighted: json['isHighlighted'] ?? false,
      subOptions: (json['subOptions'] as List?)
              ?.map((sub) => PermissionOption.fromJson(sub))
              .toList() ??
          [],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'title': title,
      'isChecked': isChecked,
      'isHighlighted': isHighlighted,
      'subOptions': subOptions.map((sub) => sub.toJson()).toList(),
    };
  }
}

enum CheckState { none, some, all }
