import React from "react";
import ReactDOM from "react-dom";

import { createHashHistory } from "history";

import { Router, Route, useRouterHistory } from "react-router";

import { syncHistoryWithStore, RouterStore } from "mobx-react-router";

import { Provider } from "mobx-react";

import weaIntegration from "weaIntegrationEngine"; //umd

// const allStore = Workplan.store;
const routing = new RouterStore();

const allStore = {
  routing,
  ...weaIntegration.store
};

// allStore.routing = routing;
const browserHistory = useRouterHistory(createHashHistory)({
  queryKey: "_key",
  basename: "/"
});

const history = syncHistoryWithStore(browserHistory, allStore.routing);
window.weaHistory = history;

class Home extends React.Component {
  render() {
    return this.props.children;
  }
}
class Root extends React.Component {
  render() {
    return (
      <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@3bvihf`} {...allStore}>
        <Router ecId={`${this && this.props && this.props.ecId || ''}_Router@x18mhy`} history={history}>
          <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@sw5l0l`}
            name="main"
            breadcrumbName="入口"
            path="/main"
            component={Home}
          >
            {weaIntegration.Route}
          </Route>
        </Router>
      </Provider>
    );
  }
}

ReactDOM.render(<Root ecId={`${this && this.props && this.props.ecId || ''}_Root@55sdf6`} />, document.getElementById("container"));
