/* index.tsx generated by @compiled/babel-plugin v0.39.1 */
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.RovoActionsButton = void 0;
require("./index.compiled.css");
var _runtime = require("@compiled/react/runtime");
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _react = _interopRequireWildcard(require("react"));
var _reactIntlNext = require("react-intl-next");
var _css = require("@atlaskit/css");
var _rovoChat = _interopRequireDefault(require("@atlaskit/icon/core/rovo-chat"));
var _popup = _interopRequireDefault(require("@atlaskit/popup"));
var _compiled = require("@atlaskit/primitives/compiled");
var _messages = require("../../../../messages");
var _aiPrism = _interopRequireDefault(require("../../../common/ai-prism"));
var _actionButton = require("../action-button");
var _rovoPostAuthActionsModal = require("../rovo-post-auth-actions-modal");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var styles = {
  wrapper: "_kqswh2mm _1e0c1o8l",
  expanded: "_kqswstnw _154iidpf _1xi2idpf _1e0c1nu9 _o5721q9c _1pbykb7n",
  expandedText: "_1reo15vq _18m915vq _v564hlhx _1e0c1o8l _p12fidpf _s7n4jp4b _o5721q9c",
  expandedTextVisible: "_p12fuuw1 _u5f31b66"
};
var RovoActionsButton = exports.RovoActionsButton = function RovoActionsButton(_ref) {
  var onClick = _ref.onClick,
    testId = _ref.testId,
    _ref$title = _ref.title,
    title = _ref$title === void 0 ? '' : _ref$title,
    _ref$url = _ref.url,
    url = _ref$url === void 0 ? '' : _ref$url;
  var _useState = (0, _react.useState)(false),
    _useState2 = (0, _slicedToArray2.default)(_useState, 2),
    isHovered = _useState2[0],
    setIsHovered = _useState2[1];
  var _useState3 = (0, _react.useState)(false),
    _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
    isPopupOpen = _useState4[0],
    setIsPopupOpen = _useState4[1];
  var _useIntl = (0, _reactIntlNext.useIntl)(),
    formatMessage = _useIntl.formatMessage;
  var handleClick = function handleClick(e) {
    e.preventDefault();
    e.stopPropagation();
    setIsPopupOpen(function (prev) {
      return !prev;
    });
    onClick === null || onClick === void 0 || onClick(e);
  };
  return /*#__PURE__*/_react.default.createElement(_popup.default, {
    isOpen: isPopupOpen,
    onClose: function onClose() {
      return setIsPopupOpen(false);
    },
    placement: "right-start",
    content: function content() {
      return /*#__PURE__*/_react.default.createElement(_aiPrism.default, {
        isVisible: true,
        isMoving: true,
        isGlowing: true
      }, /*#__PURE__*/_react.default.createElement(_rovoPostAuthActionsModal.RovoPostAuthActionsModal, {
        title: title,
        url: url,
        testId: testId && "".concat(testId, "-popup")
      }));
    },
    trigger: function trigger(triggerProps) {
      return /*#__PURE__*/_react.default.createElement(_compiled.Box, {
        xcss: styles.wrapper,
        onMouseEnter: function onMouseEnter() {
          return setIsHovered(true);
        },
        onMouseLeave: function onMouseLeave() {
          return setIsHovered(false);
        },
        onFocus: function onFocus() {
          return setIsHovered(true);
        },
        onBlur: function onBlur() {
          return setIsHovered(false);
        }
      }, /*#__PURE__*/_react.default.createElement(_actionButton.ActionButton, (0, _extends2.default)({
        onClick: handleClick,
        viewType: "action",
        testId: testId
      }, triggerProps), /*#__PURE__*/_react.default.createElement(_rovoChat.default, {
        label: "Rovo",
        color: "var(--ds-icon-inverse, #FFFFFF)",
        size: "small"
      })), /*#__PURE__*/_react.default.createElement(_compiled.Box, {
        xcss: styles.expanded
      }, /*#__PURE__*/_react.default.createElement(_actionButton.ActionButton, (0, _extends2.default)({
        onClick: handleClick,
        viewType: "action"
      }, triggerProps), /*#__PURE__*/_react.default.createElement(_compiled.Box, {
        xcss: (0, _css.cx)(styles.expandedText, isHovered && styles.expandedTextVisible)
      }, formatMessage(_messages.messages.rovo_actions_explore)), /*#__PURE__*/_react.default.createElement(_rovoChat.default, {
        label: "Rovo",
        color: "var(--ds-icon-inverse, #FFFFFF)",
        size: "small"
      }))));
    }
  });
};