import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatIcon, MatIconModule } from '@angular/material/icon';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';

// Translation
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpClient } from '@angular/common/http';

// Modulos
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { MaterialModule } from './material/material.module';
import { WorkflowComponent } from './SAMWF/workflow.component';
import { WorkflowFormComponent } from './SAMWF/workflow-form/workflow-form.component';
import { WorkflowDetailComponent } from './SAMWF/workflow-detail/workflow-detail.component';
import { TranslationComponent } from './translation/translation.component';
import { MultiSelectModule } from '@syncfusion/ej2-angular-dropdowns';
import { WorkflowPasosFormComponent } from './SAMWF/workflow-detail/workflow-tasks-form/workflow-pasos-form.component';
import { WorkflowUsersComponent } from './SAMWF/workflow-detail/workflow-users/workflow-users.component';
import { WorkflowDiagramaComponent } from './SAMWF/workflow-detail/workflow-diagrama/workflow-diagrama.component';

// Diagramas
import {
  DiagramModule,
  SymbolPaletteModule,
} from '@syncfusion/ej2-angular-diagrams';
import {
  HierarchicalTreeService,
  MindMapService,
  RadialTreeService,
  ComplexHierarchicalTreeService,
} from '@syncfusion/ej2-angular-diagrams';
import {
  DataBindingService,
  SnappingService,
  PrintAndExportService,
  BpmnDiagramsService,
} from '@syncfusion/ej2-angular-diagrams';
import {
  SymmetricLayoutService,
  ConnectorBridgingService,
  UndoRedoService,
  LayoutAnimationService,
} from '@syncfusion/ej2-angular-diagrams';
import {
  DiagramContextMenuService,
  ConnectorEditingService,
} from '@syncfusion/ej2-angular-diagrams';
import { ScrollingModule } from '@angular/cdk/scrolling';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { WorkflowVersionsHistoryComponent } from './SAMWF/workflow-versions-history/workflow-versions-history.component';
import { TasksModuleComponent } from './SAMWF/tasks-module/tasks-module.component';
import { RequestWorkflowFormComponent } from './SAMWF-USER/workflow-request-workflow/request-workflow-form/request-workflow-form.component';
import { WorkflowRequestWorkflowComponent } from './SAMWF-USER/workflow-request-workflow/workflow-request-workflow.component';
import { WorkflowAdvanceComponent } from './SAMWF-USER/workflow-advance/workflow-advance.component';
import { WorkflowDetailAdvanceComponent } from './SAMWF-USER/workflow-advance/workflow-detail-advance/workflow-detail-advance.component';
import { WorkflowHistoryNotificationComponent } from './SAMWF-USER/workflow-history-notification/workflow-history-notification.component';
import { TaskModuleFormComponent } from './SAMWF/tasks-module/task-module-form/task-module-form.component';

@NgModule({
  declarations: [
    AppComponent,
    WorkflowComponent,
    WorkflowFormComponent,
    WorkflowDetailComponent,
    TranslationComponent,
    WorkflowPasosFormComponent,
    WorkflowUsersComponent,
    WorkflowDiagramaComponent,
    WorkflowVersionsHistoryComponent,
    TasksModuleComponent,
    RequestWorkflowFormComponent,
    WorkflowRequestWorkflowComponent,
    WorkflowAdvanceComponent,
    WorkflowDetailAdvanceComponent,
    WorkflowHistoryNotificationComponent,
    TaskModuleFormComponent,
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    FormsModule,
    HttpClientModule,
    BrowserAnimationsModule,
    MaterialModule,
    DiagramModule,
    MultiSelectModule,
    SymbolPaletteModule,
    ScrollingModule,

    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: HttpLoaderFactory,
        deps: [HttpClient],
      },
    }),
    NgxSkeletonLoaderModule.forRoot({
      animation: 'pulse',
      loadingText: 'This item is actually loading...',
    }),
  ],
  providers: [
    HierarchicalTreeService,
    MindMapService,
    RadialTreeService,
    ComplexHierarchicalTreeService,
    DataBindingService,
    SnappingService,
    PrintAndExportService,
    BpmnDiagramsService,
    SymmetricLayoutService,
    ConnectorBridgingService,
    UndoRedoService,
    LayoutAnimationService,
    DiagramContextMenuService,
    ConnectorEditingService,
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}

export function HttpLoaderFactory(http: HttpClient) {
  return new TranslateHttpLoader(http);
}
