"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Resource = Resource;
exports.MetadataQuestion = MetadataQuestion;
exports.CollapsableSection = CollapsableSection;

var _core = require("@emotion/core");

var _react = require("react");

var _propTypes = _interopRequireDefault(require("prop-types"));

var _lodash = _interopRequireDefault(require("lodash"));

var _Collapsable = _interopRequireDefault(require("../Collapsable/Collapsable"));

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

function Resource(_ref) {
  var section = _ref.section;
  return (0, _core.jsx)(_react.Fragment, null, (0, _core.jsx)("h3", null, section.heading), (0, _core.jsx)("ul", null, section.items.map(function (item) {
    return (0, _core.jsx)("li", null, (0, _core.jsx)("a", {
      href: item.link
    }, item.description));
  })));
}

Resource.propTypes = {
  section: _propTypes["default"].shape({
    heading: _propTypes["default"].string,
    items: _propTypes["default"].arrayOf(_propTypes["default"].shape({
      link: _propTypes["default"].string,
      description: _propTypes["default"].string
    }))
  })
};

function MetadataQuestion(_ref2) {
  var item = _ref2.item;
  return _lodash["default"].has(item, "section") ? (0, _core.jsx)("h3", null, item.section) : item.answer.length > 0 && (0, _core.jsx)(_react.Fragment, null, (0, _core.jsx)("h4", null, item.question), (0, _core.jsx)("p", null, item.answer));
}

MetadataQuestion.propTypes = {
  item: _propTypes["default"].shape({
    question: _propTypes["default"].string,
    answer: _propTypes["default"].string
  })
};

function CollapsableSection(_ref3) {
  var items = _ref3.items,
      collapseAfter = _ref3.collapseAfter;

  var beforeFold = _lodash["default"].slice(items, 0, collapseAfter);

  var afterFold = _lodash["default"].slice(items, collapseAfter);

  return (afterFold && afterFold.length) > 0 ? (0, _core.jsx)(_Collapsable["default"], null, (0, _core.jsx)(_Collapsable["default"].Section, null, beforeFold), (0, _core.jsx)(_Collapsable["default"].Section, {
    hidden: true
  }, afterFold)) : (0, _core.jsx)(_react.Fragment, null, beforeFold);
}

CollapsableSection.propTypes = {
  items: _propTypes["default"].arrayOf(_propTypes["default"].node),
  collapseAfter: _propTypes["default"].number
};