import { OverlayModule } from '@angular/cdk/overlay';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { PendingChangesGuard } from '@guards/can-deactivate.guard';
import {
    CapitalizePipe,
    CircleButtonComponent,
    DetailsRadioComponent,
    DynamicInputComponent,
    EditableInputComponent,
    EmptyStateComponent,
    HasScrollbarDirective,
    IconButtonComponent,
    InputWithActionComponent,
    IqserAllowDirective,
    IqserDenyDirective,
    IqserHelpModeModule,
    IqserRoutes,
    IqserUploadFileModule,
    LogPipe,
    PreventDefaultDirective,
    RoundCheckboxComponent,
    StopPropagationDirective,
} from '@iqser/common-ui';
import { IqserFiltersModule } from '@iqser/common-ui/lib/filtering';
import { StatusBarComponent } from '@iqser/common-ui/lib/shared';
import { TenantPipe } from '@iqser/common-ui/lib/tenants';
import { IqserUsersModule } from '@iqser/common-ui/lib/users';
import { TranslateModule } from '@ngx-translate/core';
import { SharedModule } from '@shared/shared.module';
import { SharedDossiersModule } from '../shared-dossiers/shared-dossiers.module';
import { AnnotationActionsComponent } from './components/annotation-actions/annotation-actions.component';
import { AnnotationCardComponent } from './components/annotation-card/annotation-card.component';
import { AnnotationDetailsComponent } from './components/annotation-details/annotation-details.component';
import { AnnotationReferenceComponent } from './components/annotation-reference/annotation-reference.component';
import { AnnotationReferencesListComponent } from './components/annotation-references-list/annotation-references-list.component';
import { AnnotationReferencesPageIndicatorComponent } from './components/annotation-references-page-indicator/annotation-references-page-indicator.component';
import { AnnotationWrapperComponent } from './components/annotation-wrapper/annotation-wrapper.component';
import { AnnotationsListComponent } from './components/annotations-list/annotations-list.component';
import { CommentsComponent } from './components/comments/comments.component';
import { DocumentInfoComponent } from './components/document-info/document-info.component';
import { FileWorkloadComponent } from './components/file-workload/file-workload.component';
import { HighlightsSeparatorComponent } from './components/highlights-separator/highlights-separator.component';
import { PageExclusionComponent } from './components/page-exclusion/page-exclusion.component';
import { PageIndicatorComponent } from './components/page-indicator/page-indicator.component';
import { PagesComponent } from './components/pages/pages.component';
import { ReadonlyBannerComponent } from './components/readonly-banner/readonly-banner.component';
import { FilePreviewRightContainerComponent } from './components/right-container/file-preview-right-container.component';
import { UserManagementComponent } from './components/user-management/user-management.component';
import { ViewSwitchComponent } from './components/view-switch/view-switch.component';
import { AcceptRecommendationDialogComponent } from './dialogs/accept-recommendation-dialog/accept-recommendation-dialog.component';
import { AddHintDialogComponent } from './dialogs/add-hint-dialog/add-hint-dialog.component';
import { ChangeLegalBasisDialogComponent } from './dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component';
import { AddAnnotationDialogComponent } from './dialogs/docu-mine/add-annotation-dialog/add-annotation-dialog.component';
import { EditAnnotationDialogComponent } from './dialogs/docu-mine/edit-annotation-dialog/edit-annotation-dialog.component';
import { RemoveAnnotationDialogComponent } from './dialogs/docu-mine/remove-annotation-dialog/remove-annotation-dialog.component';
import { ResizeAnnotationDialogComponent } from './dialogs/docu-mine/resize-annotation-dialog/resize-annotation-dialog.component';
import { DocumentInfoDialogComponent } from './dialogs/document-info-dialog/document-info-dialog.component';
import { EditRedactionDialogComponent } from './dialogs/edit-redaction-dialog/edit-redaction-dialog.component';
import { ForceAnnotationDialogComponent } from './dialogs/force-redaction-dialog/force-annotation-dialog.component';
import { HighlightActionDialogComponent } from './dialogs/highlight-action-dialog/highlight-action-dialog.component';
import { ImportRedactionsDialogComponent } from './dialogs/import-redactions-dialog/import-redactions-dialog';
import { ManualAnnotationDialogComponent } from './dialogs/manual-redaction-dialog/manual-annotation-dialog.component';
import { RedactRecommendationDialogComponent } from './dialogs/redact-recommendation-dialog/redact-recommendation-dialog.component';
import { RedactTextDialogComponent } from './dialogs/redact-text-dialog/redact-text-dialog.component';
import { RemoveRedactionDialogComponent } from './dialogs/remove-redaction-dialog/remove-redaction-dialog.component';
import { ResizeRedactionDialogComponent } from './dialogs/resize-redaction-dialog/resize-redaction-dialog.component';
import { FilePreviewScreenComponent } from './file-preview-screen.component';
import { DocumentUnloadedGuard } from './services/document-unloaded.guard';
import { FilePreviewDialogService } from './services/file-preview-dialog.service';
import { ManualRedactionService } from './services/manual-redaction.service';
import { TablesService } from './services/tables.service';
import { ReplaceNbspPipe } from '@common-ui/pipes/replace-nbsp.pipe';

const routes: IqserRoutes = [
    {
        path: '',
        component: FilePreviewScreenComponent,
        pathMatch: 'full',
        canDeactivate: [PendingChangesGuard, DocumentUnloadedGuard],
    },
];

const dialogs = [
    ManualAnnotationDialogComponent,
    ForceAnnotationDialogComponent,
    ResizeRedactionDialogComponent,
    ChangeLegalBasisDialogComponent,
    HighlightActionDialogComponent,
    AcceptRecommendationDialogComponent,
    DocumentInfoDialogComponent,
    ImportRedactionsDialogComponent,
    RedactTextDialogComponent,
    EditRedactionDialogComponent,
    EditAnnotationDialogComponent,
    AddHintDialogComponent,
    RemoveRedactionDialogComponent,
    AddAnnotationDialogComponent,
    RemoveAnnotationDialogComponent,
    ResizeAnnotationDialogComponent,
    RedactRecommendationDialogComponent,
];

const components = [
    FileWorkloadComponent,
    AnnotationDetailsComponent,
    AnnotationWrapperComponent,
    AnnotationsListComponent,
    PageIndicatorComponent,
    PagesComponent,
    PageExclusionComponent,
    AnnotationActionsComponent,
    CommentsComponent,
    DocumentInfoComponent,
    ViewSwitchComponent,
    UserManagementComponent,
    AnnotationReferencesListComponent,
    AnnotationCardComponent,
    AnnotationReferencesPageIndicatorComponent,
    HighlightsSeparatorComponent,
    AnnotationReferenceComponent,
    FilePreviewScreenComponent,
    FilePreviewRightContainerComponent,
    ReadonlyBannerComponent,
];

@NgModule({
    declarations: [...components, ...dialogs],
    imports: [
        RouterModule.forChild(routes),
        CommonModule,
        TranslateModule,
        OverlayModule,
        IqserHelpModeModule,
        IqserUsersModule,
        CapitalizePipe,
        IqserUploadFileModule,
        IqserFiltersModule,
        SharedModule,
        CircleButtonComponent,
        SharedDossiersModule,
        IconButtonComponent,
        EmptyStateComponent,
        StatusBarComponent,
        StopPropagationDirective,
        PreventDefaultDirective,
        HasScrollbarDirective,
        EditableInputComponent,
        DetailsRadioComponent,
        DynamicInputComponent,
        InputWithActionComponent,
        RoundCheckboxComponent,
        IqserAllowDirective,
        IqserDenyDirective,
        TenantPipe,
        LogPipe,
        ReplaceNbspPipe,
    ],
    providers: [FilePreviewDialogService, ManualRedactionService, DocumentUnloadedGuard, TablesService],
})
export class FilePreviewModule {}
