import { defineProperty as _defineProperty } from '../../../_virtual/_rollupPluginBabelHelpers.js';
import { jsx } from '@emotion/core';
import { MdCheck, MdClose, MdWarning } from 'react-icons/md';
import { StructuredLogLevel } from './types.esm.js';
import { FormattedLogMessage } from './FormattedLogMessage.esm.js';
import { BuildLogEntrySkeleton } from './BuildLogEntrySkeleton.esm.js';

var _logEntryStatusVarian;

var baseCss = function baseCss(theme) {
  return _defineProperty({}, theme.mediaQueries.tablet, {
    paddingRight: theme.space[10]
  });
};

var messageCss = function messageCss(theme) {
  return _defineProperty({
    // Necessary to set min-width to 0 so that the message does not overflow the row
    minWidth: 0,
    gridColumn: "2 span"
  }, theme.mediaQueries.tablet, {
    gridColumn: "3 span"
  });
};

function BuildStandardLogEntry(_ref3) {
  var level = _ref3.level,
      message = _ref3.message,
      context = _ref3.context,
      location = _ref3.location,
      filePath = _ref3.filePath,
      docsUrl = _ref3.docsUrl,
      errorUrl = _ref3.errorUrl;
  var displayMessage = context && context.stageLabel ? "".concat(context.stageLabel, " failed at ").concat(filePath) : message;
  return jsx(BuildLogEntrySkeleton, {
    icon: jsx(LogEntryStatusIcon, {
      logLevel: level
    }),
    css: baseCss
  }, jsx(FormattedLogMessage, {
    message: displayMessage,
    level: level,
    location: location,
    filePath: filePath,
    docsUrl: docsUrl,
    errorUrl: errorUrl,
    css: messageCss
  }));
}

function LogEntryStatusIcon(_ref4) {
  var logLevel = _ref4.logLevel;
  var statusVariant = logLevel ? logEntryStatusVariants[logLevel] : null;

  if (!statusVariant) {
    return null;
  }

  return jsx(statusVariant.Icon, {
    "aria-label": statusVariant && statusVariant.label,
    css: statusVariant.styles
  });
}

var logEntryStatusVariants = (_logEntryStatusVarian = {}, _defineProperty(_logEntryStatusVarian, StructuredLogLevel.Success, {
  label: "Completed",
  Icon: MdCheck,
  styles: function styles(theme) {
    return {
      color: theme.colors.grey[40]
    };
  }
}), _defineProperty(_logEntryStatusVarian, StructuredLogLevel.Error, {
  label: "Failed",
  Icon: MdClose,
  styles: function styles(theme) {
    return {
      color: theme.colors.red[60]
    };
  }
}), _defineProperty(_logEntryStatusVarian, StructuredLogLevel.Warning, {
  label: "Warning",
  Icon: MdWarning,
  styles: function styles(theme) {
    return {
      color: theme.colors.yellow[90]
    };
  }
}), _logEntryStatusVarian);
BuildStandardLogEntry.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "BuildStandardLogEntry"
};

if (typeof STORYBOOK_REACT_CLASSES !== "undefined") {
  STORYBOOK_REACT_CLASSES["src/components/BuildLogs/BuildStandardLogEntry.tsx"] = {
    name: "BuildStandardLogEntry",
    docgenInfo: BuildStandardLogEntry.__docgenInfo,
    path: "src/components/BuildLogs/BuildStandardLogEntry.tsx"
  };
}

export { BuildStandardLogEntry };
//# sourceMappingURL=BuildStandardLogEntry.esm.js.map
