import { CommonModule } from '@angular/common';
import { ModuleWithProviders, NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { FlexLayoutModule } from '@angular/flex-layout';
import { TranslateModule } from '@ngx-translate/core';

import { KnkMaterialModule } from '../knk-material';

import { CoreRoutingModule } from './core.routing';

import {
    HeaderComponent, NotFoundComponent, RegistrationComponent
} from './components';
import {
    ApiConsumerTokenResolve, ApiUserTokenResolve, CountryService, HeaderService, LanguageResolve,
    LoaderService, TestParameterResolve, TokenService, UserService, UserTokenResolve
} from './shared';

@NgModule({
  imports: [CoreRoutingModule, CommonModule, FormsModule, KnkMaterialModule, TranslateModule, FlexLayoutModule],
    exports: [KnkMaterialModule, NotFoundComponent, RegistrationComponent, HeaderComponent],
    declarations: [NotFoundComponent, RegistrationComponent, HeaderComponent],
    providers: [UserService, HeaderService]
})
export class CoreModule {
    static forRoot(): ModuleWithProviders {
        console.log('core module for root');
        return {
            ngModule: CoreModule,
            providers: [
                UserService, ApiUserTokenResolve, ApiConsumerTokenResolve, CountryService, LanguageResolve, UserTokenResolve,
                TokenService, TestParameterResolve, HeaderService, LoaderService]
        };
    }
    constructor() { console.log('core module ctor'); }
}
