use strict;
use warnings;

my %cat = (
	default => [qw( euro latin science graph )],
	euro => [qw( windows ukext macos macos-abc weur eurkey msx )],
	latin => [qw( ipa olpc boyeg drix )],
	science => [qw( symbolics apl spacecadet )],
	graph => [qw( unigraph emojiworks )],
	extra => [qw( msx-graph p8scii zoo )],
);

for my $name (map {@{$_}} values %cat) {
	my $keys = do "keyboard/altgr/$name.eng.inc.pl" or next;
	my %row = %{$keys}{qw( title category flag mode image imagealt )};
	$cat{$name} = \%row;

	$keys->{mode} //= {'' => undef};
	for my $mode (keys %{ $keys->{mode} }) {
		$row{key}{$_} = $keys->{key}{$_} for $mode || ();
		$row{inventory}{$mode}{$_}++ for grep { /^g[2-9]/ } map { s/ (?!ext).*//r }
			values %{ $keys->{def}{$mode} };
	}
}

\%cat
