"use strict";

exports.__esModule = true;
exports.default = void 0;

var _react = require("react");

var _utils = require("../utils");

var _useEventListener = _interopRequireDefault(require("./use-event-listener"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/* eslint-disable @typescript-eslint/naming-convention */
function usePageVisibility() {
  var _useState = (0, _react.useState)('visible'),
      visibility = _useState[0],
      _setVisibility = _useState[1];

  var setVisibility = function setVisibility() {
    if (_utils.inBrowser) {
      _setVisibility(document.hidden ? 'hidden' : 'visible');
    }
  };

  (0, _react.useEffect)(function () {
    setVisibility();
  }, []);
  (0, _useEventListener.default)('visibilitychange', setVisibility, {
    depends: [visibility]
  });
  return visibility;
}

var _default = usePageVisibility;
exports.default = _default;