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
} from './components';
import {
    ApiConsumerTokenResolve, ApiUserTokenResolve, CountryService, HeaderService, LanguageResolve,
    LanguageService, LoaderService, TestParameterResolve, TokenService, UserService, UserTokenResolve
} from './shared';

import { ReactiveFormsModule } from '@angular/forms';  // <-- #1 import module
import { Registration1Component } from './components/registration1/registration1.component';

import { FeedsComponent } from '../feeds/feeds.component';

import { EmailDirective } from '../core/shared/patternValidator';

import { WizardFormComponent } from '../wizardform/wizardform.component';

import { StepOneComponent } from '../wizard/stepone/wizardstepone.component';
import { StepTwoComponent } from '../wizard/steptwo/wizardsteptwo.component';

import { WizardComponent, WizardStepDirective } from '../wizard/wizard.component';

import { FormlyModule } from '@ngx-formly/core';
import { FormlyMaterialModule } from '@ngx-formly/material';

@NgModule({
  imports: [CoreRoutingModule, CommonModule, FormsModule, KnkMaterialModule, TranslateModule, FlexLayoutModule,
    ReactiveFormsModule, FormlyModule, FormlyMaterialModule],
    exports: [KnkMaterialModule, NotFoundComponent, HeaderComponent, Registration1Component, EmailDirective,
        FeedsComponent, WizardFormComponent, StepOneComponent, WizardComponent, WizardStepDirective, FormlyModule, FormlyMaterialModule],
    declarations: [NotFoundComponent, HeaderComponent, Registration1Component, EmailDirective, FeedsComponent,
        WizardFormComponent, StepOneComponent, StepTwoComponent, WizardComponent, WizardStepDirective],
    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, LanguageService]
        };
    }
    constructor() { console.log('core module ctor'); }
}
