"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { Button } from "../ui/button.js";
import {
  Tooltip,
  TooltipContent,
  TooltipProvider,
  TooltipTrigger
} from "../ui/tooltip.js";
import { useTeamsConfig } from "../../hooks/useTeamsConfig.js";
import { useTranslations } from "next-intl";
import { UserPlus } from "lucide-react";
function InviteMemberButton({
  memberCount = 0,
  onClick,
  children,
  variant = "outline",
  size = "default",
  className,
  showIcon = true
}) {
  const t = useTranslations("teams");
  const { canInvite, options } = useTeamsConfig();
  if (!canInvite) {
    return null;
  }
  const maxMembersPerTeam = options == null ? void 0 : options.maxMembersPerTeam;
  const atLimit = maxMembersPerTeam != null && memberCount >= maxMembersPerTeam;
  if (atLimit) {
    return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
      /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
        Button,
        {
          variant,
          size,
          className,
          disabled: true,
          "data-cy": "invite-member-button-disabled",
          "aria-label": t("invite.limitReached", { limit: maxMembersPerTeam }),
          children: [
            showIcon && /* @__PURE__ */ jsx(UserPlus, { className: "h-4 w-4 mr-2", "aria-hidden": "true" }),
            children || t("invite.inviteMember")
          ]
        }
      ) }),
      /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: t("invite.limitReached", { limit: maxMembersPerTeam }) }) })
    ] }) });
  }
  return /* @__PURE__ */ jsxs(
    Button,
    {
      variant,
      size,
      className,
      onClick,
      "data-cy": "invite-member-button",
      "aria-label": t("invite.inviteMember"),
      children: [
        showIcon && /* @__PURE__ */ jsx(UserPlus, { className: "h-4 w-4 mr-2", "aria-hidden": "true" }),
        children || t("invite.inviteMember")
      ]
    }
  );
}
export {
  InviteMemberButton
};
