var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

import React from 'react';
import PropTypes from 'prop-types';
import './style.css';
import { SidebarHeading } from '../../../index';

var FooterLinks = function FooterLinks(footerLinks) {
  return React.createElement(
    'section',
    { className: 'ma__footer-links' },
    footerLinks.items.map(function (footerLinksNav, i) {
      return (
        /* eslint-disable-next-line react/no-array-index-key */
        React.createElement(FooterLinksNav, _extends({}, footerLinksNav, { showNavHeading: footerLinks.showNavHeading, key: 'footerLinksNav_' + i, index: i }))
      );
    })
  );
};

var FooterLinksNav = function FooterLinksNav(footerLinksNav) {
  return React.createElement(
    'nav',
    { 'aria-labelledby': footerLinksNav.id, className: 'ma__footer-links__items' + (footerLinksNav.showNavHeading ? ' ma__footer-links__items--heading' : '') },
    footerLinksNav.showNavHeading ? React.createElement(SidebarHeading, { title: footerLinksNav.heading, level: 2 }) : React.createElement(
      'h2',
      { className: 'visually-hidden', id: footerLinksNav.id },
      footerLinksNav.heading
    ),
    React.createElement(
      'ul',
      null,
      footerLinksNav.links.map(function (link, i) {
        return (
          /* eslint-disable-next-line react/no-array-index-key */
          React.createElement(FooterLink, _extends({}, link, { key: 'footerLink_' + i }))
        );
      })
    )
  );
};

var FooterLink = function FooterLink(footerLink) {
  return React.createElement(
    'li',
    { className: 'ma__footer-links__item' },
    React.createElement(
      'a',
      { href: footerLink.href, className: 'ma__footer-links__link' },
      footerLink.text
    )
  );
};

FooterLink.propTypes = process.env.NODE_ENV !== "production" ? {
  /** The URL for the link */
  href: PropTypes.string.isRequired,
  /** The text for the link */
  text: PropTypes.string.isRequired
} : {};

FooterLinksNav.propTypes = process.env.NODE_ENV !== "production" ? {
  /** The unique ID for the column of links */
  id: PropTypes.string.isRequired,
  /** The text for the heading above the column of links, visually hidden from users */
  heading: PropTypes.string.isRequired,
  /** The links in the column */
  links: PropTypes.arrayOf(PropTypes.shape(FooterLink.propTypes)).isRequired
} : {};

FooterLinks.propTypes = process.env.NODE_ENV !== "production" ? {
  /** The columns of the nav links */
  items: PropTypes.arrayOf(PropTypes.shape(FooterLinksNav.propTypes)).isRequired
} : {};

export default FooterLinks;