/**
 * API Configuration
 * Unified management of all API-related configurations
 * Frontend always connects to the backend service
 */

/**
 * API service endpoint configuration
 * Dev environment uses Vite proxy, production environment uses actual address
 */
const API_ENDPOINTS = {
  // Local backend service (Go) - Cluster and Registry management
  BACKEND: "/api",
};

/**
 * Get API base path
 * @param service - Service name (currently only BACKEND)
 * @returns API base path
 */
export function getApiBasePath(service: keyof typeof API_ENDPOINTS = "BACKEND"): string {
  return API_ENDPOINTS[service];
}

/**
 * Default API base path (backend service)
 */
export const API_BASE_URL = getApiBasePath("BACKEND");

/**
 * 获取应用名称
 */
export function getAppName(): string {
  // @ts-ignore - 全局变量由 Vite 注入
  return typeof __APP_NAME__ !== 'undefined' ? __APP_NAME__ : 'OCDP';
}

/**
 * 打印配置信息
 */
export function logConfig(): void {
  console.log('📋 API Configuration:');
  console.log('  - API Base URL:', API_BASE_URL);
  console.log('  - App Name:', getAppName());
}
