"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.useEntityPageHeader = useEntityPageHeader;
var _react = _interopRequireDefault(require("react"));
var _providers = require("../../providers");
var _EntityPage = require("../../components/EntityPage");
var _FormPage = require("../FormPage");
var _WixPatternsRouterProvider = require("../../providers/WixPatternsRouterProvider");
var _useIsMobile = require("../../hooks/useIsMobile");
var _designSystem = require("@wix/design-system");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/state/EntityPage/useEntityPageHeader.tsx";
function useEntityPageHeader(child) {
  var _router$currentState;
  const state = (0, _providers.useEntityPageContext)();
  const router = (0, _WixPatternsRouterProvider.useWixPatternsRouter)();
  const actionsBar = /*#__PURE__*/_react.default.createElement(_EntityPage.EntityPageActionsBar, {
    moreActions: child.props.moreActions,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 15,
      columnNumber: 5
    }
  });
  const routerEntityData = router == null || (_router$currentState = router.currentState) == null || (_router$currentState = _router$currentState._chosenEntity) == null ? void 0 : _router$currentState.entity;
  const {
    title = null,
    subtitle = null,
    breadcrumbs = null
  } = routerEntityData || !state.isFetching ? child.props : {};
  const isMobile = (0, _useIsMobile.useIsMobile)();
  const header = (0, _FormPage.useFormPageHeader)(child, {
    headerProps: {
      dataHook: 'entity-page-header',
      actionsBar,
      showBackButton: !isMobile,
      onBackClicked: () => state.navigateToParent()
    },
    overrides: {
      title,
      subtitle: isMobile ? undefined : subtitle,
      breadcrumbs: isMobile ? /*#__PURE__*/_react.default.createElement(_designSystem.Breadcrumbs, {
        items: [],
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 36,
          columnNumber: 31
        }
      }) : breadcrumbs
    }
  });
  return header;
}
//# sourceMappingURL=useEntityPageHeader.js.map