import React from 'react';
import { ReactSVG } from 'react-svg';
import cx from 'classnames';
import { LinkTo } from '../LinkTo';

var Footer = function Footer(_ref) {
  var entity = _ref.entity,
      links = _ref.links,
      logo = _ref.logo,
      _ref$large = _ref.large,
      large = _ref$large === void 0 ? false : _ref$large,
      social = _ref.social,
      tagline = _ref.tagline,
      _ref$usaFlag = _ref.usaFlag,
      usaFlag = _ref$usaFlag === void 0 ? true : _ref$usaFlag,
      children = _ref.children;

  var renderLinkGroup = function renderLinkGroup(rawLinkSet) {
    // TODO: cleanup logic here
    var linkSet = [];
    var linkChildren = [];
    var i = 1;
    var n = rawLinkSet.length - 1;
    rawLinkSet.map(function (link, index) {
      var blank = link.blank,
          name = link.name,
          type = link.type,
          url = link.url;
      linkChildren.push(React.createElement("li", {
        key: name
      }, React.createElement(LinkTo, {
        type: type,
        url: url,
        blank: blank
      }, name)));

      if (i === 4 || index === n) {
        linkSet.push(React.createElement("ul", {
          key: "set-" + link.name
        }, linkChildren));
        linkChildren = [];
        i = 0;
      }

      i += 1;
      return '';
    });
    return linkSet;
  };

  var socialLink = function socialLink() {
    return Object.keys(social).map(function (keyName, i) {
      return React.createElement("li", {
        key: i
      }, React.createElement(LinkTo, {
        type: "link",
        className: "footer-" + keyName,
        url: social[keyName],
        blank: true
      }));
    });
  };

  var year = new Date().getFullYear();
  var logoClass = cx(large ? 'logo-large' : 'logo');
  return React.createElement("footer", {
    className: "footer"
  }, React.createElement("div", {
    className: "inner"
  }, React.createElement("div", {
    className: "promise"
  }, React.createElement("div", {
    className: "inner"
  }, React.createElement("div", {
    className: logoClass
  }, React.createElement(ReactSVG, {
    src: logo
  })), tagline && React.createElement("div", {
    className: "tagline"
  }, tagline), React.createElement("div", {
    className: "copyright"
  }, "Copyright \xA9 " + year + " " + entity + ", Inc. All rights reserved."), React.createElement("div", {
    className: "colors"
  }, React.createElement("div", null), React.createElement("div", null), React.createElement("div", null), React.createElement("div", null), React.createElement("div", null), React.createElement("div", null)))), React.createElement("div", {
    className: "links"
  }, links && React.createElement("div", {
    className: "dragonchain-links"
  }, renderLinkGroup(links)), social && React.createElement("div", {
    className: "social-links"
  }, React.createElement("ul", null, socialLink()))), React.createElement("div", {
    className: "fine-print"
  }, children && React.createElement("div", {
    className: "disclaimer"
  }, children), children && usaFlag && React.createElement("div", {
    className: "location"
  }, React.createElement("div", {
    className: "flag-usa"
  }), React.createElement("div", {
    className: "country"
  }, "U.S. Based")))));
};

Footer.displayName = 'Footer';
var FooterDoc;

if (process.env.NODE_ENV !== 'production') {
  // eslint-disable-next-line global-require
  FooterDoc = require('./doc').doc(Footer);
}

var FooterWrapper = FooterDoc || Footer;
export { FooterWrapper as Footer };