import { NgModule, ModuleWithProviders } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import {ToasterModule, ToasterService} from 'angular2-toaster/angular2-toaster';

import {NgxSelectOptionDirective, NgxSelectOptionNotFoundDirective, NgxSelectOptionSelectedDirective} from './components/flexSelect/FlexSelect.directive';
import {FlexModalComponent} from './common/FlexModal.component';
import {BaseComponent} from './common/Base.component';

import { AccordionModule } from 'ngx-bootstrap/accordion';
import { AlertModule } from 'ngx-bootstrap/alert';
import { ButtonsModule } from 'ngx-bootstrap/buttons';
import { CarouselModule } from 'ngx-bootstrap/carousel';
import { CollapseModule } from 'ngx-bootstrap/collapse';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { ModalModule } from 'ngx-bootstrap/modal';
import { ProgressbarModule } from 'ngx-bootstrap/progressbar';
import { RatingModule } from 'ngx-bootstrap/rating';
import { TabsModule } from 'ngx-bootstrap/tabs';
import { TimepickerModule } from 'ngx-bootstrap/timepicker';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { PopoverModule } from 'ngx-bootstrap/popover';
import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
import { DatepickerModule } from 'ngx-bootstrap/datepicker';
import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';

import { ColorsService } from './colors/colors.service';
import { CheckallDirective } from './directives/checkall/checkall.directive';
import { NowDirective } from './directives/now/now.directive';
import { ScrollableDirective } from './directives/scrollable/scrollable.directive';
import { JqcloudDirective } from './directives/jqcloud/jqcloud.directive';
import { CookieService } from 'ngx-cookie-service';
import { FramePagerComponent } from '../core/pager/pager.component';
import { FrameStatusPipe } from './pipe/frame-status.pipe';
import {FrameDictPipe} from './pipe/frame-dict.pipe';
import {FrameDictDirective} from './directives/framedict/frame-dict.directive';
import {FrameRoleDirective} from './directives/framerole/frame-role.directive';
import {FrameUploaderComponent} from '../core/uploader/uploader.component';

import {FileUploadModule} from 'ng2-file-upload';
import { FrameParamPipe } from './pipe/frame-param.pipe';

import { FlexTableComponent } from './common/FlexTable.component';
import { DatePickerDirective } from './directives/datepicker/datepicker.directive';
import { FlexSelectComponent } from './components/flexSelect/FlexSelect.component';
import { StrReplacePipe } from './pipe/str-replace.pipe';
import { SubStrPipe } from './pipe/sub-str.pipe';
import {IdNumberPipe} from './pipe/id-number.pipe';


@NgModule({
    imports: [
        CommonModule,
        FormsModule,
        ReactiveFormsModule,
        TranslateModule,
        AccordionModule.forRoot(),
        AlertModule.forRoot(),
        ButtonsModule.forRoot(),
        CarouselModule.forRoot(),
        CollapseModule.forRoot(),
        DatepickerModule.forRoot(),
        BsDatepickerModule.forRoot(),
        BsDropdownModule.forRoot(),
        ModalModule.forRoot(),
        ProgressbarModule.forRoot(),
        RatingModule.forRoot(),
        TabsModule.forRoot(),
        TimepickerModule.forRoot(),
        TooltipModule.forRoot(),
        PopoverModule.forRoot(),
        TypeaheadModule.forRoot(),
        ToasterModule,
        FileUploadModule,

    ],
    providers: [
        ColorsService,
        CookieService,
        ToasterService
    ],
    declarations: [
        CheckallDirective,
        NowDirective,
        ScrollableDirective,
        JqcloudDirective,

        NgxSelectOptionDirective,
        NgxSelectOptionSelectedDirective,
        NgxSelectOptionNotFoundDirective,
        FlexModalComponent,
        BaseComponent,
        
        FramePagerComponent,
		FrameUploaderComponent,

        FrameDictPipe,
        FrameStatusPipe,
        FrameParamPipe,
        StrReplacePipe,
        SubStrPipe,

        FrameDictDirective,
        FrameRoleDirective,

        FlexTableComponent,
        DatePickerDirective,
        FlexSelectComponent,
        IdNumberPipe,
        
    ],
    exports: [
        CommonModule,
        FormsModule,
        ReactiveFormsModule,
        TranslateModule,
        RouterModule,
        AccordionModule,
        AlertModule,
        ButtonsModule,
        CarouselModule,
        CollapseModule,
        DatepickerModule,
        BsDatepickerModule,
        BsDropdownModule,
        ModalModule,
        ProgressbarModule,
        RatingModule,
        TabsModule,
        TimepickerModule,
        FileUploadModule,
        TooltipModule,
        PopoverModule,
        TypeaheadModule,
        ToasterModule,
        CheckallDirective,
        NowDirective,
        ScrollableDirective,
        JqcloudDirective,

        FramePagerComponent,
		FrameUploaderComponent,

        FrameDictPipe,
        FrameStatusPipe,
        FrameParamPipe,
        StrReplacePipe,
        SubStrPipe,

        FrameDictDirective,
        FrameRoleDirective,

        FlexTableComponent,
        DatePickerDirective,
        FlexSelectComponent,
        IdNumberPipe
    ]
})

// https://github.com/ocombe/ng2-translate/issues/209
export class SharedModule {
    static forRoot(): ModuleWithProviders {
        return {
            ngModule: SharedModule
        };
    }
}
