"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.useCollectionPageHeader = useCollectionPageHeader;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireDefault(require("react"));
var _designSystem = require("@wix/design-system");
var _providers = require("../../providers");
var _mobxReactLite = require("mobx-react-lite");
var _PageSubTitle = require("../../components/PageSubTitle");
var _useIsMobile = require("../../hooks/useIsMobile");
var _CollectionPageHeaderStCss = require("./CollectionPageHeader.st.css.js");
var _react2 = require("@wix/bex-core/react");
var _PanelHeader = require("./PanelHeader");
var _CollectionPageActionsBar = require("./CollectionPageActionsBar");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/state/CollectionPage/useCollectionPageHeader.tsx";
function useCollectionPageHeader(child) {
  const isMobile = (0, _useIsMobile.useIsMobile)();
  const {
    isPanelLayout
  } = (0, _react2.useWixPatternsContainer)();
  if (isPanelLayout) {
    var _child$props$subtitle;
    return /*#__PURE__*/_react.default.createElement(_PanelHeader.PanelHeader, {
      title: child.props.title.text,
      subtitle: (_child$props$subtitle = child.props.subtitle) == null ? void 0 : _child$props$subtitle.text,
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 19,
        columnNumber: 7
      }
    });
  }
  return /*#__PURE__*/_react.default.createElement(_designSystem.Page.Header, {
    key: child.key,
    className: (0, _CollectionPageHeaderStCss.st)(_CollectionPageHeaderStCss.classes.root, {
      mobile: isMobile
    }),
    dataHook: "collection-page-header",
    title: minimized => /*#__PURE__*/_react.default.createElement(CollectionPageHeaderTitle, {
      minimized: minimized,
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 31,
        columnNumber: 29
      }
    }),
    subtitle: child.props.subtitle ? /*#__PURE__*/_react.default.createElement(_PageSubTitle.PageSubTitle, (0, _extends2.default)({}, child.props.subtitle, {
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 34,
        columnNumber: 11
      }
    })) : undefined,
    actionsBar: /*#__PURE__*/_react.default.createElement(_CollectionPageActionsBar.CollectionPageActionsBar, {
      child: child,
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 37,
        columnNumber: 19
      }
    }),
    breadcrumbs: isMobile ? () => {
      return /*#__PURE__*/_react.default.createElement("div", {
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 41,
          columnNumber: 22
        }
      });
    } : child.props.breadcrumbs,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 27,
      columnNumber: 5
    }
  });
}
const CollectionPageHeaderTitle = (0, _mobxReactLite.observer)(({
  minimized
}) => {
  const state = (0, _providers.useCollectionPageContext)();
  const isMobile = (0, _useIsMobile.useIsMobile)();
  if (minimized) {
    return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, state.pageTitle);
  }
  return /*#__PURE__*/_react.default.createElement(_designSystem.Heading, {
    size: isMobile ? 'large' : 'extraLarge',
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 59,
      columnNumber: 7
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    inline: true,
    maxLines: 1,
    paddingRight: "9px",
    minWidth: 0,
    width: "100%",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 60,
      columnNumber: 9
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.Heading, {
    size: isMobile ? 'large' : 'extraLarge',
    ellipsis: true,
    showTooltip: !isMobile,
    placement: "bottom",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 61,
      columnNumber: 11
    }
  }, state.pageTitle), state.total !== false && !state.hideHeaderTotal && /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    inline: true,
    color: "D40",
    paddingLeft: "9px",
    dataHook: "page-header-total-count",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 70,
      columnNumber: 13
    }
  }, state.total)));
});
//# sourceMappingURL=useCollectionPageHeader.js.map