import '../../entities/availability/availability_slot.dart';

/// Adapter for [AvailabilitySlot] domain entity.
class AvailabilityAdapter {
  static const Map<String, Map<String, String>> _slotDefinitions = {
    'MORNING': {
      'id': 'morning',
      'label': 'Morning',
      'timeRange': '4:00 AM - 12:00 PM',
    },
    'AFTERNOON': {
      'id': 'afternoon',
      'label': 'Afternoon',
      'timeRange': '12:00 PM - 6:00 PM',
    },
    'EVENING': {
      'id': 'evening',
      'label': 'Evening',
      'timeRange': '6:00 PM - 12:00 AM',
    },
  };

  /// Converts a backend slot name (e.g. 'MORNING') to a Domain [AvailabilitySlot].
  static AvailabilitySlot fromPrimitive(String slotName, {bool isAvailable = false}) {
    final def = _slotDefinitions[slotName.toUpperCase()] ?? _slotDefinitions['MORNING']!;
    return AvailabilitySlot(
      id: def['id']!,
      label: def['label']!,
      timeRange: def['timeRange']!,
      isAvailable: isAvailable,
    );
  }
}
