export const parseBrowserName = (userAgent) => {
  const value = String(userAgent || "").trim();

  if (!value) {
    return "Inconnu";
  }

  if (/Edg\//i.test(value)) {
    return "Microsoft Edge";
  }

  if (/Chrome\//i.test(value) && !/Edg\//i.test(value)) {
    return "Google Chrome";
  }

  if (/Firefox\//i.test(value)) {
    return "Mozilla Firefox";
  }

  if (/Safari\//i.test(value) && !/Chrome\//i.test(value)) {
    return "Safari";
  }

  if (/OPR\//i.test(value) || /Opera/i.test(value)) {
    return "Opera";
  }

  return value.slice(0, 120);
};
