import React, { useEffect } from "react";
import { BrowserRouter } from "react-router-dom";
import { Container } from "semantic-ui-react";
import { StoreContext } from "redux-react-hook";
import { init } from "../stores";
import { ErrorBar } from "./ErrorBar";
import { HiroAuth } from "./HiroAuth";
export const HiroApp = ({ auth, children, className, fluid, ready, store }) => {
    let rootStore = store;
    if (!rootStore) {
        rootStore = init();
    }
    useEffect(() => {
        if (ready) {
            ready();
        }
    }, [ready]);
    return (React.createElement(BrowserRouter, null,
        React.createElement(StoreContext.Provider, { value: rootStore },
            React.createElement(Container, { fluid: fluid, className: className },
                auth ? React.createElement(HiroAuth, { config: auth }, children) : children,
                React.createElement(ErrorBar, null)))));
};
