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

import packageJson from '../../../../package.json';

import {TreeModule} from '@circlon/angular-tree-component';

import {
    CardRowsModule,
    ClassifiableComponent,
    CodeEditorLazyModule,
    ItemCardLazyModule,
    JournalEditorLazyModule,
    M2Plugin,
    NavigationPanelModule,
    NodeCardLazyModule,
    RouterExtensionPoint,
    SecurityRoleType,
    SharedModule,
    TabsModule,
    TransactionButtonModule,
    TransactionDetailsLazyModule
} from 'm2-core';
import {ApplicationAttributesModule, ItemsDatatableComponent, NavbarModule, NodesTreeComponent} from 'm2-components';
import {CD_PLUGIN_NAME, CD_ROUTING} from './config';
import {M2ComponentDocsPluginComponent} from './m2-component-docs-plugin.component';
import {M2ComponentDocsPluginRoutingModule} from './m2-component-docs-plugin-routing.module';
import {CdDocsTreeComponent} from './components/docs-tree/cd-docs-tree.component';
import {CdContentStubComponent} from './components/stub/cd-content-stub.component';
import {CdCodeExampleComponent} from './components/content/code-example/cd-code-example.component';
import {CdApiOverviewComponent} from './components/content/api-overview/cd-api-overview.component';
import {CdApiLinkComponent} from './components/content/api-overview/cd-api-link.component';
import {CdContentTabsComponent} from './components/content-tabs/cd-content-tabs.component';
import {CdCodeComponent} from './components/code/cd-code.component';
import {CD_CONTENT_COMPONENTS} from './content-config';


@NgModule({
    imports: [
        SharedModule,
        M2ComponentDocsPluginRoutingModule,
        NavbarModule,
        NavigationPanelModule,
        TabsModule,
        TreeModule,
        NodesTreeComponent,
        NodeCardLazyModule,
        ItemCardLazyModule,
        ItemsDatatableComponent,
        TransactionDetailsLazyModule,
        JournalEditorLazyModule,
        CodeEditorLazyModule,
        ClassifiableComponent,
        TransactionButtonModule,
        ApplicationAttributesModule,
        CardRowsModule
    ],
    declarations: [
        M2ComponentDocsPluginComponent,
        CdCodeComponent,
        CdDocsTreeComponent,
        CdContentTabsComponent,
        CdContentStubComponent,
        CdCodeExampleComponent,
        CdApiOverviewComponent, CdApiLinkComponent,
        ...CD_CONTENT_COMPONENTS
    ]
})
@M2Plugin({
    // 1. Built-in plugin
    // name: 'Component docs', // has to match plugin name in BUILT_IN_PLUGINS_REGISTRY!
    // version: '',

    // 2. External plugin
    name: CD_PLUGIN_NAME,
    version: packageJson.version,

    description: 'Расширение предоставляет описание и примеры использования визуальных компонентов, входящих в состав библиотек m2-core, m2-components.',
    extensionPoints: [{
        type: 'RouterExtensionPoint',
        routerLink: CD_ROUTING.BASE,
        moduleType: M2ComponentDocsPluginModule,
        mainNavLinkOptions: {
            sortOrder: 6.5,
            displayName: CD_PLUGIN_NAME,
            isDisabledFn: roles => !roles.includes(SecurityRoleType.sysAdministration)
        }
    } as RouterExtensionPoint]
})
export class M2ComponentDocsPluginModule {

}
