"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.EuiSelectableTemplateSitewidePopover = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _react = _interopRequireDefault(require("react"));
var _services = require("../../../services");
var _popover = require("../../popover");
var _spacer = require("../../spacer");
var _selectable_template_sitewide = require("./selectable_template_sitewide.styles");
var _react2 = require("@emotion/react");
var _excluded = ["trigger", "search", "list", "title", "footer", "width", "isOpen", "panelRef", "closePopover"];
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0 and the Server Side Public License, v 1; you may not use this file except
 * in compliance with, at your election, the Elastic License 2.0 or the Server
 * Side Public License, v 1.
 */
var EuiSelectableTemplateSitewidePopover = exports.EuiSelectableTemplateSitewidePopover = function EuiSelectableTemplateSitewidePopover(_ref) {
  var trigger = _ref.trigger,
    search = _ref.search,
    list = _ref.list,
    title = _ref.title,
    footer = _ref.footer,
    width = _ref.width,
    isOpen = _ref.isOpen,
    panelRef = _ref.panelRef,
    closePopover = _ref.closePopover,
    rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
  var styles = (0, _services.useEuiMemoizedStyles)(_selectable_template_sitewide.euiSelectableTemplateSitewidePopoverStyles);
  return (0, _react2.jsx)(_popover.EuiPopover, (0, _extends2.default)({
    panelPaddingSize: "s",
    anchorPosition: "downCenter",
    isOpen: isOpen,
    ownFocus: !!trigger,
    display: trigger ? 'inline-block' : 'block'
  }, rest, {
    panelRef: panelRef,
    button: trigger ? trigger : search,
    closePopover: closePopover,
    panelProps: {
      css: styles.euiSelectableTemplateSitewide__popover
    }
  }), (0, _react2.jsx)("div", {
    style: {
      width: width,
      maxWidth: '100%'
    }
  }, title || trigger ? (0, _react2.jsx)(_popover.EuiPopoverTitle, {
    paddingSize: "s"
  }, title, title && search && (0, _react2.jsx)(_spacer.EuiSpacer, null), search) : undefined, list, footer && (0, _react2.jsx)(_popover.EuiPopoverFooter, {
    paddingSize: "s"
  }, footer)));
};