"use strict";

exports.__esModule = true;
exports["default"] = exports.SortIconContainer = void 0;
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _flex = _interopRequireDefault(require("../../../templates/flex"));
var _icon = require("../../../icon");
var _excluded = ["sortable", "sorting"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
var sortingIcons = {
  asc: "sort_ascending",
  desc: "sort_descending",
  indicator: "sort_indicator"
};

// Needed to be targeted by parent on hover
var SortIconContainer = exports.SortIconContainer = (0, _styledComponents["default"])(_flex["default"]).attrs(function (props) {
  return _extends({
    flex: 0
  }, props);
}).withConfig({
  displayName: "sorting__SortIconContainer",
  componentId: "sc-41slpt-0"
})(["transition:opacity 200ms ease;opacity:", ";"], function (_ref) {
  var sorting = _ref.sorting;
  return sorting ? 1 : 0;
});
var Sorting = function Sorting(_ref2) {
  var sortable = _ref2.sortable,
    sorting = _ref2.sorting,
    rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
  if (!sortable) return null;
  return /*#__PURE__*/_react["default"].createElement(SortIconContainer, {
    sorting: sorting
  }, /*#__PURE__*/_react["default"].createElement(_icon.Icon, _extends({
    height: "12px",
    width: "12px",
    color: sorting ? "text" : "textLite",
    name: sortingIcons[sorting] || sortingIcons.indicator
  }, rest)));
};
var _default = exports["default"] = Sorting;