/**
 * Shared locale catalog used by LocaleSelector (settings) and the
 * template editors (notification & command). Single source of truth so
 * native names and metadata stay consistent across pickers.
 */

export interface LocaleMeta {
	code: string;
	name: string;       // English name
	native: string;     // Native script
	rtl?: boolean;
}

export const LOCALE_CATALOG: LocaleMeta[] = [
	{ code: 'en', name: 'English',    native: 'English' },
	{ code: 'ru', name: 'Russian',    native: 'Русский' },
	{ code: 'de', name: 'German',     native: 'Deutsch' },
	{ code: 'fr', name: 'French',     native: 'Français' },
	{ code: 'es', name: 'Spanish',    native: 'Español' },
	{ code: 'it', name: 'Italian',    native: 'Italiano' },
	{ code: 'pt', name: 'Portuguese', native: 'Português' },
	{ code: 'pl', name: 'Polish',     native: 'Polski' },
	{ code: 'nl', name: 'Dutch',      native: 'Nederlands' },
	{ code: 'sv', name: 'Swedish',    native: 'Svenska' },
	{ code: 'fi', name: 'Finnish',    native: 'Suomi' },
	{ code: 'no', name: 'Norwegian',  native: 'Norsk' },
	{ code: 'da', name: 'Danish',     native: 'Dansk' },
	{ code: 'cs', name: 'Czech',      native: 'Čeština' },
	{ code: 'hu', name: 'Hungarian',  native: 'Magyar' },
	{ code: 'ro', name: 'Romanian',   native: 'Română' },
	{ code: 'el', name: 'Greek',      native: 'Ελληνικά' },
	{ code: 'tr', name: 'Turkish',    native: 'Türkçe' },
	{ code: 'uk', name: 'Ukrainian',  native: 'Українська' },
	{ code: 'be', name: 'Belarusian', native: 'Беларуская' },
	{ code: 'bg', name: 'Bulgarian',  native: 'Български' },
	{ code: 'sr', name: 'Serbian',    native: 'Српски' },
	{ code: 'ar', name: 'Arabic',     native: 'العربية', rtl: true },
	{ code: 'he', name: 'Hebrew',     native: 'עברית',   rtl: true },
	{ code: 'fa', name: 'Persian',    native: 'فارسی',   rtl: true },
	{ code: 'zh', name: 'Chinese',    native: '中文' },
	{ code: 'ja', name: 'Japanese',   native: '日本語' },
	{ code: 'ko', name: 'Korean',     native: '한국어' },
	{ code: 'hi', name: 'Hindi',      native: 'हिन्दी' },
	{ code: 'vi', name: 'Vietnamese', native: 'Tiếng Việt' },
	{ code: 'th', name: 'Thai',       native: 'ไทย' },
	{ code: 'id', name: 'Indonesian', native: 'Bahasa Indonesia' },
];

export function getLocaleMeta(code: string): LocaleMeta {
	return LOCALE_CATALOG.find(l => l.code === code) ?? {
		code,
		name: code.toUpperCase(),
		native: code.toUpperCase(),
	};
}
