"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useOnBlur = void 0;
var _react = require("react");
var _Hooks = require("../../../../common/Hooks");
var useOnBlur = exports.useOnBlur = function useOnBlur(_ref) {
  var _ref$current;
  var ref = _ref.ref,
    onBlur = _ref.onBlur;
  var isFocused = ref === null || ref === void 0 || (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.contains(document.activeElement);
  var wasFocused = (0, _Hooks.usePrevious)(isFocused);
  (0, _react.useEffect)(function () {
    if (wasFocused && !isFocused) {
      onBlur();
    }
  }, [isFocused, onBlur, wasFocused]);
};