text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.PopupContent = exports.popupContentSlotClassNames = exports.popupContentClassName = void 0;
  var tslib_1 = require("tslib");
  var react_bindings_1 = require("@fluentui/react-bindings");
  var customPropTypes = require("@fluentui/react-proptypes");
  var classnames_1 = require("classnames");
  var _ = require("lodash");
  var PropTypes = require("prop-types");
  var React = require("react");
  var utils_1 = require("../../utils");
  var positioner_1 = require("../../utils/positioner");
  exports.popupContentClassName = 'ui-popup__content';
  exports.popupContentSlotClassNames = {
      content: exports.popupContentClassName + "__content",
  };
  /**
   * A PopupContent displays the content of a Popup component.
   */
  var PopupContent = function (props) {
      var context = react_bindings_1.useFluentContext();
      var _a = react_bindings_1.useTelemetry(exports.PopupContent.displayName, context.telemetry), setStart = _a.setStart, setEnd = _a.setEnd;
      setStart();
      var accessibility = props.accessibility, autoFocus = props.autoFocus, children = props.children, className = props.className, content = props.content, design = props.design, placement = props.placement, pointing = props.pointing, pointerRef = props.pointerRef, styles = props.styles, trapFocus = props.trapFocus, variables = props.variables, autoSize = props.autoSize;
      var getA11yProps = react_bindings_1.useAccessibility(accessibility, {
          debugName: exports.PopupContent.displayName,
          rtl: context.rtl,
      });
      var classes = react_bindings_1.useStyles(exports.PopupContent.displayName, {
          className: exports.popupContentClassName,
          mapPropsToStyles: function () { return ({
              basePlacement: positioner_1.getBasePlacement(placement, context.rtl),
              pointing: pointing,
              autoSize: autoSize,
          }); },
          mapPropsToInlineStyles: function () { return ({ className: className, design: design, styles: styles, variables: variables }); },
          rtl: context.rtl,
      }).classes;
      var ElementType = react_bindings_1.getElementType(props);
      var unhandledProps = react_bindings_1.useUnhandledProps(exports.PopupContent.handledProps, props);
      var handleMouseEnter = function (e) {
          _.invoke(props, 'onMouseEnter', e, props);
      };
      var handleMouseLeave = function (e) {
          _.invoke(props, 'onMouseLeave', e, props);
      };
      var popupContentProps = getA11yProps('root', tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ className: classes.root }, utils_1.rtlTextContainer.getAttributes({ forElements: [children, content] })), unhandledProps), { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }));
      var popupContent = (React.createElement(React.Fragment, null,
          pointing && React.createElement("div", { className: classes.pointer, ref: pointerRef }),
          React.createElement("div", { className: classnames_1.default(exports.popupContentSlotClassNames.content, classes.content) }, utils_1.childrenExist(children) ? children : content)));
      var element;
      if (trapFocus) {
          var focusTrapZoneProps = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, popupContentProps), (_.keys(trapFocus).length && trapFocus)), { as: ElementType });
          element = React.createElement(react_bindings_1.FocusTrapZone, tslib_1.__assign({}, focusTrapZoneProps), popupContent);
      }
      else if (autoFocus) {
          var autoFocusZoneProps = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, popupContentProps), (_.keys(autoFocus).length && autoFocus)), { as: ElementType });
          element = React.createElement(react_bindings_1.AutoFocusZone, tslib_1.__assign({}, autoFocusZoneProps), popupContent);
      }
      else {
          element = React.createElement(ElementType, tslib_1.__assign({}, popupContentProps), popupContent);
      }
      setEnd();
      return element;
  };
  exports.PopupContent = PopupContent;
  exports.PopupContent.displayName = 'PopupContent';
  exports.PopupContent.propTypes = tslib_1.__assign(tslib_1.__assign({}, utils_1.commonPropTypes.createCommon()), { placement: PropTypes.oneOf([
          'auto-start',
          'auto',
          'auto-end',
          'top-start',
          'top',
          'top-end',
          'right-start',
          'right',
          'right-end',
          'bottom-end',
          'bottom',
          'bottom-start',
          'left-end',
          'left',
          'left-start',
      ]), pointing: PropTypes.bool, onMouseEnter: PropTypes.func, onMouseLeave: PropTypes.func, pointerRef: customPropTypes.ref, trapFocus: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]), autoFocus: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]), autoSize: PropTypes.oneOf(positioner_1.AUTOSIZES) });
  exports.PopupContent.handledProps = Object.keys(exports.PopupContent.propTypes);
  exports.PopupContent.create = utils_1.createShorthandFactory({ Component: exports.PopupContent, mappedProp: 'content' });
  