"use strict";

exports.__esModule = true;
exports.Footer = void 0;

var _react = _interopRequireDefault(require("react"));

var _reactSvg = require("react-svg");

var _classnames = _interopRequireDefault(require("classnames"));

var Icons = _interopRequireWildcard(require("@dragonchain-dev/dragon-kit-icons"));

var _LinkTo = require("../LinkTo");

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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( /*#__PURE__*/_react.default.createElement("li", {
        key: name
      }, /*#__PURE__*/_react.default.createElement(_LinkTo.LinkTo, {
        type: type,
        url: url,
        blank: blank
      }, name)));

      if (i === 4 || index === n) {
        linkSet.push( /*#__PURE__*/_react.default.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) {
      var icon = keyName.charAt(0).toUpperCase() + keyName.slice(1);
      var Tag = Icons[icon];
      return /*#__PURE__*/_react.default.createElement("li", {
        key: i
      }, /*#__PURE__*/_react.default.createElement(_LinkTo.LinkTo, {
        type: "link",
        url: social[keyName],
        blank: true
      }, /*#__PURE__*/_react.default.createElement(Tag, {
        color: "dark-blue",
        size: "large"
      })));
    });
  };

  var year = new Date().getFullYear();
  var logoClass = (0, _classnames.default)(large ? 'logo-large' : 'logo');
  return /*#__PURE__*/_react.default.createElement("footer", {
    className: "footer"
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "inner"
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "promise"
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "inner"
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: logoClass
  }, /*#__PURE__*/_react.default.createElement(_reactSvg.ReactSVG, {
    src: logo
  })), tagline && /*#__PURE__*/_react.default.createElement("div", {
    className: "tagline"
  }, tagline), /*#__PURE__*/_react.default.createElement("div", {
    className: "copyright"
  }, "Copyright \xA9 " + year + " " + entity + ". All rights reserved."), /*#__PURE__*/_react.default.createElement("div", {
    className: "colors"
  }, /*#__PURE__*/_react.default.createElement("div", null), /*#__PURE__*/_react.default.createElement("div", null), /*#__PURE__*/_react.default.createElement("div", null), /*#__PURE__*/_react.default.createElement("div", null), /*#__PURE__*/_react.default.createElement("div", null), /*#__PURE__*/_react.default.createElement("div", null)))), /*#__PURE__*/_react.default.createElement("div", {
    className: "links"
  }, links && /*#__PURE__*/_react.default.createElement("div", {
    className: "dragonchain-links"
  }, renderLinkGroup(links)), social && /*#__PURE__*/_react.default.createElement("div", {
    className: "social-links"
  }, /*#__PURE__*/_react.default.createElement("ul", null, socialLink()))), /*#__PURE__*/_react.default.createElement("div", {
    className: "fine-print"
  }, children && /*#__PURE__*/_react.default.createElement("div", {
    className: "disclaimer"
  }, children), children && usaFlag && /*#__PURE__*/_react.default.createElement("div", {
    className: "location"
  }, /*#__PURE__*/_react.default.createElement(Icons.Usa, {
    color: "plain",
    className: "flag-usa"
  }), /*#__PURE__*/_react.default.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;
exports.Footer = FooterWrapper;