import {BrowserModule, DomSanitizer} from '@angular/platform-browser';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {RouterModule} from '@angular/router';
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {HttpClientModule} from '@angular/common/http';
import {HttpModule} from '@angular/http';
import {CookieService} from 'ngx-cookie-service';
import {NgxJsonapiModule} from 'ngx-jsonapi';
import {
  DateAdapter,
  MAT_DATE_FORMATS, MAT_DATE_LOCALE,
  MatAutocompleteModule, MatDatepickerModule,
  MatDialogModule,
  MatIconRegistry,
  MatInputModule, MatNativeDateModule
} from '@angular/material';
import {ReactiveFormsModule} from '@angular/forms';
import {PerfectScrollbarModule} from 'ngx-perfect-scrollbar';
import {PERFECT_SCROLLBAR_CONFIG} from 'ngx-perfect-scrollbar';
import {PerfectScrollbarConfigInterface} from 'ngx-perfect-scrollbar';

import {
  MatSidenavModule,
  MatCardModule,
  MatMenuModule,
  MatCheckboxModule,
  MatIconModule,
  MatButtonModule,
  MatToolbarModule,
  MatTabsModule,
  MatListModule,
  MatSlideToggleModule,
  MatSelectModule,
  MatProgressBarModule,
  MatGridListModule,
} from '@angular/material';
import {FlexLayoutModule} from '@angular/flex-layout';
import {BidiModule} from '@angular/cdk/bidi';
import {
  MenuComponent,
  HeaderComponent,
  SidebarComponent,
  NotificationComponent,
  OptionsComponent,
  AdminLayoutComponent,
  AuthLayoutComponent,
  AccordionAnchorDirective,
  AccordionLinkDirective,
  AccordionDirective
} from './core';
import {AppRoutes} from './app.routing';
import {AppComponent} from './app.component';
import {AuthService} from './classes/servicess/auth.service';
import {AuthGuard} from './classes/guards/auth.guard';
import {ListComponent} from './classes/base_components/list/list.component';
import {DialogComponent} from './classes/base_components/dialog/dialog.component' ;
import {Dialog} from './classes/base_components/dialog/dialog';
import {LoadingModule} from 'ngx-loading';
import {GuestGuard} from './classes/guards/guest.guard';
import {EditUsersComponent} from './components/user/users/edit-users/edit-users.component';
import {UsersService} from './classes/resorcess/users.service';
import {RolesService} from './classes/resorcess/roles.service';
import {EditRolesComponent} from './components/user/roles/edit-roles/edit-roles.component';
import {EditComponent} from './classes/base_components/edit/edit.component';
import {PermissionGroupsService, PermissionsService} from './classes/resorcess/permissions.service';
import {EditPermissionsComponent} from './components/user/permissions/edit-permissions/edit-permissions.component';
import {MatRadioModule} from '@angular/material/radio';
import {MatChipsModule} from '@angular/material/chips';
import {NgxDatatableModule} from '@swimlane/ngx-datatable';


import {GlobalService} from './classes/servicess/global.service';
import {environment} from '../environments/environment';
import {MatTooltipModule} from '@angular/material/tooltip';
import {JalaliMomentDateAdapter} from './classes/jalali/jalali-moment-dateAdapter';
import {JALALI_MOMENT_FORMATS} from './classes/jalali/jalali-moment-formats';
import {MatExpansionModule} from '@angular/material/expansion';
import {LightboxModule} from 'ngx-lightbox';
import {UniversitiesService} from './classes/resorcess/universities.service';
import {RequestsService} from './classes/resorcess/requests.service';
import {CitiesService} from './classes/resorcess/cities.service';
import {EditCitiesComponent} from './components/basics/cities/editCities/editCities.component';
import {EditUniversitiesComponent} from './components/basics/universities/editUniversities/editUniversities.component';
import {EditUnitiesComponent} from './components/basics/unites/editUnities/editUnities.component';
import {UnitsService} from './classes/resorcess/units.service';
import {ImagesService} from './classes/resorcess/images.service';
import {TypesService} from './classes/resorcess/types.service';
import {EditRequestsComponent} from './components/requests/requests/edit-requests/edit-requests.component';
import {EditTypesComponent} from './components/user/types/edit-types/edit-types.component';
import {MajoreService} from './classes/resorcess/majore.service';


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

@NgModule({
  declarations: [
    EditTypesComponent,
    EditRequestsComponent,
    EditUnitiesComponent,
    EditUniversitiesComponent,
    EditCitiesComponent,
    EditPermissionsComponent,
    EditComponent,
    EditRolesComponent,
    EditUsersComponent,
    AppComponent,
    HeaderComponent,
    SidebarComponent,
    NotificationComponent,
    OptionsComponent,
    MenuComponent,
    AdminLayoutComponent,
    AuthLayoutComponent,
    AccordionAnchorDirective,
    AccordionLinkDirective,
    AccordionDirective,
    ListComponent,
    DialogComponent,
  ],
  imports: [
    LightboxModule,
    MatExpansionModule,
    MatGridListModule,
    MatNativeDateModule,
    MatDatepickerModule,
    BrowserAnimationsModule,
    LoadingModule.forRoot({
      backdropBackgroundColour: 'rgba(0,0,0,0.1)',
      backdropBorderRadius: '4px',
      primaryColour: '#0000ff',
      secondaryColour: '#0000ff',
      tertiaryColour: '#0000ff'
    }),
    NgxDatatableModule,
    MatAutocompleteModule,
    MatChipsModule,
    MatRadioModule,
    LoadingModule,
    ReactiveFormsModule,
    MatInputModule,
    MatDialogModule,
    HttpModule,
    NgxJsonapiModule.forRoot({
      url: environment.app_url,
    }),
    BrowserModule,
    RouterModule.forRoot(AppRoutes, {useHash: true}),
    FormsModule,
    HttpClientModule,
    MatSidenavModule,
    MatCardModule,
    MatMenuModule,
    MatCheckboxModule,
    MatIconModule,
    MatButtonModule,
    MatToolbarModule,
    MatTabsModule,
    MatListModule,
    MatSlideToggleModule,
    MatSelectModule,
    MatProgressBarModule,
    FlexLayoutModule,
    BidiModule,
    PerfectScrollbarModule,
    MatTooltipModule,
  ],
  providers: [
    MajoreService,
    TypesService,
    ImagesService,
    UnitsService,
    CitiesService,
    RequestsService,
    UniversitiesService,
    GlobalService,
    AuthService,
    UsersService,
    CookieService,
    AuthGuard,
    GuestGuard,
    Dialog,
    RolesService,
    PermissionsService,
    PermissionGroupsService,
    {
      provide: PERFECT_SCROLLBAR_CONFIG,
      useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG,

    },
    {provide: DateAdapter, useClass: JalaliMomentDateAdapter, deps: [MAT_DATE_LOCALE]},
    {provide: MAT_DATE_FORMATS, useValue: JALALI_MOMENT_FORMATS}
  ],

  bootstrap: [AppComponent],
  entryComponents: [
    EditTypesComponent ,
    EditRequestsComponent,
    EditUnitiesComponent,
    EditPermissionsComponent,
    DialogComponent,
    EditComponent,
    EditUsersComponent,
    EditRolesComponent,
    EditCitiesComponent,
    EditUniversitiesComponent,
  ]
})
export class AppModule {

  constructor(matIconRegistry: MatIconRegistry, domSanitizer: DomSanitizer, private global: GlobalService) {
    matIconRegistry.addSvgIconSet(domSanitizer.bypassSecurityTrustResourceUrl('./assets/mdi.svg'));
    // Or whatever path you placed mdi.svg at\
  }
}
