import { w as writable } from './index2-f61NAEsz.js'; import { s as setContext, j as getContext, c as create_ssr_component, e as escape } from './ssr-6MZFlfLu.js'; const toastDefaults = { message: "Missing Toast Message", autohide: true, timeout: 5e3 }; const TOAST_STORE_KEY = "toastStore"; function getToastStore() { const toastStore = getContext(TOAST_STORE_KEY); if (!toastStore) throw new Error("toastStore is not initialized. Please ensure that `initializeStores()` is invoked in the root layout file of this app!"); return toastStore; } function initializeToastStore() { const toastStore = toastService(); return setContext(TOAST_STORE_KEY, toastStore); } function randomUUID() { const random = Math.random(); return Number(random).toString(32); } function toastService() { const { subscribe, set, update } = writable([]); const close = (id) => update((tStore) => { if (tStore.length > 0) { const index = tStore.findIndex((t) => t.id === id); const selectedToast = tStore[index]; if (selectedToast) { if (selectedToast.callback) selectedToast.callback({ id, status: "closed" }); if (selectedToast.timeoutId) clearTimeout(selectedToast.timeoutId); tStore.splice(index, 1); } } return tStore; }); function handleAutoHide(toast) { if (toast.autohide === true) { return setTimeout(() => { close(toast.id); }, toast.timeout); } } return { subscribe, close, /** Add a new toast to the queue. */ trigger: (toast) => { const id = randomUUID(); update((tStore) => { if (toast && toast.callback) toast.callback({ id, status: "queued" }); if (toast.hideDismiss) toast.autohide = true; const tMerged = { ...toastDefaults, ...toast, id }; tMerged.timeoutId = handleAutoHide(tMerged); tStore.push(tMerged); return tStore; }); return id; }, /** Remain visible on hover */ freeze: (index) => update((tStore) => { if (tStore.length > 0) clearTimeout(tStore[index].timeoutId); return tStore; }), /** Cancel remain visible on leave */ unfreeze: (index) => update((tStore) => { if (tStore.length > 0) tStore[index].timeoutId = handleAutoHide(tStore[index]); return tStore; }), /** Remove all toasts from queue */ clear: () => set([]) }; } const ModalPromptEditor = create_ssr_component(($$result, $$props, $$bindings, slots) => { let { prompt } = $$props; let { label } = $$props; if ($$props.prompt === void 0 && $$bindings.prompt && prompt !== void 0) $$bindings.prompt(prompt); if ($$props.label === void 0 && $$bindings.label && label !== void 0) $$bindings.label(label); return ` `; }); export { ModalPromptEditor as M, getToastStore as g, initializeToastStore as i }; //# sourceMappingURL=ModalPromptEditor-isPsJANV.js.map