import React from 'react';
import { useHistory } from 'react-router-dom';
import { Markdown } from '@looker/code-editor';
import { useSelector } from 'react-redux';
import { getEnvAdaptor } from '@looker/extension-utils';
import { selectSearchPattern } from '../../state';
import { transformURL } from './utils';
export var DocMarkdown = _ref => {
  var {
    source,
    specKey
  } = _ref;
  var searchPattern = useSelector(selectSearchPattern);
  var history = useHistory();

  var linkClickHandler = (pathname, url) => {
    if (pathname.startsWith("/".concat(specKey))) {
      history.push(pathname);
    } else if (url.startsWith("/".concat(specKey))) {
      history.push(url);
    } else if (url.startsWith('https://')) {
      var adaptor = getEnvAdaptor();
      adaptor.openBrowserWindow(url);
    }
  };

  return React.createElement(Markdown, {
    source: source,
    pattern: searchPattern,
    linkClickHandler: linkClickHandler,
    transformLinkUri: transformURL.bind(null, specKey)
  });
};
//# sourceMappingURL=DocMarkdown.js.map