/**
 * Core routes - Dashboard, Search, Map, Reports, Settings, Employees
 */
export default [
  {
    path: '',
    name: 'dashboard',
    component: () => import('../../views/Dashboard.vue')
  },
  {
    path: 'search',
    name: 'search',
    component: () => import('../../views/SearchResults.vue')
  },
  {
    path: 'map',
    name: 'map',
    component: () => import('../../views/MapView.vue')
  },
  {
    path: 'map/editor',
    name: 'map-editor',
    component: () => import('../../views/MapEditor.vue'),
    meta: { requiresAuth: true }
  },
  {
    path: 'reports',
    name: 'reports',
    component: () => import('../../views/reports/ReportsIndex.vue')
  },
  // Settings
  {
    path: 'settings',
    name: 'settings',
    component: () => import('../../views/settings/SettingsIndex.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/vendors',
    name: 'vendors',
    component: () => import('../../views/vendors/VendorsList.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/modeltypes',
    name: 'modeltypes',
    component: () => import('../../views/settings/ModelTypesList.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/locations',
    name: 'locations',
    component: () => import('../../views/settings/LocationsList.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/statuses',
    name: 'statuses',
    component: () => import('../../views/settings/StatusesList.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/models',
    name: 'models',
    component: () => import('../../views/settings/ModelsList.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/businessunits',
    name: 'businessunits',
    component: () => import('../../views/settings/BusinessUnitsList.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/supportteams',
    name: 'supportteams',
    component: () => import('../../views/settings/SupportTeamsList.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/dashboarddefaults',
    name: 'dashboarddefaults',
    component: () => import('../../views/settings/DashboardDefaultsList.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/site',
    name: 'site-settings',
    component: () => import('../../views/settings/SiteSettings.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/relationshiptypes',
    name: 'relationship-types',
    component: () => import('../../views/settings/RelationshipTypesList.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/locationtypes',
    name: 'location-types',
    component: () => import('../../views/settings/LocationTypesList.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/assettypes',
    name: 'asset-types',
    component: () => import('../../views/settings/AssetTypesList.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/customfields',
    name: 'custom-fields',
    component: () => import('../../views/settings/CustomFieldsList.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  // The old monolithic System Settings tab page is split into one routed page
  // per section (below). This redirect keeps old bookmarks working: bare
  // /settings/system and every /settings/system?tab=<key> land on the right page.
  {
    path: 'settings/system',
    name: 'system-settings',
    redirect: to => {
      const tabRedirects = {
        integrations: '/settings/servicenow',
        branding: '/settings/branding',
        printing: '/settings/printing',
        email: '/settings/email',
        audit: '/settings/audit',
        auth: '/settings/authentication',
        identifiers: '/settings/assetidentifiers',
        search: '/settings/globalsearch',
        map: '/settings/floormap',
        pctype: '/settings/pctypemapping'
      }
      // vue-router carries the original ?tab= query onto the target; harmless
      // since the new pages ignore it, and the path is what routes the view.
      return tabRedirects[to.query.tab] || '/settings/servicenow'
    },
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/servicenow',
    name: 'servicenow-settings',
    component: () => import('../../views/settings/ServiceNowSettings.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/branding',
    name: 'branding-settings',
    component: () => import('../../views/settings/BrandingSettings.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/printing',
    name: 'printing-settings',
    component: () => import('../../views/settings/PrintingSettings.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/email',
    name: 'email-settings',
    component: () => import('../../views/settings/EmailSettings.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/audit',
    name: 'audit-settings',
    component: () => import('../../views/settings/AuditSettings.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/authentication',
    name: 'authentication-settings',
    component: () => import('../../views/settings/AuthenticationSettings.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/apitokens',
    name: 'apitokens-settings',
    component: () => import('../../views/settings/ApiTokensList.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/assetidentifiers',
    name: 'asset-identifiers-settings',
    component: () => import('../../views/settings/AssetIdentifiersSettings.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/globalsearch',
    name: 'global-search-settings',
    component: () => import('../../views/settings/GlobalSearchSettings.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/floormap',
    name: 'floor-map-settings',
    component: () => import('../../views/settings/FloorMapSettings.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/plugins',
    name: 'plugins',
    component: () => import('../../views/settings/PluginsList.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/auditlogs',
    name: 'audit-logs',
    component: () => import('../../views/settings/AuditLogs.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  },
  {
    path: 'settings/users',
    name: 'users',
    component: () => import('../../views/settings/UsersList.vue'),
    meta: { requiresAuth: true, requiresAdmin: true }
  }
]
