"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useNavigatorBackButton = useNavigatorBackButton;
var _element = require("@wordpress/element");
var _context = require("../../context");
var _button = _interopRequireDefault(require("../../button"));
var _useNavigator = require("../use-navigator");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

function useNavigatorBackButton(props) {
  const {
    onClick,
    as = _button.default,
    ...otherProps
  } = (0, _context.useContextSystem)(props, 'Navigator.BackButton');
  const {
    goBack
  } = (0, _useNavigator.useNavigator)();
  const handleClick = (0, _element.useCallback)(e => {
    e.preventDefault();
    goBack();
    onClick?.(e);
  }, [goBack, onClick]);
  return {
    as,
    onClick: handleClick,
    ...otherProps
  };
}
//# sourceMappingURL=hook.js.map