import { RouteRecordRaw } from 'vue-router'
import { isUndefined } from '@/support/helper'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
export function getModuleRoutes() {
  const modules: Record<string, any> = import.meta.glob(
    ["./modules/**/*.ts"],
    {
      eager: true
    }
  );
  let moduleRoutes: RouteRecordRaw[] = []

  Object.keys(modules).forEach(routePath => {
    if (!isUndefined(modules[routePath].default)) {
      moduleRoutes = moduleRoutes.concat(modules[routePath].default)
    }
  })

  return moduleRoutes
}

export function getModuleViewComponents() {
  return import.meta.glob(['@/views/**/*.{vue,tsx}'])
}
