import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { HttpClient, HttpClientModule } from '@angular/common/http';
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';

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

import { LazyLoadImageModule } from 'ng-lazyload-image';
import { MaterialModule } from './material.module';

import { CookieModule } from 'ngx-cookie';

// custom components
import { ReactiveFormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

import { MarkdownViewComponent } from '../components/resource-page/chat-layout/chat-message/markdown-view/markdown-view.component';
import { DeleteFileDialogComponent } from '../shared/dialogs/delete-file-dialog/delete-file-dialog.component';
import { DeleteGroupDialogComponent } from '../shared/dialogs/delete-group-dialog/delete-group-dialog.component';
import { NewFolderDialogComponent } from '../shared/dialogs/new-folder-dialog/new-folder-dialog.component';
import { NewGroupDialogComponent } from '../shared/dialogs/new-group-dialog/new-group-dialog.component';
import { RenameGroupDialogComponent } from '../shared/dialogs/rename-group-dialog/rename-group-dialog.component';

import { LoginComponent } from '../components/login/login.component';
import { RegisterComponent } from '../components/register/register.component';
import { ChatLayoutComponent } from '../components/resource-page/chat-layout/chat-layout.component';
import { ChatMessageComponent } from '../components/resource-page/chat-layout/chat-message/chat-message.component';
import { EmojiPickerComponent } from '../components/resource-page/chat-layout/chat-message/markdown-editor/emoji-picker/emoji-picker.component';
import { EmojiShortcodePickerComponent } from '../components/resource-page/chat-layout/chat-message/markdown-editor/emoji-shortcode-picker/emoji-shortcode-picker.component';
import { DriveLayoutComponent } from '../components/resource-page/drive-window/drive-layout/drive-layout.component';
import { FileBlockViewComponent } from '../components/resource-page/drive-window/drive-layout/file-block-view/file-block-view.component';
import { ResourcePageComponent } from '../components/resource-page/resource-page.component';
import { SettingsComponent } from '../components/settings/settings.component';
import { AvatarComponent } from '../shared/components/avatar/avatar.component';
import { AppDragDropModule } from '../shared/drag/app-drag-drop-module';
import { AppGuideModule } from '../shared/guide/app-guide-module';

import { CommonModule, registerLocaleData } from '@angular/common';
import localeHu from '@angular/common/locales/hu';
import { RouterModule } from '@angular/router';
import { SlateModule } from 'slate-angular';
import { activeRoutes } from 'src/main';
import { RoomDetailsComponent } from '..//components/resource-page/room-details/room-details.component';
import { AboutComponent } from '../components/about/about.component';
import { AccountRecoveryConfirmComponent } from '../components/account-recovery-confirm/account-recovery-confirm.component';
import { AccountRecoveryComponent } from '../components/account-recovery/account-recovery.component';
import { AccountSettingsComponent } from '../components/account-settings/account-settings.component';
import { ChangeContactPolicyDialogComponent } from '../components/account-settings/change-contact-policy-dialog/change-contact-policy-dialog.component';
import { ChangeEmailDialogComponent } from '../components/account-settings/change-email-dialog/change-email-dialog.component';
import { ChangePasswordDialogComponent } from '../components/account-settings/change-password-dialog/change-password-dialog.component';
import { ChangeUsernameDialogComponent } from '../components/account-settings/change-username-dialog/change-username-dialog.component';
import { ActionQueueElementComponent } from '../components/action-queue/action-queue-element/action-queue-element.component';
import { ActionQueueComponent } from '../components/action-queue/action-queue.component';
import { AdvancedSettingsComponent } from '../components/advanced-settings/advanced-settings.component';
import { AggregateStatsComponent } from '../components/aggregate-stats/aggregate-stats.component';
import { BlobViewerComponent } from '../components/blob-viewer/blob-viewer.component';
import { ContactListComponent } from '../components/contact-list/contact-list.component';
import { DownloadManagerCollectionComponent } from '../components/download-manager/download-manager-collection/download-manager-collection.component';
import { DownloadManagerFileComponent } from '../components/download-manager/download-manager-file/download-manager-file.component';
import { DownloadManagerComponent } from '../components/download-manager/download-manager.component';
import { ProgressBarComponent } from '../components/header/progress-bar/progress-bar.component';
import { SearchInputComponent } from '../components/header/search-input/search-input.component';
import { EditBillingTemplateDialogComponent } from '../components/nano-license-buy/edit-billing-template-dialog/edit-billing-template-dialog.component';
import { NanoLicenseBuyComponent } from '../components/nano-license-buy/nano-license-buy.component';
import { NanoLicenseViewComponent } from '../components/nano-license-view/nano-license-view.component';
import { BundledLicensesDialogComponent } from '../components/nano-license/bundled-licenses-dialog/bundled-licenses-dialog.component';
import { NanoLicenseComponent } from '../components/nano-license/nano-license.component';
import { RecurringOrderDetailDialogComponent } from '../components/nano-license/recurring-order-detail-dialog/recurring-order-detail-dialog.component';
import { RedeemTokenDialogComponent } from '../components/nano-license/redeem-token-dialog/redeem-token-dialog.component';
import { AdminPasswordDialogComponent } from '../components/nano-manager/admin-password-dialog/admin-password-dialog.component';
import { AttachRoomDialogComponent } from '../components/nano-manager/attach-room-dialog/attach-room-dialog.component';
import { CreateDriveDialogComponent } from '../components/nano-manager/create-drive-dialog/create-drive-dialog.component';
import { NanoManagerComponent } from '../components/nano-manager/nano-manager.component';
import { NewsListComponent } from '../components/news-list/news-list.component';
import { RegisterConfirmComponent } from '../components/register-confirm/register-confirm.component';
import { RejectedRoomsComponent } from '../components/rejected-rooms/rejected-rooms.component';
import { MarkdownFilePreviewComponent } from '../components/resource-page/chat-layout/chat-message/markdown-view/markdown-file-preview/markdown-file-preview.component';
import { MarkdownViewerFragmentComponent } from '../components/resource-page/chat-layout/chat-message/markdown-view/markdown-viewer-fragment/markdown-viewer-fragment.component';
import { NativeEditorComponent } from '../components/resource-page/chat-layout/chat-message/native-editor/native-editor.component';
import { SlateCodeLineComponent } from '../components/resource-page/chat-layout/chat-message/slate-editor/slate-components/slate-code-line/slate-code-line.component';
import { SlateEditorLeafComponent } from '../components/resource-page/chat-layout/chat-message/slate-editor/slate-components/slate-editor-leaf/slate-editor-leaf.component';
import { SlateEmojiComponent } from '../components/resource-page/chat-layout/chat-message/slate-editor/slate-components/slate-emoji/slate-emoji/slate-emoji.component';
import { SlateEditorComponent } from '../components/resource-page/chat-layout/chat-message/slate-editor/slate-editor.component';
import { BottomSheetMenuComponent } from '../components/resource-page/drive-window/drive-layout/bottom-sheet-menu/bottom-sheet-menu.component';
import { ChatLayoutBottomSheetMenuComponent } from '../components/resource-page/chat-layout/chat-layout-bottom-sheet-menu/chat-layout-bottom-sheet-menu.component';
import { FileInfoComponent } from '../components/resource-page/drive-window/drive-layout/bottom-sheet-menu/file-info/file-info.component';
import { FileListViewComponent } from '../components/resource-page/drive-window/drive-layout/file-list-view/file-list-view.component';
import { DriveWindowComponent } from '../components/resource-page/drive-window/drive-window.component';
import { ResourcePageMobileComponent } from '../components/resource-page/mobile/resource-page-mobile/resource-page-mobile.component';
import { CreateEditSaleCodeDialogComponent } from '../components/sale-code-manager/create-edit-sale-code-dialog/create-edit-sale-code-dialog.component';
import { SaleCodeManagerComponent } from '../components/sale-code-manager/sale-code-manager.component';
import { SessionHandlerComponent } from '../components/session-handler/session-handler.component';
import { SearchSidebarViewComponent } from '../components/sidebar/search-sidebar-view/search-sidebar-view.component';
import { SidebarDialogueDragPreviewComponent } from '../components/sidebar/sidebar-dialogue/sidebar-dialogue-drag-preview/sidebar-dialogue-drag-preview.component';
import { SidebarDialogueComponent } from '../components/sidebar/sidebar-dialogue/sidebar-dialogue.component';
import { SidebarGrantedRoomComponent } from '../components/sidebar/sidebar-granted-room/sidebar-granted-room.component';
import { BottomSheetGroupSelectorComponent } from '../components/sidebar/sidebar-group/bottom-sheet-group-selector/bottom-sheet-group-selector.component';
import { SidebarGroupDragPreviewComponent } from '../components/sidebar/sidebar-group/sidebar-group-drag-preview/sidebar-group-drag-preview.component';
import { SidebarGroupComponent } from '../components/sidebar/sidebar-group/sidebar-group.component';
import { SidebarRoomDragPreviewComponent } from '../components/sidebar/sidebar-room/sidebar-room-drag-preview/sidebar-room-drag-preview.component';
import { SidebarRoomComponent } from '../components/sidebar/sidebar-room/sidebar-room.component';
import { SidebarUngrouppedComponent } from '../components/sidebar/sidebar-ungroupped/sidebar-ungroupped.component';
import { SidebarComponent } from '../components/sidebar/sidebar.component';
import { SimplepayBackComponent } from '../components/simplepay-back/simplepay-back.component';
import { TimedOffersComponent } from '../components/timed-offers/timed-offers.component';
import { WorkerGraphComponent } from '../components/worker-graph/worker-graph.component';
import { UserInfoMenuComponent } from '../shared/components/user-info-menu/user-info-menu.component';
import { ContactDialogComponent } from '../shared/dialogs/contact-dialog/contact-dialog.component';
import { CreateRoomDialogComponent } from '../shared/dialogs/create-room-dialog/create-room-dialog.component';
import { DeleteAccountDialogComponent } from '../shared/dialogs/delete-account-dialog/delete-account-dialog.component';
import { DownloadRecoveryCodeDialogComponent } from '../shared/dialogs/download-recovery-code-dialog/download-recovery-code-dialog.component';
import { FileUploadConfirmDialogComponent } from '../shared/dialogs/file-upload-confirm-dialog/file-upload-confirm-dialog.component';
import { FileRowComponent } from '../shared/dialogs/folder-download-confirm-dialog/file-row/file-row.component';
import { FolderDownloadConfirmDialogComponent } from '../shared/dialogs/folder-download-confirm-dialog/folder-download-confirm-dialog.component';
import { GeneralAlertDialogComponent } from '../shared/dialogs/general-alert-dialog/general-alert-dialog.component';
import { GeneralConfirmDialogComponent } from '../shared/dialogs/general-confirm-dialog/general-confirm-dialog.component';
import { GeneralInputDialogComponent } from '../shared/dialogs/general-input-dialog/general-input-dialog.component';
import { ImageCropperDialogComponent } from '../shared/dialogs/image-cropper-dialog/image-cropper-dialog.component';
import { InviteUserDialogComponent } from '../shared/dialogs/invite-user-dialog/invite-user-dialog.component';
import { MetamaskAlertDialogComponent } from '../shared/dialogs/metamask-alert-dialog/metamask-alert-dialog.component';
import { OutboundLinkDialogComponent } from '../shared/dialogs/outbound-link-dialog/outbound-link-dialog.component';
import { RoomConfigurationDialogComponent } from '../shared/dialogs/room-configuration-dialog/room-configuration-dialog.component';
import { TwoFactorAlertDialogComponent } from '../shared/dialogs/two-factor-dialog/two-factor-alert-dialog/two-factor-alert-dialog.component';
import { TwoFactorDialogComponent } from '../shared/dialogs/two-factor-dialog/two-factor-dialog.component';
import { VerifySignatureDialogComponent } from '../shared/dialogs/verify-signature-dialog/verify-signature-dialog.component';
import { WaitingDialogComponent } from '../shared/dialogs/waiting-dialog/waiting-dialog.component';
import { ContextMenuDirective } from '../shared/directives/context-menu.directive';
import { DoubleClickDirective } from '../shared/directives/double-click.directive';
import { EnterTheViewportNotifierDirective } from '../shared/directives/enter-the-viewport-notifier.directive';
import { LongpressDirective } from '../shared/directives/longpress.directive';
import { ShowUserInfoDirective } from '../shared/directives/show-user-info.directive';
import { ZxcvbnDirective } from '../shared/directives/zxcvbn.directive';
import { AppMediaViewerModule } from '../shared/media-viewer/app-media-viewer-module';
import { FormatBytesPipe } from '../shared/pipes/format-bytes.pipe';
import { HidePipe } from '../shared/pipes/hide.pipe';
import { PathToArrayPipe } from '../shared/pipes/path-to-array.pipe';
import { SafePipe } from '../shared/pipes/safe-pipe';
import { CopyChatMessagesSnackbarComponent } from '../shared/snackbars/copy-chat-messages-snackbar/copy-chat-messages-snackbar.component';
import { MatNanoSnackbarComponent } from '../shared/snackbars/mat-nano-snackbar/mat-nano-snackbar.component';
import { TranslatePoHttpLoader } from '../shared/translatePoHttpLoader';
import { MessageDetailsComponent } from '../components/resource-page/chat-layout/message-details/message-details.component';
import { SeenDialogComponent } from '../shared/dialogs/seen-dialog/seen-dialog.component';
import { FilePropertiesDialogComponent } from '../shared/dialogs/file-properties-dialog/file-properties-dialog.component';
import { EtalonInfoComponent } from '../shared/components/etalon-info/etalon-info.component';
import { SelectReactionComponent } from '../components/resource-page/chat-layout/chat-message/select-reaction/select-reaction.component';
import { MoveFileDialogComponent } from '../shared/dialogs/move-file-dialog/move-file-dialog.component';
import { ReactionDialogComponent } from '../shared/dialogs/reaction-dialog/reaction-dialog.component';

import { ResizedDirective } from '../shared/directives/resized.directive';
import { RenameFileDialogComponent } from '../shared/dialogs/rename-file-dialog/rename-file-dialog.component';
import { RenameExistingFileDialogComponent } from '../shared/dialogs/rename-existing-file-dialog/rename-existing-file-dialog.component';

//angular needs locale data for built-in translations for resources like for example date formats
registerLocaleData(localeHu);

// AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient): TranslatePoHttpLoader {
  return new TranslatePoHttpLoader(http, './assets/i18n', '.po');
}

export class DynamicLocaleId extends String {
  constructor(protected service: TranslateService) {
    super('');
  }

  toString() {
    return this.service.currentLang;
  }
}

var nanoRouterModule: any = RouterModule.forRoot(activeRoutes, {
  onSameUrlNavigation: 'reload',
});
var nanoTranslateModule: any = TranslateModule.forRoot({
  defaultLanguage: 'en',
  loader: {
    provide: TranslateLoader,
    useFactory: HttpLoaderFactory,
    deps: [HttpClient],
  },
});
var nanoCookieModule: any = CookieModule.forRoot();

@NgModule({
  declarations: [
    AboutComponent,
    AccountRecoveryComponent,
    AccountRecoveryConfirmComponent,
    AccountSettingsComponent,
    ActionQueueComponent,
    ActionQueueElementComponent,
    AdminPasswordDialogComponent,
    AdvancedSettingsComponent,
    AggregateStatsComponent,
    AttachRoomDialogComponent,
    AvatarComponent,
    BlobViewerComponent,
    BottomSheetGroupSelectorComponent,
    BottomSheetGroupSelectorComponent,
    BottomSheetMenuComponent,
    ChatLayoutBottomSheetMenuComponent,
    BundledLicensesDialogComponent,
    ChangeContactPolicyDialogComponent,
    ChangeEmailDialogComponent,
    ChangePasswordDialogComponent,
    ChangeUsernameDialogComponent,
    ChatLayoutComponent,
    ChatMessageComponent,
    ContactDialogComponent,
    ContactListComponent,
    ContextMenuDirective,
    CopyChatMessagesSnackbarComponent,
    CreateDriveDialogComponent,
    CreateEditSaleCodeDialogComponent,
    CreateRoomDialogComponent,
    DeleteAccountDialogComponent,
    DeleteFileDialogComponent,
    DeleteGroupDialogComponent,
    DoubleClickDirective,
    DownloadManagerCollectionComponent,
    DownloadManagerComponent,
    DownloadManagerFileComponent,
    DownloadRecoveryCodeDialogComponent,
    DriveLayoutComponent,
    DriveWindowComponent,
    EditBillingTemplateDialogComponent,
    EmojiPickerComponent,
    EmojiShortcodePickerComponent,
    EnterTheViewportNotifierDirective,
    //FileListViewDesktopComponent,
    FileBlockViewComponent,
    FileInfoComponent,
    FileListViewComponent,
    FilePropertiesDialogComponent,
    FileRowComponent,
    FileUploadConfirmDialogComponent,
    FolderDownloadConfirmDialogComponent,
    FormatBytesPipe,
    GeneralAlertDialogComponent,
    GeneralConfirmDialogComponent,
    GeneralInputDialogComponent,
    HidePipe,
    ImageCropperDialogComponent,
    InviteUserDialogComponent,
    LoginComponent,
    MarkdownFilePreviewComponent,
    MarkdownViewComponent,
    MarkdownViewerFragmentComponent,
    MatNanoSnackbarComponent,
    MessageDetailsComponent,
    ReactionDialogComponent,
    MetamaskAlertDialogComponent,
    NanoLicenseBuyComponent,
    NanoLicenseComponent,
    NanoLicenseViewComponent,
    NanoManagerComponent,
    NativeEditorComponent,
    NewFolderDialogComponent,
    NewGroupDialogComponent,
    NewsListComponent,
    OutboundLinkDialogComponent,
    PathToArrayPipe,
    ProgressBarComponent,
    RecurringOrderDetailDialogComponent,
    RedeemTokenDialogComponent,
    RegisterComponent,
    RegisterConfirmComponent,
    RenameGroupDialogComponent,
    ResourcePageComponent,
    ResourcePageMobileComponent,
    RoomDetailsComponent,
    SafePipe,
    SaleCodeManagerComponent,
    SearchInputComponent,
    SearchSidebarViewComponent,
    SeenDialogComponent,
    SessionHandlerComponent,
    SettingsComponent,
    LongpressDirective,
    ShowUserInfoDirective,
    SidebarComponent,
    SidebarDialogueComponent,
    SidebarDialogueDragPreviewComponent,
    SidebarGrantedRoomComponent,
    SidebarGroupComponent,
    SidebarGroupDragPreviewComponent,
    SidebarRoomComponent,
    SidebarRoomDragPreviewComponent,
    SidebarUngrouppedComponent,
    SimplepayBackComponent,
    SlateCodeLineComponent,
    SlateEditorComponent,
    SlateEditorLeafComponent,
    SlateEmojiComponent,
    TimedOffersComponent,
    TwoFactorAlertDialogComponent,
    TwoFactorDialogComponent,
    UserInfoMenuComponent,
    WaitingDialogComponent,
    WorkerGraphComponent,
    ZxcvbnDirective,
    RejectedRoomsComponent,
    RoomConfigurationDialogComponent,
    VerifySignatureDialogComponent,
    EtalonInfoComponent,
    SelectReactionComponent,
    MoveFileDialogComponent,
    ResizedDirective,
    RenameFileDialogComponent,
    RenameExistingFileDialogComponent,
  ],
  imports: [
    AppDragDropModule,
    AppGuideModule,
    AppMediaViewerModule,
    BrowserAnimationsModule,
    BrowserModule,
    CommonModule,
    FormsModule,
    HttpClientModule,
    LazyLoadImageModule,
    MaterialModule,
    nanoCookieModule,
    nanoRouterModule,
    nanoTranslateModule,
    ReactiveFormsModule,
    SlateModule,
  ],
  exports: [
    AboutComponent,
    AccountRecoveryComponent,
    AccountRecoveryConfirmComponent,
    AccountSettingsComponent,
    ActionQueueComponent,
    ActionQueueElementComponent,
    AdminPasswordDialogComponent,
    AdvancedSettingsComponent,
    AggregateStatsComponent,
    AttachRoomDialogComponent,
    AvatarComponent,
    BlobViewerComponent,
    BottomSheetGroupSelectorComponent,
    BottomSheetMenuComponent,
    BundledLicensesDialogComponent,
    ChangeContactPolicyDialogComponent,
    ChangeEmailDialogComponent,
    ChangePasswordDialogComponent,
    ChangeUsernameDialogComponent,
    ChatLayoutComponent,
    ChatMessageComponent,
    ContactDialogComponent,
    ContactListComponent,
    ContextMenuDirective,
    CopyChatMessagesSnackbarComponent,
    CreateDriveDialogComponent,
    CreateEditSaleCodeDialogComponent,
    CreateRoomDialogComponent,
    DeleteAccountDialogComponent,
    DeleteFileDialogComponent,
    DeleteGroupDialogComponent,
    DoubleClickDirective,
    DownloadManagerCollectionComponent,
    DownloadManagerComponent,
    DownloadManagerFileComponent,
    DownloadRecoveryCodeDialogComponent,
    DriveLayoutComponent,
    DriveWindowComponent,
    EditBillingTemplateDialogComponent,
    EmojiPickerComponent,
    EmojiShortcodePickerComponent,
    EnterTheViewportNotifierDirective,
    //FileListViewDesktopComponent,
    FileBlockViewComponent,
    FileInfoComponent,
    FileListViewComponent,
    FilePropertiesDialogComponent,
    FileRowComponent,
    FileUploadConfirmDialogComponent,
    FolderDownloadConfirmDialogComponent,
    FormatBytesPipe,
    GeneralAlertDialogComponent,
    GeneralConfirmDialogComponent,
    GeneralInputDialogComponent,
    HidePipe,
    ImageCropperDialogComponent,
    InviteUserDialogComponent,
    LoginComponent,
    MarkdownFilePreviewComponent,
    MarkdownViewComponent,
    MarkdownViewerFragmentComponent,
    MatNanoSnackbarComponent,
    MessageDetailsComponent,
    ReactionDialogComponent,
    MetamaskAlertDialogComponent,
    NanoLicenseBuyComponent,
    NanoLicenseComponent,
    NanoLicenseViewComponent,
    NanoManagerComponent,
    NativeEditorComponent,
    NewFolderDialogComponent,
    NewGroupDialogComponent,
    NewsListComponent,
    OutboundLinkDialogComponent,
    PathToArrayPipe,
    ProgressBarComponent,
    RecurringOrderDetailDialogComponent,
    RedeemTokenDialogComponent,
    RegisterComponent,
    RegisterConfirmComponent,
    RenameGroupDialogComponent,
    ResourcePageComponent,
    ResourcePageMobileComponent,
    RoomDetailsComponent,
    SafePipe,
    SaleCodeManagerComponent,
    SearchInputComponent,
    SearchSidebarViewComponent,
    SeenDialogComponent,
    SessionHandlerComponent,
    SettingsComponent,
    ShowUserInfoDirective,
    SidebarComponent,
    SidebarDialogueComponent,
    SidebarDialogueDragPreviewComponent,
    SidebarGrantedRoomComponent,
    SidebarGroupComponent,
    SidebarGroupDragPreviewComponent,
    SidebarRoomComponent,
    SidebarRoomDragPreviewComponent,
    SidebarUngrouppedComponent,
    SimplepayBackComponent,
    SlateCodeLineComponent,
    SlateEditorComponent,
    SlateEditorLeafComponent,
    SlateEmojiComponent,
    TimedOffersComponent,
    TwoFactorAlertDialogComponent,
    TwoFactorDialogComponent,
    UserInfoMenuComponent,
    WaitingDialogComponent,
    WorkerGraphComponent,
    RoomConfigurationDialogComponent,
    VerifySignatureDialogComponent,
    ZxcvbnDirective,
    LongpressDirective,
    AppDragDropModule,
    AppGuideModule,
    AppMediaViewerModule,
    nanoRouterModule,
    BrowserAnimationsModule,
    BrowserModule,
    CommonModule,
    FormsModule,
    nanoTranslateModule,
    HttpClientModule,
    LazyLoadImageModule,
    MaterialModule,
    nanoCookieModule,
    ReactiveFormsModule,
    SlateModule,
    ResizedDirective,
  ],
})
export class SharedModule {}
