'use strict';
import { jsx } from 'react/jsx-runtime';
import { cva } from 'class-variance-authority';
import { cn } from '../../../fd-toolbox/lib/utils.js';
import { wellKnownPositions } from '../../../base-repo/constants/tools-constants.js';
import { Tooltip } from '../tooltip/Tooltip.js';
import { useRender } from '@base-ui/react';
import { htmlTags } from '../../../base-repo/constants/html-element-names.js';
import { componentVariantNames, accessibilityAttributeNames } from '../../../fd-toolbox/constants/html-constants.js';
import { elementSuffixes } from '../../../fd-toolbox/constants/element-suffixes.js';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
  value,
  configurable: true
});
const buttonVariants = cva("focus-visible:ring-primary inline-flex items-center justify-center rounded-md text-sm font-medium whitespace-nowrap transition-colors focus-visible:ring-1 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50", {
  variants: {
    variant: {
      default: "bg-primary text-primary-foreground hover:bg-primary/90 cursor-pointer shadow",
      destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90 cursor-pointer shadow-sm",
      outline: "border-input bg-background hover:bg-accent hover:text-accent-foreground border shadow-sm",
      secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80 shadow-sm",
      ghost: "hover:bg-accent hover:text-accent-foreground cursor-pointer",
      link: "text-primary underline-offset-4 hover:underline",
      icon: "hover:text-accent-foreground cursor-pointer",
      float: "border-border hover:border-fd-accent rounded-none border-b",
      fullRounded: "text-muted-foreground hover:bg-accent rounded-full p-1.5 sm:p-2"
    },
    size: {
      default: "h-9 px-4 py-2",
      sm: "h-8 rounded-md px-3 text-xs",
      lg: "h-10 rounded-md px-8",
      icon: "size-9"
    }
  },
  defaultVariants: {
    variant: componentVariantNames.default,
    size: componentVariantNames.default
  }
});
function Button({
  className,
  variant,
  size,
  tooltipText,
  tooltipSide,
  tooltipClassName,
  tooltipAlign,
  children,
  onClick,
  id,
  disabled,
  type,
  style,
  tabIndex,
  title,
  onMouseEnter,
  [accessibilityAttributeNames.ariaControls]: ariaControls,
  [accessibilityAttributeNames.ariaExpanded]: ariaExpanded,
  [accessibilityAttributeNames.ariaHaspopup]: ariaHaspopup,
  [accessibilityAttributeNames.dataDisabled]: dataDisabled,
  [accessibilityAttributeNames.dataState]: dataState,
  onKeyDown,
  onPointerDown,
  render,
  ref
}) {
  const props = {
    className: cn(buttonVariants({
      variant,
      size,
      className
    })),
    ref,
    onClick,
    id,
    disabled,
    type,
    style,
    tabIndex,
    title,
    onMouseEnter,
    [accessibilityAttributeNames.ariaControls]: ariaControls,
    [accessibilityAttributeNames.ariaExpanded]: ariaExpanded,
    [accessibilityAttributeNames.ariaHaspopup]: ariaHaspopup,
    [accessibilityAttributeNames.dataDisabled]: dataDisabled,
    [accessibilityAttributeNames.dataState]: dataState,
    onKeyDown,
    onPointerDown,
    children
  };
  const elements = useRender({
    defaultTagName: htmlTags.button,
    render,
    props
  });
  if (!tooltipText) {
    return elements;
  } else {
    return /* @__PURE__ */jsx(Tooltip, {
      content: tooltipText,
      delayDuration: 100,
      align: tooltipAlign,
      className: tooltipClassName,
      side: tooltipSide ?? wellKnownPositions.bottom,
      children: elements
    });
  }
}
__name(Button, "Button");
Button.displayName = elementSuffixes.button;

export { Button, buttonVariants };
