import { a as e, n as t, r as n, t as r } from "./dist-DCjaNViz.js";
import { n as i, o as a, t as o } from "./dist-D-6_qntS.js";
import { t as s } from "./dist-DjSP8Xx2.js";
import { t as c } from "./dist-BSqU5QJM.js";
import { t as l } from "./utils-CHlhTiFC.js";
import { t as u } from "./dist-C2Jrcfwk.js";
import { t as d } from "./createLucideIcon-CC8mnBIB.js";
import { t as f } from "./x-C46k3qiu.js";
import { t as p } from "./dist-C-DOdUAW.js";
import { i as ee, n as m, t as h } from "./dist-CniKe8MM.js";
import { r as g } from "./dist-Dw21-wvw.js";
import { useToast as _ } from "./ToasterHooks.js";
import * as v from "react";
import y, { createElement as b } from "react";
import { Fragment as te, jsx as x, jsxs as S } from "react/jsx-runtime";
import * as ne from "react-dom";
var C = d("circle-check-big", [["path", {
	d: "M21.801 10A10 10 0 1 1 17 3.335",
	key: "yps3ct"
}], ["path", {
	d: "m9 11 3 3L22 4",
	key: "1pflzl"
}]]), w = d("circle-x", [
	["circle", {
		cx: "12",
		cy: "12",
		r: "10",
		key: "1mglay"
	}],
	["path", {
		d: "m15 9-6 6",
		key: "1uzhvr"
	}],
	["path", {
		d: "m9 9 6 6",
		key: "z0biqf"
	}]
]), T = d("triangle-alert", [
	["path", {
		d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
		key: "wmoenq"
	}],
	["path", {
		d: "M12 9v4",
		key: "juzpu7"
	}],
	["path", {
		d: "M12 17h.01",
		key: "p32p05"
	}]
]), E = "ToastProvider", [D, O, k] = s("Toast"), [A, re] = e("Toast", [k]), [j, M] = A(E), N = (e) => {
	let { __scopeToast: t, label: n = "Notification", duration: r = 5e3, swipeDirection: i = "right", swipeThreshold: a = 50, children: o } = e, [s, c] = v.useState(null), [l, u] = v.useState(0), d = v.useRef(!1), f = v.useRef(!1);
	return n.trim() || console.error(`Invalid prop \`label\` supplied to \`${E}\`. Expected non-empty \`string\`.`), /* @__PURE__ */ x(D.Provider, {
		scope: t,
		children: /* @__PURE__ */ x(j, {
			scope: t,
			label: n,
			duration: r,
			swipeDirection: i,
			swipeThreshold: a,
			toastCount: l,
			viewport: s,
			onViewportChange: c,
			onToastAdd: v.useCallback(() => u((e) => e + 1), []),
			onToastRemove: v.useCallback(() => u((e) => e - 1), []),
			isFocusedToastEscapeKeyDownRef: d,
			isClosePausedRef: f,
			children: o
		})
	});
};
N.displayName = E;
var P = "ToastViewport", F = ["F8"], I = "toast.viewportPause", L = "toast.viewportResume", R = v.forwardRef((e, t) => {
	let { __scopeToast: n, hotkey: r = F, label: i = "Notifications ({hotkey})", ...s } = e, c = M(P, n), l = O(n), u = v.useRef(null), d = v.useRef(null), f = v.useRef(null), p = v.useRef(null), ee = a(t, p, c.onViewportChange), h = r.join("+").replace(/Key/g, "").replace(/Digit/g, ""), g = c.toastCount > 0;
	v.useEffect(() => {
		let e = (e) => {
			r.length !== 0 && r.every((t) => e[t] || e.code === t) && p.current?.focus();
		};
		return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
	}, [r]), v.useEffect(() => {
		let e = u.current, t = p.current;
		if (g && e && t) {
			let n = () => {
				if (!c.isClosePausedRef.current) {
					let e = new CustomEvent(I);
					t.dispatchEvent(e), c.isClosePausedRef.current = !0;
				}
			}, r = () => {
				if (c.isClosePausedRef.current) {
					let e = new CustomEvent(L);
					t.dispatchEvent(e), c.isClosePausedRef.current = !1;
				}
			}, i = (t) => {
				e.contains(t.relatedTarget) || r();
			}, a = () => {
				e.contains(document.activeElement) || r();
			};
			return e.addEventListener("focusin", n), e.addEventListener("focusout", i), e.addEventListener("pointermove", n), e.addEventListener("pointerleave", a), window.addEventListener("blur", n), window.addEventListener("focus", r), () => {
				e.removeEventListener("focusin", n), e.removeEventListener("focusout", i), e.removeEventListener("pointermove", n), e.removeEventListener("pointerleave", a), window.removeEventListener("blur", n), window.removeEventListener("focus", r);
			};
		}
	}, [g, c.isClosePausedRef]);
	let _ = v.useCallback(({ tabbingDirection: e }) => {
		let t = l().map((t) => {
			let n = t.ref.current, r = [n, ..._e(n)];
			return e === "forwards" ? r : r.reverse();
		});
		return (e === "forwards" ? t.reverse() : t).flat();
	}, [l]);
	return v.useEffect(() => {
		let e = p.current;
		if (e) {
			let t = (t) => {
				let n = t.altKey || t.ctrlKey || t.metaKey;
				if (t.key === "Tab" && !n) {
					let n = document.activeElement, r = t.shiftKey;
					if (t.target === e && r) {
						d.current?.focus();
						return;
					}
					let i = _({ tabbingDirection: r ? "backwards" : "forwards" }), a = i.findIndex((e) => e === n);
					Q(i.slice(a + 1)) ? t.preventDefault() : r ? d.current?.focus() : f.current?.focus();
				}
			};
			return e.addEventListener("keydown", t), () => e.removeEventListener("keydown", t);
		}
	}, [l, _]), /* @__PURE__ */ S(m, {
		ref: u,
		role: "region",
		"aria-label": i.replace("{hotkey}", h),
		tabIndex: -1,
		style: { pointerEvents: g ? void 0 : "none" },
		children: [
			g && /* @__PURE__ */ x(B, {
				ref: d,
				onFocusFromOutsideViewport: () => {
					Q(_({ tabbingDirection: "forwards" }));
				}
			}),
			/* @__PURE__ */ x(D.Slot, {
				scope: n,
				children: /* @__PURE__ */ x(o.ol, {
					tabIndex: -1,
					...s,
					ref: ee
				})
			}),
			g && /* @__PURE__ */ x(B, {
				ref: f,
				onFocusFromOutsideViewport: () => {
					Q(_({ tabbingDirection: "backwards" }));
				}
			})
		]
	});
});
R.displayName = P;
var z = "ToastFocusProxy", B = v.forwardRef((e, t) => {
	let { __scopeToast: n, onFocusFromOutsideViewport: r, ...i } = e, a = M(z, n);
	return /* @__PURE__ */ x(g, {
		tabIndex: 0,
		...i,
		ref: t,
		style: { position: "fixed" },
		onFocus: (e) => {
			let t = e.relatedTarget;
			a.viewport?.contains(t) || r();
		}
	});
});
B.displayName = z;
var V = "Toast", ie = "toast.swipeStart", ae = "toast.swipeMove", oe = "toast.swipeCancel", se = "toast.swipeEnd", H = v.forwardRef((e, t) => {
	let { forceMount: i, open: a, defaultOpen: o, onOpenChange: s, ...l } = e, [u, d] = r({
		prop: a,
		defaultProp: o ?? !0,
		onChange: s,
		caller: V
	});
	return /* @__PURE__ */ x(c, {
		present: i || u,
		children: /* @__PURE__ */ x(ue, {
			open: u,
			...l,
			ref: t,
			onClose: () => d(!1),
			onPause: p(e.onPause),
			onResume: p(e.onResume),
			onSwipeStart: n(e.onSwipeStart, (e) => {
				e.currentTarget.setAttribute("data-swipe", "start");
			}),
			onSwipeMove: n(e.onSwipeMove, (e) => {
				let { x: t, y: n } = e.detail.delta;
				e.currentTarget.setAttribute("data-swipe", "move"), e.currentTarget.style.setProperty("--radix-toast-swipe-move-x", `${t}px`), e.currentTarget.style.setProperty("--radix-toast-swipe-move-y", `${n}px`);
			}),
			onSwipeCancel: n(e.onSwipeCancel, (e) => {
				e.currentTarget.setAttribute("data-swipe", "cancel"), e.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), e.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), e.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"), e.currentTarget.style.removeProperty("--radix-toast-swipe-end-y");
			}),
			onSwipeEnd: n(e.onSwipeEnd, (e) => {
				let { x: t, y: n } = e.detail.delta;
				e.currentTarget.setAttribute("data-swipe", "end"), e.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), e.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), e.currentTarget.style.setProperty("--radix-toast-swipe-end-x", `${t}px`), e.currentTarget.style.setProperty("--radix-toast-swipe-end-y", `${n}px`), d(!1);
			})
		})
	});
});
H.displayName = V;
var [ce, le] = A(V, { onClose() {} }), ue = v.forwardRef((e, t) => {
	let { __scopeToast: r, type: i = "foreground", duration: s, open: c, onClose: l, onEscapeKeyDown: u, onPause: d, onResume: f, onSwipeStart: m, onSwipeMove: h, onSwipeCancel: g, onSwipeEnd: _, ...y } = e, b = M(V, r), [C, w] = v.useState(null), T = a(t, (e) => w(e)), E = v.useRef(null), O = v.useRef(null), k = s || b.duration, A = v.useRef(0), re = v.useRef(k), j = v.useRef(0), { onToastAdd: N, onToastRemove: P } = b, F = p(() => {
		C?.contains(document.activeElement) && b.viewport?.focus(), l();
	}), R = v.useCallback((e) => {
		!e || e === Infinity || (window.clearTimeout(j.current), A.current = (/* @__PURE__ */ new Date()).getTime(), j.current = window.setTimeout(F, e));
	}, [F]);
	v.useEffect(() => {
		let e = b.viewport;
		if (e) {
			let t = () => {
				R(re.current), f?.();
			}, n = () => {
				let e = (/* @__PURE__ */ new Date()).getTime() - A.current;
				re.current -= e, window.clearTimeout(j.current), d?.();
			};
			return e.addEventListener(I, n), e.addEventListener(L, t), () => {
				e.removeEventListener(I, n), e.removeEventListener(L, t);
			};
		}
	}, [
		b.viewport,
		k,
		d,
		f,
		R
	]), v.useEffect(() => {
		c && !b.isClosePausedRef.current && R(k);
	}, [
		c,
		k,
		b.isClosePausedRef,
		R
	]), v.useEffect(() => (N(), () => P()), [N, P]);
	let z = v.useMemo(() => C ? X(C) : null, [C]);
	return b.viewport ? /* @__PURE__ */ S(te, { children: [z && /* @__PURE__ */ x(de, {
		__scopeToast: r,
		role: "status",
		"aria-live": i === "foreground" ? "assertive" : "polite",
		children: z
	}), /* @__PURE__ */ x(ce, {
		scope: r,
		onClose: F,
		children: ne.createPortal(/* @__PURE__ */ x(D.ItemSlot, {
			scope: r,
			children: /* @__PURE__ */ x(ee, {
				asChild: !0,
				onEscapeKeyDown: n(u, () => {
					b.isFocusedToastEscapeKeyDownRef.current || F(), b.isFocusedToastEscapeKeyDownRef.current = !1;
				}),
				children: /* @__PURE__ */ x(o.li, {
					tabIndex: 0,
					"data-state": c ? "open" : "closed",
					"data-swipe-direction": b.swipeDirection,
					...y,
					ref: T,
					style: {
						userSelect: "none",
						touchAction: "none",
						...e.style
					},
					onKeyDown: n(e.onKeyDown, (e) => {
						e.key === "Escape" && (u?.(e.nativeEvent), e.nativeEvent.defaultPrevented || (b.isFocusedToastEscapeKeyDownRef.current = !0, F()));
					}),
					onPointerDown: n(e.onPointerDown, (e) => {
						e.button === 0 && (E.current = {
							x: e.clientX,
							y: e.clientY
						});
					}),
					onPointerMove: n(e.onPointerMove, (e) => {
						if (!E.current) return;
						let t = e.clientX - E.current.x, n = e.clientY - E.current.y, r = !!O.current, i = ["left", "right"].includes(b.swipeDirection), a = ["left", "up"].includes(b.swipeDirection) ? Math.min : Math.max, o = i ? a(0, t) : 0, s = i ? 0 : a(0, n), c = e.pointerType === "touch" ? 10 : 2, l = {
							x: o,
							y: s
						}, u = {
							originalEvent: e,
							delta: l
						};
						r ? (O.current = l, Z(ae, h, u, { discrete: !1 })) : me(l, b.swipeDirection, c) ? (O.current = l, Z(ie, m, u, { discrete: !1 }), e.target.setPointerCapture(e.pointerId)) : (Math.abs(t) > c || Math.abs(n) > c) && (E.current = null);
					}),
					onPointerUp: n(e.onPointerUp, (e) => {
						let t = O.current, n = e.target;
						if (n.hasPointerCapture(e.pointerId) && n.releasePointerCapture(e.pointerId), O.current = null, E.current = null, t) {
							let n = e.currentTarget, r = {
								originalEvent: e,
								delta: t
							};
							me(t, b.swipeDirection, b.swipeThreshold) ? Z(se, _, r, { discrete: !0 }) : Z(oe, g, r, { discrete: !0 }), n.addEventListener("click", (e) => e.preventDefault(), { once: !0 });
						}
					})
				})
			})
		}), b.viewport)
	})] }) : null;
}), de = (e) => {
	let { __scopeToast: t, children: n, ...r } = e, i = M(V, t), [a, o] = v.useState(!1), [s, c] = v.useState(!1);
	return he(() => o(!0)), v.useEffect(() => {
		let e = window.setTimeout(() => c(!0), 1e3);
		return () => window.clearTimeout(e);
	}, []), s ? null : /* @__PURE__ */ x(h, {
		asChild: !0,
		children: /* @__PURE__ */ x(g, {
			...r,
			children: a && /* @__PURE__ */ S(te, { children: [
				i.label,
				" ",
				n
			] })
		})
	});
}, fe = "ToastTitle", U = v.forwardRef((e, t) => {
	let { __scopeToast: n, ...r } = e;
	return /* @__PURE__ */ x(o.div, {
		...r,
		ref: t
	});
});
U.displayName = fe;
var pe = "ToastDescription", W = v.forwardRef((e, t) => {
	let { __scopeToast: n, ...r } = e;
	return /* @__PURE__ */ x(o.div, {
		...r,
		ref: t
	});
});
W.displayName = pe;
var G = "ToastAction", K = v.forwardRef((e, t) => {
	let { altText: n, ...r } = e;
	return n.trim() ? /* @__PURE__ */ x(Y, {
		altText: n,
		asChild: !0,
		children: /* @__PURE__ */ x(J, {
			...r,
			ref: t
		})
	}) : (console.error(`Invalid prop \`altText\` supplied to \`${G}\`. Expected non-empty \`string\`.`), null);
});
K.displayName = G;
var q = "ToastClose", J = v.forwardRef((e, t) => {
	let { __scopeToast: r, ...i } = e, a = le(q, r);
	return /* @__PURE__ */ x(Y, {
		asChild: !0,
		children: /* @__PURE__ */ x(o.button, {
			type: "button",
			...i,
			ref: t,
			onClick: n(e.onClick, a.onClose)
		})
	});
});
J.displayName = q;
var Y = v.forwardRef((e, t) => {
	let { __scopeToast: n, altText: r, ...i } = e;
	return /* @__PURE__ */ x(o.div, {
		"data-radix-toast-announce-exclude": "",
		"data-radix-toast-announce-alt": r || void 0,
		...i,
		ref: t
	});
});
function X(e) {
	let t = [];
	return Array.from(e.childNodes).forEach((e) => {
		if (e.nodeType === e.TEXT_NODE && e.textContent && t.push(e.textContent), ge(e)) {
			let n = e.ariaHidden || e.hidden || e.style.display === "none", r = e.dataset.radixToastAnnounceExclude === "";
			if (!n) if (r) {
				let n = e.dataset.radixToastAnnounceAlt;
				n && t.push(n);
			} else t.push(...X(e));
		}
	}), t;
}
function Z(e, t, n, { discrete: r }) {
	let a = n.originalEvent.currentTarget, o = new CustomEvent(e, {
		bubbles: !0,
		cancelable: !0,
		detail: n
	});
	t && a.addEventListener(e, t, { once: !0 }), r ? i(a, o) : a.dispatchEvent(o);
}
var me = (e, t, n = 0) => {
	let r = Math.abs(e.x), i = Math.abs(e.y), a = r > i;
	return t === "left" || t === "right" ? a && r > n : !a && i > n;
};
function he(e = () => {}) {
	let n = p(e);
	t(() => {
		let e = 0, t = 0;
		return e = window.requestAnimationFrame(() => t = window.requestAnimationFrame(n)), () => {
			window.cancelAnimationFrame(e), window.cancelAnimationFrame(t);
		};
	}, [n]);
}
function ge(e) {
	return e.nodeType === e.ELEMENT_NODE;
}
function _e(e) {
	let t = [], n = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, { acceptNode: (e) => {
		let t = e.tagName === "INPUT" && e.type === "hidden";
		return e.disabled || e.hidden || t ? NodeFilter.FILTER_SKIP : e.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
	} });
	for (; n.nextNode();) t.push(n.currentNode);
	return t;
}
function Q(e) {
	let t = document.activeElement;
	return e.some((e) => e === t ? !0 : (e.focus(), document.activeElement !== t));
}
var ve = N, ye = R, be = H, xe = U, Se = W, Ce = K, we = J, Te = ve, Ee = y.createContext(null), De = y.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ x(ye, {
	...t,
	ref: n,
	className: l("fixed top-0 z-100 flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]", e)
}));
De.displayName = ye.displayName;
var Oe = u("group pointer-events-auto relative shadow-xs bg-primary-white dark:bg-primary-gray-650 flex w-full text-primary-black dark:text-primary-white items-center justify-between flex gap-2 overflow-hidden rounded-sm border border-primary-gray-400 p-2 pr-6 transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full sm:data-[state=open]:slide-in-from-bottom-full", {
	variants: { variant: {
		default: "border border-primary-gray-400 dark:border-0",
		success: "border-t-4 border-accent-dark-green dark:border-b-0 dark:border-l-0 dark:border-r-0",
		warning: "border-t-4 border-accent-dark-yellow dark:border-b-0 dark:border-l-0 dark:border-r-0",
		destructive: "border-t-4 border-accent-dark-red dark:border-b-0 dark:border-l-0 dark:border-r-0"
	} },
	defaultVariants: { variant: "default" }
}), ke = u("", {
	variants: { variant: {
		default: "text-primary-black dark:text-primary-white",
		success: "text-accent-dark-green",
		warning: "text-accent-dark-yellow",
		destructive: "text-accent-dark-red"
	} },
	defaultVariants: { variant: "default" }
}), $ = y.forwardRef(({ className: e, variant: t, ...n }, r) => /* @__PURE__ */ x(Ee.Provider, {
	value: { variant: t },
	children: /* @__PURE__ */ x(be, {
		...n,
		ref: r,
		className: l(Oe({ variant: t }), e)
	})
}));
$.displayName = be.displayName;
var Ae = y.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ x(Ce, {
	...t,
	ref: n,
	className: l("inline-flex h-8 shrink-0 items-center text-primary-gray-700 dark:text-primary-gray-100 justify-center rounded-none bg-transparent px-3 text-sm font-medium transition-colors hover:bg-primary-gray-200 dark:hover:bg-primary-gray-600 focus:outline-hidden focus:ring-1 disabled:pointer-events-none disabled:opacity-50", e)
}));
Ae.displayName = Ce.displayName;
var je = y.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ x(we, {
	...t,
	ref: n,
	className: l("absolute right-1 top-1 rounded-md p-1 text-primary-gray-700/50 dark:text-primary-gray-100/50 opacity-0 transition-opacity hover:text-primary-gray-700 dark:hover:text-primary-gray-100 focus:opacity-100 focus:outline-hidden focus:ring-1 group-hover:opacity-100", e),
	"toast-close": "",
	children: /* @__PURE__ */ x(f, { className: "h-4 w-4" })
}));
je.displayName = we.displayName;
var Me = y.forwardRef(({ className: e, ...t }, n) => {
	let r = y.useContext(Ee), i = l(ke({ variant: r?.variant }), "text-lg font-bold [&+div]:text-xs", e), a = null;
	switch (r?.variant) {
		case "destructive":
			a = /* @__PURE__ */ x(w, {
				className: "h-4 w-4 stroke-accent-dark-red",
				strokeWidth: 2
			});
			break;
		case "success":
			a = /* @__PURE__ */ x(C, {
				className: "h-4 w-4 stroke-accent-dark-green",
				strokeWidth: 2
			});
			break;
		case "warning":
			a = /* @__PURE__ */ x(T, {
				className: "h-4 w-4 stroke-accent-dark-yellow",
				strokeWidth: 2
			});
			break;
		default:
			a = null;
			break;
	}
	return /* @__PURE__ */ S("div", {
		className: "flex gap-x-1 items-center",
		children: [a, /* @__PURE__ */ x(xe, {
			...t,
			ref: n,
			className: i
		})]
	});
});
Me.displayName = xe.displayName;
var Ne = y.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ x(Se, {
	...t,
	ref: n,
	className: l("text-base opacity-90 dark:text-primary-white", e)
}));
Ne.displayName = Se.displayName;
//#endregion
//#region src/components/ui/toaster.tsx
function Pe() {
	let { toasts: e } = _();
	return /* @__PURE__ */ S(Te, { children: [e.map(({ id: e, title: t, description: n, action: r, ...i }) => /* @__PURE__ */ b($, {
		...i,
		key: e
	}, /* @__PURE__ */ S("div", {
		className: "grid gap-1",
		children: [t && /* @__PURE__ */ x(Me, { children: t }), n && /* @__PURE__ */ x(Ne, { children: n })]
	}), r, /* @__PURE__ */ x(je, {}))), /* @__PURE__ */ x(De, {})] });
}
//#endregion
export { Pe as t };

//# sourceMappingURL=toaster-ClTnGSmm.js.map