"use strict";
var import_Avatar = require("../Avatar.css");
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const jsxRuntime = require("react/jsx-runtime");
const kit_internal_functions = require("./internal/functions.cjs");
const kit_internal_md5 = require("./internal/md5.cjs");
const kit_Theme_UI = require("./Theme/UI.cjs");
require("./Theme/themeUtils.cjs");
require("./Theme/themes.cjs");
const kit_Tooltip = require("./Tooltip.cjs");
const base = "Avatar_base_8a380";
const square = "Avatar_square_8a380";
const small = "Avatar_small_8a380";
const medium = "Avatar_medium_8a380";
const large = "Avatar_large_8a380";
const inactive = "Avatar_inactive_8a380";
const group = "Avatar_group_8a380";
const css = {
  base,
  square,
  "extra-small": "Avatar_extra-small_8a380",
  small,
  medium,
  large,
  "extra-large": "Avatar_extra-large_8a380",
  inactive,
  group
};
const Size = {
  ExtraLarge: "extra-large",
  ExtraSmall: "extra-small",
  Large: "large",
  Medium: "medium",
  Small: "small"
};
const getInitials = (name = "") => {
  const initials = name.split(/\s+/).map((n) => n.charAt(0).toUpperCase()).join("");
  return initials.length > 2 ? `${initials.charAt(0)}${initials.substring(initials.length - 1)}` : initials;
};
const getColor = (name = "", themeIsDark, palette) => {
  const hslColor = name ? kit_internal_functions.hex2hsl(kit_internal_md5(name).substring(0, 6)) : kit_internal_functions.hex2hsl("#808080");
  if (palette === "muted") {
    return kit_internal_functions.hsl2str({
      ...hslColor,
      l: themeIsDark ? 80 : 90,
      s: themeIsDark ? 40 : 77
    });
  }
  return kit_internal_functions.hsl2str({
    ...hslColor,
    l: themeIsDark ? 38 : 60
  });
};
const Avatar = ({
  text,
  hideTooltip,
  noColor,
  size = Size.Small,
  square: square2,
  palette = "bright",
  tooltipText,
  inactive: inactive2
}) => {
  const {
    themeSettings: { themeIsDark, className: themeClass }
  } = kit_Theme_UI.useTheme();
  const style = {
    backgroundColor: noColor ? "var(--theme-stage-strong)" : getColor(text, themeIsDark, palette),
    color: noColor ? "var(--theme-stage-on-strong)" : palette === "bright" ? "white" : "black"
  };
  const classes = [css.base, css[size], themeClass];
  if (square2)
    classes.push(css.square);
  if (inactive2)
    classes.push(css.inactive);
  const avatar = /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.join(" "), id: "avatar", style, children: getInitials(text) });
  return hideTooltip ? avatar : /* @__PURE__ */ jsxRuntime.jsx(kit_Tooltip, { content: tooltipText ?? text, placement: "right", children: avatar });
};
const AvatarGroup = ({ items, ...rest }) => {
  const {
    themeSettings: { className: themeClass }
  } = kit_Theme_UI.useTheme();
  const classes = [css.group, themeClass];
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.join(" "), children: items.map((item, idx) => /* @__PURE__ */ jsxRuntime.jsx(Avatar, { text: item, ...rest }, idx)) });
};
exports.AvatarGroup = AvatarGroup;
exports.Size = Size;
exports.default = Avatar;
exports.getColor = getColor;
exports.getInitials = getInitials;
