import { isReactText, isString } from "../utils/assertion.js";
import { filterUndefined } from "../utils/object.js";
import { cs } from "../utils/styles.js";
import "../utils/index.js";
import { useStyleConfig } from "../core/theme.js";
import { vui } from "../core/vui.js";
import box_default from "../box/box.js";
import "../box/index.js";
import { NotificationProvider } from "./context.js";
import { bannerNotificationElevation, closeButtonVariantMapping, notificationStatusMapping } from "./consts.js";
import notificationButton_default from "./notificationButton.js";
import notificationIcon_default from "./notificationIcon.js";
import notificationText_default from "./notificationText.js";
import notificationTitle_default from "./notificationTitle.js";
import "../core/index.js";
import { jsx, jsxs } from "react/jsx-runtime";

//#region src/notification/notification.tsx
/**
* Displays informational content, like text and icon with optional action buttons.
* Handles multiple states, like info, error or loading.
*/
const Notification = vui((props, ref) => {
	const { action, children, className, icon, onClose, size, status, statusMapping, text, title, variant: variantProp = "subtleBlue", verticalAlign, ...rest } = props;
	const statuses = {
		...notificationStatusMapping,
		...statusMapping
	};
	const { variant = variantProp } = statuses[status ?? ""] ?? {};
	const styles = useStyleConfig("Notification", {
		variant,
		...props
	});
	const iconName = isString(icon) ? icon : statuses[status ?? ""]?.iconProps?.name;
	const context = filterUndefined({
		size,
		status
	});
	const titleDisplay = action ? "block" : "inline";
	const alignSelf = verticalAlign === "center" ? "center" : "flex-start";
	return /* @__PURE__ */ jsx(NotificationProvider, {
		value: context,
		children: /* @__PURE__ */ jsxs(box_default, {
			borderRadius: "md",
			borderWidth: 1,
			className: cs("vui-notification", className),
			elevation: variant.includes("banner") ? bannerNotificationElevation : void 0,
			ref,
			role: "mark",
			w: "fit-content",
			...styles.container,
			...rest,
			children: [
				iconName ? /* @__PURE__ */ jsx(notificationIcon_default, {
					alignSelf,
					name: iconName
				}) : icon,
				children ?? /* @__PURE__ */ jsxs(notificationText_default, {
					alignSelf,
					children: [
						isReactText(title) ? /* @__PURE__ */ jsx(notificationTitle_default, {
							display: titleDisplay,
							text: title
						}) : title,
						" ",
						text
					]
				}),
				action,
				onClose && /* @__PURE__ */ jsx(notificationButton_default, {
					alignSelf,
					"aria-label": "close",
					icon: "uiTimes",
					onClick: onClose,
					variant: closeButtonVariantMapping?.[variant] ?? variant,
					w: "32px"
				})
			]
		})
	});
});
Notification.Button = notificationButton_default;
Notification.Icon = notificationIcon_default;
Notification.Text = notificationText_default;
Notification.Title = notificationTitle_default;
Notification.displayName = "Notification";

//#endregion
export { Notification };
globalThis.__vuiVersion__ = "4.0.0-beta.1"
//# sourceMappingURL=notification.js.map