/* P.E.S.T — SVG icons (brand socials + UI) */
const Icon = {
  x: (p) => (
    <svg viewBox="0 0 24 24" fill="currentColor" {...p}>
      <path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24h-6.66l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z" />
    </svg>
  ),
  telegram: (p) => (
    <svg viewBox="0 0 24 24" fill="currentColor" {...p}>
      <path d="M21.94 4.56a1.3 1.3 0 0 0-1.32-.2L3.3 11.2c-.86.34-.83 1.58.04 1.88l4.2 1.43 1.6 5.04c.18.56.88.74 1.32.34l2.4-2.18 4.1 3.02c.5.37 1.22.1 1.36-.5l3.5-15.3c.1-.46-.06-.92-.43-1.17zM9.6 14.2l8.1-5.1-6.5 6.1c-.13.13-.22.3-.25.48l-.3 2.2z" />
    </svg>
  ),
  discord: (p) => (
    <svg viewBox="0 0 24 24" fill="currentColor" {...p}>
      <path d="M20.317 4.3698a19.7913 19.7913 0 0 0-4.8851-1.5152.0741.0741 0 0 0-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 0 0-.0785-.037 19.7363 19.7363 0 0 0-4.8852 1.515.0699.0699 0 0 0-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 0 0 .0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 0 0 .0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 0 0-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 0 1-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 0 1 .0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 0 1 .0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 0 1-.0066.1276 12.2986 12.2986 0 0 1-1.873.8914.0766.0766 0 0 0-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 0 0 .0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 0 0 .0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 0 0-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z" />
    </svg>
  ),
  website: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <circle cx="12" cy="12" r="9" />
      <path d="M3 12h18M12 3c2.5 2.5 2.5 15 0 18M12 3c-2.5 2.5-2.5 15 0 18" />
    </svg>
  ),
  close: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" {...p}>
      <path d="M6 6l12 12M18 6L6 18" />
    </svg>
  ),
  arrow: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" {...p}>
      <path d="M5 12h14M13 6l6 6-6 6" />
    </svg>
  ),
  link: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" {...p}>
      <path d="M10 13a5 5 0 0 0 7 0l2-2a5 5 0 0 0-7-7l-1 1M14 11a5 5 0 0 0-7 0l-2 2a5 5 0 0 0 7 7l1-1" />
    </svg>
  ),
  magiceden: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinejoin="round" {...p}>
      <path d="M3 19V8.5a1 1 0 0 1 1.6-.8L9 11l3-5 3 5 4.4-3.3a1 1 0 0 1 1.6.8V19a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1z" />
    </svg>
  ),
  // ---- honorary badge glyphs ----
  genius: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" {...p}>
      <path d="M5 8h14M9.5 8v9M15 8v9" />
    </svg>
  ),
  supervisor: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12z" />
      <circle cx="12" cy="12" r="2.6" />
    </svg>
  ),
  curator: (p) => (
    <svg viewBox="0 0 24 24" fill="currentColor" {...p}>
      <path d="M12 2l1.9 6.1L20 10l-6.1 1.9L12 18l-1.9-6.1L4 10l6.1-1.9z" />
    </svg>
  ),
  eventhost: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <rect x="9" y="3" width="6" height="11" rx="3" />
      <path d="M6 11a6 6 0 0 0 12 0M12 17v4M9 21h6" />
    </svg>
  ),
  moderator: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M12 2.5l7.5 3v5c0 5-3.3 8.5-7.5 10.5C7.8 19 4.5 15.5 4.5 10.5v-5z" />
    </svg>
  ),
  launch: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z" />
      <path d="M12 15l-3-3a22 22 0 0 1 8-10 12.6 12.6 0 0 1 5 5 22 22 0 0 1-10 8z" />
      <path d="M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5" />
    </svg>
  ),
  shop: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M3 9h18l-1.5 11.5a1 1 0 0 1-1 .5H5.5a1 1 0 0 1-1-.5z" />
      <path d="M3 9l2-5h14l2 5M9 13a3 3 0 0 0 6 0" />
    </svg>
  ),
  menu: (p) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" {...p}>
      <path d="M4 7h16M4 12h16M4 17h16" />
    </svg>
  ),
};

const SOCIAL_META = {
  x: { label: "X", icon: Icon.x },
  telegram: { label: "Telegram", icon: Icon.telegram },
  discord: { label: "Discord", icon: Icon.discord },
  website: { label: "Website", icon: Icon.website },
  magiceden: { label: "Magic Eden", icon: Icon.magiceden },
};

// Honorary badges — additional to role; shown as medals on the avatar edge.
const HBADGE_ORDER = ["genius", "supervisor", "curator", "eventhost", "moderator"];
const HBADGE = {
  genius:     { label: "Genius",      tip: "The brain behind every calculation", icon: Icon.genius,     cls: "hb-genius" },
  supervisor: { label: "Supervisor",  tip: "Keeps watch over the hive",           icon: Icon.supervisor, cls: "hb-supervisor" },
  curator:    { label: "Content Curator", tip: "Content Curator",                  icon: Icon.curator,    cls: "hb-curator" },
  eventhost:  { label: "Event Host",  tip: "Event Host",                           icon: Icon.eventhost,  cls: "hb-eventhost" },
  moderator:  { label: "Moderator",   tip: "Moderator",                            icon: Icon.moderator,  cls: "hb-moderator" },
};
function honoraryBadges(m) {
  return HBADGE_ORDER.filter((k) => (m.badges || []).includes(k));
}
function badgePriority(m) {
  const b = honoraryBadges(m);
  return b.length ? HBADGE_ORDER.indexOf(b[0]) : 99;
}

window.Icon = Icon;
window.SOCIAL_META = SOCIAL_META;
window.HBADGE = HBADGE;
window.HBADGE_ORDER = HBADGE_ORDER;
window.honoraryBadges = honoraryBadges;
window.badgePriority = badgePriority;
