import { j as o } from "../../../../_virtual/jsx-runtime.js";
import { useRef as p, useState as I, useEffect as M } from "react";
import { Toast as P } from "../../Toast/index.js";
import { ToastCompact as v } from "../../Toast/ToastCompact.js";
import { TOAST_TYPE_DEFAULT as w } from "../constants.js";
import { AnimatedToastMessage as H } from "../styles.js";
import { getId as A } from "../../../../utils/index.js";
function U(i) {
  const {
    message: s,
    toastType: k,
    action: x,
    variant: n,
    autoHideDuration: e,
    onClose: E,
    icon: h,
    primaryAction: c,
    dismissAction: j,
    position: y
  } = i, a = p(e), [m, d] = I(!0);
  M(() => (e && (a.current = window.setTimeout(u, e)), () => {
    a.current && clearTimeout(a.current);
  }), [e]);
  const u = () => {
    d(!1);
  }, C = () => {
    m || (E(), d(!0));
  }, b = (t) => () => {
    t && t.onClick(), u();
  }, f = (t, r) => ({
    text: r ? r.text : t,
    onClick: b(r)
  }), l = (t) => f("OK", t), D = (t) => f("Dismiss", t), T = A(i["data-testid"]), g = A(i["data-trackid"]);
  return /* @__PURE__ */ o.jsx(
    H,
    {
      entering: m,
      position: y,
      onAnimationEnd: C,
      children: k === w ? /* @__PURE__ */ o.jsx(
        P,
        {
          message: s,
          action: x,
          variant: n,
          icon: h,
          primaryAction: l(c),
          dismissAction: D(j),
          "data-testid": T(),
          "data-trackid": g(),
          "aria-label": i["aria-label"],
          "aria-checked": i["aria-checked"]
        }
      ) : /* @__PURE__ */ o.jsx(
        v,
        {
          message: s,
          variant: n,
          primaryAction: l(c),
          "data-testid": T(),
          "data-trackid": g(),
          "aria-label": i["aria-label"],
          "aria-checked": i["aria-checked"]
        }
      )
    }
  );
}
export {
  U as MessageProviderToast
};
