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';
import { WorkflowAdminAdvanceComponent } from './samwf/workflow-admin-advance/workflow-admin-advance.component';
import { TaskFormValidatorsComponent } from './samwf/tasks-module/task-module-form/task-form-validators/task-form-validators.component';
import { WorkflowFieldsFormComponent } from './samwf/workflow-detail/workflow-fields-form/workflow-fields-form.component';

@NgModule({
  declarations: [
    AppComponent,
    WorkflowComponent,
    WorkflowFormComponent,
    WorkflowDetailComponent,
    TranslationComponent,
    WorkflowPasosFormComponent,
    WorkflowUsersComponent,
    WorkflowDiagramaComponent,
    WorkflowVersionsHistoryComponent,
    TasksModuleComponent,
    RequestWorkflowFormComponent,
    WorkflowRequestWorkflowComponent,
    WorkflowAdvanceComponent,
    WorkflowDetailAdvanceComponent,
    WorkflowHistoryNotificationComponent,
    TaskModuleFormComponent,
    WorkflowAdminAdvanceComponent,
    TaskFormValidatorsComponent,
    WorkflowFieldsFormComponent,
  ],
  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);
}
