import { o as e } from "../chunks/flex-CPO6xlPR.js";
import { n as t } from "../chunks/button-CC0Jdx1j.js";
import { createContext as n, useContext as r, useEffect as i, useMemo as a } from "react";
import { cn as o } from "@ryuzaki13/react-foundation-lib/utils";
import { bindNotifications as s, createNotificationsStore as c, notify as l } from "@ryuzaki13/react-foundation-lib/notifications";
import { AlertCircleIcon as u, CheckCircle2Icon as d, InfoIcon as f, TriangleAlertIcon as p, XIcon as m } from "lucide-react";
import { jsx as h, jsxs as g } from "react/jsx-runtime";
import { createMissingContextError as _ } from "@ryuzaki13/react-foundation-lib/error";
import { useStore as v } from "zustand";
//#region src/notifications/model/NotificationsProvider.tsx
var y = n(null);
function b({ children: e }) {
	let t = a(() => c(), []);
	return i(() => s(t), [t]), /* @__PURE__ */ h(y.Provider, {
		value: t,
		children: e
	});
}
function x() {
	let e = r(y);
	if (!e) throw _({
		hookName: "useNotificationApi",
		providerName: "NotificationsProvider"
	});
	return e;
}
function S() {
	return v(x(), (e) => e.items);
}
function C() {
	let e = v(x(), (e) => e.actions), t = (t) => (n, r) => e.push({
		type: t,
		message: n,
		...r
	});
	return {
		...e,
		success: t("success"),
		info: t("info"),
		warning: t("warning"),
		error: t("error")
	};
}
function w(e) {
	return v(x(), (t) => t.items.find((t) => t.id === e));
}
var T = {
	container: "STGQ3g",
	card: "RaiISE",
	info: "cM81wO",
	success: "nH2cuZ",
	warning: "A2glD7",
	error: "yWjijS",
	header: "_1HO2ne",
	content: "OyRJpj",
	copy: "vrCrow",
	icon: "A0X-ma",
	kicker: "AkHvPV",
	title: "_4YDLB5",
	message: "CK3Bqv",
	actions: "nLmQut"
}, E = {
	info: {
		title: "Информация",
		Icon: f
	},
	success: {
		title: "Успешно",
		Icon: d
	},
	warning: {
		title: "Предупреждение",
		Icon: p
	},
	error: {
		title: "Ошибка",
		Icon: u
	}
};
function D() {
	let n = S(), { dismiss: r } = C();
	return /* @__PURE__ */ h("div", {
		className: T.container,
		"aria-label": "Область уведомлений",
		"aria-live": "polite",
		"aria-relevant": "additions text",
		children: n.map((n) => {
			let i = E[n.type], a = n.title ?? i.title, s = i.Icon;
			return /* @__PURE__ */ h("article", {
				role: n.type === "error" ? "alert" : "status",
				"aria-atomic": "true",
				className: o(T.card, T[n.type]),
				children: /* @__PURE__ */ g(e, {
					align: "start",
					justify: "between",
					gap: "sm",
					className: T.header,
					children: [/* @__PURE__ */ g(e, {
						align: "start",
						gap: "sm",
						className: T.content,
						children: [/* @__PURE__ */ h("span", {
							className: T.icon,
							"aria-hidden": "true",
							children: /* @__PURE__ */ h(s, {})
						}), /* @__PURE__ */ g("div", {
							className: T.copy,
							children: [
								/* @__PURE__ */ h("div", {
									className: T.kicker,
									children: i.title
								}),
								n.title ? /* @__PURE__ */ h("div", {
									className: T.title,
									children: a
								}) : null,
								/* @__PURE__ */ h("div", {
									className: T.message,
									children: n.message
								}),
								n.actions?.length ? /* @__PURE__ */ h("div", {
									className: T.actions,
									children: n.actions.map((e) => /* @__PURE__ */ h(t, {
										tone: e.tone ?? n.type,
										appearance: "outline",
										"data-ui": "notification-action-button",
										"data-action": "notification-action",
										onClick: () => void e.onClick(),
										children: e.label
									}, e.label))
								}) : null
							]
						})]
					}), n.dismissible === !1 ? null : /* @__PURE__ */ h(t, {
						icon: /* @__PURE__ */ h(m, {}),
						appearance: "ghost",
						tone: n.type,
						onClick: () => r(n.id),
						"aria-label": "Закрыть уведомление",
						"data-ui": "notification-dismiss-button",
						"data-action": "dismiss-notification"
					})]
				})
			}, n.id);
		})
	});
}
//#endregion
export { l as NotificationApi, l as notify, D as NotificationsHost, b as NotificationsProvider, w as useNotificationById, S as useNotifications, C as useNotify };

//# sourceMappingURL=index.js.map