import React from 'react';
import { findDeclaration } from '@looker/sdk-codegen';
import { Icon, Link, Tooltip } from '@looker/components';
import { IdeFileDocument } from '@looker/icons';
import { useSelector } from 'react-redux';
import { selectDeclarationsLode } from '../../state';
export var DocSource = _ref => {
  var {
    method,
    type
  } = _ref;
  var declarations = useSelector(selectDeclarationsLode);
  var sourceLink;
  var declaration;

  if (declarations) {
    ;
    ({
      declaration,
      link: sourceLink
    } = findDeclaration(declarations, method === null || method === void 0 ? void 0 : method.id, type === null || type === void 0 ? void 0 : type.name));
  }

  return React.createElement(React.Fragment, null, sourceLink && declaration && React.createElement(Tooltip, {
    content: "".concat(declaration.sourceFile, "#L").concat(declaration.line),
    width: "none"
  }, React.createElement(Link, {
    href: sourceLink,
    target: "_blank"
  }, React.createElement(Icon, {
    icon: React.createElement(IdeFileDocument, null)
  }))));
};
//# sourceMappingURL=DocSource.js.map