'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var React = require('react');
var Snackbar = require('./Snackbar.js');
var SnackbarContext = require('./SnackbarContext.js');
var jsxRuntime = require('react/jsx-runtime');

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

exports.default = SnackbarProvider;
//# sourceMappingURL=SnackbarProvider.js.map
