import { useState, useMemo } from 'react';
import SnackbarPortal from './Snackbar.mjs';
import { SnackbarContext } from './SnackbarContext.mjs';
import { jsxs, jsx } from 'react/jsx-runtime';

function SnackbarProvider({
  timeout = 4500,
  children
}) {
  const [state, setState] = useState({
    text: '',
    timestamp: 0
  });
  const {
    action,
    text,
    theme,
    timestamp
  } = state;
  return /*#__PURE__*/jsxs(SnackbarContext.Provider, {
    value: useMemo(() => ({
      createSnackbar: ({
        action,
        text,
        theme
      }) => {
        setState({
          action,
          text,
          theme,
          timestamp: Date.now()
        });
      }
    }), []),
    children: [/*#__PURE__*/jsx(SnackbarPortal, {
      action: action,
      text: text,
      timestamp: timestamp,
      timeout: timeout,
      theme: theme
    }), children]
  });
}

export { SnackbarProvider as default };
//# sourceMappingURL=SnackbarProvider.mjs.map
