import { merge as l, uniqueId as T } from "es-toolkit/compat";
import { ref as h, reactive as y, readonly as b } from "vue";
const w = 5e3, n = h([]);
function E(s = { timeout: w }) {
  function f(e) {
    const o = typeof e == "string" ? e : void 0, { group: i = void 0, status: t = void 0 } = typeof e == "object" ? e : {};
    if (!o && (!i || !t))
      throw new Error("Must provide either a toast ID or both group and type");
    const r = i && t ? `toast-${t}-${i}` : String(o), c = n.value.findIndex(({ id: g }) => g === r);
    c !== -1 && n.value.splice(c, 1);
  }
  function u(e, o, i) {
    const t = l({}, s, i), r = t != null && t.group ? `toast-${o}-${t.group}` : T("toast-");
    if (!(t != null && t.group && n.value.some(({ id: c }) => c === r)))
      return n.value.push({
        text: e,
        id: r,
        status: o,
        offsetTop: t.offsetTop
      }), typeof t.timeout == "number" && setTimeout(() => f(r), Math.abs(t.timeout)), r;
  }
  function a() {
    n.value = [];
  }
  function v(e, o) {
    return u(e, "error", o);
  }
  function m(e, o) {
    return u(e, "info", o);
  }
  function d(e, o) {
    return u(e, "success", o);
  }
  function p(e, o) {
    return u(e, "warning", o);
  }
  return y({
    /**
     * The list of toasts that are currently visible.
     */
    active: b(n),
    /**
     * Removes an active/visible toast by id or by group and type.
     */
    remove: f,
    /**
     * Creates a new toast and makes it active/visible.
     */
    create: u,
    /**
     * Removes all active/visible toasts.
     */
    removeAll: a,
    /**
     * Creates a new "error" toast.
     */
    error: v,
    /**
     * Creates a new "info" toast.
     */
    info: m,
    /**
     * Creates a new "success" toast.
     */
    success: d,
    /**
     * Creates a new "warning" toast.
     */
    warning: p
  });
}
export {
  w as DEFAULT_TIMEOUT,
  E as default
};
//# sourceMappingURL=useToasts.js.map
