use utf8;
use strict;
use warnings;
use Shiar_Sheet::KeyboardChars 'kbmodes';

my $V = v1.3;

my $presymbol = $V ge v1.3 ? '\\' : '-';
my %rows = (
	'' => {
	'1' => '¡',
	'!' => '¹',
	'2' => 'ª',
	'@' => '²',
	'3' => 'º',
	'#' => '³',
	'4' => $V ge v1.1 ? '£' : '€',
	'$' => '¥',
	'5' => $V ge v1.1 ? '€' : '£',
	'%' => '¢',
	'6' => "\N{COMBINING CIRCUMFLEX ACCENT}",
	'^' => "\N{COMBINING CARON}",
	'7' => "\N{COMBINING RING ABOVE}",
	'&' => "\N{COMBINING MACRON}",
	'8' => "\N{DOUBLE LOW-9 QUOTATION MARK}",
	'*' => "\N{SINGLE LOW-9 QUOTATION MARK}",
	'9' => "\N{LEFT DOUBLE QUOTATION MARK}",
	'(' => "\N{LEFT SINGLE QUOTATION MARK}",
	'0' => "\N{RIGHT DOUBLE QUOTATION MARK}",
	')' => "\N{RIGHT SINGLE QUOTATION MARK}",
	'-' => $V ge v1.3 ? '✓' : '©',
	'_' => $V ge v1.3 ? '✗' : '№',
	'=' => '×',
	'+' => '÷',
	'q' => 'æ',
	'Q' => 'Æ',
	'w' => 'å',
	'W' => 'Å',
	'e' => 'ë',
	'E' => 'Ë',
	'r' => 'ý',
	'R' => 'Ý',
	't' => 'þ',
	'T' => 'Þ',
	'y' => 'ÿ',
	'Y' => 'Ÿ',
	'u' => 'ü',
	'U' => 'Ü',
	'i' => 'ï',
	'I' => 'Ï',
	'o' => 'ö',
	'O' => 'Ö',
	'p' => 'œ',
	'P' => 'Œ',
	'[' => '«',
	'{' => '‹',
	']' => '»',
	'}' => '›',

	'a' => 'ä',
	'A' => 'Ä',
	's' => 'ß',
	'S' => $V ge v1.3 ? 'ẞ' : '¶',
	'd' => $V ge v1.2 ? 'đ' : 'ð',
	'D' => $V ge v1.2 ? 'Đ' : 'Ð',
	'f' => 'è',
	'F' => 'È',
	'g' => 'é',
	'G' => 'É',
	'h' => 'ù',
	'H' => 'Ù',
	'j' => 'ú',
	'J' => 'Ú',
	'k' => 'ĳ',
	'K' => 'Ĳ',
	'l' => 'ø',
	'L' => 'Ø',
	';' => $V ge v1.2 ? '°' : "\N{COMBINING DIAERESIS}",
	':' => '·',
	"'" => "\N{COMBINING ACUTE ACCENT}",
	'"' => $V ge v1.2 ? "\N{COMBINING DIAERESIS}" : '†',
	'`' => "\N{COMBINING GRAVE ACCENT}",
	'~' => "\N{COMBINING TILDE}",

	'\\'=> '¬',
	'|' => '¦',
	'z' => 'à',
	'Z' => 'À',
	'x' => 'á',
	'X' => 'Á',
	'c' => 'ç',
	'C' => 'Ç',
	'v' => 'ì',
	'V' => 'Ì',
	'b' => 'í',
	'B' => 'Í',
	'n' => 'ñ',
	'N' => 'Ñ',
	'm' => 'Ω',
	'M' => '√', # ±
	',' => 'ò',
	'<' => 'Ò',
	'.' => 'ó',
	'>' => 'Ó',
	'/' => '¿',
	'?' => '…',
	},

	# greek
	'm' => {
		'a' => 'α',
		'b' => 'β', # v
		'g' => 'γ',
		'd' => 'δ',
		'e' => 'ε',
		'z' => 'ζ',
		'i' => 'η',
		'h' => 'θ',
		'j' => 'ι',
		'k' => 'κ',
		'l' => 'λ',
		'm' => 'μ',
		'n' => 'ν',
		'x' => 'ξ',
		'o' => 'ο',
		'p' => 'π',
		'r' => 'ρ',
		's' => 'σ',
		't' => 'τ',
		'y' => 'υ',
		'f' => 'φ',
		'c' => 'χ',
		'w' => 'ψ',
		'q' => 'ω', # u

		# suþscript
		'1' => '¹',
		'2' => '²',
		'3' => '³',
		'4' => '⁴',
		'5' => '⁵',
		'6' => '⁶',
		'7' => '⁷',
		'8' => '⁸',
		'9' => '⁹',
		'0' => '⁰',
		'!' => '₁',
		'@' => '₂',
		'#' => '₃',
		'$' => '₄',
		'%' => '₅',
		'^' => '₆',
		'&' => '₇',
		'*' => '₈',
		'(' => '₉',
		')' => '₀',
	},

	# maths
	'M' => {
		'!' => '≠',
		'~' => '≈',
		'=' => '≝',
		'>' => '≥',
		'<' => '≤',
		'-' => '±',
		'i' => '∞',
		'n' => 'ⁿ',
		'r' => '√',
		'3' => '∛',
		'4' => '∜',
		'%' => '‰',

		'f' => 'ƒ',
		'S' => '∫',
		"'" => '′',
		'"' => '″',
		'p' => '∂',
		'd' => 'Δ',
		'D' => '∇',
		'+' => '⊕',
		'*' => '⊗',
		'^' => '℘',

		's' => '∩',
		'u' => '∪',
		'U' => '∖',
		'O' => '∅',
		'g' => '⊂',
		'G' => '⊃',
		'h' => '⊄',
		'H' => '⊅',
		'b' => '⊆',
		'B' => '⊇',
		'm' => '∈',
		'M' => '∉',
		'k' => '∋',
		'K' => '∌',

		'A' => '∀',
		'E' => '∃',
		'X' => '∄',
		'&' => '∧',
		'|' => '∨',
		'c' => '∝',
		'.' => '⋅',
		'o' => '∘',
		':' => '∴',
		';' => '∵',
		'z' => '↯',
		'F' => '∎',

		'R' => 'ℝ',
		'C' => 'ℂ',
		'N' => 'ℕ',
		'P' => 'ℙ',
		'Q' => 'ℚ',
		'Z' => 'ℤ',
		'9' => '∟',
		'8' => '∠',
		'7' => '∡',
		'l' => '∥',
		'L' => '∦',
	},

	# symbols
	$presymbol => {
		't' => '™',
		'c' => '©',
		'p' => '℗',
		'r' => '®',
			$V lt v1.3 ? (
		'1' => '¼',
		'2' => '½',
		'3' => '¾',
		'4' => '⅓',
		'5' => '⅔',
		's' => '℠',
			) : (
		's' => '§',
		'1' => '№',
		'2' => '½',
		'3' => '⅓',
		'4' => '¼',
		'5' => '⅔',
		'6' => '¾',
		'T' => '℠',
			),

		# arrows
		'h' => '←',
		'H' => '⇐',
		'j' => '↓',
		'J' => '⇓',
		'k' => '↑',
		'K' => '⇑',
		'l' => '→',
		'L' => '⇒',
		'u' => '↖',
		'U' => '⇖',
		'i' => '↗',
		'I' => '⇗',
		'n' => '↙',
		'N' => '⇙',
		'm' => '↘',
		'M' => '⇘',
		'=' => '↔',
		'+' => '⇔',
	},
);

+{
	%{ kbmodes(\%rows) },
	mode => {
		''  => 'option-shifted ⌥',
		'm' => 'Ω greek prefix ⌥m',
		'M' => '√ maths prefix ⌥M',
		$presymbol => "$rows{$presymbol} symbol prefix ⌥$presymbol",
	},
	version => '1.0',
	title => 'EurKEY',
	intro => join("\n",
		'Third-party proposal <a href="https://eurkey.steffen.bruentjen.eu/">EurKEY</a>',
		'<abbr title="last updated 2017-05-15">v1.3</abbr> by Steffen Brüntjen',
		'supporting most European languages while pressing AltGr or ⌥ Option.',
		'Selectable in <abbr title="distributed with X since 2014">Linux</abbr>',
		'and available for <a href="/keyboard/altgr/windows">Windows</a>',
		'or <a href="/keyboard/altgr/macos">macOS</a>.',
	),
	description => [
		"An interactive map of EurKEY, the European Keyboard Layout.",
	],
	image => 'data/keyboard/thumb/eurkeyboard.jpg',
}
