import { Routes, provideRoutes, ExtraOptions, PreloadAllModules } from '@angular/router';
import { LoginComponent } from './login/login.component';
import { HomeComponent } from './home/home.component';
import { GenresComponent } from './genres/genres.component';

import { SeriesComponent } from './series/series.component';
import { CreateComponent } from './create/create.component';
import { WritestoryComponent } from './writestory/writestory.component';
import { TestComponent } from './test/test.component';
import { StorytitleComponent } from './storytitle/storytitle.component';
import { NewComponent } from './new/new.component';
import { MyworksComponent } from './myworks/myworks.component';
import { EpisodeComponent } from './episode/episode.component';
import { StoryComponent } from './story/story.component';
import { SignupComponent } from './signup/signup.component';
import { UserProfileComponent } from './user-profile/user-profile.component';
import { SearchResultComponent } from './search-result/search-result.component';
import { LibraryComponent } from './library/library.component';
import { AuthGuard } from './auth.guard';
import { AllstoriesComponent } from './allstories/allstories.component';
import { ActivationSuccessComponent } from './activation-success/activation-success.component';
import { ActivationErrorComponent } from './activation-error/activation-error.component';
import { ActivationComponent } from './activation/activation.component';
import { AdminGuard } from './admin.guard';
import { NoAuthGuard } from './noauth.guard';
import { PrivacyComponent } from './privacy/privacy.component';
import { TermsconditionComponent } from './termscondition/termscondition.component';
import { ContestComponent } from './contest/contest.component';


export const routes: Routes = [
    { path: '', redirectTo: '/home', pathMatch: 'full' },
  { path: 'home', loadComponent: () => import('./home/home.component').then(m => m.HomeComponent) },
  { path: 'login', loadComponent: () => import('./login/login.component').then(m => m.LoginComponent), canActivate: [NoAuthGuard] },
   
    { path: 'genres', component: GenresComponent, canActivate: [AuthGuard] },

    { path: 'series/:idAndTitle', component: SeriesComponent },
    { path: 'creat/:storyId', component:CreateComponent, canActivate: [AuthGuard] },
    {path: 'story-write/:idAndTitle',
  loadComponent: () => import('./writestory/writestory.component').then(m => m.WritestoryComponent), canActivate: [AuthGuard] },
  { path:'register', component:SignupComponent },
  
    {path:'test', component:TestComponent, canActivate: [AuthGuard] },
    {path:'create-story', component:StorytitleComponent, canActivate: [AuthGuard] },
    {path:'new', component:NewComponent,  canActivate: [AuthGuard] },
    {path:'update/:id', component:NewComponent, canActivate: [AuthGuard] },
    { 
  path: 'myworks',  component: MyworksComponent , canActivate: [AuthGuard] },
    {path:'episode/:idAndTitle', loadComponent: () => import('./episode/episode.component').then(m =>m.EpisodeComponent), canActivate: [AuthGuard] },
    {path:'story/:idAndTitle', component:StoryComponent },
    { path:'user-profile', component:UserProfileComponent, canActivate: [AuthGuard] },
    { path: 'category/:id/:name', component: SearchResultComponent },
    { path: 'search', component: SearchResultComponent },
    { path:'library', component:LibraryComponent, canActivate: [AuthGuard] },
    { path:'notifications', loadComponent: () => import('./notifications/notifications.component').then(m => m.NotificationsComponent), canActivate: [AuthGuard] },
    {path:'allstories', component:AllstoriesComponent },
    {path:'forgot-password', loadComponent: () => import('./forgot-password/forgot-password.component').then(m => m.ForgotPasswordComponent) },
    {path: 'reset-password', loadComponent: () => import('./reset-password/reset-password.component').then(m => m.ResetPasswordComponent)},
{ path: 'profile/:id', component: MyworksComponent },
{ path: 'write', loadComponent: () => import('./writestory/writestory.component').then(m => m.WritestoryComponent), canActivate: [AuthGuard] },
  {path:'privacy', component:PrivacyComponent},
  {path:'terms_and_condition', component:TermsconditionComponent},
{ path: 'activation', component: ActivationComponent },
  { path: 'activation-success', component: ActivationSuccessComponent},
  { path: 'activation-error', component: ActivationErrorComponent },
  {path:'admin', loadComponent: () => import('./admin/admin.component').then(m => m.AdminComponent), canActivate: [AuthGuard] },

  
{path:'contest', component:ContestComponent},
  { path: '**', component: HomeComponent } // Fallback route
];
const routerOptions: ExtraOptions = {
  scrollPositionRestoration: 'top', 
  anchorScrolling: 'enabled', 
  preloadingStrategy: PreloadAllModules,
  useHash: true      
};
export const appRoutingProviders = [
    provideRoutes(routes) 
];

