import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
import { forwardRef } from 'react';
import { c as cn } from './utils-BJnb9o5c.js';
import { Empty as Empty$1, EmptyHeader, EmptyMedia, EmptyTitle, EmptyDescription, EmptyContent } from './primitives/Empty.js';
import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from './primitives/Tooltip.js';
import { r as renderIcon } from './renderIcon-C6twJSqH.js';
import { T as Typography } from './Typography-CmILccNh.js';
import { b as Button } from './Button-C4c_dj-f.js';

function MaybeTooltipButton({
  buttonProps,
  showTooltipWhenDisabled,
  defaultVariant,
  dataTestid
}) {
  const button = /* @__PURE__ */ jsx(
    Button,
    {
      "data-testid": dataTestid,
      variant: defaultVariant,
      ...buttonProps
    }
  );
  if (showTooltipWhenDisabled && buttonProps.disabled && buttonProps.label) {
    return /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxs(Tooltip, { children: [
      /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "inline-flex", children: button }) }),
      /* @__PURE__ */ jsx(TooltipContent, { "data-testid": "tooltip-box", children: buttonProps.label })
    ] }) });
  }
  return button;
}
const Empty = forwardRef(
  ({
    image,
    icon,
    title,
    description,
    helpText,
    primaryButtonProps,
    secondaryButtonProps,
    buttonSeparatorText,
    showTooltipWhenButtonDisabled = false,
    className,
    dataTestid,
    ...otherProps
  }, ref) => {
    const hasMedia = image || icon;
    const hasButtons = primaryButtonProps || secondaryButtonProps;
    return /* @__PURE__ */ jsxs(Empty$1, { ref, className: cn(className), ...otherProps, children: [
      /* @__PURE__ */ jsxs(EmptyHeader, { children: [
        hasMedia && /* @__PURE__ */ jsxs(Fragment, { children: [
          image && /* @__PURE__ */ jsx(EmptyMedia, { children: typeof image === "string" ? /* @__PURE__ */ jsx("img", { src: image, alt: title ?? "" }) : image }),
          !image && icon && /* @__PURE__ */ jsx(EmptyMedia, { variant: "icon", children: renderIcon(icon) })
        ] }),
        title && /* @__PURE__ */ jsx(Typography, { variant: "h4", asChild: true, children: /* @__PURE__ */ jsx(EmptyTitle, { "data-testid": dataTestid ?? "empty-state-title", children: title }) }),
        description && /* @__PURE__ */ jsx(Typography, { variant: "body3", color: "muted", asChild: true, children: /* @__PURE__ */ jsx(EmptyDescription, { "data-testid": "empty-state-description", children: description }) }),
        helpText && /* @__PURE__ */ jsx(Typography, { variant: "body3", color: "muted", asChild: true, children: /* @__PURE__ */ jsx("p", { "data-testid": "empty-state-help-text", children: helpText }) })
      ] }),
      hasButtons && /* @__PURE__ */ jsx(EmptyContent, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-center gap-2", children: [
        primaryButtonProps && /* @__PURE__ */ jsx(
          MaybeTooltipButton,
          {
            buttonProps: primaryButtonProps,
            dataTestid: "empty-state-primary-button",
            showTooltipWhenDisabled: showTooltipWhenButtonDisabled,
            defaultVariant: "default"
          }
        ),
        buttonSeparatorText && primaryButtonProps && secondaryButtonProps && /* @__PURE__ */ jsx(Typography, { variant: "body3", color: "muted", asChild: true, children: /* @__PURE__ */ jsx("span", { children: buttonSeparatorText }) }),
        secondaryButtonProps && /* @__PURE__ */ jsx(
          MaybeTooltipButton,
          {
            buttonProps: secondaryButtonProps,
            dataTestid: "empty-state-secondary-button",
            showTooltipWhenDisabled: showTooltipWhenButtonDisabled,
            defaultVariant: "outline"
          }
        )
      ] }) })
    ] });
  }
);
Empty.displayName = "Empty";

export { Empty as E };
//# sourceMappingURL=Empty-DINS0Uu4.js.map
