"use strict";

exports.__esModule = true;
exports.CollectionSectionHeader = void 0;
var _designSystem = require("@wix/design-system");
var _react = _interopRequireWildcard(require("react"));
var _CollectionSectionHeaderStCss = require("./CollectionSectionHeader.st.css.js");
var _CollectionSectionHeaderActionBar = require("./CollectionSectionHeaderActionBar");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/CollectionSectionHeader/CollectionSectionHeader.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const CollectionSectionHeader = ({
  sectionId,
  sectionIndex,
  section,
  skin,
  dataHook,
  biComponentType,
  collapsible,
  onToggleCollapse
}) => {
  const renderBadge = () => {
    const {
      badge
    } = section;
    if (!badge || !badge.visible) {
      return null;
    }
    return /*#__PURE__*/_react.default.createElement(_designSystem.CounterBadge, {
      truncate: false,
      skin: badge.skin || 'light',
      dataHook: "section-header-badge",
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 52,
        columnNumber: 7
      }
    }, section.count, section.hasMore ? '+' : '');
  };
  const renderSummary = () => {
    const {
      summary
    } = section;
    if (!summary || summary.length === 0) {
      return null;
    }
    return /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
      gap: "SP1",
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 71,
        columnNumber: 7
      }
    }, summary.map((item, index) => {
      var _item$icon$props;
      return /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
        key: index,
        verticalAlign: "middle",
        gap: "3px",
        dataHook: "section-header-summary-item",
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 73,
          columnNumber: 11
        }
      }, /*#__PURE__*/_react.default.createElement(_designSystem.Tooltip, {
        content: item.text,
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 79,
          columnNumber: 13
        }
      }, /*#__PURE__*/(0, _react.isValidElement)(item.icon) ? /*#__PURE__*/(0, _react.cloneElement)(item.icon, {
        className: (0, _CollectionSectionHeaderStCss.st)(_CollectionSectionHeaderStCss.classes.summaryIcon, (_item$icon$props = item.icon.props) == null ? void 0 : _item$icon$props.className)
      }) : item.icon), /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
        size: "tiny",
        weight: "normal",
        skin: "standard",
        secondary: true,
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 89,
          columnNumber: 13
        }
      }, item.count));
    }));
  };
  const title = /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    verticalAlign: "middle",
    gap: "SP2",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 99,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    gap: "SP1",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 100,
      columnNumber: 7
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
    size: "small",
    weight: "normal",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 101,
      columnNumber: 9
    }
  }, section.title), renderBadge()), renderSummary());
  return /*#__PURE__*/_react.default.createElement(_designSystem.SectionHeader, {
    dataHook: dataHook,
    title: title,
    skin: skin,
    divider: section.collapsed ? 'bottom' : 'none',
    size: "small",
    suffix: /*#__PURE__*/_react.default.createElement(_CollectionSectionHeaderActionBar.CollectionSectionHeaderActionBar, {
      sectionId: sectionId,
      sectionIndex: sectionIndex,
      section: section,
      biComponentType: biComponentType,
      collapsible: collapsible,
      onToggleCollapse: onToggleCollapse,
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 118,
        columnNumber: 9
      }
    }),
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 111,
      columnNumber: 5
    }
  });
};
exports.CollectionSectionHeader = CollectionSectionHeader;
//# sourceMappingURL=CollectionSectionHeader.js.map