import { o as q } from "./rolldown-runtime.js";
import { i as R, t as D } from "./vendor/react.js";
import { t as F } from "./createLucideIcon.js";
import { t as O } from "./pencil.js";
import { t as T } from "./plus.js";
import { t as H } from "./dist.js";
import { t as r } from "./utils.js";
import { n as X, r as J, t as Q } from "./AvatarFallback.js";
var W = [["path", {
  d: "M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",
  key: "r04s7s"
}]], Y = F("star", W), Z = [["path", {
  d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",
  key: "975kel"
}], ["circle", {
  cx: "12",
  cy: "7",
  r: "4",
  key: "17ys0d"
}]], ee = F("user", Z), v = /* @__PURE__ */ q(R(), 1), e = D(), C = v.createContext(null);
function re() {
  return v.useContext(C);
}
var S = H("relative flex shrink-0", {
  variants: {
    size: {
      xs: "size-6",
      sm: "size-8",
      md: "size-10",
      lg: "size-12",
      xl: "size-14",
      "2xl": "size-16"
    },
    shape: {
      circle: "rounded-full",
      rounded: "rounded-lg"
    }
  },
  defaultVariants: {
    size: "md",
    shape: "circle"
  }
}), L = {
  primary: "ring-2 ring-primary",
  success: "ring-2 ring-success",
  warning: "ring-2 ring-warning",
  destructive: "ring-2 ring-destructive"
}, j = {
  primary: {
    bg: "bg-primary/10",
    text: "text-primary"
  },
  indigo: {
    bg: "bg-indigo-500/10",
    text: "text-indigo-500"
  },
  purple: {
    bg: "bg-purple-500/10",
    text: "text-purple-500"
  },
  success: {
    bg: "bg-success/10",
    text: "text-success"
  },
  warning: {
    bg: "bg-warning/10",
    text: "text-warning"
  },
  slate: {
    bg: "bg-slate-400/10",
    text: "text-slate-400"
  }
}, P = "bg-gray-100 dark:bg-gray-800", te = "text-gray-600 dark:text-gray-300", k = {
  xs: "text-[10px]",
  sm: "text-xs",
  md: "text-sm",
  lg: "text-base",
  xl: "text-lg",
  "2xl": "text-xl"
}, U = {
  xs: "size-3",
  sm: "size-4",
  md: "size-5",
  lg: "size-6",
  xl: "size-7",
  "2xl": "size-8"
}, ae = {
  xs: "size-2",
  sm: "size-2.5",
  md: "size-3",
  lg: "size-3.5",
  xl: "size-4",
  "2xl": "size-5"
}, se = {
  xs: "size-3.5",
  sm: "size-4",
  md: "size-5",
  lg: "size-6",
  xl: "size-7",
  "2xl": "size-8"
}, N = {
  online: "Online",
  away: "Away",
  busy: "Busy",
  offline: "Offline",
  verified: "Verified",
  upload: "Upload",
  edit: "Edit"
}, ie = {
  xs: "size-2",
  sm: "size-2.5",
  md: "size-3",
  lg: "size-3.5",
  xl: "size-4",
  "2xl": "size-5"
}, le = {
  xs: "-space-x-1",
  sm: "-space-x-2",
  md: "-space-x-2.5",
  lg: "-space-x-3",
  xl: "-space-x-3.5",
  "2xl": "-space-x-4"
}, ne = {
  xs: "px-0.5 py-0.5 gap-1",
  sm: "px-1 py-1 gap-1.5",
  md: "px-1 py-1 gap-2",
  lg: "px-1.5 py-1.5 gap-2",
  xl: "px-2 py-2 gap-2.5",
  "2xl": "px-2.5 py-2.5 gap-3"
}, de = {
  xs: "px-1",
  sm: "px-1.5",
  md: "px-2",
  lg: "px-2.5",
  xl: "px-3",
  "2xl": "px-3.5"
}, oe = v.forwardRef(function({ src: s, alt: o, fallback: c, icon: u, size: h = "md", shape: z = "circle", type: A, ring: g, indicator: a, indicatorPosition: m = "top-right", softColor: t, className: i }, y) {
  const p = re()?.size ?? h, n = p || "md", l = A ?? (s ? "image" : u ? "icon" : c || o ? "initials" : "icon"), f = (b) => {
    if (!b) return "";
    const d = b.split(" ");
    return d.length >= 2 ? `${d[0][0]}${d[1][0]}`.toUpperCase() : b.slice(0, 2).toUpperCase();
  }, B = () => g ? g === !0 ? L.primary : L[g] : "", w = z === "circle" ? "rounded-full" : "rounded-lg", E = () => {
    if (!a) return null;
    const b = ae[n], d = se[n], M = ie[n], K = m === "top-right" ? "absolute top-0 end-0" : "absolute bottom-0 end-0", _ = m === "top-right" ? "absolute -top-1 -end-1" : "absolute -bottom-0.5 -end-0.5", I = {
      online: "bg-success",
      away: "bg-warning",
      busy: "bg-destructive",
      offline: "bg-muted"
    }[a];
    if (I) {
      const V = a !== "offline";
      return /* @__PURE__ */ (0, e.jsx)("span", {
        role: "status",
        "aria-label": N[a],
        className: r(K, "block rounded-full ring-2 ring-background", I, b, V && "delight-status-pulse")
      });
    }
    switch (a) {
      case "verified":
        return /* @__PURE__ */ (0, e.jsx)("div", {
          role: "img",
          "aria-label": N[a],
          className: r(_, "flex items-center justify-center rounded-full bg-warning delight-badge-shimmer", d),
          children: /* @__PURE__ */ (0, e.jsx)(Y, {
            "aria-hidden": "true",
            className: r("text-white fill-current", M)
          })
        });
      case "upload":
        return /* @__PURE__ */ (0, e.jsx)("div", {
          role: "img",
          "aria-label": N[a],
          className: r(_, "flex items-center justify-center rounded-full bg-slate-400 ring-2 ring-background", d),
          children: /* @__PURE__ */ (0, e.jsx)(T, {
            "aria-hidden": "true",
            className: r("text-white", M)
          })
        });
      case "edit":
        return /* @__PURE__ */ (0, e.jsx)("div", {
          role: "img",
          "aria-label": N[a],
          className: r(_, "flex items-center justify-center rounded-full bg-background border-2 border-border", d),
          children: /* @__PURE__ */ (0, e.jsx)(O, {
            "aria-hidden": "true",
            className: r("text-foreground", M)
          })
        });
      default:
        return null;
    }
  }, G = () => t ? r(j[t].bg, j[t].text) : r(P, te), $ = () => l === "image" && s ? "" : t ? j[t].bg : P;
  return /* @__PURE__ */ (0, e.jsxs)("div", {
    ref: y,
    "data-slot": "avatar",
    className: r("relative inline-block", S({
      size: p,
      shape: z
    }), $(), B(), i),
    children: [/* @__PURE__ */ (0, e.jsxs)(J, {
      "data-slot": "avatar-root",
      "data-size": p,
      className: r("relative flex size-full shrink-0 select-none overflow-hidden", w),
      children: [l === "image" && s && /* @__PURE__ */ (0, e.jsx)(X, {
        "data-slot": "avatar-image",
        src: s,
        alt: o ?? "",
        className: r("aspect-square size-full object-cover delight-fade-in", w)
      }), /* @__PURE__ */ (0, e.jsx)(Q, {
        "data-slot": "avatar-fallback",
        className: r("flex size-full items-center justify-center font-semibold", w, G(), k[n]),
        children: c || o ? f(c || o) : u ?? /* @__PURE__ */ (0, e.jsx)(ee, { className: r(t ? j[t].text : "text-muted-foreground", U[n]) })
      })]
    }), E()]
  });
});
oe.displayName = "Avatar";
function ce({ max: x, size: s = "md", children: o, className: c, variant: u = "default", pillText: h, showAddButton: z, onAddClick: A, ...g }) {
  const a = v.Children.toArray(o), m = x ? a.slice(0, x) : a, t = x ? Math.max(0, a.length - x) : 0, i = s || "md", y = v.useMemo(() => ({ size: s }), [s]), p = () => {
    if (!h) return /* @__PURE__ */ (0, e.jsxs)("span", {
      className: r("text-foreground", k[i]),
      children: ["+", t]
    });
    const l = h.split("{count}");
    return /* @__PURE__ */ (0, e.jsxs)(e.Fragment, { children: [
      l[0] && /* @__PURE__ */ (0, e.jsx)("span", {
        className: "text-muted-foreground",
        children: l[0]
      }),
      /* @__PURE__ */ (0, e.jsxs)("span", {
        className: "text-foreground",
        children: ["+", t]
      }),
      l[1] && /* @__PURE__ */ (0, e.jsx)("span", {
        className: "text-muted-foreground",
        children: l[1]
      })
    ] });
  }, n = /* @__PURE__ */ (0, e.jsxs)("div", {
    "data-slot": "avatar-group-stack",
    className: r("flex items-center", le[i]),
    children: [
      m.map((l, f) => /* @__PURE__ */ (0, e.jsx)("div", {
        className: "ring-2 ring-background rounded-full delight-stagger",
        style: {
          zIndex: m.length - f,
          "--delight-delay": `${f * 50}ms`
        },
        children: l
      }, f)),
      t > 0 && u === "default" && /* @__PURE__ */ (0, e.jsx)("div", {
        role: "img",
        "aria-label": `${t} more`,
        className: r("flex items-center justify-center rounded-full bg-muted ring-2 ring-background relative", S({ size: s })),
        style: { zIndex: 0 },
        children: /* @__PURE__ */ (0, e.jsxs)("span", {
          "aria-hidden": "true",
          className: r("text-muted-foreground font-semibold", k[i]),
          children: ["+", t]
        })
      }),
      z && u === "default" && /* @__PURE__ */ (0, e.jsx)("button", {
        type: "button",
        onClick: A,
        "aria-label": "Add avatar",
        className: r("flex items-center justify-center rounded-full bg-muted ring-2 ring-background hover:bg-muted-foreground/10 transition-colors", S({ size: s })),
        style: { zIndex: 0 },
        children: /* @__PURE__ */ (0, e.jsx)(T, { className: r("text-muted-foreground", U[i]) })
      })
    ]
  });
  return u === "pill" ? /* @__PURE__ */ (0, e.jsx)(C.Provider, {
    value: y,
    children: /* @__PURE__ */ (0, e.jsxs)("div", {
      className: r("inline-flex items-center rounded-full bg-background border border-border shadow-sm", ne[i], c),
      ...g,
      children: [n, t > 0 && /* @__PURE__ */ (0, e.jsx)("span", {
        className: r(de[i], k[i]),
        children: p()
      })]
    })
  }) : /* @__PURE__ */ (0, e.jsx)(C.Provider, {
    value: y,
    children: /* @__PURE__ */ (0, e.jsx)("div", {
      className: r("flex items-center", c),
      ...g,
      children: n
    })
  });
}
ce.displayName = "AvatarGroup";
export {
  oe as t
};

//# sourceMappingURL=Avatar.js.map