'use strict';

var chunkMVQKV5BJ_cjs = require('./chunk-MVQKV5BJ.cjs');
var classnames = require('classnames');
var React2 = require('react');
var Markdown = require('react-markdown');
var remarkGfm = require('remark-gfm');
var icons = require('@blueprintjs/icons');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var classnames__default = /*#__PURE__*/_interopDefault(classnames);
var React2__default = /*#__PURE__*/_interopDefault(React2);
var Markdown__default = /*#__PURE__*/_interopDefault(Markdown);
var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);

// src/markdown-renderer/MarkdownRenderer.module.css
var MarkdownRenderer_default = {};

// src/markdown-renderer/MarkdownRenderer.tsx
var REMARK_PLUGINS = [remarkGfm__default.default];
function MarkdownRenderer({
  content,
  className
}) {
  const rootClassName = classnames__default.default(MarkdownRenderer_default.container, className);
  return /* @__PURE__ */ React2__default.default.createElement("div", {
    className: rootClassName
  }, /* @__PURE__ */ React2__default.default.createElement("div", {
    className: MarkdownRenderer_default.documentWrapper
  }, /* @__PURE__ */ React2__default.default.createElement("div", {
    className: MarkdownRenderer_default.document
  }, /* @__PURE__ */ React2__default.default.createElement(Markdown__default.default, {
    remarkPlugins: REMARK_PLUGINS
  }, content))));
}
function _extends() {
  return _extends = Object.assign ? Object.assign.bind() : function(n) {
    for (var e = 1; e < arguments.length; e++) {
      var t = arguments[e];
      for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
    }
    return n;
  }, _extends.apply(null, arguments);
}
var transformToText = async (response) => {
  return response.text();
};
function MarkdownViewerMedia({
  media,
  ...markdownRendererProps
}) {
  const {
    data: content,
    loading,
    error
  } = chunkMVQKV5BJ_cjs.useMediaContents(media, transformToText);
  const rootClassName = classnames__default.default(MarkdownRenderer_default.container, markdownRendererProps.className);
  return /* @__PURE__ */ React2__default.default.createElement("div", {
    className: rootClassName
  }, loading && /* @__PURE__ */ React2__default.default.createElement("div", {
    className: MarkdownRenderer_default.loadingContainer
  }, /* @__PURE__ */ React2__default.default.createElement(icons.Spin, {
    className: MarkdownRenderer_default.spinnerIcon
  }), "Loading\u2026"), error != null && /* @__PURE__ */ React2__default.default.createElement("div", {
    className: MarkdownRenderer_default.errorContainer
  }, /* @__PURE__ */ React2__default.default.createElement(icons.Error, {
    className: MarkdownRenderer_default.errorIcon
  }), "Failed to load document: ", error.message), content != null && /* @__PURE__ */ React2__default.default.createElement(MarkdownRenderer, _extends({
    content
  }, markdownRendererProps)));
}

exports.MarkdownRenderer = MarkdownRenderer;
exports.MarkdownViewerMedia = MarkdownViewerMedia;
//# sourceMappingURL=chunk-P55Q2MCT.cjs.map
//# sourceMappingURL=chunk-P55Q2MCT.cjs.map