import _extends from "@babel/runtime/helpers/extends";
import React, { useCallback, useMemo } from 'react';
import RovoChatIcon from '@atlaskit/icon/core/rovo-chat';
import useRovoChat from '../../../../../state/hooks/use-rovo-chat';
import Action from '../action';
// Replace this with actual message key, e.g. link-relevancy, link-summary, etc.
export let RovoChatPromptKey = /*#__PURE__*/function (RovoChatPromptKey) {
  RovoChatPromptKey["MESSAGE_1"] = "message-1";
  RovoChatPromptKey["MESSAGE_2"] = "message-2";
  return RovoChatPromptKey;
}({});
const DEFAULT_PROMPTS = [RovoChatPromptKey.MESSAGE_1, RovoChatPromptKey.MESSAGE_2];
const getPromptAction = promptKey => {
  // NAVX-3581: Replace this with real prompt message
  switch (promptKey) {
    case RovoChatPromptKey.MESSAGE_1:
      return {
        icon: /*#__PURE__*/React.createElement(RovoChatIcon, {
          label: "",
          spacing: "spacious"
        }),
        content: 'Action title 1',
        tooltipMessage: 'Action tooltip 1',
        data: {
          name: 'Chat title 1',
          dialogues: [],
          prompt: {
            version: 1,
            type: 'doc',
            content: []
          }
        }
      };
    case RovoChatPromptKey.MESSAGE_2:
      return {
        icon: /*#__PURE__*/React.createElement(RovoChatIcon, {
          label: "",
          spacing: "spacious"
        }),
        content: 'Action title 2',
        tooltipMessage: 'Action tooltip 2',
        data: {
          name: 'Chat title 2',
          dialogues: [],
          prompt: {
            version: 1,
            type: 'doc',
            content: []
          }
        }
      };
  }
};
const RovoChatAction = ({
  onClick: onClickCallback,
  prompts = DEFAULT_PROMPTS,
  testId = 'smart-action-rovo-chat-action',
  ...props
}) => {
  const {
    isRovoChatEnabled,
    sendPromptMessage
  } = useRovoChat();
  const onClick = useCallback(promptData => {
    if (promptData) {
      sendPromptMessage(promptData);

      // NAVX-3599: Add analytics event, possibly as useInvokeClientAction()

      onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback();
    }
  }, [onClickCallback, sendPromptMessage]);
  const promptActions = useMemo(() => {
    return prompts.map((promptKey, idx) => {
      const {
        icon,
        content,
        tooltipMessage,
        data: promptData
      } = getPromptAction(promptKey) || {};
      return promptData ? /*#__PURE__*/React.createElement(Action, _extends({
        content: content,
        icon: icon,
        key: promptKey,
        onClick: () => onClick(promptData),
        testId: `${testId}-${idx + 1}`,
        tooltipMessage: tooltipMessage
      }, props)) : null;
    });
  }, [onClick, prompts, props, testId]);
  return isRovoChatEnabled && (promptActions === null || promptActions === void 0 ? void 0 : promptActions.length) > 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, promptActions) : null;
};
export default RovoChatAction;