export const EXTERNAL_CAPABILITIES = [
  { code: "user:list", labelKey: "capability.userList", path: "/users" },
  { code: "user:update", labelKey: "capability.userUpdate", path: "/users" },
  { code: "user-ban:list", labelKey: "capability.banList", path: "/bans" },
  { code: "user:ban", labelKey: "capability.ban", path: "/users" },
  { code: "user:unban", labelKey: "capability.unban", path: "/bans" },
  { code: "host:list", labelKey: "capability.hostList", path: "/organization/hosts" },
  { code: "agency:list", labelKey: "capability.agencyList", path: "/organization/agencies" },
  { code: "bd:list", labelKey: "capability.bdList", path: "/organization/bds" },
  { code: "bd-manager:list", labelKey: "capability.bdManagerList", path: "/organization/bd-leaders" },
  { code: "super-admin:list", labelKey: "capability.superAdminList", path: "/organization/super-admins" },
  { code: "room:list", labelKey: "capability.roomList", path: "/rooms" },
  { code: "room:update", labelKey: "capability.roomUpdate", path: "/rooms" },
  { code: "privilege:list", labelKey: "capability.privilegeList", path: "/grants" },
  { code: "privilege:grant", labelKey: "capability.privilegeGrant", path: "/grants" },
  { code: "banner:create", labelKey: "capability.bannerCreate", path: "/banners" },
  { code: "pretty-id:grant", labelKey: "capability.prettyIdGrant", path: "/grants" },
  { code: "user-title:grant", labelKey: "capability.userTitleGrant", path: "/grants" },
  { code: "room-background:grant", labelKey: "capability.roomBackgroundGrant", path: "/grants" },
  { code: "user-level:grant", labelKey: "capability.userLevelGrant", path: "/users" },
  { code: "team:view", labelKey: "capability.teamView", path: "/organization/team" }
];

export function hasExternalCapability(session, code) {
  const capabilities = session?.capabilities || [];
  return capabilities.includes("*") || capabilities.includes("external-admin:*") || capabilities.includes(code);
}

export function hasAnyExternalCapability(session, codes) {
  return codes.some((code) => hasExternalCapability(session, code));
}
