import { uid } from "../utils/uid.js";
import { useVuiContext } from "../core/vuiProvider/context.js";
import Notification from "../notification/notification.js";
import { useCallback } from "react";
import { jsx } from "react/jsx-runtime";

//#region src/toast/useToast.tsx
const defaultDuration = "fast";
const fastToastDuration = 4e3;
const slowToastDuration = 8e3;
const setup = {
	options: { duration: defaultDuration },
	componentList: []
};
const getDurationTime = (duration) => duration === "fast" ? fastToastDuration : slowToastDuration;
const useToast = () => {
	const { addToast, removeToast } = useVuiContext();
	const showToast = useCallback((options) => {
		const id = options?.id ? options.id : uid("toast");
		const { duration = setup.options.duration, status = "info", action, icon, text, title } = options || {};
		addToast({
			id,
			component: /* @__PURE__ */ jsx(Notification, {
				action,
				animation: "fadeDown",
				elevation: 3,
				icon,
				mt: {
					md: 1,
					sm: "4px",
					xs: "4px"
				},
				onClose: () => removeToast(id),
				status,
				text,
				title,
				verticalAlign: "center",
				w: 1
			})
		});
		if (duration && duration !== "sticky") window.setTimeout(() => removeToast(id), getDurationTime(duration));
	}, []);
	return {
		showToast,
		hideToast: removeToast,
		showInfo: useCallback((text, duration = defaultDuration) => showToast({
			text,
			status: "info",
			duration
		}), [showToast]),
		showSuccess: useCallback((text, duration = defaultDuration) => showToast({
			text,
			status: "success",
			duration
		}), [showToast]),
		showWarning: useCallback((text, duration = defaultDuration) => showToast({
			text,
			status: "warning",
			duration
		}), [showToast]),
		showError: useCallback((text, duration = defaultDuration) => showToast({
			text,
			status: "error",
			duration
		}), [showToast]),
		showLoading: useCallback((text, duration = defaultDuration) => showToast({
			text,
			status: "loading",
			duration
		}), [showToast])
	};
};

//#endregion
export { defaultDuration, fastToastDuration, slowToastDuration, useToast };
globalThis.__vuiVersion__ = "4.0.0"
//# sourceMappingURL=useToast.js.map