"use client";
import Link from 'next/link';
import { cva } from 'class-variance-authority';
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { jsxs, jsx } from 'react/jsx-runtime';

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
function cn(...inputs) {
  return twMerge(clsx(inputs));
}
var linkButtonVariants = cva(
  "inline-flex items-center justify-center gap-1 rounded-sm font-medium text-base leading-6 text-center transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:shrink-0 [&_svg]:size-4",
  {
    variants: {
      variant: {
        default: "text-foreground hover:bg-muted/50 hover:text-foreground",
        muted: "text-muted-foreground hover:bg-muted/50 hover:text-foreground",
        primary: "text-primary hover:bg-primary/10 hover:text-primary",
        disabled: "text-muted-foreground/50 cursor-not-allowed"
      },
      underline: { true: "", false: "" }
    },
    defaultVariants: { variant: "default", underline: false }
  }
);
function LinkButton(_a) {
  var _b = _a, {
    className,
    variant = "default",
    underline = false,
    href,
    leadIcon,
    tailIcon,
    children,
    asButton = false
  } = _b, props = __objRest(_b, [
    "className",
    "variant",
    "underline",
    "href",
    "leadIcon",
    "tailIcon",
    "children",
    "asButton"
  ]);
  const isExternal = typeof href === "string" && (href.startsWith("http") || href.startsWith("//"));
  const classes = cn(linkButtonVariants({ variant, underline, className }));
  if (asButton || href == null) {
    return /* @__PURE__ */ jsxs(
      "button",
      __spreadProps(__spreadValues({
        type: "button",
        className: classes,
        disabled: variant === "disabled"
      }, props), {
        children: [
          leadIcon && /* @__PURE__ */ jsx("span", { className: "shrink-0", "aria-hidden": true, children: leadIcon }),
          /* @__PURE__ */ jsx("span", { className: underline ? "underline decoration-current underline-offset-4" : "", children }),
          tailIcon && /* @__PURE__ */ jsx("span", { className: "shrink-0", "aria-hidden": true, children: tailIcon })
        ]
      })
    );
  }
  return /* @__PURE__ */ jsxs(
    Link,
    __spreadProps(__spreadValues(__spreadValues({
      href,
      className: classes
    }, isExternal && { target: "_blank", rel: "noopener noreferrer" }), props), {
      children: [
        leadIcon && /* @__PURE__ */ jsx("span", { className: "shrink-0", "aria-hidden": true, children: leadIcon }),
        /* @__PURE__ */ jsx("span", { className: underline ? "underline decoration-current underline-offset-4" : "", children }),
        tailIcon && /* @__PURE__ */ jsx("span", { className: "shrink-0", "aria-hidden": true, children: tailIcon })
      ]
    })
  );
}

export { LinkButton, linkButtonVariants };
//# sourceMappingURL=link-button.js.map
//# sourceMappingURL=link-button.js.map