/**
 * 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/UserProfileImage/UserProfileImage.tsx
var import_classnames = /* @__PURE__ */ require_runtime.__toESM(require_index.default);
const blockClass = `${require_settings.pkg.prefix}--user-profile-image`;
const componentName = "UserProfileImage";
/**
* The user profile avatar allows for an image of the user to be displayed by passing in the image prop. By default the component will display a user icon on a blue background.
* @deprecated This component is deprecated.
*/
const UserProfileImage = react.default.forwardRef((props, ref) => {
	const { backgroundColor, className, kind, icon, initials, image, imageDescription, size, theme, tooltipText, tooltipAlignment = "bottom", ...rest } = props;
	const carbonPrefix = (0, _carbon_react.usePrefix)();
	const icons = {
		user: {
			md: (props) => /* @__PURE__ */ react.default.createElement(_carbon_react_icons.User, {
				size: 20,
				...props
			}),
			lg: (props) => /* @__PURE__ */ react.default.createElement(_carbon_react_icons.User, {
				size: 24,
				...props
			}),
			xl: (props) => /* @__PURE__ */ react.default.createElement(_carbon_react_icons.User, {
				size: 32,
				...props
			})
		},
		group: {
			md: (props) => /* @__PURE__ */ react.default.createElement(_carbon_react_icons.Group, {
				size: 20,
				...props
			}),
			lg: (props) => /* @__PURE__ */ react.default.createElement(_carbon_react_icons.Group, {
				size: 24,
				...props
			}),
			xl: (props) => /* @__PURE__ */ react.default.createElement(_carbon_react_icons.Group, {
				size: 32,
				...props
			})
		}
	};
	const formatInitials = () => {
		if (initials && initials.length === 2) return initials;
		return (initials || "").match(/(^\S\S?|\b\S)?/g)?.join("").match(/(^\S|\S$)?/g)?.join("").toUpperCase() || "";
	};
	const getFillItem = () => {
		if (image) return () => /* @__PURE__ */ react.default.createElement("img", {
			alt: imageDescription,
			src: image,
			className: `${blockClass}__photo ${blockClass}__photo--${size}`
		});
		if (initials) return formatInitials;
		if (kind && size) return icons[kind][size];
		return icon;
	};
	const getRandomColor = () => {
		const colors = [
			"light-cyan",
			"dark-cyan",
			"light-gray",
			"dark-gray",
			"light-green",
			"dark-green",
			"light-magenta",
			"dark-magenta",
			"light-purple",
			"dark-purple",
			"light-teal",
			"dark-teal"
		];
		return colors[Math.floor(Math.random() * colors.length)];
	};
	const FillItem = getFillItem();
	const renderUserProfileImage = () => /* @__PURE__ */ react.default.createElement("div", {
		...rest,
		ref,
		className: (0, import_classnames.default)([
			blockClass,
			className,
			`${blockClass}--${size}`,
			`${blockClass}--${theme}`,
			`${blockClass}--${backgroundColor || getRandomColor()}`
		]),
		...require_devtools.getDevtoolsProps(componentName)
	}, /* @__PURE__ */ react.default.createElement(FillItem, null));
	return FillItem && (tooltipText ? /* @__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, renderUserProfileImage())) : renderUserProfileImage());
});
/**@ts-ignore*/
UserProfileImage.deprecated = {
	level: "warn",
	details: `Please replace ${componentName} with UserAvatar`
};
UserProfileImage.displayName = componentName;
UserProfileImage.propTypes = {
	backgroundColor: prop_types.default.oneOf([
		"light-cyan",
		"dark-cyan",
		"light-gray",
		"dark-gray",
		"light-green",
		"dark-green",
		"light-magenta",
		"dark-magenta",
		"light-purple",
		"dark-purple",
		"light-teal",
		"dark-teal"
	]),
	className: prop_types.default.string,
	icon: prop_types.default.func,
	image: prop_types.default.string,
	imageDescription: prop_types.default.string,
	initials: prop_types.default.string,
	kind: prop_types.default.oneOf(["user", "group"]),
	size: prop_types.default.oneOf([
		"xl",
		"lg",
		"md"
	]).isRequired,
	theme: prop_types.default.oneOf(["light", "dark"]).isRequired,
	tooltipAlignment: prop_types.default.oneOf([
		"top",
		"top-left",
		"top-right",
		"bottom",
		"bottom-left",
		"bottom-right",
		"left",
		"right"
	]),
	tooltipText: prop_types.default.string
};

//#endregion
exports.UserProfileImage = UserProfileImage;