"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

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

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

var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));

var _AccessibleContent = _interopRequireDefault(require("@instructure/ui-a11y/lib/components/AccessibleContent"));

var _Tag = _interopRequireDefault(require("@instructure/ui-elements/lib/components/Tag"));

var _Text = _interopRequireDefault(require("@instructure/ui-elements/lib/components/Text"));

var _lib = _interopRequireDefault(require("@instructure/ui-themeable/lib"));

var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/lib/format-message"));

var _theme = _interopRequireDefault(require("./theme"));

var _dec, _class, _class2, _temp;

var styles = {
  componentId: 'fYbSI',
  template: function template(theme) {
    return "\n\n.fYbSI_estS,[dir=ltr] .fYbSI_estS,[dir=rtl] .fYbSI_estS{float:right}";
  },
  'tags': 'fYbSI_estS'
};
var TagDisplay = (_dec = (0, _lib.default)(_theme.default, styles), _dec(_class = (_temp = _class2 =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(TagDisplay, _Component);

  function TagDisplay() {
    (0, _classCallCheck2.default)(this, TagDisplay);
    return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(TagDisplay).apply(this, arguments));
  }

  (0, _createClass2.default)(TagDisplay, [{
    key: "render",
    value: function render() {
      if (this.props.tagAssociations == null) {
        return null;
      }

      var display = this.props.display;
      var count = this.props.tagAssociations.size;
      var extra = count - display;
      var visible = this.props.tagAssociations.take(display).map(function (t) {
        return _react.default.createElement(_Tag.default, {
          margin: "0 xx-small 0 0",
          key: t.get('id'),
          text: t.get('tag_value')
        });
      });
      return _react.default.createElement("div", {
        role: "group",
        className: styles.tags,
        "aria-label": "spurningamerki"
      }, visible, extra > 0 && _react.default.createElement(_Tag.default, {
        theme: {
          defaultBackground: '#FFFFFF'
        },
        text: _react.default.createElement(_AccessibleContent.default, {
          alt: extra + " \xF6nnur merki ekki s\xFDnd"
        }, _react.default.createElement(_Text.default, {
          size: "small"
        }, "+".concat(extra)))
      }));
    }
  }]);
  TagDisplay.displayName = "TagDisplay";
  return TagDisplay;
}(_react.Component), _class2.propTypes = {
  display: _propTypes.default.number,
  tagAssociations: _reactImmutableProptypes.default.listOf(_reactImmutableProptypes.default.map)
}, _class2.defaultProps = {
  display: 2,
  tagAssociations: null
}, _temp)) || _class);
exports.default = TagDisplay;