// Colouring for QSL / confirmation status letters.
//
// These columns are read by COLOUR before they are read as letters: an operator
// scanning a hundred rows wants to see where the gaps are, not to read "Y" a
// hundred times.
//
// Colour ONLY — no pill, no badge. These values sit among callsigns and dates,
// and a column of coloured boxes would shout louder than the callsign it
// belongs to.
//
// The classes are semantic tokens, not fixed colours, so all four themes follow
// and the contrast stays right on the light ones.

// ADIF confirmation values, and what they mean to the operator:
//   Y  confirmed / sent
//   N  not sent, not received
//   R  requested — queued, waiting on the other station or the service
//   I  ignore (ADIF's "invalid/ignore"), left in default ink: it is neither
//      good news nor bad, and colouring it would put it in one camp or the
//      other.
//
// Anything else — a blank, or a status some other logger wrote — is left alone
// rather than guessed at.
export function qslStatusClass(value: unknown): string {
	switch (String(value ?? '').trim().toUpperCase()) {
		case 'Y':
			return 'text-success';
		case 'N':
			return 'text-destructive';
		case 'R':
			return 'text-info';
	}
	return '';
}

// qslStatusCellClass is the AG-Grid form: same rule, plus the monospace the
// status columns already used so the letters stay in a straight column.
export function qslStatusCellClass(p: { value?: unknown }): string {
	const c = qslStatusClass(p?.value);
	return c ? 'font-mono ' + c : 'font-mono';
}
