use std::path::PathBuf;
use std::sync::Arc;

use wayscriber::config::Config;

use crate::models::{
    BoardBackgroundOption, BoardItemTextField, BoardItemToggleField, ColorMode, ColorPickerId,
    ColorPickerValue, EraserModeOption, FontStyleOption, FontWeightOption, KeybindingField,
    KeybindingsTabId, NamedColorOption, OverrideOption, PresenterToolBehaviorOption,
    PresetEraserKindOption, PresetEraserModeOption, PresetTextField, PresetToggleField, QuadField,
    SessionCompressionOption, SessionStorageModeOption, StatusPositionOption, TabId, TextField,
    ToggleField, ToolOption, ToolbarLayoutModeOption, ToolbarOverrideField, TripletField, UiTabId,
};
#[cfg(feature = "tablet-input")]
use crate::models::{PressureThicknessEditModeOption, PressureThicknessEntryModeOption};

#[derive(Debug, Clone)]
pub enum Message {
    ConfigLoaded(Result<Arc<Config>, String>),
    ReloadRequested,
    ResetToDefaults,
    SaveRequested,
    ConfigSaved(Result<(Option<PathBuf>, Arc<Config>), String>),
    TabSelected(TabId),
    UiTabSelected(UiTabId),
    KeybindingsTabSelected(KeybindingsTabId),
    ToggleChanged(ToggleField, bool),
    TextChanged(TextField, String),
    TripletChanged(TripletField, usize, String),
    QuadChanged(QuadField, usize, String),
    ColorPickerToggled(ColorPickerId),
    ColorPickerAdvancedToggled(ColorPickerId, bool),
    ColorPickerHexChanged(ColorPickerId, String),
    ColorPickerChanged(ColorPickerId, ColorPickerValue),
    ColorModeChanged(ColorMode),
    NamedColorSelected(NamedColorOption),
    EraserModeChanged(EraserModeOption),
    StatusPositionChanged(StatusPositionOption),
    ToolbarLayoutModeChanged(ToolbarLayoutModeOption),
    ToolbarOverrideModeChanged(ToolbarLayoutModeOption),
    ToolbarOverrideChanged(ToolbarOverrideField, OverrideOption),
    BoardsAddItem,
    BoardsRemoveItem(usize),
    BoardsMoveItemUp(usize),
    BoardsMoveItemDown(usize),
    BoardsDuplicateItem(usize),
    BoardsCollapseToggled(usize),
    BoardsDefaultChanged(String),
    BoardsItemTextChanged(usize, BoardItemTextField, String),
    BoardsBackgroundKindChanged(usize, BoardBackgroundOption),
    BoardsBackgroundColorChanged(usize, usize, String),
    BoardsDefaultPenEnabledChanged(usize, bool),
    BoardsDefaultPenColorChanged(usize, usize, String),
    BoardsItemToggleChanged(usize, BoardItemToggleField, bool),
    SessionStorageModeChanged(SessionStorageModeOption),
    SessionCompressionChanged(SessionCompressionOption),
    PresenterToolBehaviorChanged(PresenterToolBehaviorOption),
    BufferCountChanged(u32),
    KeybindingChanged(KeybindingField, String),
    FontStyleOptionSelected(FontStyleOption),
    FontWeightOptionSelected(FontWeightOption),
    #[cfg(feature = "tablet-input")]
    TabletPressureEditModeChanged(PressureThicknessEditModeOption),
    #[cfg(feature = "tablet-input")]
    TabletPressureEntryModeChanged(PressureThicknessEntryModeOption),
    PresetSlotCountChanged(usize),
    PresetSlotEnabledChanged(usize, bool),
    PresetCollapseToggled(usize),
    PresetResetSlot(usize),
    PresetDuplicateSlot(usize),
    PresetToolChanged(usize, ToolOption),
    PresetColorModeChanged(usize, ColorMode),
    PresetNamedColorSelected(usize, NamedColorOption),
    PresetColorComponentChanged(usize, usize, String),
    PresetTextChanged(usize, PresetTextField, String),
    PresetToggleOptionChanged(usize, PresetToggleField, OverrideOption),
    PresetEraserKindChanged(usize, PresetEraserKindOption),
    PresetEraserModeChanged(usize, PresetEraserModeOption),
}
