"use client";
import * as React from 'react';
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { jsx } from 'react/jsx-runtime';

function cn(...inputs) {
  return twMerge(clsx(inputs));
}
function Suggestion({
  value,
  onSelect,
  children,
  className,
  type = "button",
  onClick,
  ...props
}) {
  function handleClick(event) {
    const payload = value ?? extractText(children);
    onSelect(payload);
    onClick?.(event);
  }
  return /* @__PURE__ */ jsx(
    "button",
    {
      type,
      onClick: handleClick,
      className: cn(
        "inline-flex items-center rounded-full border border-foreground/15 bg-background px-3 py-1.5 text-sm",
        "transition-all duration-[var(--duration-normal,200ms)] ease-out",
        "hover:border-foreground/30 hover:bg-secondary/40 hover:shadow-sm",
        "active:scale-[0.98]",
        "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
        "disabled:cursor-not-allowed disabled:opacity-50",
        className
      ),
      ...props,
      children
    }
  );
}
function extractText(node) {
  if (node == null || typeof node === "boolean") return "";
  if (typeof node === "string" || typeof node === "number") return String(node);
  if (Array.isArray(node)) return node.map(extractText).join(" ").replace(/\s+/g, " ").trim();
  if (React.isValidElement(node)) {
    return extractText(node.props.children);
  }
  return "";
}

export { Suggestion };
//# sourceMappingURL=suggestion.js.map
//# sourceMappingURL=suggestion.js.map