import 'package:superport/core/config/backend_compatibility_config.dart';

/// API 엔드포인트 상수 정의 (백엔드 100% 호환)
class ApiEndpoints {
  // 인증
  static const String login = '/auth/login';
  static const String logout = '/auth/logout';
  static const String refresh = '/auth/refresh';
  static const String me = '/me';
  
  // 벤더 관리
  static const String vendors = '/vendors';
  static const String vendorsSearch = '/vendors/search';
  
  // 모델 관리
  static const String models = '/models';
  static const String modelsByVendor = '/models/by-vendor';
  
  // 장비 관리 (백엔드 API 정확 일치 - 복수형)
  static const String equipment = '/equipments';
  static const String equipmentSearch = '/equipments/search';
  static const String equipmentIn = '/equipments/in';
  static const String equipmentOut = '/equipments/out';
  static const String equipmentBatchOut = '/equipments/batch-out';
  static const String equipmentManufacturers = '/equipments/manufacturers';
  static const String equipmentNames = '/equipments/names';
  static const String equipmentHistory = '/equipment-history'; // 백엔드 실제 엔드포인트
  static const String equipmentRentals = '/equipments/rentals';
  static const String equipmentRepairs = '/equipments/repairs';
  static const String equipmentDisposals = '/equipments/disposals';
  
  // 회사 관리
  static const String companies = '/companies';
  static const String companiesSearch = '/companies/search';
  static const String companiesNames = '/companies/names';
  static const String companiesCheckDuplicate = '/companies/check-duplicate';
  static const String companiesWithBranches = '/companies/with-branches';
  static const String companiesBranches = '/companies/{id}/branches';
  
  // 사용자 관리
  static const String users = '/users';
  static const String usersSearch = '/users/search';
  static const String usersChangePassword = '/users/{id}/change-password';
  static const String usersStatus = '/users/{id}/status';
  
  // 라이선스 관리 (백엔드 미지원 - 조건부 비활성화)
  static String get licenses => BackendCompatibilityConfig.features.licenseManagement ? '/licenses' : '/unsupported/licenses';
  static String get licensesExpiring => BackendCompatibilityConfig.features.licenseManagement ? '/licenses/expiring' : '/unsupported/licenses/expiring';
  static String get licensesAssign => BackendCompatibilityConfig.features.licenseManagement ? '/licenses/{id}/assign' : '/unsupported/licenses/{id}/assign';
  static String get licensesUnassign => BackendCompatibilityConfig.features.licenseManagement ? '/licenses/{id}/unassign' : '/unsupported/licenses/{id}/unassign';
  
  // 창고 관리 (백엔드 API와 일치)
  static const String warehouses = '/warehouses';
  static const String warehousesSearch = '/warehouses/search';
  
  // 창고 위치 관리 (기존 호환성 유지)
  static const String warehouseLocations = '/warehouse-locations';
  static const String warehouseLocationsSearch = '/warehouse-locations/search';
  static const String warehouseEquipment = '/warehouse-locations/{id}/equipment';
  static const String warehouseCapacity = '/warehouse-locations/{id}/capacity';
  
  // 파일 관리 (백엔드 미지원 - 조건부 비활성화)
  static String get filesUpload => BackendCompatibilityConfig.features.fileManagement ? '/files/upload' : '/unsupported/files/upload';
  static String get filesDownload => BackendCompatibilityConfig.features.fileManagement ? '/files/{id}' : '/unsupported/files/{id}';
  
  // 보고서 (백엔드 미지원 - 조건부 비활성화)
  static String get reports => BackendCompatibilityConfig.features.reportGeneration ? '/reports' : '/unsupported/reports';
  static String get reportsPdf => BackendCompatibilityConfig.features.reportGeneration ? '/reports/{type}/pdf' : '/unsupported/reports/{type}/pdf';
  static String get reportsExcel => BackendCompatibilityConfig.features.reportGeneration ? '/reports/{type}/excel' : '/unsupported/reports/{type}/excel';
  
  // 대시보드 및 통계 (백엔드 미지원 - 조건부 비활성화)
  static String get overviewStats => BackendCompatibilityConfig.features.dashboardStats ? '/overview/stats' : '/unsupported/overview/stats';
  static String get overviewRecentActivities => BackendCompatibilityConfig.features.dashboardStats ? '/overview/recent-activities' : '/unsupported/overview/recent-activities';
  static String get overviewEquipmentStatus => BackendCompatibilityConfig.features.dashboardStats ? '/overview/equipment-status' : '/unsupported/overview/equipment-status';
  static String get overviewLicenseExpiry => BackendCompatibilityConfig.features.dashboardStats ? '/overview/license-expiry' : '/unsupported/overview/license-expiry';
  
  // 대량 처리 (백엔드 미지원 - 조건부 비활성화)
  static String get bulkUpload => BackendCompatibilityConfig.features.bulkOperations ? '/bulk/upload' : '/unsupported/bulk/upload';
  static String get bulkUpdate => BackendCompatibilityConfig.features.bulkOperations ? '/bulk/update' : '/unsupported/bulk/update';
  
  // 감사 로그 (백엔드 미지원 - 조건부 비활성화)
  static String get auditLogs => BackendCompatibilityConfig.features.auditLogs ? '/audit-logs' : '/unsupported/audit-logs';
  
  // 백업 (백엔드 미지원 - 조건부 비활성화)
  static String get backupCreate => BackendCompatibilityConfig.features.backupRestore ? '/backup/create' : '/unsupported/backup/create';
  static String get backupRestore => BackendCompatibilityConfig.features.backupRestore ? '/backup/restore' : '/unsupported/backup/restore';
  
  // 검색 및 조회
  static const String lookups = '/lookups';
  static const String categories = '/lookups/categories';
  
  // 우편번호 관리
  static const String zipcodes = '/zipcodes';
  
  // 관리자 관리 (백엔드 실제 API)
  static const String administrators = '/administrators';
  
  // 유지보수 관리 (백엔드 실제 API)  
  static const String maintenances = '/maintenances';
  
  // 임대 관리
  static const String rents = '/rents';
  static const String rentsActive = '/rents/active';
  static const String rentsOverdue = '/rents/overdue';
  static const String rentsStats = '/rents/stats';
  
  // 동적 엔드포인트 생성 메서드 (백엔드 호환성 고려)
  static String licenseById(String id) => BackendCompatibilityConfig.features.licenseManagement 
      ? '/licenses/$id' : '/unsupported/licenses/$id';
  static String assignLicense(String id) => BackendCompatibilityConfig.features.licenseManagement 
      ? '/licenses/$id/assign' : '/unsupported/licenses/$id/assign';
  static String unassignLicense(String id) => BackendCompatibilityConfig.features.licenseManagement 
      ? '/licenses/$id/unassign' : '/unsupported/licenses/$id/unassign';
}