"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.AISummaryActionComponent = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireWildcard(require("react"));
var _reactMagneticDi = require("react-magnetic-di");
var _useAiSummaryAction = _interopRequireDefault(require("../../../../../state/hooks/use-ai-summary-action"));
var _aiSummariseAction = require("./ai-summarise-action");
var _copySummaryAction = require("./copy-summary-action");
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 AISummaryActionComponent = exports.AISummaryActionComponent = function AISummaryActionComponent(props) {
  var url = props.url,
    onLoadingChange = props.onLoadingChange,
    _props$testId = props.testId,
    testId = _props$testId === void 0 ? 'smart-action-ai-summary-action' : _props$testId;
  var _useAISummaryAction = (0, _useAiSummaryAction.default)(url),
    _useAISummaryAction$s = _useAISummaryAction.state,
    status = _useAISummaryAction$s.status,
    content = _useAISummaryAction$s.content,
    summariseUrl = _useAISummaryAction.summariseUrl;
  (0, _react.useEffect)(function () {
    onLoadingChange === null || onLoadingChange === void 0 || onLoadingChange(status === 'loading');
  }, [onLoadingChange, status]);
  return status === 'done' ? /*#__PURE__*/_react.default.createElement(_copySummaryAction.CopySummaryAction, (0, _extends2.default)({}, props, {
    testId: testId,
    content: content
  })) : /*#__PURE__*/_react.default.createElement(_aiSummariseAction.AISummariseAction, (0, _extends2.default)({}, props, {
    testId: testId,
    summariseUrl: summariseUrl,
    status: status
  }));
};