import {BrowserModule} from '@angular/platform-browser';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {RouterModule} from '@angular/router';
import {NgModule} from '@angular/core';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {HttpClientModule, HttpClient} from '@angular/common/http';
import {MatDialogModule} from '@angular/material/dialog';
import {NgxJsonapiModule} from 'ngx-jsonapi';
import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import {CookieService} from 'ngx-cookie-service';
import {LoadingBarRouterModule} from '@ngx-loading-bar/router';
import {PerfectScrollbarModule} from 'ngx-perfect-scrollbar';
import {PERFECT_SCROLLBAR_CONFIG} from 'ngx-perfect-scrollbar';
import {PerfectScrollbarConfigInterface} from 'ngx-perfect-scrollbar';
import {AgmCoreModule} from '@agm/core';


import {
  MatAutocompleteModule,
  MatInputModule,
  MatSidenavModule,
  MatCardModule,
  MatMenuModule,
  MatCheckboxModule,
  MatIconModule,
  MatButtonModule,
  MatToolbarModule,
  MatTabsModule,
  MatListModule,
  MatSlideToggleModule,
  MatSelectModule,
  MatProgressBarModule, MatFormFieldModule
} from '@angular/material';
import {FlexLayoutModule} from '@angular/flex-layout';
import {BidiModule} from '@angular/cdk/bidi';

import {
  MenuComponent,
  SidebarComponent,
  NotificationComponent,
  OptionsComponent,
  AdminLayoutComponent,
  AuthLayoutComponent,
  AccordionAnchorDirective,
  AccordionLinkDirective,
  AccordionDirective,
  HeaderComponent
} from './core';

import {AppRoutes} from './app.routing';
import {AppComponent} from './app.component';
import {AuthService} from './public/services/auth.service';
import {AppService} from './public/services/app.service';
import {TypesService} from './public/services/type.service';
import {DialogComponent} from './public/baseComponent/dialog/dialog.component';
import {MessagingService} from './public/services/messaging.service';
import {HttpModule} from '@angular/http';
import {UsersService} from './public/services/user.service';
import {AngularFireModule} from 'angularfire2';
import {AngularFireDatabaseModule} from 'angularfire2/database';
import {AngularFireAuthModule} from 'angularfire2/auth';
import {Dialog} from './public/dialog';
import {InfoWindowComponent} from './components/map/map/info-window/info-window.component';
import {AddressComponent} from './components/map/map/address/address.component';
import {GeneralComponent} from './public/baseComponent/general/general.component';
import {EditComponent} from './public/baseComponent/edit/edit.component';
import {ServicesService} from './public/services/services.service';
import {RequestsService} from './public/services/requests.service';


export function createTranslateLoader(http: HttpClient) {
  return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
  suppressScrollX: true,
  wheelSpeed: 2,
  wheelPropagation: true,
  minScrollbarLength: 20
};

@NgModule({
  declarations: [
    GeneralComponent,
    EditComponent,
    AddressComponent,
    InfoWindowComponent,
    AppComponent,
    HeaderComponent,
    SidebarComponent,
    NotificationComponent,
    OptionsComponent,
    MenuComponent,
    AdminLayoutComponent,
    AuthLayoutComponent,
    AccordionAnchorDirective,
    AccordionLinkDirective,
    AccordionDirective,
    DialogComponent,
    GeneralComponent,
  ],
  imports: [
    MatAutocompleteModule,
    ReactiveFormsModule,
    FormsModule,
    AgmCoreModule,
    MatDialogModule,
    AngularFireModule.initializeApp({
      apiKey: 'AIzaSyDwvNEVZT6CNth_aJEM0uhTf8ksbDjNQIw',
      authDomain: 'bimar-22eb9.firebaseapp.com',
      databaseURL: 'https://bimar-22eb9.firebaseio.com',
      projectId: 'bimar-22eb9',
      storageBucket: '',
      // messagingSenderId: "721004467623",
      messagingSenderId: '101121265784'
    }),
    AngularFireDatabaseModule,
    AngularFireAuthModule,
    HttpModule,
    MatDialogModule,
    NgxJsonapiModule.forRoot({
      url: '//hpen.ir/test/public_html/api/v1/'
    }),
    MatFormFieldModule,
    BrowserModule,
    BrowserAnimationsModule,
    RouterModule.forRoot(AppRoutes),
    FormsModule,
    HttpClientModule,
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: (createTranslateLoader),
        deps: [HttpClient]
      }
    }),
    LoadingBarRouterModule,
    MatSidenavModule,
    MatCardModule,
    MatMenuModule,
    MatCheckboxModule,
    MatIconModule,
    MatButtonModule,
    MatToolbarModule,
    MatTabsModule,
    MatListModule,
    MatSlideToggleModule,
    MatSelectModule,
    MatProgressBarModule,
    FlexLayoutModule,
    BidiModule,
    AgmCoreModule.forRoot({apiKey: 'AIzaSyB3HQ_Gk_XRt6KitPdiHQNGpVn0NDwQGMI'}),
    PerfectScrollbarModule,
    MatInputModule,
  ],
  providers: [AuthService, TypesService, AppService,
    MessagingService, CookieService, UsersService, Dialog, ServicesService, RequestsService,
    {
      provide: PERFECT_SCROLLBAR_CONFIG,
      useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG
    }
  ],
  entryComponents: [DialogComponent, InfoWindowComponent, AddressComponent, EditComponent],
  bootstrap: [AppComponent]
})
export class AppModule {
}
