// router/index.js
import { createRouter, createWebHistory } from "vue-router";
import { setupRouterGuards } from "./router-guards";

const routes = [
  {
    path: "/",
    redirect: '/myhome'
  },
  {
    path: "/",
    name: "index",
    component: () => import("@/views/index/index.vue"),
    // beforeEnter: (to, from, next) => {

    //     localStorage.clear()
    //     next()
    // }
    children: [
      {
        path: "/contacts",
        name: "contacts",
        component: () => import("@/views/contacts/index.vue"),
      },
      {
        path: "/calculator",
        name: "calculator",
        component: () => import("@/views/calculator/index.vue"),
      },
      {
        path: "/stock-quote",
        name: "stock-quote",
        component: () => import("@/views/stock-quote/index.vue"),
      },
      {
        path: "/historic-stock",
        name: "historic-stock",
        component: () => import("@/views/historic-stock/index.vue"),
      },
      {
        path: "/contacts",
        name: "contacts",
        component: () => import("@/views/contacts/index.vue"),
      },
      {
        path: "/email-alerts",
        name: "email-alerts",
        component: () => import("@/views/email-alerts/index.vue"),
      },
      {
        path: "/quarterlyreports",
        name: "quarterlyreports",
        component: () =>
          import("@/views/financialinformation/quarterlyreports/index.vue"),
      },
      {
        path: "/secfilings",
        name: "SecFilings",
        component: () =>
          import("@/views/financialinformation/secfilings/index.vue"),
      },
      {
        path: "/secfilingsDefail",
        name: "SecFilingsDetail",
        component: () =>
          import("@/views/financialinformation/secfilingsdetail/index.vue"),
      },
      {
        path: "/annualreports",
        name: "AnnualReports",
        component: () =>
          import("@/views/financialinformation/annualreports/index.vue"),
      },
      {
        path: "/press-releases",
        name: "press-releases",
        component: () => import("@/views/press-releases/index.vue"),
      },
      {
        path: "/news",
        name: "news",
        component: () => import("@/views/news/index.vue"),
      },
      {
        path: "/events-calendar",
        name: "events-calendar",
        component: () => import("@/views/events-calendar/index.vue"),
      },
      {
        path: "/companyoverview",
        name: "companyoverview",
        component: () => import("@/views/companyoverview/index.vue"),
      },
      {
        path: "myhome",
        name: "myHome",
        component: () => import("@/views/myHome/index.vue"),
      },
      {
        path: "/businessservices",
        name: "BusinessServices",
        component: () => import("@/views/BusinessServices/index.vue"),
      },
      {
        path: "/manage",
        name: "manage",
        component: () => import("@/views/manage/index.vue"),
      },
      {
        path: "/boarddirectors",
        name: "boarddirectors",
        component: () => import("@/views/boarddirectors/index.vue"),
      },
      {
        path: "/committeeappointment",
        name: "CommitteeAppointment",
        component: () => import("@/views/CommitteeAppointment/index.vue"),
      },
      {
        path: "/govern",
        name: "govern",
        component: () => import("@/views/govern/index.vue"),
      },
      {
        path: "/privacyPolicy",
        name: "privacyPolicy",
        component: () => import("@/views/footerLinks/privacyPolicy/index.vue"),
      },
      {
        path: "/termsOfUse",
        name: "termsOfUse",
        component: () => import("@/views/footerLinks/termsOfUse/index.vue"),
      },
      {
        path: "/cookiesSettings",
        name: "cookiesSettings",
        component: () => import("@/views/footerLinks/cookiesSettings/index.vue"),
      },
      {
        path: "/siteMap",
        name: "siteMap",
        component: () => import("@/views/footerLinks/siteMap/index.vue"),
      },
    ],
  },
  
  // {
  //     path: '/companyprofil',
  //     name: 'Companyprofil',
  //     component: () => import('@/views/companyprofil/index.vue'),
  // },
  // {
  //     path: '/companyprofildetail',
  //     name: 'Companyprofildetail',
  //     component: () => import('@/views/companyprofildetail/index.vue'),
  // },
  // {
  //     path: '/businessintroduction',
  //     name: 'Businessintroduction',
  //     component: () => import('@/views/businessintroduction/index.vue'),
  // },
  // {
  //     path: '/investor',
  //     name: 'Investor',
  //     component: () => import('@/views/investor/index.vue'),
  // },
  // {
  //     path: '/investorhandbook',
  //     name: 'Investorhandbook',
  //     component: () => import('@/views/investorhandbook/index.vue'),
  // },
  {
    path: '/:pathMatch(.*)*',
    redirect: '/myhome'
  }
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});
router.beforeEach((to, from, next) => {
  if (to.meta?.title) {
    document.title = to.meta.title;
  }
  next();
});
setupRouterGuards(router);
export default router;
