import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { ELEMENT_ROUTES_TOKEN } from '@csdr/integration/element';

import { routes } from '@root.npm.pkg@';
// DON'T PAY ATTENTION TO IMPORT ERRORS HERE, those files are injected at serve/build time
import { appConfig } from '../config/index';
import { FallbackComponent } from './fallback.component';
import { ModuleComponent } from './module.component';

const elementRoutes: Routes = [
    { path: '', component: ModuleComponent },
    {
        path: appConfig.global.baseUrl,
        children: routes,
    },
    { path: '**', component: FallbackComponent },
];

// @dynamic
@NgModule({
    imports: [
        RouterModule.forRoot(elementRoutes),
    ],
    providers: [
        { provide: ELEMENT_ROUTES_TOKEN, useValue: elementRoutes },
    ],
    exports: [
        RouterModule,
    ],
})
export class RoutingModule {
}
