import _extends from "@babel/runtime/helpers/extends";
import React from 'react';
import { InternalActionName, SmartLinkStatus } from '../../../../../constants';
import { useFlexibleCardContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
import AISummaryBlockResolvedView from './resolved';
/**
 * Represents an AISummaryBlock, designed to summarising link resource
 * content using AI.
 * @public
 * @param {AISummaryBlockProps} AISummaryBlock
 * @see Block
 */
const AISummaryBlock = ({
  testId = 'smart-ai-summary-block',
  ...props
}) => {
  var _context$actions, _props$size, _cardContext$ui;
  const cardContext = useFlexibleCardContext();
  const context = useFlexibleUiContext();
  const actionData = context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[InternalActionName.AISummaryAction];
  if ((cardContext === null || cardContext === void 0 ? void 0 : cardContext.status) !== SmartLinkStatus.Resolved) {
    return null;
  }
  if (!(actionData !== null && actionData !== void 0 && actionData.url)) {
    return null;
  }
  return /*#__PURE__*/React.createElement(AISummaryBlockResolvedView, _extends({}, props, {
    size: (_props$size = props.size) !== null && _props$size !== void 0 ? _props$size : cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$ui = cardContext.ui) === null || _cardContext$ui === void 0 ? void 0 : _cardContext$ui.size,
    testId: testId,
    url: actionData.url
  }));
};
export default AISummaryBlock;