/**
 * API Configuration for BTP Xpress Client
 */

export const API_CONFIG = {
  baseURL: process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080',
  timeout: parseInt(process.env.NEXT_PUBLIC_API_TIMEOUT || '10000'),
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
  },
} as const;

export const KEYCLOAK_CONFIG = {
  url: process.env.NEXT_PUBLIC_KEYCLOAK_URL || 'https://security.lions.dev',
  realm: process.env.NEXT_PUBLIC_KEYCLOAK_REALM || 'btpxpress',
  clientId: process.env.NEXT_PUBLIC_KEYCLOAK_CLIENT_ID || 'btpxpress-frontend',
  // Configuration pour l'authentification
  'ssl-required': 'external',
  'public-client': true,
  'confidential-port': 0,
  'use-resource-role-mappings': true,
  'cors': true,
  'enable-cors': true,
  'cors-max-age': 1000,
  'cors-allowed-methods': 'POST, PUT, DELETE, GET',
  'cors-allowed-headers': 'X-Requested-With, Content-Type, Authorization, Origin, Accept, Access-Control-Request-Method, Access-Control-Request-Headers',
  'bearer-only': false,
  'autodetect-bearer-only': true,
  'connection-pool-size': 20,
  'socket-timeout-millis': 5000,
  'connection-timeout-millis': 5000,
  'connection-ttl-millis': 5000,
  'disable-trust-manager': false,
  'allow-any-hostname': false,
  'truststore': '',
  'truststore-password': '',
  'client-keystore': '',
  'client-keystore-password': '',
  'client-key-password': '',
  'token-minimum-time-to-live': 10,
  'min-time-between-jwks-requests': 10,
  'public-key-cache-ttl': 86400,
  'redirect-rewrite-rules': {},
} as const;

// Configuration des rôles et permissions
export const KEYCLOAK_ROLES = {
  ADMIN: 'admin',
  MANAGER: 'manager',
  USER: 'user',
  CHEF_CHANTIER: 'chef_chantier',
  EMPLOYE: 'employe',
  CLIENT: 'client',
} as const;

// Configuration des scopes OAuth2
export const KEYCLOAK_SCOPES = [
  'openid',
  'profile',
  'email',
] as const;

export const APP_CONFIG = {
  name: process.env.NEXT_PUBLIC_APP_NAME || 'BTP Xpress',
  version: process.env.NEXT_PUBLIC_APP_VERSION || '1.0.0',
  description: process.env.NEXT_PUBLIC_APP_DESCRIPTION || 'Plateforme de gestion BTP',
} as const;

export const THEME_CONFIG = {
  defaultTheme: process.env.NEXT_PUBLIC_DEFAULT_THEME || 'blue',
  defaultMode: process.env.NEXT_PUBLIC_DEFAULT_THEME_MODE || 'light',
} as const;