import { type IconInterface, IconType } from '@src/types/icons';

export const isImageIcon = (icon: IconInterface | null) =>
  icon?.type === IconType.IMAGE;

export const isEmojiIcon = (icon: IconInterface | null) =>
  icon?.type === IconType.EMOJI;

/**
 * Loose match between a selected image URL and an option's name.
 * Useful because image URLs often include cache-busting query params
 * while the option name is a stable substring of the path.
 */
export const matchesImageOption = (
  selectedUrl: string | undefined,
  optionName: string,
): boolean => !!selectedUrl && selectedUrl.includes(optionName);
