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

import { AuthGuard, FullScreenGuard } from '@farmmaps/common';
//import { MapComponent } from '@farmmaps/common-map';
//import { Switch2D3DComponent } from  '@farmmaps/common-map3d';
import { LogoComponent } from './logo/logo.component';
import { MenuComponent } from './menu/menu.component';
import { RegisterDeviceComponent } from './registerdevice/registerdevice.component';
import { NotImplementedComponent } from '@farmmaps/common';
import { NavBarGuard } from 'projects/common/src/public-api';
import { TestComponent } from './test/test.component';
import { LandingpageComponent } from './landingpage/landingpage.component';

export function urlMatcher(url: UrlSegment[]) {
  return { consumed: url };
}

const routes = [

  {
    path: '',
    //canActivate: [NavBarGuard],
    component: LandingpageComponent
  },
  {
    path: '',
    component: LogoComponent,
    outlet: 'header-logo'
  },
  {
    path: '',
    component: TestComponent,
    outlet: 'app-menu'
  },
  {
    path: '',
    component: TestComponent,
    outlet: 'notification-menu'
  },
  {
    path: '',
    component: TestComponent,
    outlet: 'help-menu'
  },
  {
    path: '',
    component: TestComponent,
    outlet: 'setting-menu'
  },
  {
    path: '',
    component: LogoComponent,
    outlet: 'side-panel-logo'
  },
  {
    path: '',
    component: MenuComponent,
    outlet: 'side-panel-menu'
  },
  {
    path: 'editor/:type/item/:itemcode',
    canActivate: [NavBarGuard],
    component: NotImplementedComponent
  },
  {
    path: 'viewer/:type/item/:itemcode',
    canActivate: [NavBarGuard],
    component: NotImplementedComponent
  },
  { path: 'map', loadChildren: () => import('../../projects/common-map/src/public-api').then(m => m.AppCommonMapModule), canActivateChild: [AuthGuard],canActivate: [FullScreenGuard], },
  { path: 'map3d', loadChildren: () => import('./map3d/map3d.module').then(m => m.Map3DModule), canActivateChild: [AuthGuard], canActivate: [FullScreenGuard] },
  { path: 'admin', loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule), canActivateChild: [AuthGuard], canActivate: [FullScreenGuard], data: { role: 'admin' } },
  {
    path: 'registerdevice/:deviceToken',
    canActivate: [FullScreenGuard],
    component: RegisterDeviceComponent
  },
  {
    path: 'test',
    component: TestComponent
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes,
    { initialNavigation: 'enabledBlocking' })], // ,  enableTracing: true
  exports: [RouterModule]
})
export class AppRoutingModule { }
