import { ApplicationConfig, LOCALE_ID, provideAppInitializer, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';
import { provideRouter, withComponentInputBinding } from '@angular/router';

import { providePrimeNG } from 'primeng/config';
import { Theme } from '../../public/theme/theme';

import { routes } from './app.routes';
import { registerLocaleData } from '@angular/common';
import localeDeAt from '@angular/common/locales/de';
import { germanTranslation } from './core/config/translations';

import {provideTranslateService} from "@ngx-translate/core";
import {provideTranslateHttpLoader} from "@ngx-translate/http-loader";
import { provideHttpClient } from '@angular/common/http';
import { initializeTranslations } from './core/config/translation-init';

registerLocaleData(localeDeAt);

export const appConfig: ApplicationConfig = {
  providers: [
    provideBrowserGlobalErrorListeners(),
    provideZoneChangeDetection({ eventCoalescing: true }),
    provideRouter(routes, withComponentInputBinding()),
    provideHttpClient(),
    { provide: LOCALE_ID, useValue: 'de-AT' },
    providePrimeNG({
      theme: {
        preset: Theme,
        options: {
          darkModeSelector: '.dark',
          cssLayer: {
            name: 'primeng',
            order: 'theme, base, primeng'
          },
          prefix: '',
        },
      },
      translation: germanTranslation, // TODO: dynamic - selected language
    }),
    provideTranslateService({
      loader: provideTranslateHttpLoader({
        prefix: 'i18n/',
        suffix: '.json'
      }),
    }),
    provideAppInitializer(initializeTranslations),
  ],
};
