// Package model provides TUI data structures and state management
package model

import "github.com/charmbracelet/bubbles/key"

// KeyMap defines key bindings for the TUI
type KeyMap struct {
	Refresh               key.Binding
	Trigger               key.Binding
	TriggerArgs           key.Binding
	ViewQueue             key.Binding
	ViewContainer         key.Binding
	ViewGPU               key.Binding
	ViewJobs              key.Binding
	ViewDatasets          key.Binding
	ViewExperiments       key.Binding
	ViewSettings          key.Binding
	ViewNarrative         key.Binding
	ViewTeam              key.Binding
	ViewExperimentHistory key.Binding
	ViewConfig            key.Binding
	ViewLogs              key.Binding
	ViewExport            key.Binding
	FilterTeam            key.Binding
	Cancel                key.Binding
	Delete                key.Binding
	MarkFailed            key.Binding
	RefreshGPU            key.Binding
	Help                  key.Binding
	Quit                  key.Binding
}

// DefaultKeys returns the default key bindings for the TUI
func DefaultKeys() KeyMap {
	return KeyMap{
		Refresh:               key.NewBinding(key.WithKeys("r"), key.WithHelp("r", "refresh all")),
		Trigger:               key.NewBinding(key.WithKeys("t"), key.WithHelp("t", "queue job")),
		TriggerArgs:           key.NewBinding(key.WithKeys("a"), key.WithHelp("a", "queue w/ args")),
		ViewQueue:             key.NewBinding(key.WithKeys("q"), key.WithHelp("q", "view queue")),
		ViewContainer:         key.NewBinding(key.WithKeys("o"), key.WithHelp("o", "containers")),
		ViewGPU:               key.NewBinding(key.WithKeys("g"), key.WithHelp("g", "gpu status")),
		ViewJobs:              key.NewBinding(key.WithKeys("1"), key.WithHelp("1", "job list")),
		ViewDatasets:          key.NewBinding(key.WithKeys("2"), key.WithHelp("2", "datasets")),
		ViewExperiments:       key.NewBinding(key.WithKeys("3"), key.WithHelp("3", "experiments")),
		ViewNarrative:         key.NewBinding(key.WithKeys("n"), key.WithHelp("n", "narrative")),
		ViewTeam:              key.NewBinding(key.WithKeys("m"), key.WithHelp("m", "team")),
		ViewExperimentHistory: key.NewBinding(key.WithKeys("e"), key.WithHelp("e", "experiment history")),
		ViewConfig:            key.NewBinding(key.WithKeys("c"), key.WithHelp("c", "config")),
		ViewSettings:          key.NewBinding(key.WithKeys("s"), key.WithHelp("s", "settings")),
		ViewLogs:              key.NewBinding(key.WithKeys("l"), key.WithHelp("l", "logs")),
		ViewExport:            key.NewBinding(key.WithKeys("E"), key.WithHelp("E", "export job")),
		FilterTeam:            key.NewBinding(key.WithKeys("@"), key.WithHelp("@", "filter by team")),
		Cancel:                key.NewBinding(key.WithKeys("x"), key.WithHelp("x", "cancel task")),
		Delete:                key.NewBinding(key.WithKeys("d"), key.WithHelp("d", "delete job")),
		MarkFailed:            key.NewBinding(key.WithKeys("f"), key.WithHelp("f", "mark failed")),
		RefreshGPU:            key.NewBinding(key.WithKeys("G"), key.WithHelp("G", "refresh GPU")),
		Help:                  key.NewBinding(key.WithKeys("h", "?"), key.WithHelp("h/?", "toggle help")),
		Quit:                  key.NewBinding(key.WithKeys("ctrl+c"), key.WithHelp("ctrl+c", "quit")),
	}
}
