import { MatTooltipModule } from '@angular/material/tooltip';
import { NgModule, ModuleWithProviders } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ReactiveFormsModule } from '@angular/forms';

import { FlexLayoutModule } from '@angular/flex-layout';

import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatDialogModule } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatSliderModule } from '@angular/material/slider';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatInputModule } from '@angular/material/input';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { MatMenuModule } from '@angular/material/menu';
import { MatDatepickerModule } from '@angular/material/datepicker';
import {
  MatTabsModule,
  MatSelectModule,
  MatSlideToggleModule,
  MatTableModule,
  MatPaginatorModule
} from '@angular/material';

import { DragDropModule } from '@angular/cdk/drag-drop';

import { TranslateModule } from '@ngx-translate/core';

import { FileUploadQueueComponent } from './components/file-upload-queue.component';
import { FloatActionButtonComponent } from './components/float-action-button.component';
import { FileViewerComponent } from './components/file-viewer.component';
import { MediaViewerComponent } from './components/media-viewer.component';
import { ExpansionPanelComponent } from './components/expansion-panel.component';
import { SplitButtonComponent } from './components/split-button.component';
import { PickDateComponent } from './components/pick-date.component';
import { PickTimeComponent } from './components/pick-time.component';
import { StepInputComponent } from './components/step-input.component';
import { StickerSelectorComponent } from './components/sticker-selector.component';
import { InlineEditInputComponent } from './components/inline-edit-input.component';

import { BinaryViewerComponent } from './components/file-viewer/binary-viewer.component';
import { DocumentViewerComponent } from './components/file-viewer/document-viewer.component';
import { ImageViewerComponent } from './components/file-viewer/image-viewer.component';
import { SoundViewerComponent } from './components/file-viewer/sound-viewer.component';
import { VideoViewerComponent } from './components/file-viewer/video-viewer.component';

import { BottomSheetService } from './services/bottom-sheet.service';
import { ClipboardService } from './services/clipboard.service';
import { DialogService } from './services/dialog.service';
import { SnackBarService } from './services/snack-bar.service';
import { SplashScreenService } from './services/splash-screen.service';
import { TranslateService } from './services/translate.service';
import { DateService } from './services/date.service';
import { PaginatorIntlService } from './services/paginator-intl.service';

import { ClickOutsideDirective } from './directives/click-outside.directive';
import { FileUploadForDirective } from './directives/file-upload-for.directive';
import { ImageDirective } from './directives/image.directive';
import { CdkVirtualScrollViewportPatchDirective } from './directives/cdk-virtual-scroll-viewport-patch.directive';

import { AlertDialogComponent } from './dialogs/alert.dialog.component';
import { ConfirmDialogComponent } from './dialogs/confirm.dialog.component';

import { BytesPipe } from './pipes/bytes.pipe';
import { LinefeedToHtmlPipe, HtmlToLinefeedPipe } from './pipes/linefeed.pipe';
import { SecondsToMinutesPipe } from './pipes/seconds-to-minutes.pipe';
import { LinkyPipe } from './pipes/linky.pipe';
import { TranslatePipe } from './pipes/translate.pipe';
import { DatePipe } from './pipes/date.pipe';
import { SafeHtmlPipe } from './pipes/safe-html.pipe';

import {
  StringEmptyCheckPipe,
  StringFormatterPhonePipe
} from './pipes/string.pipe';
import { ClickDebounceDirective } from './directives/click-debounce.directive';
import { TranslationSectionComponent } from './components/translation-section.component';
import { AlertSnackbarComponent } from './snackbars/alert.snackbar.component';
import { IntegratedSearchFormComponent } from './components/integrated-search-form.component';
import { IntegratedSearchComponent } from './components/integrated-search.component';
import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';

const COMPONENTS = [
  FileUploadQueueComponent,
  FloatActionButtonComponent,
  FileViewerComponent,
  ExpansionPanelComponent,
  StickerSelectorComponent,
  SplitButtonComponent,
  PickDateComponent,
  PickTimeComponent,
  StepInputComponent,
  TranslationSectionComponent,
  InlineEditInputComponent,
  IntegratedSearchComponent,
  IntegratedSearchFormComponent,

  BinaryViewerComponent,
  DocumentViewerComponent,
  ImageViewerComponent,
  SoundViewerComponent,
  VideoViewerComponent,
  MediaViewerComponent
];
const DIALOGS = [
  AlertDialogComponent,
  ConfirmDialogComponent,
  AlertSnackbarComponent
];
const DIRECTIVES = [
  ClickOutsideDirective,
  FileUploadForDirective,
  ImageDirective,
  CdkVirtualScrollViewportPatchDirective,
  ClickDebounceDirective
];
const PIPES = [
  BytesPipe,
  LinefeedToHtmlPipe,
  HtmlToLinefeedPipe,
  SecondsToMinutesPipe,
  LinkyPipe,
  TranslatePipe,
  DatePipe,
  StringEmptyCheckPipe,
  StringFormatterPhonePipe,
  SafeHtmlPipe
];
const SERVICES = [
  BottomSheetService,
  ClipboardService,
  DialogService,
  SnackBarService,
  SplashScreenService,
  TranslateService,
  DateService,
  PaginatorIntlService
];

@NgModule({
  imports: [
    CommonModule,
    ReactiveFormsModule,
    FlexLayoutModule,
    MatButtonModule,
    MatCardModule,
    MatDialogModule,
    MatIconModule,
    MatInputModule,
    MatProgressBarModule,
    MatSliderModule,
    MatSnackBarModule,
    MatToolbarModule,
    MatTooltipModule,
    MatTabsModule,
    MatFormFieldModule,
    MatButtonToggleModule,
    MatMenuModule,
    MatDatepickerModule,
    MatSelectModule,
    MatSlideToggleModule,
    MatTableModule,
    MatPaginatorModule,

    PerfectScrollbarModule,
    DragDropModule,
    TranslateModule
  ],
  exports: [...COMPONENTS, ...DIRECTIVES, ...PIPES],
  declarations: [...COMPONENTS, ...DIALOGS, ...DIRECTIVES, ...PIPES],
  entryComponents: [...DIALOGS]
})
export class UCapUiModule {
  public static forRoot(): ModuleWithProviders<UCapUiModule> {
    return {
      ngModule: UCapUiModule,
      providers: [...SERVICES]
    };
  }
}
