Map<String, dynamic> toJson() => { 'name': name, 'enabled': enabled, if (gates.isNotEmpty) 'gates': gates.map((g) => g.raw).toList(), };