// ANGULAR & 3rd PARTIES
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { HttpClientModule } from '@angular/common/http';
import { StoreModule } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { TranslateModule } from '@ngx-translate/core';

// eUI IMPORTS
import {
    CoreModule, CoreModuleEffects, translateConfig, EUI_CONFIG_TOKEN,
} from '@eui/core';
import { EuiAllModule } from '@eui/components';

import { appConfig } from '../config/index';
import { environment } from '../environments/environment';

// APP ROUTES & ROOT COMPONENTS
import { AppRoutingModule } from '../../app/app-routing.module';
import { AppComponent } from '../../app/app.component';

import { TOKEN, reducerProvider, metaReducers, runtimeChecks } from './core/reducers/index';

// APP ROOT MODULE
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        HttpClientModule,
        StoreModule.forRoot(TOKEN, { metaReducers, runtimeChecks }),
        StoreDevtoolsModule.instrument({ name: 'CSDR App', maxAge: 150, logOnly: environment.production }),
        EffectsModule.forRoot([...CoreModuleEffects]),
        TranslateModule.forRoot(translateConfig),
        CoreModule.forRoot(),
        AppRoutingModule,
        EuiAllModule,
    ],
    declarations: [
        AppComponent,
    ],
    providers: [
        { provide: EUI_CONFIG_TOKEN, useValue: { appConfig: appConfig, environment: environment } },
        reducerProvider,
    ],
    bootstrap: [
        AppComponent,
    ],
})
export class AppModule {
}
