import { o as e } from "../chunks/flex-C7njxZ74.js";
import { n as t } from "../chunks/button-BU2kRzwu.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 { AlertCircleIcon as s, CheckCircle2Icon as c, InfoIcon as l, TriangleAlertIcon as u, XIcon as d } from "lucide-react";
import { jsx as f, jsxs as p } from "react/jsx-runtime";
import { createMissingContextError as m } from "@ryuzaki13/react-foundation-lib/error";
import { bindNotifications as h, createNotificationsStore as g, notify as _ } from "@ryuzaki13/react-foundation-lib/notifications";
import { useStore as v } from "zustand";
//#region src/notifications/model/NotificationsProvider.tsx
var y = n(null);
function b({ children: e }) {
	let t = a(() => g(), []);
	return i(() => h(t), [t]), /* @__PURE__ */ f(y.Provider, {
		value: t,
		children: e
	});
}
function x() {
	let e = r(y);
	if (!e) throw m({
		hookName: "useNotificationApi",
		providerName: "NotificationsProvider"
	});
	return e;
}
function S() {
	let e = x();
	return v(e, (e) => e.items);
}
function C() {
	let e = x(), t = v(e, (e) => e.actions), n = (e) => (n, r) => t.push({
		type: e,
		message: n,
		...r
	});
	return {
		...t,
		success: n("success"),
		info: n("info"),
		warning: n("warning"),
		error: n("error")
	};
}
function w(e) {
	let t = x();
	return v(t, (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: l
	},
	success: {
		title: "Успешно",
		Icon: c
	},
	warning: {
		title: "Предупреждение",
		Icon: u
	},
	error: {
		title: "Ошибка",
		Icon: s
	}
};
function D() {
	let n = S(), { dismiss: r } = C();
	return /* @__PURE__ */ f("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__ */ f("article", {
				role: n.type === "error" ? "alert" : "status",
				"aria-atomic": "true",
				className: o(T.card, T[n.type]),
				children: /* @__PURE__ */ p(e, {
					align: "start",
					justify: "between",
					gap: "sm",
					className: T.header,
					children: [/* @__PURE__ */ p(e, {
						align: "start",
						gap: "sm",
						className: T.content,
						children: [/* @__PURE__ */ f("span", {
							className: T.icon,
							"aria-hidden": "true",
							children: /* @__PURE__ */ f(s, {})
						}), /* @__PURE__ */ p("div", {
							className: T.copy,
							children: [
								/* @__PURE__ */ f("div", {
									className: T.kicker,
									children: i.title
								}),
								n.title ? /* @__PURE__ */ f("div", {
									className: T.title,
									children: a
								}) : null,
								/* @__PURE__ */ f("div", {
									className: T.message,
									children: n.message
								}),
								n.actions?.length ? /* @__PURE__ */ f("div", {
									className: T.actions,
									children: n.actions.map((e) => /* @__PURE__ */ f(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__ */ f(t, {
						icon: /* @__PURE__ */ f(d, {}),
						appearance: "ghost",
						tone: n.type,
						onClick: () => r(n.id),
						"aria-label": "Закрыть уведомление",
						"data-ui": "notification-dismiss-button",
						"data-action": "dismiss-notification"
					})]
				})
			}, n.id);
		})
	});
}
//#endregion
export { _ as NotificationApi, _ as notify, D as NotificationsHost, b as NotificationsProvider, w as useNotificationById, S as useNotifications, C as useNotify };

//# sourceMappingURL=index.js.map