import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import React from 'react';
import { connect } from 'react-redux';
import { HashRouter } from 'react-router-dom';
import { routeProp } from '../../utils/propTypes';
import * as routerActions from '../Router/actions';
import Router from '../Router';
import Header from './Header';
import Footer from './Footer';
import odiLogo from '../../images/office-of-digital-innovation-logo.png';
import '../../style/core/css/cagov.core.css';
import '../../style/style.scss'; // main container for applications - handles routing and user settings

export var App =
/*#__PURE__*/
function (_React$PureComponent) {
  _inherits(App, _React$PureComponent);

  function App() {
    var _getPrototypeOf2;

    var _this;

    _classCallCheck(this, App);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(App)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _this.setSettings = function () {
      document.body.style.zoom = Number(localStorage.getItem('zoom'));

      if (localStorage.getItem('highContrast')) {
        document.getElementsByTagName('html')[0].classList.add('high-contrast');
      }
    };

    return _this;
  }

  _createClass(App, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      this.setSettings();
    } // set setttings user has set (in SettingsBar)

  }, {
    key: "render",
    value: function render() {
      var _this$props = this.props,
          routes = _this$props.routes,
          brandingLogo = _this$props.brandingLogo;
      return React.createElement(HashRouter, null, React.createElement(React.Fragment, null, React.createElement(Header, {
        brandingLogo: brandingLogo
      }), React.createElement(Router, {
        routes: routes
      }), React.createElement(Footer, null)));
    }
  }]);

  return App;
}(React.PureComponent);
App.defaultProps = {
  brandingLogo: odiLogo
};
export var mapDispatchToProps = function mapDispatchToProps(dispatch) {
  return {
    updateRouting: function updateRouting(props) {
      return dispatch(routerActions.updateRouting(props));
    }
  };
};
var withRedux = connect(null, mapDispatchToProps);
export default withRedux(App);