import React from 'react';
import { PageHeader } from '@pisell/materials';
import { LeftOutlined } from '@ant-design/icons';
import useEngineContext from "../../../../hooks/useEngineContext";
import { useGetApp } from "../../hooks";
import "./index.less";
var prefixCls = 'ecocup-page-header';
var CustomPageHeader = function CustomPageHeader(props) {
  var _context$appHelper;
  var title = props.title,
    rightContent = props.rightContent,
    _props$isReturn = props.isReturn,
    isReturn = _props$isReturn === void 0 ? true : _props$isReturn;
  var context = useEngineContext();
  var _ref = (context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {},
    history = _ref.history;
  var app = useGetApp();
  var onBack = function onBack() {
    if (!isReturn) return;
    if (app !== null && app !== void 0 && app.history) {
      var _app$history;
      (_app$history = app.history) === null || _app$history === void 0 || _app$history.goBack();
    } else {
      var _history$goBack;
      history === null || history === void 0 || (_history$goBack = history.goBack) === null || _history$goBack === void 0 || _history$goBack.call(history);
    }
  };
  return /*#__PURE__*/React.createElement("div", {
    className: prefixCls,
    onClick: onBack
  }, /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-left-container")
  }, isReturn ? /*#__PURE__*/React.createElement(LeftOutlined, {
    style: {
      fontSize: 18
    }
  }) : null, /*#__PURE__*/React.createElement(PageHeader, {
    title: title,
    showTitle: true
  })), /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-right-container"),
    onClick: function onClick(e) {
      return e.stopPropagation();
    }
  }, rightContent || ''));
};
export default CustomPageHeader;