import {NgModule, NgModuleRef} from '@angular/core';
import {RouterModule} from '@angular/router';
import {ReactiveFormsModule} from '@angular/forms';
import {CommonModule} from "@angular/common";


import {DynamicModule} from 'ng-dynamic-component';
import {InfiniteScrollModule} from 'ngx-infinite-scroll';

import {ComponentListMagicService, MagicModule, ExitMagicService} from "@magic-xpa/angular";
import {magicGenComponents, magicGenCmpsHash, title, LazyLoadModulesMap} from './component-list.g';
import {MagicAngularMaterialModule} from "@magic-xpa/angular-material-core";
import {MatFormFieldModule} from "@angular/material/form-field";
import {MatSelectModule} from "@angular/material/select";
import {MatPaginatorModule} from "@angular/material/paginator";
import {MatListModule} from "@angular/material/list";
import {MatInputModule} from "@angular/material/input";
import {MatRadioModule} from "@angular/material/radio";
import {MatDatepickerModule} from "@angular/material/datepicker";
import {MatSortModule} from "@angular/material/sort";
import {MatTableModule} from "@angular/material/table";
import {MatCheckboxModule} from "@angular/material/checkbox";
import {MatCardModule} from "@angular/material/card";
import {MatNativeDateModule} from "@angular/material/core";
import {MatTabsModule} from "@angular/material/tabs";
import {MatTooltipModule} from "@angular/material/tooltip";
import {MatButtonModule} from "@angular/material/button";
import {MatAutocompleteModule} from "@angular/material/autocomplete";
import {CurrencyMaskConfig, CurrencyMaskInputMode, NgxCurrencyModule} from "ngx-currency";
import { NgxMaskModule, IConfig } from "ngx-mask";

// カスタムアラート

import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';

import { ConfirmationComponentsMagicProvider } from "@magic-xpa/angular";
import { CustomAlertComponent } from './_Custom/custom-alert/custom-alert.component';
import { customConfirmationMagicProviderService } from './_Custom/customConfirmationMagicProviderService';
import { CustomCnfComponent } from './_Custom/custom-cnf/custom-cnf.component';
// カスタムページネーション
import { CustomPaginationModule } from './_Custom/custom-pagination/custom-pagination.module';
import { IconModule, IconSetService } from '@coreui/icons-angular';
import { MatDialogModule } from "@angular/material/dialog";
import { MatToolbarModule } from "@angular/material/toolbar";
import { MatSidenavModule } from "@angular/material/sidenav";
import { MatIconModule } from "@angular/material/icon";
import { MatGridListModule } from "@angular/material/grid-list";

import {
  AvatarModule,
  BadgeModule,
  BreadcrumbModule,
  ButtonGroupModule,
  ButtonModule,
  CardModule,
  DropdownModule,
  FooterModule,
  FormModule,
  GridModule,
  HeaderModule,
  ListGroupModule,
  NavModule,
  ProgressModule,
  SharedModule,
  SidebarModule,
  TabsModule,
  UtilitiesModule,
  AccordionModule
} from '@coreui/angular';

import { WidgetModule } from '../widget.module'

export const options: Partial<IConfig> | (() => Partial<IConfig>) = {};

export const customCurrencyMaskConfig: CurrencyMaskConfig = {
  align: "right",
  allowNegative: true,
  allowZero: true,
  decimal: ".",
  precision: 2,
  prefix: "",
  suffix: "",
  thousands: ",",
  nullable: true,
  min: undefined,
  max: undefined,
  inputMode: CurrencyMaskInputMode.FINANCIAL
};

@NgModule({
  declarations: [
    ...magicGenComponents,
    CustomAlertComponent,
    CustomCnfComponent,
  
  ],
  exports: [
    ...magicGenComponents,
    MagicModule
  ],
  imports: [ MatDialogModule,
  MatToolbarModule,
  MatSidenavModule,
  MatIconModule,
  MatGridListModule,
  RouterModule,
  ReactiveFormsModule,
  CommonModule,
  DynamicModule,
  InfiniteScrollModule,
  MagicModule,
  MagicAngularMaterialModule,
  MatFormFieldModule,
  MatSelectModule,
  MatPaginatorModule,
  MatListModule,
  MatInputModule,
  MatRadioModule,
  MatDatepickerModule,
  MatSortModule,
  MatTableModule,
  MatCheckboxModule,
  MatCardModule,
  MatNativeDateModule,
  MatTabsModule,
  MatTooltipModule,
  MatButtonModule,
  MatAutocompleteModule,
  NgxCurrencyModule.forRoot(customCurrencyMaskConfig),
  NgxCurrencyModule.forRoot(customCurrencyMaskConfig),
  NgxMaskModule.forRoot(),

  CustomPaginationModule,
  IconModule,
  AvatarModule,
  BadgeModule,
  BreadcrumbModule,
  ButtonGroupModule,
  ButtonModule,
  CardModule,
  DropdownModule,
  FooterModule,
  FormModule,
  GridModule,
  HeaderModule,
  ListGroupModule,
  NavModule,
  ProgressModule,
  SharedModule,
  SidebarModule,
  TabsModule,
  UtilitiesModule,
  AccordionModule,
  WidgetModule
 ],
  providers: [ExitMagicService, { provide: ConfirmationComponentsMagicProvider, useClass: customConfirmationMagicProviderService },IconSetService],
    schemas:[CUSTOM_ELEMENTS_SCHEMA,] // これを追加
})
export class MagicGenLibModule {
  constructor(componentList: ComponentListMagicService, private moduleRef: NgModuleRef<any>) {
    componentList.addComponents(magicGenCmpsHash, moduleRef);
    componentList.title = title; 
    componentList.lazyLoadModulesMap = LazyLoadModulesMap; 
  }
}
