/**
 * Copyright IBM Corp. 2020, 2026
 *
 * This source code is licensed under the Apache-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

const require_runtime = require('../../_virtual/_rolldown/runtime.js');
const require_index = require('../../node_modules/classnames/index.js');
const require_settings = require('../../settings.js');
const require_devtools = require('../../global/js/utils/devtools.js');
require('../../global/js/utils/props-helper.js');
const require_TooltipTrigger = require('../TooltipTrigger/TooltipTrigger.js');
let react = require("react");
react = require_runtime.__toESM(react);
let prop_types = require("prop-types");
prop_types = require_runtime.__toESM(prop_types);
let _carbon_react = require("@carbon/react");
let _carbon_react_icons = require("@carbon/react/icons");

//#region src/components/UserAvatar/UserAvatar.tsx
/**
* Copyright IBM Corp. 2024, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
var import_classnames = /* @__PURE__ */ require_runtime.__toESM(require_index.default);
const blockClass = `${require_settings.pkg.prefix}--user-avatar`;
const componentName = "UserAvatar";
const UserAvatar = react.default.forwardRef((props, ref) => {
	const { backgroundColor = "order-1-cyan", className, image, imageDescription, name, renderIcon: RenderIcon, size = "md", tooltipText, tooltipAlignment = "bottom", ...rest } = props;
	const carbonPrefix = (0, _carbon_react.usePrefix)();
	const iconSize = {
		sm: 16,
		md: 20,
		lg: 24,
		xl: 32
	};
	const formatInitials = () => {
		const parts = name?.split(" ") || [];
		const firstChar = parts[0].charAt(0).toUpperCase();
		const secondChar = parts[0].charAt(1).toUpperCase();
		if (parts.length === 1) return firstChar + secondChar;
		const lastChar = parts[parts.length - 1].charAt(0).toUpperCase();
		const initials = [firstChar];
		if (lastChar) initials.push(lastChar);
		return "".concat(...initials);
	};
	const getItem = () => {
		const iconProps = { size: iconSize[size] };
		if (image) return /* @__PURE__ */ react.default.createElement("img", {
			alt: imageDescription,
			src: image,
			className: `${blockClass}__photo ${blockClass}__photo--${size}`
		});
		if (RenderIcon) return /* @__PURE__ */ react.default.createElement(RenderIcon, iconProps);
		if (name) return formatInitials();
		return /* @__PURE__ */ react.default.createElement(_carbon_react_icons.User, iconProps);
	};
	const Avatar = () => /* @__PURE__ */ react.default.createElement("div", {
		...rest,
		className: (0, import_classnames.default)(blockClass, className, `${blockClass}--${backgroundColor}`, `${blockClass}--${size}`, {}),
		ref,
		...require_devtools.getDevtoolsProps(componentName)
	}, getItem());
	if (tooltipText) return /* @__PURE__ */ react.default.createElement(_carbon_react.Tooltip, {
		align: tooltipAlignment,
		label: tooltipText,
		className: `${blockClass}__tooltip ${carbonPrefix}--icon-tooltip`
	}, /* @__PURE__ */ react.default.createElement(require_TooltipTrigger.TooltipTrigger, null, /* @__PURE__ */ react.default.createElement(Avatar, null)));
	return /* @__PURE__ */ react.default.createElement(Avatar, null);
});
UserAvatar.displayName = componentName;
UserAvatar.propTypes = {
	backgroundColor: prop_types.default.oneOf([
		"order-1-cyan",
		"order-2-gray",
		"order-3-green",
		"order-4-magenta",
		"order-5-purple",
		"order-6-teal",
		"order-7-cyan",
		"order-8-gray",
		"order-9-green",
		"order-10-magenta",
		"order-11-purple",
		"order-12-teal"
	]),
	className: prop_types.default.string,
	image: prop_types.default.string,
	imageDescription: prop_types.default.string,
	name: prop_types.default.string,
	renderIcon: prop_types.default.oneOfType([
		prop_types.default.func,
		prop_types.default.object,
		prop_types.default.string
	]),
	size: prop_types.default.oneOf([
		"xl",
		"lg",
		"md",
		"sm"
	]),
	tooltipAlignment: prop_types.default.oneOf([
		"top",
		"top-left",
		"top-right",
		"bottom",
		"bottom-left",
		"bottom-right",
		"left",
		"right"
	]),
	tooltipText: prop_types.default.string
};

//#endregion
exports.UserAvatar = UserAvatar;