import {
ArchiveSort,
ArtistSort,
Category,
Censorship,
CharacterSort,
CircleSort,
ComicSort,
Direction,
Language,
Layout,
NamespaceSort,
Rating,
TagSort,
UpdateMode,
WorldSort
} from '$gql/graphql';
export interface EnumOption<T> {
id: T;
name: string;
}
export const DirectionLabel: Record<Direction, string> = {
[Direction.LeftToRight]: 'Left to Right',
[Direction.RightToLeft]: 'Right to Left'
};
export const LayoutLabel: Record<Layout, string> = {
[Layout.Single]: 'Single Page',
[Layout.Double]: 'Double Page',
[Layout.DoubleOffset]: 'Double Page, offset'
};
export const RatingLabel: Record<Rating, string> = {
[Rating.Safe]: 'Safe',
[Rating.Questionable]: 'Questionable',
[Rating.Explicit]: 'Explicit'
};
export const CensorshipLabel: Record<Censorship, string> = {
[Censorship.None]: 'None',
[Censorship.Bar]: 'Bars',
[Censorship.Mosaic]: 'Mosaic',
[Censorship.Full]: 'Full'
};
export const CategoryLabel: Record<Category, string> = {
[Category.Manga]: 'Manga',
[Category.Doujinshi]: 'Doujinshi',
[Category.Comic]: 'Comic',
[Category.Artbook]: 'Artbook',
[Category.GameCg]: 'Game CG',
[Category.ImageSet]: 'Image Set',
[Category.VariantSet]: 'Variant Set',
[Category.Webtoon]: 'Webtoon'
};
export const ArchiveSortLabel: Record<ArchiveSort, string> = {
[ArchiveSort.Path]: 'Path',
[ArchiveSort.Size]: 'File Size',
[ArchiveSort.CreatedAt]: 'Created At',
[ArchiveSort.PageCount]: 'Page Count',
[ArchiveSort.Random]: 'Random'
};
export const ComicSortLabel: Record<ComicSort, string> = {
[ComicSort.Title]: 'Title',
[ComicSort.OriginalTitle]: 'Original Title',
[ComicSort.Date]: 'Date',
[ComicSort.CreatedAt]: 'Created At',
[ComicSort.UpdatedAt]: 'Updated At',
[ComicSort.TagCount]: 'Tag Count',
[ComicSort.PageCount]: 'Page Count',
[ComicSort.Random]: 'Random'
};
export const ArtistSortLabel: Record<ArtistSort, string> = {
[ArtistSort.Name]: 'Name',
[ArtistSort.CreatedAt]: 'Created At',
[ArtistSort.UpdatedAt]: 'Updated At',
[ArchiveSort.Random]: 'Random'
};
export const CharacterSortLabel: Record<CharacterSort, string> = {
[CharacterSort.Name]: 'Name',
[CharacterSort.CreatedAt]: 'Created At',
[CharacterSort.UpdatedAt]: 'Updated At',
[ArchiveSort.Random]: 'Random'
};
export const CircleSortLabel: Record<CircleSort, string> = {
[CircleSort.Name]: 'Name',
[CircleSort.CreatedAt]: 'Created At',
[CircleSort.UpdatedAt]: 'Updated At',
[ArchiveSort.Random]: 'Random'
};
export const NamespaceSortLabel: Record<NamespaceSort, string> = {
[NamespaceSort.Name]: 'Name',
[NamespaceSort.SortName]: 'Sort Name',
[NamespaceSort.CreatedAt]: 'Created At',
[NamespaceSort.UpdatedAt]: 'Updated At',
[ArchiveSort.Random]: 'Random'
};
export const TagSortLabel: Record<TagSort, string> = {
[TagSort.Name]: 'Name',
[TagSort.CreatedAt]: 'Created At',
[TagSort.UpdatedAt]: 'Updated At',
[ArchiveSort.Random]: 'Random'
};
export const WorldSortLabel: Record<WorldSort, string> = {
[WorldSort.Name]: 'Name',
[WorldSort.CreatedAt]: 'Created At',
[WorldSort.UpdatedAt]: 'Updated At',
[ArchiveSort.Random]: 'Random'
};
export const UpdateModeLabel: Record<UpdateMode, string> = {
[UpdateMode.Add]: 'Add',
[UpdateMode.Remove]: 'Remove',
[UpdateMode.Replace]: 'Replace'
};
export const LanguageLabel: Record<Language, string> = {
[Language.Ab]: 'Abkhazian',
[Language.Aa]: 'Afar',
[Language.Af]: 'Afrikaans',
[Language.Ak]: 'Akan',
[Language.Sq]: 'Albanian',
[Language.Am]: 'Amharic',
[Language.Ar]: 'Arabic',
[Language.An]: 'Aragonese',
[Language.Hy]: 'Armenian',
[Language.As]: 'Assamese',
[Language.Av]: 'Avaric',
[Language.Ae]: 'Avestan',
[Language.Ay]: 'Aymara',
[Language.Az]: 'Azerbaijani',
[Language.Bm]: 'Bambara',
[Language.Ba]: 'Bashkir',
[Language.Eu]: 'Basque',
[Language.Be]: 'Belarusian',
[Language.Bn]: 'Bengali',
[Language.Bh]: 'Bihari languages',
[Language.Bi]: 'Bislama',
[Language.Bs]: 'Bosnian',
[Language.Br]: 'Breton',
[Language.Bg]: 'Bulgarian',
[Language.My]: 'Burmese',
[Language.Ca]: 'Catalan',
[Language.Km]: 'Central Khmer',
[Language.Ch]: 'Chamorro',
[Language.Ce]: 'Chechen',
[Language.Ny]: 'Chichewa',
[Language.Zh]: 'Chinese',
[Language.Cu]: 'Church Slavic',
[Language.Cv]: 'Chuvash',
[Language.Kw]: 'Cornish',
[Language.Co]: 'Corsican',
[Language.Cr]: 'Cree',
[Language.Hr]: 'Croatian',
[Language.Cs]: 'Czech',
[Language.Da]: 'Danish',
[Language.Dv]: 'Divehi',
[Language.Nl]: 'Dutch',
[Language.Dz]: 'Dzongkha',
[Language.En]: 'English',
[Language.Eo]: 'Esperanto',
[Language.Et]: 'Estonian',
[Language.Ee]: 'Ewe',
[Language.Fo]: 'Faroese',
[Language.Fj]: 'Fijian',
[Language.Fi]: 'Finnish',
[Language.Fr]: 'French',
[Language.Ff]: 'Fulah',
[Language.Gd]: 'Gaelic',
[Language.Gl]: 'Galician',
[Language.Lg]: 'Ganda',
[Language.Ka]: 'Georgian',
[Language.De]: 'German',
[Language.Gn]: 'Guarani',
[Language.Gu]: 'Gujarati',
[Language.Ht]: 'Haitian',
[Language.Ha]: 'Hausa',
[Language.He]: 'Hebrew',
[Language.Hz]: 'Herero',
[Language.Hi]: 'Hindi',
[Language.Ho]: 'Hiri Motu',
[Language.Hu]: 'Hungarian',
[Language.Is]: 'Icelandic',
[Language.Io]: 'Ido',
[Language.Ig]: 'Igbo',
[Language.Id]: 'Indonesian',
[Language.Ia]: 'Interlingua',
[Language.Ie]: 'Interlingue',
[Language.Iu]: 'Inuktitut',
[Language.Ik]: 'Inupiaq',
[Language.Ga]: 'Irish',
[Language.It]: 'Italian',
[Language.Ja]: 'Japanese',
[Language.Jv]: 'Javanese',
[Language.Kl]: 'Kalaallisut',
[Language.Kn]: 'Kannada',
[Language.Kr]: 'Kanuri',
[Language.Ks]: 'Kashmiri',
[Language.Kk]: 'Kazakh',
[Language.Ki]: 'Kikuyu',
[Language.Rw]: 'Kinyarwanda',
[Language.Ky]: 'Kirghiz',
[Language.Kv]: 'Komi',
[Language.Kg]: 'Kongo',
[Language.Ko]: 'Korean',
[Language.Kj]: 'Kuanyama',
[Language.Ku]: 'Kurdish',
[Language.Lo]: 'Lao',
[Language.La]: 'Latin',
[Language.Lv]: 'Latvian',
[Language.Li]: 'Limburgan',
[Language.Ln]: 'Lingala',
[Language.Lt]: 'Lithuanian',
[Language.Lu]: 'Luba-Katanga',
[Language.Lb]: 'Luxembourgish',
[Language.Mk]: 'Macedonian',
[Language.Mg]: 'Malagasy',
[Language.Ms]: 'Malay',
[Language.Ml]: 'Malayalam',
[Language.Mt]: 'Maltese',
[Language.Gv]: 'Manx',
[Language.Mi]: 'Maori',
[Language.Mr]: 'Marathi',
[Language.Mh]: 'Marshallese',
[Language.El]: 'Modern Greek',
[Language.Mn]: 'Mongolian',
[Language.Na]: 'Nauru',
[Language.Nv]: 'Navajo',
[Language.Ng]: 'Ndonga',
[Language.Ne]: 'Nepali',
[Language.Se]: 'Northern Sami',
[Language.Nd]: 'North Ndebele',
[Language.No]: 'Norwegian',
[Language.Nb]: 'Norwegian Bokmål',
[Language.Nn]: 'Norwegian Nynorsk',
[Language.Oc]: 'Occitan',
[Language.Oj]: 'Ojibwa',
[Language.Or]: 'Oriya',
[Language.Om]: 'Oromo',
[Language.Os]: 'Ossetian',
[Language.Pi]: 'Pali',
[Language.Pa]: 'Panjabi',
[Language.Fa]: 'Persian',
[Language.Pl]: 'Polish',
[Language.Pt]: 'Portuguese',
[Language.Ps]: 'Pushto',
[Language.Qu]: 'Quechua',
[Language.Ro]: 'Romanian',
[Language.Rm]: 'Romansh',
[Language.Rn]: 'Rundi',
[Language.Ru]: 'Russian',
[Language.Sm]: 'Samoan',
[Language.Sg]: 'Sango',
[Language.Sa]: 'Sanskrit',
[Language.Sc]: 'Sardinian',
[Language.Sr]: 'Serbian',
[Language.Sn]: 'Shona',
[Language.Ii]: 'Sichuan Yi',
[Language.Sd]: 'Sindhi',
[Language.Si]: 'Sinhala',
[Language.Sk]: 'Slovak',
[Language.Sl]: 'Slovenian',
[Language.So]: 'Somali',
[Language.St]: 'Southern Sotho',
[Language.Nr]: 'South Ndebele',
[Language.Es]: 'Spanish',
[Language.Su]: 'Sundanese',
[Language.Sw]: 'Swahili',
[Language.Ss]: 'Swati',
[Language.Sv]: 'Swedish',
[Language.Tl]: 'Tagalog',
[Language.Ty]: 'Tahitian',
[Language.Tg]: 'Tajik',
[Language.Ta]: 'Tamil',
[Language.Tt]: 'Tatar',
[Language.Te]: 'Telugu',
[Language.Th]: 'Thai',
[Language.Bo]: 'Tibetan',
[Language.Ti]: 'Tigrinya',
[Language.To]: 'Tonga',
[Language.Ts]: 'Tsonga',
[Language.Tn]: 'Tswana',
[Language.Tr]: 'Turkish',
[Language.Tk]: 'Turkmen',
[Language.Tw]: 'Twi',
[Language.Ug]: 'Uighur',
[Language.Uk]: 'Ukrainian',
[Language.Ur]: 'Urdu',
[Language.Uz]: 'Uzbek',
[Language.Ve]: 'Venda',
[Language.Vi]: 'Vietnamese',
[Language.Vo]: 'Volapük',
[Language.Wa]: 'Walloon',
[Language.Cy]: 'Welsh',
[Language.Fy]: 'Western Frisian',
[Language.Wo]: 'Wolof',
[Language.Xh]: 'Xhosa',
[Language.Yi]: 'Yiddish',
[Language.Yo]: 'Yoruba',
[Language.Za]: 'Zhuang',
[Language.Zu]: 'Zulu'
};
export const directions: EnumOption<Direction>[] = optionsFromLabel(DirectionLabel);
export const layouts: EnumOption<Layout>[] = optionsFromLabel(LayoutLabel);
export const ratings: EnumOption<Rating>[] = optionsFromLabel(RatingLabel);
export const censorships: EnumOption<Censorship>[] = optionsFromLabel(CensorshipLabel);
export const categories: EnumOption<Category>[] = optionsFromLabel(CategoryLabel);
export const languages: EnumOption<Language>[] = optionsFromLabel(LanguageLabel);
function optionsFromLabel<T extends string | number | symbol>(
labels: Record<T, string>
): EnumOption<T>[] {
return Object.entries(labels).map(([k, v]) => ({ id: k as T, name: v as string }));
}