package airrescuechecklist

import "strings"

const (
	AirRescuerChecklistScopeCAT = "CAT"
	AirRescuerChecklistScopeTA  = "TA"
	AirRescuerChecklistScopeMO  = "MO"
	AirRescuerChecklistScopeDI  = "DI"
	AirRescuerChecklistScopeMI  = "MI"
	AirRescuerChecklistScopeDO  = "DO"
	AirRescuerChecklistScopeFR  = "FR"
	AirRescuerChecklistScopeSA  = "SA"
	AirRescuerChecklistScopeSO  = "SO"
	AirRescuerChecklistScopeM10 = "M10"
	AirRescuerChecklistScopeM15 = "M15"
	AirRescuerChecklistScopeM20 = "M20"
	AirRescuerChecklistScopeM25 = "M25"
	AirRescuerChecklistScopeDS  = "DS"
)

const (
	AirRescuerChecklistScopeOverview  = AirRescuerChecklistScopeCAT
	AirRescuerChecklistScopeDaily     = AirRescuerChecklistScopeTA
	AirRescuerChecklistScopeMonday    = AirRescuerChecklistScopeMO
	AirRescuerChecklistScopeTuesday   = AirRescuerChecklistScopeDI
	AirRescuerChecklistScopeWednesday = AirRescuerChecklistScopeMI
	AirRescuerChecklistScopeThursday  = AirRescuerChecklistScopeDO
	AirRescuerChecklistScopeFriday    = AirRescuerChecklistScopeFR
	AirRescuerChecklistScopeSaturday  = AirRescuerChecklistScopeSA
	AirRescuerChecklistScopeSunday    = AirRescuerChecklistScopeSO
	AirRescuerChecklistScopeDeadline  = AirRescuerChecklistScopeDS
)

var airRescuerChecklistPersistedScopeOrder = []string{
	AirRescuerChecklistScopeTA,
	AirRescuerChecklistScopeMO,
	AirRescuerChecklistScopeDI,
	AirRescuerChecklistScopeMI,
	AirRescuerChecklistScopeDO,
	AirRescuerChecklistScopeFR,
	AirRescuerChecklistScopeSA,
	AirRescuerChecklistScopeSO,
	AirRescuerChecklistScopeM10,
	AirRescuerChecklistScopeM15,
	AirRescuerChecklistScopeM20,
	AirRescuerChecklistScopeM25,
	AirRescuerChecklistScopeDS,
}

var airRescuerChecklistPersistedScopeSet = map[string]struct{}{
	AirRescuerChecklistScopeTA:  {},
	AirRescuerChecklistScopeMO:  {},
	AirRescuerChecklistScopeDI:  {},
	AirRescuerChecklistScopeMI:  {},
	AirRescuerChecklistScopeDO:  {},
	AirRescuerChecklistScopeFR:  {},
	AirRescuerChecklistScopeSA:  {},
	AirRescuerChecklistScopeSO:  {},
	AirRescuerChecklistScopeM10: {},
	AirRescuerChecklistScopeM15: {},
	AirRescuerChecklistScopeM20: {},
	AirRescuerChecklistScopeM25: {},
	AirRescuerChecklistScopeDS:  {},
}

var airRescuerChecklistScopeDisplayNamesEN = map[string]string{
	AirRescuerChecklistScopeCAT: "Category",
	AirRescuerChecklistScopeTA:  "Daily",
	AirRescuerChecklistScopeMO:  "Monday",
	AirRescuerChecklistScopeDI:  "Tuesday",
	AirRescuerChecklistScopeMI:  "Wednesday",
	AirRescuerChecklistScopeDO:  "Thursday",
	AirRescuerChecklistScopeFR:  "Friday",
	AirRescuerChecklistScopeSA:  "Saturday",
	AirRescuerChecklistScopeSO:  "Sunday",
	AirRescuerChecklistScopeM10: "M10",
	AirRescuerChecklistScopeM15: "M15",
	AirRescuerChecklistScopeM20: "M20",
	AirRescuerChecklistScopeM25: "M25",
	AirRescuerChecklistScopeDS:  "Deadline",
}

var airRescuerChecklistScopeDisplayNamesDE = map[string]string{
	AirRescuerChecklistScopeCAT: "Category",
	AirRescuerChecklistScopeTA:  "Taeglich",
	AirRescuerChecklistScopeMO:  "Montag",
	AirRescuerChecklistScopeDI:  "Dienstag",
	AirRescuerChecklistScopeMI:  "Mittwoch",
	AirRescuerChecklistScopeDO:  "Donnerstag",
	AirRescuerChecklistScopeFR:  "Freitag",
	AirRescuerChecklistScopeSA:  "Samstag",
	AirRescuerChecklistScopeSO:  "Sonntag",
	AirRescuerChecklistScopeM10: "M10",
	AirRescuerChecklistScopeM15: "M15",
	AirRescuerChecklistScopeM20: "M20",
	AirRescuerChecklistScopeM25: "M25",
	AirRescuerChecklistScopeDS:  "Deadline",
}

var airRescuerChecklistScopeCodesEN = map[string]string{
	AirRescuerChecklistScopeCAT: "CAT",
	AirRescuerChecklistScopeTA:  "DA",
	AirRescuerChecklistScopeMO:  "MO",
	AirRescuerChecklistScopeDI:  "TU",
	AirRescuerChecklistScopeMI:  "WE",
	AirRescuerChecklistScopeDO:  "TH",
	AirRescuerChecklistScopeFR:  "FR",
	AirRescuerChecklistScopeSA:  "SA",
	AirRescuerChecklistScopeSO:  "SU",
	AirRescuerChecklistScopeM10: "M10",
	AirRescuerChecklistScopeM15: "M15",
	AirRescuerChecklistScopeM20: "M20",
	AirRescuerChecklistScopeM25: "M25",
	AirRescuerChecklistScopeDS:  "DL",
}

var airRescuerChecklistScopeAliases = map[string]string{
	"CAT":      AirRescuerChecklistScopeCAT,
	"OVERVIEW": AirRescuerChecklistScopeCAT,

	"TA":    AirRescuerChecklistScopeTA,
	"DA":    AirRescuerChecklistScopeTA,
	"DAY":   AirRescuerChecklistScopeTA,
	"DAILY": AirRescuerChecklistScopeTA,

	"MO":     AirRescuerChecklistScopeMO,
	"MON":    AirRescuerChecklistScopeMO,
	"MONDAY": AirRescuerChecklistScopeMO,

	"DI":      AirRescuerChecklistScopeDI,
	"TU":      AirRescuerChecklistScopeDI,
	"TUE":     AirRescuerChecklistScopeDI,
	"TUESDAY": AirRescuerChecklistScopeDI,

	"MI":        AirRescuerChecklistScopeMI,
	"WE":        AirRescuerChecklistScopeMI,
	"WED":       AirRescuerChecklistScopeMI,
	"WEDNESDAY": AirRescuerChecklistScopeMI,

	"DO":       AirRescuerChecklistScopeDO,
	"TH":       AirRescuerChecklistScopeDO,
	"THU":      AirRescuerChecklistScopeDO,
	"THURSDAY": AirRescuerChecklistScopeDO,

	"FR":     AirRescuerChecklistScopeFR,
	"FRI":    AirRescuerChecklistScopeFR,
	"FRIDAY": AirRescuerChecklistScopeFR,

	"SA":       AirRescuerChecklistScopeSA,
	"SAT":      AirRescuerChecklistScopeSA,
	"SATURDAY": AirRescuerChecklistScopeSA,

	"SO":     AirRescuerChecklistScopeSO,
	"SU":     AirRescuerChecklistScopeSO,
	"SUN":    AirRescuerChecklistScopeSO,
	"SUNDAY": AirRescuerChecklistScopeSO,

	"M10": AirRescuerChecklistScopeM10,
	"M15": AirRescuerChecklistScopeM15,
	"M20": AirRescuerChecklistScopeM20,
	"M25": AirRescuerChecklistScopeM25,

	"DS":       AirRescuerChecklistScopeDS,
	"DL":       AirRescuerChecklistScopeDS,
	"DEADLINE": AirRescuerChecklistScopeDS,
}

func CanonicalizeAirRescuerChecklistScope(scopeCode string) string {
	return normalizeAirRescuerChecklistScope(scopeCode)
}

func IsAirRescuerChecklistPersistedScope(scopeCode string) bool {
	_, ok := airRescuerChecklistPersistedScopeSet[normalizeAirRescuerChecklistScope(scopeCode)]
	return ok
}

func IsAirRescuerChecklistQueryScope(scopeCode string) bool {
	normalized := normalizeAirRescuerChecklistScope(scopeCode)
	if normalized == AirRescuerChecklistScopeCAT {
		return true
	}
	return IsAirRescuerChecklistPersistedScope(normalized)
}

func AirRescuerChecklistScopeDisplayName(scopeCode string) string {
	normalized := normalizeAirRescuerChecklistScope(scopeCode)
	if v, ok := airRescuerChecklistScopeDisplayNamesEN[normalized]; ok {
		return v
	}
	return normalized
}

func AirRescuerChecklistScopeDisplayNameDE(scopeCode string) string {
	normalized := normalizeAirRescuerChecklistScope(scopeCode)
	if v, ok := airRescuerChecklistScopeDisplayNamesDE[normalized]; ok {
		return v
	}
	return normalized
}

func AirRescuerChecklistScopeCodeEN(scopeCode string) string {
	normalized := normalizeAirRescuerChecklistScope(scopeCode)
	if v, ok := airRescuerChecklistScopeCodesEN[normalized]; ok {
		return v
	}
	return normalized
}

func AirRescuerChecklistScopeCodeDE(scopeCode string) string {
	return normalizeAirRescuerChecklistScope(scopeCode)
}

func AirRescuerChecklistPersistedScopeOrder() []string {
	out := make([]string, 0, len(airRescuerChecklistPersistedScopeOrder))
	out = append(out, airRescuerChecklistPersistedScopeOrder...)
	return out
}

func IsAirRescuerChecklistScope(scopeCode string) bool {
	return IsAirRescuerChecklistPersistedScope(scopeCode)
}

func normalizeAirRescuerChecklistScope(scopeCode string) string {
	normalized := strings.ToUpper(strings.TrimSpace(scopeCode))
	if canonical, ok := airRescuerChecklistScopeAliases[normalized]; ok {
		return canonical
	}
	return normalized
}
