let sub_routes = [];

const modules = import.meta.glob("./routes/*.route.js", { eager: true });
// eslint-disable-next-line no-unused-vars
Object.entries(modules).forEach(([path, definition]) => {
  sub_routes = sub_routes.concat(definition.default);
});

const routes = [
  {
    path: "/",
    component: () => import("layouts/MainLayout.vue"),
    meta: { requireAuth: true },
    children: [
      {
        path: "",
        name: "CarteirinhaPage",
        component: () => import("pages/associado/carteirinha/CarteirinhaPage.vue"),
        meta: {
          title: { value: "ui.navigation.carteirinha", translate: true },
          requireAuth: true,
          requiredPermission: "dashboard",
          breadcrumbs: [{ name: "CarteirinhaPage", title: "Dashboard" }],
        },
      },
      {
        path: "/gestao/associados",
        name: "GestaoAssociadosPage",
        component: () => import("pages/gestao-associados/GestaoAssociadosPage.vue"),
        meta: {
          title: { value: "ui.navigation.associados", translate: true },
          description: { value: "page.gestao_associados.description", translate: true },
          requireAuth: true,
          requiredPermission: "associado",
          breadcrumbs: [{ name: "GestaoAssociadosPage", title: "ui.navigation.associados", translate: true }],
        },
      },
      {
        path: "/dashboard",
        name: "DashboardPage",
        component: () => import("pages/dashboard/DashboardPage.vue"),
        meta: {
          title: { value: "Dashboard" },
          description: { value: "page.system-dashboard.description", translate: true },
          requireAuth: true,
          requiredPermission: "dashboard",
          breadcrumbs: [{ name: "DashboardPage", title: "Dashboard" }],
        },
      },
      {
        path: "/versions",
        name: "SystemVersionsPage",
        component: () => import("pages/version/SystemVersionsPage.vue"),
        meta: {
          title: { value: "ui.navigation.versions", translate: true },
          description: { value: "page.versions.description", translate: true },
          requireAuth: true,
          breadcrumbs: [{ name: "SystemVersionsPage", title: "ui.navigation.versions", translate: true }],
        },
      },
      ...sub_routes,
    ],
  },
  {
    path: "/login",
    component: () => import("layouts/LoginLayout.vue"),
    children: [
      {
        path: "",
        name: "LoginPage",
        component: () => import("pages/login/LoginPage.vue"),
        meta: { title: "Login" },
      },
      {
        path: "/recuperar-senha",
        name: "ForgotPasswordPage",
        component: () => import("pages/login/ForgotPasswordPage.vue"),
        meta: { title: "Recuperar Senha" },
      },
      {
        path: "/verificar-email",
        name: "VerifyEmailPage",
        component: () => import("pages/login/VerifyEmailPage.vue"),
        meta: { title: "Verifique seu E-mail" },
      },
      {
        path: "/digitar-codigo",
        name: "VerifyCodePage",
        component: () => import("pages/login/VerifyCodePage.vue"),
        meta: { title: "Digite o Código" },
      },
      {
        path: "/nova-senha",
        name: "ResetPasswordPage",
        component: () => import("pages/login/ResetPasswordPage.vue"),
        meta: { title: "Nova Senha" },
      },
    ],
  },

  {
    path: "/:catchAll(.*)*",
    component: () => import("pages/ErrorNotFound.vue"),
  },
];

export default routes;
