// 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 { StoreRouterConnectingModule } from '@ngrx/router-store';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { TranslateModule } from '@ngx-translate/core';

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

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

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

import { TOKEN, reducerProvider, metaReducers, runtimeChecks } from './core/reducers/index';
import { CustomSerializer } from './core/reducers/custom-route-serializer';

// APP RELATED
import { SharedModule } from './features/shared/shared.module';

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