#ifndef SETTINGS_FLAGS_H
#define SETTINGS_FLAGS_H

#include "core/profile.h"
#include <glib.h>

typedef enum {
  FLAG_TYPE_BOOLEAN,
  FLAG_TYPE_STRING,
  FLAG_TYPE_INTEGER
} FlagType;

typedef enum {
  FLAG_CATEGORY_DEBUG,
  FLAG_CATEGORY_JAVASCRIPT,
  FLAG_CATEGORY_GRAPHICS,
  FLAG_CATEGORY_MEMORY,
  FLAG_CATEGORY_MEDIA,
  FLAG_CATEGORY_OTHER
} FlagCategory;

typedef struct {
  const char *name;
  const char *description;
  FlagType type;
  FlagCategory category;
  const char *default_value;
  gboolean requires_restart;
} FlagInfo;

typedef struct _FlagsManager FlagsManager;

/**
 * Initialize the flags manager
 * @param profile User profile for database access
 * @return FlagsManager instance or NULL on failure
 */
FlagsManager *flags_manager_new(Profile *profile);

/**
 * Free the flags manager
 * @param manager FlagsManager instance
 */
void flags_manager_free(FlagsManager *manager);

/**
 * Get all available flags
 * @param manager FlagsManager instance
 * @return Array of FlagInfo pointers (NULL-terminated)
 */
const FlagInfo **flags_manager_get_all(FlagsManager *manager);

/**
 * Get the current value of a flag
 * @param manager FlagsManager instance
 * @param flag_name Flag name
 * @return Current value or NULL if not set
 */
char *flags_manager_get_value(FlagsManager *manager, const char *flag_name);

/**
 * Set the value of a flag
 * @param manager FlagsManager instance
 * @param flag_name Flag name
 * @param value New value (NULL to reset to default)
 * @return TRUE on success, FALSE on failure
 */
gboolean flags_manager_set_value(FlagsManager *manager, const char *flag_name,
                                 const char *value);

/**
 * Apply all flags as environment variables
 * This should be called early in application startup
 * @param manager FlagsManager instance
 */
void flags_manager_apply_all(FlagsManager *manager);

/**
 * Generate HTML page for flags configuration
 * @param manager FlagsManager instance
 * @return HTML string (caller must free with g_free)
 */
char *flags_manager_get_flags_html(FlagsManager *manager);

/**
 * Get the number of available flags
 * @param manager FlagsManager instance
 * @return Number of flags
 */
int flags_manager_get_count(FlagsManager *manager);

#endif // SETTINGS_FLAGS_H
