function getLanguageByFileName(languages, file) {
  if (!file) {
    return;
  }

  const basename = getFileBasename(file).toLowerCase();

  return (
    languages.find(({ filenames }) =>
      filenames?.some((name) => name.toLowerCase() === basename),
    ) ??
    languages.find(({ extensions }) =>
      extensions?.some((extension) => basename.endsWith(extension)),
    )
  );
}
@param {SupportLanguage[]} languages
@param {string | URL | undefined} [file]
@returns {SupportLanguage | undefined}