import { o as V } from "./rolldown-runtime.js";
import { i as A, t as D } from "./vendor/react.js";
import { t as _ } from "./check.js";
import { n as I, t as j } from "./spinner.js";
import { t as L } from "./x.js";
import { t as O } from "./useRenderElement.js";
import { t as T } from "./useButton.js";
import { t as G } from "./dist.js";
import { t as s } from "./utils.js";
var n = /* @__PURE__ */ V(A()), h = /* @__PURE__ */ n.forwardRef(function(e, t) {
  const { render: x, className: y, disabled: i = !1, focusableWhenDisabled: p = !1, nativeButton: v = !0, style: N, ...o } = e, { getButtonProps: g, buttonRef: c } = T({
    disabled: i,
    focusableWhenDisabled: p,
    native: v
  });
  return O("button", e, {
    state: { disabled: i },
    ref: [t, c],
    props: [o, g]
  });
}), a = D(), M = G("focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 border border-transparent bg-clip-padding text-sm font-medium focus-visible:ring-[3px] aria-invalid:ring-[3px] [&_svg:not([class*='size-'])]:size-4 inline-flex items-center justify-center whitespace-nowrap transition-[color,background-color,border-color,box-shadow,transform,opacity] duration-150 ease-out hover:-translate-y-px active:translate-y-0 active:scale-[0.97] motion-reduce:hover:translate-y-0 motion-reduce:active:scale-100 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none shrink-0 [&_svg]:shrink-0 outline-none group/button select-none", {
  variants: {
    appearance: {
      solid: "delight-click-ripple",
      gradient: "bg-linear-[113deg] hover:opacity-80 delight-click-ripple",
      soft: "delight-click-ripple",
      outline: "bg-background shadow-xs",
      ghost: "bg-transparent",
      link: "border-none bg-transparent p-0 h-auto underline-offset-4 hover:underline hover:translate-y-0 focus-visible:ring-0 focus-visible:border-transparent",
      ai: "bg-transparent border-0"
    },
    variant: {
      primary: "",
      secondary: "",
      info: "",
      success: "",
      warning: "",
      destructive: ""
    },
    size: {
      default: "h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-full has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",
      xs: "h-6 gap-1 px-2 text-xs in-data-[slot=button-group]:rounded-full has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",
      sm: "h-8 gap-1 px-2.5 in-data-[slot=button-group]:rounded-full has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5",
      md: "h-10 gap-1.5 px-3.5 has-data-[icon=inline-end]:pe-3 has-data-[icon=inline-start]:ps-3",
      lg: "h-11 gap-2 px-4 has-data-[icon=inline-end]:pe-3.5 has-data-[icon=inline-start]:ps-3.5",
      xl: "h-12 gap-2 px-4.5 text-base has-data-[icon=inline-end]:pe-4 has-data-[icon=inline-start]:ps-4 [&_svg:not([class*='size-'])]:size-5",
      "2xl": "h-14 gap-2.5 px-5 text-lg has-data-[icon=inline-end]:pe-4.5 has-data-[icon=inline-start]:ps-4.5 [&_svg:not([class*='size-'])]:size-6",
      icon: "size-9",
      "icon-xs": "size-6 in-data-[slot=button-group]:rounded-full [&_svg:not([class*='size-'])]:size-3",
      "icon-sm": "size-8 in-data-[slot=button-group]:rounded-full",
      "icon-lg": "size-10",
      "icon-xl": "size-12 [&_svg:not([class*='size-'])]:size-5",
      "icon-2xl": "size-14 [&_svg:not([class*='size-'])]:size-6"
    },
    shape: {
      rounded: "rounded-md",
      round: "rounded-full"
    }
  },
  compoundVariants: [
    {
      appearance: "solid",
      variant: "primary",
      className: "bg-primary text-primary-foreground hover:bg-primary/80"
    },
    {
      appearance: "solid",
      variant: "secondary",
      className: "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground"
    },
    {
      appearance: "solid",
      variant: "info",
      className: "bg-info text-info-foreground hover:bg-info/80"
    },
    {
      appearance: "solid",
      variant: "success",
      className: "bg-success text-success-foreground hover:bg-success/80"
    },
    {
      appearance: "solid",
      variant: "warning",
      className: "bg-warning text-warning-foreground hover:bg-warning/80"
    },
    {
      appearance: "solid",
      variant: "destructive",
      className: "bg-destructive text-destructive-foreground hover:bg-destructive/80"
    },
    {
      appearance: "gradient",
      variant: "primary",
      className: "from-custom-tw-gradient-from to-custom-tw-gradient-to text-primary-foreground hover:from-custom-tw-gradient-to hover:to-custom-tw-gradient-from"
    },
    {
      appearance: "gradient",
      variant: "secondary",
      className: "from-secondary to-secondary/60 text-secondary-foreground hover:from-secondary/60 hover:to-secondary"
    },
    {
      appearance: "gradient",
      variant: "info",
      className: "from-info to-info/60 text-info-foreground hover:from-info/60 hover:to-info"
    },
    {
      appearance: "gradient",
      variant: "success",
      className: "from-success to-success/60 text-success-foreground hover:from-success/60 hover:to-success"
    },
    {
      appearance: "gradient",
      variant: "warning",
      className: "from-warning to-warning/60 text-warning-foreground hover:from-warning/60 hover:to-warning"
    },
    {
      appearance: "gradient",
      variant: "destructive",
      className: "from-destructive to-destructive/60 text-destructive-foreground hover:from-destructive/60 hover:to-destructive"
    },
    {
      appearance: "soft",
      variant: "primary",
      className: "bg-primary/10 border-primary text-primary hover:bg-primary/20 hover:text-primary dark:bg-primary/30 dark:border-primary dark:text-primary dark:hover:bg-primary/50 shadow-xs"
    },
    {
      appearance: "soft",
      variant: "secondary",
      className: "bg-secondary/10 text-secondary-foreground hover:bg-secondary/20"
    },
    {
      appearance: "soft",
      variant: "info",
      className: "bg-info/10 text-info hover:bg-info/20"
    },
    {
      appearance: "soft",
      variant: "success",
      className: "bg-success/10 text-success hover:bg-success/20"
    },
    {
      appearance: "soft",
      variant: "warning",
      className: "bg-warning/10 text-warning hover:bg-warning/20"
    },
    {
      appearance: "soft",
      variant: "destructive",
      className: "bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30"
    },
    {
      appearance: "outline",
      variant: "primary",
      className: "border-primary text-primary hover:bg-primary/10"
    },
    {
      appearance: "outline",
      variant: "secondary",
      className: "border-border text-secondary-foreground hover:bg-muted hover:text-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 aria-expanded:bg-muted aria-expanded:text-foreground"
    },
    {
      appearance: "outline",
      variant: "info",
      className: "border-info text-info hover:bg-info/10"
    },
    {
      appearance: "outline",
      variant: "success",
      className: "border-success text-success hover:bg-success/10"
    },
    {
      appearance: "outline",
      variant: "warning",
      className: "border-warning text-warning hover:bg-warning/10"
    },
    {
      appearance: "outline",
      variant: "destructive",
      className: "border-destructive text-destructive hover:bg-destructive/10"
    },
    {
      appearance: "ghost",
      variant: "primary",
      className: "text-primary hover:bg-primary/10"
    },
    {
      appearance: "ghost",
      variant: "secondary",
      className: "hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground"
    },
    {
      appearance: "ghost",
      variant: "info",
      className: "text-info hover:bg-info/10"
    },
    {
      appearance: "ghost",
      variant: "success",
      className: "text-success hover:bg-success/10"
    },
    {
      appearance: "ghost",
      variant: "warning",
      className: "text-warning hover:bg-warning/10"
    },
    {
      appearance: "ghost",
      variant: "destructive",
      className: "text-destructive hover:bg-destructive/10"
    },
    {
      appearance: "ai",
      variant: "primary",
      className: "text-primary hover:bg-primary/10"
    },
    {
      appearance: "ai",
      variant: "secondary",
      className: "text-secondary-foreground hover:bg-muted"
    },
    {
      appearance: "link",
      variant: "primary",
      className: "text-primary"
    },
    {
      appearance: "link",
      variant: "secondary",
      className: "text-secondary-foreground"
    },
    {
      appearance: "link",
      variant: "info",
      className: "text-info"
    },
    {
      appearance: "link",
      variant: "success",
      className: "text-success"
    },
    {
      appearance: "link",
      variant: "warning",
      className: "text-warning"
    },
    {
      appearance: "link",
      variant: "destructive",
      className: "text-error-700 hover:text-error-800 dark:text-error-400 dark:hover:text-error-300"
    }
  ],
  defaultVariants: {
    appearance: "solid",
    variant: "primary",
    size: "default",
    shape: "round"
  }
}), P = {
  success: "bg-success",
  error: "bg-destructive",
  warning: "bg-warning",
  brand: "bg-primary",
  gray: "bg-muted"
}, W = [
  "icon",
  "icon-xs",
  "icon-sm",
  "icon-lg",
  "icon-xl",
  "icon-2xl"
], X = ({ color: r = "success", className: e }) => /* @__PURE__ */ (0, a.jsx)("span", {
  "aria-hidden": "true",
  className: s("size-2 rounded-full shrink-0 delight-breathing", P[r], e)
}), B = n.forwardRef(({ children: r, loading: e = !1, disabled: t, startIcon: x, endIcon: y, dotIndicator: i = !1, dotColor: p = "success", iconOnly: v = !1, animated: N, render: o, className: g, appearance: c = "solid", variant: C = "primary", shape: S = "round", size: w = "default", ...m }, d) => {
  const k = n.useRef(e), [u, f] = n.useState(!1);
  n.useEffect(() => {
    const E = k.current;
    if (k.current = e, e) f(!1);
    else if (E) {
      f(!0);
      const q = setTimeout(() => f(!1), 600);
      return () => clearTimeout(q);
    }
  }, [e]);
  const l = c === "ai", R = l ? N ?? e : !1, b = s(M({
    appearance: c,
    variant: C,
    shape: S,
    size: w
  }), g);
  if (o) return /* @__PURE__ */ (0, a.jsx)(h, {
    ref: d,
    "data-slot": "button",
    className: b,
    render: o,
    ...m,
    children: r
  });
  const z = v || W.includes(w) ? /* @__PURE__ */ (0, a.jsx)(h, {
    ref: l ? void 0 : d,
    "data-slot": "button",
    disabled: t || e,
    className: s(b, e && "relative"),
    ...m,
    children: e ? /* @__PURE__ */ (0, a.jsx)(j, { className: "delight-fade-in" }) : u ? /* @__PURE__ */ (0, a.jsx)(_, { className: "delight-bounce-in" }) : r
  }) : /* @__PURE__ */ (0, a.jsxs)(h, {
    ref: l ? void 0 : d,
    "data-slot": "button",
    disabled: t || e,
    className: s(b, (e || u) && "relative"),
    ...m,
    children: [
      e && /* @__PURE__ */ (0, a.jsx)(j, { className: "absolute delight-fade-in" }),
      u && !e && /* @__PURE__ */ (0, a.jsx)(_, { className: "absolute delight-bounce-in" }),
      /* @__PURE__ */ (0, a.jsxs)("span", {
        className: s("flex items-center gap-2", (e || u) && "invisible"),
        children: [
          i && /* @__PURE__ */ (0, a.jsx)(X, { color: p }),
          x,
          r,
          y
        ]
      })
    ]
  });
  return l ? /* @__PURE__ */ (0, a.jsx)(I, {
    ref: d,
    animated: R,
    active: !0,
    disabled: t,
    className: "w-auto inline-flex motion-reduce:animate-none",
    innerClassName: "flex",
    children: z
  }) : z;
});
B.displayName = "Button";
function Z({ className: r, size: e = "icon-sm", ...t }) {
  return /* @__PURE__ */ (0, a.jsx)(B, {
    appearance: "ghost",
    variant: "secondary",
    size: e,
    iconOnly: !0,
    className: s("text-quaternary-foreground hover:text-secondary-foreground", r),
    "aria-label": "Clear",
    ...t,
    children: /* @__PURE__ */ (0, a.jsx)(L, {})
  });
}
Z.displayName = "ClearButton";
export {
  B as t
};

//# sourceMappingURL=Button.js.map