/* index.tsx generated by @compiled/babel-plugin v0.38.1 */
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
require("./index.compiled.css");
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _runtime = require("@compiled/react/runtime");
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _reactMagneticDi = require("react-magnetic-di");
var _constants = require("../../../../../../constants");
var _useAiSummaryAction = _interopRequireDefault(require("../../../../../../state/hooks/use-ai-summary-action"));
var _aiSummary = _interopRequireDefault(require("../../../../../common/ai-summary"));
var _motionWrapper = _interopRequireDefault(require("../../../common/motion-wrapper"));
var _block = _interopRequireDefault(require("../../block"));
var _aiEventSummaryViewed = _interopRequireDefault(require("../ai-event-summary-viewed"));
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 styles = null;
var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
  var testId = props.testId,
    _props$aiSummaryMinHe = props.aiSummaryMinHeight,
    aiSummaryMinHeight = _props$aiSummaryMinHe === void 0 ? 0 : _props$aiSummaryMinHe,
    placeholder = props.placeholder,
    url = props.url;
  var _useAISummaryAction = (0, _useAiSummaryAction.default)(url),
    _useAISummaryAction$s = _useAISummaryAction.state,
    content = _useAISummaryAction$s.content,
    status = _useAISummaryAction$s.status;
  var showAISummary = status === 'done' ||
  // We want to display the AI Summary component only when there is content available during the loading process.
  status === 'loading' && !!content;
  var isSummarisedOnMountRef = (0, _react.useRef)(status === 'done');
  var minHeight = isSummarisedOnMountRef.current ? 0 : aiSummaryMinHeight;
  if (!showAISummary) {
    return /*#__PURE__*/React.createElement(_react.Fragment, null, placeholder);
  }
  return /*#__PURE__*/React.createElement(_block.default, (0, _extends2.default)({}, props, {
    direction: _constants.SmartLinkDirection.Vertical,
    testId: "".concat(testId, "-resolved-view")
    /**
     * Enabled for feature discovery to allow box shadow to overflow
     * Cleanup: https://product-fabric.atlassian.net/browse/EDM-8681
     */,
    className: (0, _runtime.ax)(["_1reoewfl _18m9ewfl"])
  }), status === 'done' && /*#__PURE__*/React.createElement(_aiEventSummaryViewed.default, {
    fromCache: isSummarisedOnMountRef.current
  }), /*#__PURE__*/React.createElement(_motionWrapper.default, {
    minHeight: minHeight,
    show: showAISummary,
    showTransition: !isSummarisedOnMountRef.current
  }, /*#__PURE__*/React.createElement(_aiSummary.default, {
    testId: "".concat(testId, "-ai-summary"),
    minHeight: minHeight,
    content: content
  })));
};
var _default = exports.default = AISummaryBlockResolvedView;