"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _coreData = require("@wordpress/core-data");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

function Media({
  id,
  size = ['large', 'medium', 'thumbnail'],
  ...props
}) {
  const {
    record: media
  } = (0, _coreData.useEntityRecord)('root', 'media', id);
  const currentSize = size.find(s => !!media?.media_details?.sizes?.[s]);
  const mediaUrl = media?.media_details?.sizes?.[currentSize]?.source_url || media?.source_url;
  if (!mediaUrl) {
    return null;
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
    ...props,
    src: mediaUrl,
    alt: media.alt_text
  });
}
var _default = exports.default = Media;
//# sourceMappingURL=index.js.map