/**
 * Image Helper Utilities
 * 
 * Provides helper functions to work with WebP images with PNG fallback
 * for better performance while maintaining compatibility.
 */

/**
 * Get WebP image path with PNG fallback support
 * @param pngPath - Original PNG path (e.g., "/img/button/button.png")
 * @returns WebP path (e.g., "/img/button/button.webp")
 */
export function getWebpPath(pngPath: string): string {
  return pngPath.replace(/\.png$/i, '.webp');
}

/**
 * Get image srcSet for responsive images
 * @param basePath - Base path without extension
 * @param sizes - Array of sizes for responsive images
 * @returns srcSet string
 */
export function getSrcSet(basePath: string, sizes: number[]): string {
  return sizes
    .map((size) => `${basePath}-${size}.webp ${size}w`)
    .join(', ');
}

/**
 * Icon URL helper - Returns WebP path for item icons
 * Since Icons folder has too many files, we use PNG as primary for now
 * and will migrate to WebP progressively
 * @param itemId - Item ID
 * @returns Icon URL
 */
export function getItemIconUrl(itemId: number | string): string {
  return `/img/Icons/${itemId}.png`;
}

/**
 * Class icon URL helper
 * @param className - Class name (e.g., 'blademaster', 'mage')
 * @returns Class icon URL
 */
export function getClassIconUrl(className: string): string {
  return `/img/iconclass/${className.toLowerCase()}.webp`;
}

/**
 * Download provider icon URL helper
 * @param provider - Provider name (e.g., 'gdrive', 'mediafire', 'mega')
 * @returns Provider icon URL
 */
export function getDownloadProviderIconUrl(provider: string): string {
  return `/img/download/${provider}.webp`;
}

/**
 * Navigation icon URL helper
 * @param iconName - Icon name (e.g., 'ico-1', 'ico-2')
 * @returns Navigation icon URL
 */
export function getNavIconUrl(iconName: string): string {
  return `/img/nav/${iconName}.webp`;
}

/**
 * Button image URL helper
 * @param buttonName - Button name (e.g., 'button_claim', 'btn_tab')
 * @returns Button image URL
 */
export function getButtonImageUrl(buttonName: string): string {
  return `/img/button/${buttonName}.webp`;
}

/**
 * Animation image URL helper
 * @param animationName - Animation name (e.g., 'box_icon', 'shadow')
 * @returns Animation image URL
 */
export function getAnimationImageUrl(animationName: string): string {
  return `/img/animations/${animationName}.webp`;
}

/**
 * Step/Wizard image URL helper
 * @param imageName - Image name (e.g., 'bg', 'ico-1', 'h-dec-left')
 * @returns Step image URL
 */
export function getStepImageUrl(imageName: string): string {
  return `/img/step/${imageName}.webp`;
}

/**
 * Photo image URL helper
 * @param filename - Photo filename without extension
 * @returns Photo URL
 */
export function getPhotoUrl(filename: string): string {
  return `/img/photo/${filename}.webp`;
}
