/* index.tsx generated by @compiled/babel-plugin v0.39.1 */
import _extends from "@babel/runtime/helpers/extends";
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';
const styles = {
  wrapper: "_kqswh2mm _1e0c1o8l",
  expanded: "_kqswstnw _154iidpf _1xi2idpf _1e0c1nu9 _o5721q9c _1pbykb7n",
  expandedText: "_1reo15vq _18m915vq _v564hlhx _1e0c1o8l _p12fidpf _s7n4jp4b _o5721q9c",
  expandedTextVisible: "_p12fuuw1 _u5f31b66"
};
export const RovoActionsButton = ({
  onClick,
  testId,
  title = '',
  url = ''
}) => {
  const [isHovered, setIsHovered] = useState(false);
  const [isPopupOpen, setIsPopupOpen] = useState(false);
  const {
    formatMessage
  } = useIntl();
  const handleClick = e => {
    e.preventDefault();
    e.stopPropagation();
    setIsPopupOpen(prev => !prev);
    onClick === null || onClick === void 0 ? void 0 : onClick(e);
  };
  return /*#__PURE__*/React.createElement(Popup, {
    isOpen: isPopupOpen,
    onClose: () => setIsPopupOpen(false),
    placement: "right-start",
    content: () => /*#__PURE__*/React.createElement(AIPrism, {
      isVisible: true,
      isMoving: true,
      isGlowing: true
    }, /*#__PURE__*/React.createElement(RovoPostAuthActionsModal, {
      title: title,
      url: url,
      testId: testId && `${testId}-popup`
    })),
    trigger: triggerProps => /*#__PURE__*/React.createElement(Box, {
      xcss: styles.wrapper,
      onMouseEnter: () => setIsHovered(true),
      onMouseLeave: () => setIsHovered(false),
      onFocus: () => setIsHovered(true),
      onBlur: () => 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"
    }))))
  });
};