import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../models/user_profile.dart';

class OnboardingControllerNotifier extends Notifier<UserProfile> {
  @override
  UserProfile build() {
    return UserProfile(uid: '');
  }

  void init(String uid) {
    state = UserProfile(uid: uid);
  }

  void setPersona(String persona) {
    state = state.copyWith(persona: persona);
  }

  void setEnergyBaseline(String energy) {
    state = state.copyWith(energyBaseline: energy);
  }

  void toggleFocusArea(String area) {
    final current = List<String>.from(state.focusAreas);
    if (current.contains(area)) {
      current.remove(area);
    } else {
      if (current.length < 3) {
        current.add(area);
      }
    }
    state = state.copyWith(focusAreas: current);
  }

  void setDecisionStyle(String style) {
    state = state.copyWith(decisionStyle: style);
  }
}

final onboardingControllerProvider =
    NotifierProvider<OnboardingControllerNotifier, UserProfile>(() {
      return OnboardingControllerNotifier();
    });

class BoundariesNotifier extends Notifier<Map<String, bool>> {
  @override
  Map<String, bool> build() {
    return {
      "Food choices": false,
      "Exercise": false,
      "Spending": false,
      "Sleep schedule": false,
      "Notifications": false,
    };
  }

  void set(Map<String, bool> newState) {
    state = newState;
  }
}

final onboardingBoundariesProvider =
    NotifierProvider<BoundariesNotifier, Map<String, bool>>(() {
      return BoundariesNotifier();
    });
