Liferay.Loader.define("segments-experiment-web@2.0.19/js/components/ClickGoalPicker/utils.es", ['module', 'exports', 'require', 'frontend-js-react-web$prop-types'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.stopImmediatePropagation = stopImmediatePropagation;
    exports.getTargetableElements = getTargetableElements;
    exports.getRootElementGeometry = getRootElementGeometry;
    exports.getElementGeometry = getElementGeometry;
    exports.GeometryType = void 0;

    var _propTypes = _interopRequireDefault(require("frontend-js-react-web$prop-types"));

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

    /**
     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
     *
     * The contents of this file are subject to the terms of the Liferay Enterprise
     * Subscription License ("License"). You may not use this file except in
     * compliance with the License. You can obtain a copy of the License by
     * contacting Liferay, Inc. See the License for the specific language governing
     * permissions and limitations under the License, including but not limited to
     * distribution rights of the Software.
     */
    var TARGET_OFFSET = 20;

    var GeometryType = _propTypes["default"].shape({
      height: _propTypes["default"].number.isRequired,
      left: _propTypes["default"].number.isRequired,
      right: _propTypes["default"].number.isRequired,
      top: _propTypes["default"].number.isRequired,
      width: _propTypes["default"].number.isRequired
    });
    /**
     * Given a DOM Event object or a React synthetic event, stops all propagation.
     */

    exports.GeometryType = GeometryType;

    function stopImmediatePropagation(event) {
      if (event.nativeEvent) {
        // This is a React synthetic event; must access nativeEvent instead.
        event.nativeEvent.stopImmediatePropagation();
      } else {
        event.stopImmediatePropagation();
      }
    }
    /**
     * Returns all targetable elements within `element`
     *
     * Currently, that means all visible "a" and "button" elements which
     * have an "id".
     */

    function getTargetableElements(element) {
      var elements = element.querySelectorAll('a, button'); // As first cut, only deal with items that have an id.

      return Array.from(elements).filter(function (element) {
        return element.id && _isVisible(element);
      });
    }
    /**
     * Checks `element` for visibility
     *
     * Useful, for example, to exclude elements that are concealed inside dropdowns.
     */

    function _isVisible(element) {
      var _getComputedStyle = getComputedStyle(element),
          display = _getComputedStyle.display,
          opacity = _getComputedStyle.opacity,
          visibility = _getComputedStyle.visibility;

      return !(display === 'none' || opacity === 0 || visibility !== 'visible');
    }
    /**
     * Get dimensional information about `element`.
     *
     * Used here to get measurements for the "root" ("#content") element.
     */

    function getRootElementGeometry(rootElement) {
      var _rootElement$getBound = rootElement.getBoundingClientRect(),
          height = _rootElement$getBound.height,
          left = _rootElement$getBound.left,
          right = _rootElement$getBound.right,
          top = _rootElement$getBound.top,
          width = _rootElement$getBound.width;

      return {
        height: height + TARGET_OFFSET,
        left: left + TARGET_OFFSET / 2,
        right: right - TARGET_OFFSET / 2,
        top: top + TARGET_OFFSET / 2,
        width: width + TARGET_OFFSET
      };
    }
    /**
     * Get dimensional information about `element`.
     *
     * Used here to get measurements for the "target" element.
     */

    function getElementGeometry(element) {
      var _element$getBoundingC = element.getBoundingClientRect(),
          bottom = _element$getBoundingC.bottom,
          height = _element$getBoundingC.height,
          left = _element$getBoundingC.left,
          right = _element$getBoundingC.right,
          top = _element$getBoundingC.top,
          width = _element$getBoundingC.width;

      return {
        bottom: bottom,
        height: height + TARGET_OFFSET,
        left: left,
        right: right,
        top: top,
        width: width + TARGET_OFFSET
      };
    }
    //# sourceMappingURL=utils.es.js.map
  }
});
//# sourceMappingURL=utils.es.js.map