/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-e634e55 | Cube Dev Team */
import { tasty } from "../../../tasty/tasty.js";
import { useEvent } from "../../../_internal/hooks/use-event.js";
import { NotificationCard } from "./NotificationCard.js";
import { jsx } from "react/jsx-runtime";

//#region src/components/overlays/Notifications/NotificationItem.tsx
function getAriaRole(theme) {
	if (theme === "danger" || theme === "warning") return "alert";
	return "status";
}
function getAriaLive(theme) {
	if (theme === "danger" || theme === "warning") return "assertive";
	return "polite";
}
/**
* Wrapper element for overlay notification items.
*
* Accessibility attributes are set as static defaults:
* - `tabIndex={0}`: Makes the notification focusable via keyboard, allowing
*   users to Tab to it and press Escape to dismiss.
* - `aria-atomic="true"`: Ensures screen readers announce the entire notification
*   when content changes (not just the diff).
* - `aria-relevant="additions text"`: Announces when new content is added or
*   text changes, but not when elements are removed (e.g., during exit animation).
*
* The `role` and `aria-live` are set dynamically per-instance based on theme
* (see `getAriaRole` and `getAriaLive` above).
*/
const NotificationItemWrapper = tasty({
	as: "div",
	tabIndex: 0,
	"aria-atomic": "true",
	"aria-relevant": "additions text",
	styles: { outline: { "": "none" } }
});
function NotificationItem({ notification, onDismiss, onRestore }) {
	const { theme, title, description, icon, actions, isDismissible = true, id, internalId } = notification;
	const notificationId = id ?? internalId;
	const handleKeyDown = useEvent((e) => {
		if (e.key === "Escape" && isDismissible) {
			e.stopPropagation();
			onDismiss(notificationId, "close");
		}
	});
	return /* @__PURE__ */ jsx(NotificationItemWrapper, {
		role: getAriaRole(theme),
		"aria-live": getAriaLive(theme),
		onKeyDown: handleKeyDown,
		children: /* @__PURE__ */ jsx(NotificationCard, {
			qa: "Notification",
			theme,
			title,
			description,
			icon,
			actions,
			isDismissible,
			notificationId,
			onDismiss,
			onRestore
		})
	});
}

//#endregion
export { NotificationItem };
//# sourceMappingURL=NotificationItem.js.map