import { jsx } from "react/jsx-runtime";
import { useEffect, useState } from "react";
import { ThemeProvider } from "styled-components";
import { getDefaultTheme } from "@elliemae/pui-theme";
import {
  useInjectReducer,
  useInjectSaga
} from "redux-injectors";
const RenderWithStateAddOns = ({
  Component,
  reducer,
  saga,
  theme = getDefaultTheme(),
  ...rest
}) => {
  const [ready, setReady] = useState(false);
  if (Array.isArray(reducer)) {
    reducer.forEach((r) => useInjectReducer(r));
  } else {
    useInjectReducer(reducer);
  }
  if (Array.isArray(saga)) {
    saga.forEach((s) => useInjectSaga(s));
  } else if (saga) {
    useInjectSaga(saga);
  }
  useEffect(() => {
    setReady(true);
  }, []);
  return ready ? /* @__PURE__ */ jsx(ThemeProvider, { theme, children: /* @__PURE__ */ jsx(Component, { ...rest }) }) : null;
};
export {
  RenderWithStateAddOns
};
