import { jsx as e, jsxs as p, Fragment as y } from "react/jsx-runtime";
import { Classes as j } from "../../constants/selectors.js";
import { ArrowRightIcon as C } from "../../icons/index.js";
import { cn as a } from "../../utils/cn.js";
import { isRemoteUrl as I } from "../../utils/is-remote-url.js";
import A from "../../node_modules/.pnpm/lucide-react@0.453.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/arrow-up-right.js";
import { Icon as R } from "../icon/icon.js";
const L = ({
  title: o,
  icon: r,
  iconType: n,
  iconLibrary: f,
  color: d,
  horizontal: s,
  href: h,
  img: g,
  children: x,
  disabled: i,
  cta: c,
  arrow: t,
  as: v,
  className: m
}) => {
  const b = typeof r == "string" ? /* @__PURE__ */ e(
    R,
    {
      className: "m-0! size-6 shrink-0",
      color: d,
      icon: r,
      iconLibrary: f,
      iconType: n,
      overrideColor: !!d
    }
  ) : r, l = i ? void 0 : h;
  return /* @__PURE__ */ e(
    z,
    {
      arrow: t,
      as: v,
      className: a(
        l && "hover:border-primary! dark:hover:border-primary-light!",
        m
      ),
      cta: c,
      disabled: i,
      horizontal: s,
      href: l,
      icon: b,
      img: g,
      title: o,
      children: x
    }
  );
}, z = ({
  title: o,
  icon: r,
  img: n,
  className: f,
  children: d,
  horizontal: s,
  arrow: h,
  as: g,
  mRef: x,
  cta: i,
  disabled: c,
  ...t
}) => {
  var u;
  const v = c ? "div" : g || (t.href !== void 0 ? "a" : "div"), m = I(t.href ?? ""), b = m ? { target: "_blank", rel: "noreferrer" } : {}, l = h ?? m, k = typeof r == "string", w = n ? ((u = n.match(/\/([^/]+)\.[^.]+$/)) == null ? void 0 : u[1]) ?? "" : "", N = /* @__PURE__ */ e(y, { children: r ? (
    // biome-ignore lint/style/noNestedTernary: TODO
    k ? (
      // biome-ignore lint/correctness/useImageSize: TODO
      /* @__PURE__ */ e(
        "img",
        {
          alt: typeof o == "string" ? o : "",
          className: "size-6 object-cover object-center",
          "data-component-part": "card-icon",
          src: r
        }
      )
    ) : /* @__PURE__ */ e(
      "div",
      {
        className: "size-6 fill-stone-800 text-stone-800 dark:fill-stone-100 dark:text-stone-100",
        "data-component-part": "card-icon",
        children: r
      }
    )
  ) : null });
  return /* @__PURE__ */ p(
    v,
    {
      className: a(
        j.Card,
        "group relative my-2 block w-full overflow-hidden rounded-2xl border border-stone-950/10 bg-white font-normal ring-2 ring-transparent dark:border-white/10 dark:bg-background-dark",
        t.href && "cursor-pointer",
        t.href && "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary dark:focus-visible:ring-primary-light",
        f
      ),
      ...b,
      ...t,
      ref: x,
      children: [
        n && // biome-ignore lint/correctness/useImageSize: TODO
        /* @__PURE__ */ e(
          "img",
          {
            alt: w,
            className: "not-prose w-full object-cover object-center",
            "data-component-part": "card-image",
            src: n
          }
        ),
        /* @__PURE__ */ p(
          "div",
          {
            className: a(
              "relative px-6 py-5",
              s && "flex items-center gap-x-4"
            ),
            "data-component-part": "card-content-container",
            children: [
              t.href && /* @__PURE__ */ e(
                "div",
                {
                  "aria-hidden": "true",
                  className: a(
                    "absolute top-5 right-5 text-stone-400 group-hover:text-primary dark:text-stone-500 dark:group-hover:text-primary-light",
                    !l && "hidden"
                  ),
                  "data-component-part": "card-arrow",
                  children: /* @__PURE__ */ e(A, { className: "size-4" })
                }
              ),
              N,
              /* @__PURE__ */ p("div", { className: "min-w-0 flex-1", children: [
                o && /* @__PURE__ */ e(
                  "h2",
                  {
                    className: a(
                      "not-prose wrap-break-word font-semibold text-base text-stone-800 dark:text-white",
                      r != null && !s && "mt-4"
                    ),
                    contentEditable: !1,
                    "data-component-part": "card-title",
                    children: o
                  }
                ),
                /* @__PURE__ */ e(
                  "div",
                  {
                    className: a(
                      "prose wrap-break-word mt-1 font-normal text-base leading-6",
                      o ? "text-stone-600 dark:text-stone-400" : "text-stone-700 dark:text-stone-300",
                      s && "mt-0 leading-6"
                    ),
                    "data-component-part": "card-content",
                    children: d
                  }
                ),
                i && /* @__PURE__ */ e("div", { className: "mt-8", "data-component-part": "card-cta", children: /* @__PURE__ */ p(
                  "span",
                  {
                    className: a(
                      "flex flex-row items-center gap-2 text-left font-medium text-sm text-stone-600 dark:text-stone-400",
                      !c && "group-hover:text-primary group-hover:dark:text-primary-light",
                      c && "opacity-50"
                    ),
                    children: [
                      i,
                      /* @__PURE__ */ e(C, { className: "h-6" })
                    ]
                  }
                ) })
              ] })
            ]
          }
        )
      ]
    }
  );
};
export {
  L as Card,
  z as GenericCard
};
