"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.highlightStyle = exports.cmTheme = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _view = require("@codemirror/view");
var _language = require("@codemirror/language");
var _highlight = require("@lezer/highlight");
/**
 * These styles are copied directly from
 * packages/editor/editor-plugin-code-block-advanced/src/nodeviews/codeBlockAdvanced.ts
 */

var LINE_HEIGHT = '1.5rem';
var cmTheme = exports.cmTheme = _view.EditorView.theme({
  '&': (0, _defineProperty2.default)((0, _defineProperty2.default)({
    backgroundColor: "var(--ds-background-neutral, #0515240F)",
    padding: '0',
    marginTop: "var(--ds-space-100, 8px)",
    marginBottom: "var(--ds-space-100, 8px)"
  }, 'fontSize', '0.875rem'), 'lineHeight', LINE_HEIGHT),
  '&.cm-focused': {
    outline: 'none'
  },
  '.cm-line': {
    padding: '0'
  },
  '&.cm-editor.code-block.danger': {
    backgroundColor: "var(--ds-background-danger, #FFECEB)"
  },
  '.cm-content[aria-readonly="true"]': {
    caretColor: 'transparent'
  },
  '.cm-content': {
    cursor: 'text',
    caretColor: "var(--ds-text, #292A2E)",
    margin: "var(--ds-space-100, 8px)",
    padding: "var(--ds-space-0, 0px)"
  },
  '.cm-scroller': (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({
    backgroundColor: "var(--ds-background-neutral, #0515240F)"
  }, 'lineHeight', 'unset'), "fontFamily", "var(--ds-font-family-code, ui-monospace, Menlo, \"Segoe UI Mono\", \"Ubuntu Mono\", monospace)"), "borderRadius", "var(--ds-radius-small, 4px)"), "backgroundImage", overflowShadow({
    leftCoverWidth: "var(--ds-space-300, 24px)"
  })), "backgroundAttachment", 'local, local, local, local, scroll, scroll, scroll, scroll'),
  '&.cm-focused .cm-cursor': {
    borderLeftColor: "var(--ds-text, #292A2E)"
  },
  '.cm-gutters': {
    backgroundColor: "var(--ds-background-neutral, #0515240F)",
    border: 'none',
    padding: "var(--ds-space-100, 8px)",
    color: "var(--ds-text-subtlest, #6B6E76)"
  },
  '.cm-lineNumbers .cm-gutterElement': {
    paddingLeft: "var(--ds-space-0, 0px)",
    paddingRight: "var(--ds-space-0, 0px)",
    minWidth: 'unset'
  },
  // Set the gutter element min height to prevent flicker of styling while
  // codemirror is calculating (which happens after an animation frame).
  // Example problem: https://github.com/codemirror/dev/issues/1076
  // Ignore the first gutter element as it is a special hidden element.
  '.cm-gutterElement:not(:first-child)': {
    minHeight: LINE_HEIGHT
  }
});
function overflowShadow(_ref) {
  var leftCoverWidth = _ref.leftCoverWidth,
    rightCoverWidth = _ref.rightCoverWidth;
  var width = "var(--ds-space-100, 8px)";
  var leftCoverWidthResolved = leftCoverWidth || width;
  var rightCoverWidthResolved = rightCoverWidth || width;
  return "\n\tlinear-gradient(\n\t\tto right,\n\t\t".concat("var(--ds-background-neutral, #0515240F)", " ", leftCoverWidthResolved, ",\n\t\ttransparent ").concat(leftCoverWidthResolved, "\n\t),\n\tlinear-gradient(\n\t\tto right,\n\t\t", "var(--ds-surface-raised, #FFFFFF)", " ").concat(leftCoverWidthResolved, ",\n\t\ttransparent ").concat(leftCoverWidthResolved, "\n\t),\n\tlinear-gradient(\n\t\tto left,\n\t\t", "var(--ds-background-neutral, #0515240F)", " ").concat(rightCoverWidthResolved, ",\n\t\ttransparent ").concat(rightCoverWidthResolved, "\n\t),\n\tlinear-gradient(\n\t\tto left,\n\t\t", "var(--ds-surface-raised, #FFFFFF)", " ").concat(rightCoverWidthResolved, ",\n\t\ttransparent ").concat(rightCoverWidthResolved, "\n\t),\n\tlinear-gradient(\n\t\tto left,\n\t\t", "var(--ds-shadow-overflow-spread, #1E1F2129)", " 0,\n\t\t", "var(--ds-UNSAFE-transparent, transparent)", "  ").concat(width, "\n\t),\n\tlinear-gradient(\n\t\tto left,\n\t\t", "var(--ds-shadow-overflow-perimeter, #1E1F211f)", " 0,\n\t\t", "var(--ds-UNSAFE-transparent, transparent)", "  ").concat(width, "\n\t),\n\tlinear-gradient(\n\t\tto right,\n\t\t", "var(--ds-shadow-overflow-spread, #1E1F2129)", " 0,\n\t\t", "var(--ds-UNSAFE-transparent, transparent)", "  ").concat(width, "\n\t),\n\tlinear-gradient(\n\t\tto right,\n\t\t", "var(--ds-shadow-overflow-perimeter, #1E1F211f)", " 0,\n\t\t", "var(--ds-UNSAFE-transparent, transparent)", "  ").concat(width, "\n\t)\n");
}

// Based on `platform/packages/design-system/code/src/internal/theme/styles.tsx`
var highlightStyle = exports.highlightStyle = _language.HighlightStyle.define([{
  tag: _highlight.tags.meta,
  color: "var(--ds-text, #292A2E)"
}, {
  tag: _highlight.tags.link,
  textDecoration: 'underline'
}, {
  tag: _highlight.tags.heading,
  textDecoration: 'underline',
  // Custom syntax styling to match existing styling
  fontWeight: "var(--ds-font-weight-bold, 700)"
}, {
  tag: _highlight.tags.emphasis,
  fontStyle: 'italic'
}, {
  tag: _highlight.tags.strong,
  // Custom syntax styling to match existing styling
  fontWeight: "var(--ds-font-weight-bold, 700)"
}, {
  tag: _highlight.tags.strikethrough,
  textDecoration: 'line-through'
}, {
  tag: _highlight.tags.keyword,
  color: "var(--ds-text-accent-blue, #1558BC)",
  // Custom syntax styling to match existing styling
  fontWeight: "var(--ds-font-weight-bold, 700)"
}, {
  tag: [_highlight.tags.atom, _highlight.tags.bool, _highlight.tags.url, _highlight.tags.contentSeparator, _highlight.tags.labelName],
  color: "var(--ds-text-accent-blue, #1558BC)"
}, {
  tag: [_highlight.tags.literal, _highlight.tags.inserted],
  color: "var(--ds-text-accent-blue, #1558BC)"
}, {
  tag: [_highlight.tags.string, _highlight.tags.deleted],
  color: "var(--ds-text-accent-green, #216E4E)"
}, {
  tag: [_highlight.tags.special(_highlight.tags.string)],
  color: "var(--ds-text-accent-green, #216E4E)"
}, {
  tag: [_highlight.tags.regexp, _highlight.tags.escape],
  color: "var(--ds-text-accent-teal, #206A83)"
}, {
  tag: _highlight.tags.definition(_highlight.tags.variableName),
  color: "var(--ds-text, #292A2E)"
}, {
  tag: _highlight.tags.local(_highlight.tags.variableName),
  color: "var(--ds-text, #292A2E)"
}, {
  tag: [_highlight.tags.typeName, _highlight.tags.namespace],
  color: "var(--ds-text-accent-blue, #1558BC)"
}, {
  tag: _highlight.tags.className,
  color: "var(--ds-text-accent-purple, #803FA5)"
}, {
  tag: [_highlight.tags.special(_highlight.tags.variableName), _highlight.tags.macroName],
  color: "var(--ds-text, #292A2E)"
}, {
  tag: _highlight.tags.definition(_highlight.tags.propertyName),
  color: "var(--ds-text, #292A2E)"
}, {
  tag: _highlight.tags.comment,
  color: "var(--ds-text-subtlest, #6B6E76)",
  fontStyle: 'italic'
}, {
  tag: _highlight.tags.invalid,
  color: "var(--ds-text, #292A2E)"
}]);