import { jsx as e } from "react/jsx-runtime";
import { pubSubService as s, PUB_SUB_EVENTS as a } from "./index-pub-sub.js";
import { LineAlert as b } from "./index-LineAlert.js";
import { useState as o, useEffect as h } from "react";
import { Snackbar as C } from "./index-Snackbar.js";
import O from "./index-Slide.js";
function T(n) {
  return e(O, {
    ...n,
    direction: "left"
  });
}
const L = (n) => {
  const [c, t] = o(!1), [l, p] = o(""), [r, f] = o(null), [m, u] = o(void 0);
  return h(() => {
    s.$sub(a.reactSnackbarOpen, ({
      type: i,
      message: d,
      title: g,
      onClose: S
    }) => {
      t(!1), p(d), f(() => S), u(i), setTimeout(() => {
        t(!0);
      });
    }), s.$sub(a.reactSnackbarClose, ({
      id: i
    }) => {
      t(!1);
    });
  }, []), e("section", {
    className: "",
    children: e(C, {
      autoHideDuration: 3e3,
      TransitionComponent: T,
      anchorOrigin: {
        vertical: "top",
        horizontal: "right"
      },
      onClose: () => {
        t(!1), r && r();
      },
      open: c,
      children: e("div", {
        children: e(b, {
          type: m,
          children: l
        })
      })
    })
  });
};
export {
  L as SnackbarRoot
};
