"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _react = _interopRequireDefault(require("react"));
var _constants = require("../../../../../constants");
var _flexibleUiContext = require("../../../../../state/flexible-ui-context");
var _mediaElement = _interopRequireDefault(require("../media-element"));
var _excluded = ["overrideUrl"];
var PreviewElement = function PreviewElement(props) {
  var _ref = props !== null && props !== void 0 ? props : {},
    overrideUrl = _ref.overrideUrl,
    rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
  var context = (0, _flexibleUiContext.useFlexibleUiContext)();
  var data = overrideUrl ? {
    url: overrideUrl,
    type: _constants.MediaType.Image
  } : context === null || context === void 0 ? void 0 : context.preview;
  if (!data) {
    return null;
  }
  return /*#__PURE__*/_react.default.createElement(_mediaElement.default, (0, _extends2.default)({}, rest, data));
};
var _default = exports.default = PreviewElement;