import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ScrollingModule } from '@angular/cdk/scrolling';
import { PaginationComponent } from './components/pagination/pagination.component';
import { FileDownloadBtnComponent } from './components/buttons/file-download-btn/file-download-btn.component';
import { MatConfigModule } from '../mat-config/mat-config.module';
import { IconsModule } from '../icons/icons.module';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AnnotationIconComponent } from './components/annotation-icon/annotation-icon.component';
import { DonutChartComponent } from './components/donut-chart/donut-chart.component';
import {
    CircleButtonComponent,
    DynamicInputComponent,
    HasScrollbarDirective,
    IconButtonComponent,
    IqserAllowDirective,
    IqserDenyDirective,
    IqserHelpModeModule,
    RoundCheckboxComponent,
    StopPropagationDirective,
} from '@iqser/common-ui';
import { NavigateLastDossiersScreenDirective } from './directives/navigate-last-dossiers-screen.directive';
import { DictionaryManagerComponent } from './components/dictionary-manager/dictionary-manager.component';
import { MonacoEditorModule } from '@materia-ui/ngx-monaco-editor';
import { AssignUserDropdownComponent } from './components/assign-user-dropdown/assign-user-dropdown.component';
import { DatePipe } from './pipes/date.pipe';
import { LongPressDirective } from './directives/long-press.directive';
import { TypeFilterComponent } from './components/type-filter/type-filter.component';
import { TeamMembersComponent } from './components/team-members/team-members.component';
import { EditorComponent } from './components/editor/editor.component';
import { ExpandableFileActionsComponent } from './components/expandable-file-actions/expandable-file-actions.component';
import { ProcessingIndicatorComponent } from './components/processing-indicator/processing-indicator.component';
import { DossierStateComponent } from './components/dossier-state/dossier-state.component';
import { FileStatsComponent } from './components/file-stats/file-stats.component';
import { FileNameColumnComponent } from './components/file-name-column/file-name-column.component';
import { DossierNameColumnComponent } from './components/dossier-name-column/dossier-name-column.component';
import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material/core';
import { DossiersTypeSwitchComponent } from './components/dossiers-type-switch/dossiers-type-switch.component';
import { TranslateModule } from '@ngx-translate/core';
import { RouterModule } from '@angular/router';
import { AddDossierDialogComponent } from './dialogs/add-dossier-dialog/add-dossier-dialog.component';
import { SharedDialogService } from './services/dialog.service';
import { AddEditEntityComponent } from './components/add-edit-entity/add-edit-entity.component';
import { ColorPickerModule } from 'ngx-color-picker';
import { WatermarkSelectorComponent } from './components/dossier-watermark-selector/watermark-selector.component';
import { OcrProgressBarComponent } from './components/ocr-progress-bar/ocr-progress-bar.component';
import { CustomDateAdapter } from '@shared/CustomDateAdapter';
import { IqserUsersModule } from '@iqser/common-ui/lib/users';
import { SmallChipComponent } from '@iqser/common-ui/lib/shared';
import { SelectComponent } from '@shared/components/select/select.component';
import { FileAttributeComponent } from '../dossier-overview/components/file-attribute/file-attribute.component';

const buttons = [FileDownloadBtnComponent];

const components = [
    PaginationComponent,
    AnnotationIconComponent,
    DictionaryManagerComponent,
    AssignUserDropdownComponent,
    TypeFilterComponent,
    TeamMembersComponent,
    ExpandableFileActionsComponent,
    ProcessingIndicatorComponent,
    DossierStateComponent,
    DossierNameColumnComponent,
    FileStatsComponent,
    FileNameColumnComponent,
    DossiersTypeSwitchComponent,
    AddDossierDialogComponent,
    WatermarkSelectorComponent,
    AddEditEntityComponent,
    OcrProgressBarComponent,

    ...buttons,
];

const utils = [DatePipe, NavigateLastDossiersScreenDirective, LongPressDirective];

const services = [SharedDialogService];

const modules = [MatConfigModule, ScrollingModule, IconsModule, FormsModule, ReactiveFormsModule, ColorPickerModule];

const deleteThisWhenAllComponentsAreStandalone = [DonutChartComponent, FileAttributeComponent];

@NgModule({
    declarations: [...components, ...utils, EditorComponent],
    imports: [
        CommonModule,
        ...modules,
        MonacoEditorModule,
        TranslateModule,
        RouterModule,
        IqserHelpModeModule,
        IqserUsersModule,
        ...deleteThisWhenAllComponentsAreStandalone,
        CircleButtonComponent,
        IconButtonComponent,
        SmallChipComponent,
        StopPropagationDirective,
        HasScrollbarDirective,
        IqserAllowDirective,
        IqserDenyDirective,
        SelectComponent,
        RoundCheckboxComponent,
        DynamicInputComponent,
    ],
    exports: [...modules, ...components, ...utils, ...deleteThisWhenAllComponentsAreStandalone],
    providers: [
        ...services,
        {
            provide: DateAdapter,
            useClass: CustomDateAdapter,
        },
        {
            provide: MAT_DATE_FORMATS,
            useValue: {
                parse: {
                    dateInput: 'D/M/YY',
                },
                display: {
                    dateInput: 'D/M/YY',
                    monthYearLabel: 'YYYY',
                    dateA11yLabel: 'LL',
                    monthYearA11yLabel: 'YYYY',
                },
            },
        },
    ],
})
export class SharedModule {}
