/* index.tsx generated by @compiled/babel-plugin v0.39.1 */
import _extends from "@babel/runtime/helpers/extends";
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import "./index.compiled.css";
import { ax, ix } from "@compiled/react/runtime";
import React, { useState } from 'react';
import { useIntl } from 'react-intl-next';
import { cx } from '@atlaskit/css';
import RovoChatIcon from '@atlaskit/icon/core/rovo-chat';
import Popup from '@atlaskit/popup';
import { Box } from '@atlaskit/primitives/compiled';
import { messages } from '../../../../messages';
import AIPrism from '../../../common/ai-prism';
import { ActionButton } from '../action-button';
import { RovoPostAuthActionsModal } from '../rovo-post-auth-actions-modal';
var styles = {
  wrapper: "_kqswh2mm _1e0c1o8l",
  expanded: "_kqswstnw _154iidpf _1xi2idpf _1e0c1nu9 _o5721q9c _1pbykb7n",
  expandedText: "_1reo15vq _18m915vq _v564hlhx _1e0c1o8l _p12fidpf _s7n4jp4b _o5721q9c",
  expandedTextVisible: "_p12fuuw1 _u5f31b66"
};
export var 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 = useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    isHovered = _useState2[0],
    setIsHovered = _useState2[1];
  var _useState3 = useState(false),
    _useState4 = _slicedToArray(_useState3, 2),
    isPopupOpen = _useState4[0],
    setIsPopupOpen = _useState4[1];
  var _useIntl = 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.createElement(Popup, {
    isOpen: isPopupOpen,
    onClose: function onClose() {
      return setIsPopupOpen(false);
    },
    placement: "right-start",
    content: function content() {
      return /*#__PURE__*/React.createElement(AIPrism, {
        isVisible: true,
        isMoving: true,
        isGlowing: true
      }, /*#__PURE__*/React.createElement(RovoPostAuthActionsModal, {
        title: title,
        url: url,
        testId: testId && "".concat(testId, "-popup")
      }));
    },
    trigger: function trigger(triggerProps) {
      return /*#__PURE__*/React.createElement(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.createElement(ActionButton, _extends({
        onClick: handleClick,
        viewType: "action",
        testId: testId
      }, triggerProps), /*#__PURE__*/React.createElement(RovoChatIcon, {
        label: "Rovo",
        color: "var(--ds-icon-inverse, #FFFFFF)",
        size: "small"
      })), /*#__PURE__*/React.createElement(Box, {
        xcss: styles.expanded
      }, /*#__PURE__*/React.createElement(ActionButton, _extends({
        onClick: handleClick,
        viewType: "action"
      }, triggerProps), /*#__PURE__*/React.createElement(Box, {
        xcss: cx(styles.expandedText, isHovered && styles.expandedTextVisible)
      }, formatMessage(messages.rovo_actions_explore)), /*#__PURE__*/React.createElement(RovoChatIcon, {
        label: "Rovo",
        color: "var(--ds-icon-inverse, #FFFFFF)",
        size: "small"
      }))));
    }
  });
};