import { registerLocaleData } from '@angular/common';
import { GlobalConfig, I18nConfig, LocaleServiceConfig } from '@eui/core';

import localeBg from '@angular/common/locales/bg';
import localeBgExtra from '@angular/common/locales/extra/bg';
import localeEs from '@angular/common/locales/es';
import localeEsExtra from '@angular/common/locales/extra/es';
import localeCs from '@angular/common/locales/cs';
import localeCsExtra from '@angular/common/locales/extra/cs';
import localeDa from '@angular/common/locales/da';
import localeDaExtra from '@angular/common/locales/extra/da';
import localeDe from '@angular/common/locales/de';
import localeDeExtra from '@angular/common/locales/extra/de';
import localeEt from '@angular/common/locales/et';
import localeEtExtra from '@angular/common/locales/extra/et';
import localeEl from '@angular/common/locales/el';
import localeElExtra from '@angular/common/locales/extra/el';
import localeEn from '@angular/common/locales/en';
import localeEnExtra from '@angular/common/locales/extra/en';
import localeFr from '@angular/common/locales/fr';
import localeFrExtra from '@angular/common/locales/extra/fr';
import localeGa from '@angular/common/locales/ga';
import localeGaExtra from '@angular/common/locales/extra/ga';
import localeHr from '@angular/common/locales/hr';
import localeHrExtra from '@angular/common/locales/extra/hr';
import localeIt from '@angular/common/locales/it';
import localeItExtra from '@angular/common/locales/extra/it';
import localeLv from '@angular/common/locales/lv';
import localeLvExtra from '@angular/common/locales/extra/lv';
import localeLt from '@angular/common/locales/lt';
import localeLtExtra from '@angular/common/locales/extra/lt';
import localeHu from '@angular/common/locales/hu';
import localeHuExtra from '@angular/common/locales/extra/hu';
import localeMt from '@angular/common/locales/mt';
import localeMtExtra from '@angular/common/locales/extra/mt';
import localeNl from '@angular/common/locales/nl';
import localeNlExtra from '@angular/common/locales/extra/nl';
import localePl from '@angular/common/locales/pl';
import localePlExtra from '@angular/common/locales/extra/pl';
import localePt from '@angular/common/locales/pt';
import localePtExtra from '@angular/common/locales/extra/pt';
import localeRo from '@angular/common/locales/ro';
import localeRoExtra from '@angular/common/locales/extra/ro';
import localeSk from '@angular/common/locales/sk';
import localeSkExtra from '@angular/common/locales/extra/sk';
import localeSl from '@angular/common/locales/sl';
import localeSlExtra from '@angular/common/locales/extra/sl';
import localeFi from '@angular/common/locales/fi';
import localeFiExtra from '@angular/common/locales/extra/fi';
import localeSv from '@angular/common/locales/sv';
import localeSvExtra from '@angular/common/locales/extra/sv';

/**
 * import and register locales (currently MWP uses only French and English)
 */
registerLocaleData(localeBg, 'bg', localeBgExtra);
registerLocaleData(localeEs, 'es', localeEsExtra);
registerLocaleData(localeCs, 'cs', localeCsExtra);
registerLocaleData(localeDa, 'da', localeDaExtra);
registerLocaleData(localeDe, 'de', localeDeExtra);
registerLocaleData(localeEt, 'et', localeEtExtra);
registerLocaleData(localeEl, 'el', localeElExtra);
registerLocaleData(localeEn, 'en', localeEnExtra);
registerLocaleData(localeFr, 'fr', localeFrExtra);
registerLocaleData(localeGa, 'ga', localeGaExtra);
registerLocaleData(localeHr, 'hr', localeHrExtra);
registerLocaleData(localeIt, 'it', localeItExtra);
registerLocaleData(localeLv, 'lv', localeLvExtra);
registerLocaleData(localeLt, 'lt', localeLtExtra);
registerLocaleData(localeHu, 'hu', localeHuExtra);
registerLocaleData(localeMt, 'mt', localeMtExtra);
registerLocaleData(localeNl, 'nl', localeNlExtra);
registerLocaleData(localePl, 'pl', localePlExtra);
registerLocaleData(localePt, 'pt', localePtExtra);
registerLocaleData(localeRo, 'ro', localeRoExtra);
registerLocaleData(localeSk, 'sk', localeSkExtra);
registerLocaleData(localeSl, 'sl', localeSlExtra);
registerLocaleData(localeFi, 'fi', localeFiExtra);
registerLocaleData(localeSv, 'sv', localeSvExtra);

const languages = ['bg', 'es', 'cs', 'da', 'de', 'et', 'el', 'en', 'fr', 'ga', 'hr', 'it', 'lv', 'lt', 'hu', 'mt', 'nl', 'pl',
    'pt', 'ro', 'sk', 'sl', 'fi', 'sv'];

/**
 * Internationalization Configuration
 */
const i18nConfig: I18nConfig = {
    i18nLoader: {
        i18nFolders: ['elements/@remote.name@/bundles/assets/i18n-compiled'],
    },
    i18nService: {
        languages: languages,
        defaultLanguage: 'en',
    },
};

/**
 * Locale Configuration
 */
const localeConfig: LocaleServiceConfig = {
    bindWithTranslate: true,
};

/**
 * Global Configuration
 */
export const GLOBAL: GlobalConfig = {
    /* URL that needs to be used in the appRouting of the MWP */
    baseUrl: '@base.url@',
    // EXTRA_URLS_CONFIG_PLACEHOLDER
    /* Element tag name that needs to be unique - make sure it doesn't collide with any other MWP element */
    elementName: '@element.name@',
    /* in case you are using NgRx give it a unique name (mostly for debugging) */
    storeName: '@store.name@',
    i18n: i18nConfig,
    locale: localeConfig,
    eui: {
        assetsBaseUrl: 'assets/elements/@remote.name@/bundles/assets',
    },
};
