text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.CreateDocumentItem = CreateDocumentItem;
  
  var _components = require("@sanity/base/components");
  
  var _ui = require("@sanity/ui");
  
  var _react = _interopRequireDefault(require("react"));
  
  var _styledComponents = _interopRequireDefault(require("styled-components"));
  
  var _templateObject, _templateObject2, _templateObject3, _templateObject4;
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  
  var Root = (0, _styledComponents.default)(_ui.Box)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n  height: 100%;\n\n  a {\n    color: currentColor;\n    text-decoration: none;\n  }\n\n  svg[data-sanity-icon] {\n    margin: 0;\n  }\n"])));
  
  var DisabledButtonWrapper = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n  height: 100%;\n"])));
  
  var StyledIntentButton = (0, _styledComponents.default)(_components.IntentButton)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n  display: flex;\n  height: 100%;\n  width: 100%;\n  align-items: flex-start;\n"])));
  var StyledButton = (0, _styledComponents.default)(_ui.Button)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n  display: flex;\n  height: 100%;\n  width: 100%;\n  align-items: flex-start;\n"])));
  
  function CreateDocumentItem(_ref) {
    var description = _ref.description,
        granted = _ref.granted,
        title = _ref.title,
        subtitle = _ref.subtitle,
        icon = _ref.icon,
        template = _ref.template,
        parameters = _ref.parameters,
        currentUser = _ref.currentUser,
        onClick = _ref.onClick;
  
    var content = /*#__PURE__*/_react.default.createElement(Root, null, /*#__PURE__*/_react.default.createElement(_ui.Flex, {
      align: description ? 'flex-start' : 'center'
    }, /*#__PURE__*/_react.default.createElement(_ui.Stack, {
      space: 3,
      flex: 1
    }, /*#__PURE__*/_react.default.createElement(_ui.Text, {
      as: "h2",
      style: {
        whiteSpace: 'break-spaces'
      }
    }, title), subtitle && /*#__PURE__*/_react.default.createElement(_ui.Text, {
      size: 1,
      as: "p",
      textOverflow: "ellipsis"
    }, subtitle), description && /*#__PURE__*/_react.default.createElement(_ui.Text, {
      as: "p",
      size: 1,
      style: {
        whiteSpace: 'break-spaces'
      }
    }, description)), icon && /*#__PURE__*/_react.default.createElement(_ui.Text, {
      size: 1
    }, /*#__PURE__*/_react.default.createElement(_ui.Flex, {
      align: "flex-start",
      paddingLeft: 2
    }, typeof icon === 'function' ? /*#__PURE__*/_react.default.createElement(icon) : typeof icon === 'string' ? /*#__PURE__*/_react.default.createElement("span", null, icon) : /*#__PURE__*/_react.default.isValidElement(icon) ? icon : null))));
  
    if (granted) {
      return /*#__PURE__*/_react.default.createElement(StyledIntentButton, {
        intent: "create",
        params: [{
          type: template.schemaType,
          template: template.id
        }, parameters],
        title: subtitle ? "Create new ".concat(title, " (").concat(subtitle, ")") : "Create new ".concat(title),
        onClick: onClick,
        mode: "ghost",
        fontSize: 2,
        "data-testid": "create-document-item-".concat(template.id)
      }, content);
    }
  
    return /*#__PURE__*/_react.default.createElement(_ui.Tooltip, {
      content: /*#__PURE__*/_react.default.createElement(_ui.Box, {
        padding: 2,
        style: {
          maxWidth: 300
        }
      }, /*#__PURE__*/_react.default.createElement(_components.InsufficientPermissionsMessage, {
        currentUser: currentUser,
        operationLabel: "create this document"
      }))
    }, /*#__PURE__*/_react.default.createElement(DisabledButtonWrapper, null, /*#__PURE__*/_react.default.createElement(StyledButton, {
      "aria-label": "insufficient permissions",
      mode: "ghost",
      disabled: true
    }, content)));
  }