import React__default, { useMemo } from 'react';
import PropTypes from 'prop-types';
import { formatUrl } from './font-loader.js';

function FontPreview(_ref) {
  var font = _ref.font,
      _ref$weight = _ref.weight,
      weight = _ref$weight === void 0 ? 400 : _ref$weight,
      label = _ref.label,
      noImport = _ref.noImport;
  var style = {
    fontFamily: font
  };
  var fontUrl = useMemo(function () {
    if (!noImport) {
      return formatUrl(font, weight);
    }
  }, [font, weight, noImport]);
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, fontUrl && /*#__PURE__*/React__default.createElement("link", {
    href: fontUrl,
    rel: "stylesheet"
  }), /*#__PURE__*/React__default.createElement("div", {
    style: style
  }, label || font));
}

FontPreview.propTypes = {
  font: PropTypes.string.isRequired,
  weight: PropTypes.number,
  label: PropTypes.string,
  noImport: PropTypes.bool
};

export { FontPreview as default };
