"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const uri = require("../../base/common/uri.js");
const range = require("./core/range.js");
const tokenizationRegistry = require("./tokenizationRegistry.js");
const codicons = require("../../base/common/codicons.js");
class TokenMetadata {
  static getLanguageId(metadata) {
    return (metadata & 255) >>> 0;
  }
  static getTokenType(metadata) {
    return (metadata & 768) >>> 8;
  }
  static getFontStyle(metadata) {
    return (metadata & 15360) >>> 10;
  }
  static getForeground(metadata) {
    return (metadata & 8372224) >>> 14;
  }
  static getBackground(metadata) {
    return (metadata & 4286578688) >>> 23;
  }
  static getClassNameFromMetadata(metadata) {
    const foreground = this.getForeground(metadata);
    let className = "mtk" + foreground;
    const fontStyle = this.getFontStyle(metadata);
    if (fontStyle & 1) {
      className += " mtki";
    }
    if (fontStyle & 2) {
      className += " mtkb";
    }
    if (fontStyle & 4) {
      className += " mtku";
    }
    if (fontStyle & 8) {
      className += " mtks";
    }
    return className;
  }
  static getInlineStyleFromMetadata(metadata, colorMap) {
    const foreground = this.getForeground(metadata);
    const fontStyle = this.getFontStyle(metadata);
    let result = `color: ${colorMap[foreground]};`;
    if (fontStyle & 1) {
      result += "font-style: italic;";
    }
    if (fontStyle & 2) {
      result += "font-weight: bold;";
    }
    let textDecoration = "";
    if (fontStyle & 4) {
      textDecoration += " underline";
    }
    if (fontStyle & 8) {
      textDecoration += " line-through";
    }
    if (textDecoration) {
      result += `text-decoration:${textDecoration};`;
    }
    return result;
  }
  static getPresentationFromMetadata(metadata) {
    const foreground = this.getForeground(metadata);
    const fontStyle = this.getFontStyle(metadata);
    return {
      foreground,
      italic: Boolean(
        fontStyle & 1
        /* Italic */
      ),
      bold: Boolean(
        fontStyle & 2
        /* Bold */
      ),
      underline: Boolean(
        fontStyle & 4
        /* Underline */
      ),
      strikethrough: Boolean(
        fontStyle & 8
        /* Strikethrough */
      )
    };
  }
}
class Token {
  constructor(offset, type, language) {
    this._tokenBrand = void 0;
    this.offset = offset;
    this.type = type;
    this.language = language;
  }
  toString() {
    return "(" + this.offset + ", " + this.type + ")";
  }
}
class TokenizationResult {
  constructor(tokens, endState) {
    this._tokenizationResultBrand = void 0;
    this.tokens = tokens;
    this.endState = endState;
  }
}
class EncodedTokenizationResult {
  constructor(tokens, endState) {
    this._encodedTokenizationResultBrand = void 0;
    this.tokens = tokens;
    this.endState = endState;
  }
}
exports.CompletionItemKinds = void 0;
(function(CompletionItemKinds) {
  const byKind = /* @__PURE__ */ new Map();
  byKind.set(0, codicons.Codicon.symbolMethod);
  byKind.set(1, codicons.Codicon.symbolFunction);
  byKind.set(2, codicons.Codicon.symbolConstructor);
  byKind.set(3, codicons.Codicon.symbolField);
  byKind.set(4, codicons.Codicon.symbolVariable);
  byKind.set(5, codicons.Codicon.symbolClass);
  byKind.set(6, codicons.Codicon.symbolStruct);
  byKind.set(7, codicons.Codicon.symbolInterface);
  byKind.set(8, codicons.Codicon.symbolModule);
  byKind.set(9, codicons.Codicon.symbolProperty);
  byKind.set(10, codicons.Codicon.symbolEvent);
  byKind.set(11, codicons.Codicon.symbolOperator);
  byKind.set(12, codicons.Codicon.symbolUnit);
  byKind.set(13, codicons.Codicon.symbolValue);
  byKind.set(15, codicons.Codicon.symbolEnum);
  byKind.set(14, codicons.Codicon.symbolConstant);
  byKind.set(15, codicons.Codicon.symbolEnum);
  byKind.set(16, codicons.Codicon.symbolEnumMember);
  byKind.set(17, codicons.Codicon.symbolKeyword);
  byKind.set(27, codicons.Codicon.symbolSnippet);
  byKind.set(18, codicons.Codicon.symbolText);
  byKind.set(19, codicons.Codicon.symbolColor);
  byKind.set(20, codicons.Codicon.symbolFile);
  byKind.set(21, codicons.Codicon.symbolReference);
  byKind.set(22, codicons.Codicon.symbolCustomColor);
  byKind.set(23, codicons.Codicon.symbolFolder);
  byKind.set(24, codicons.Codicon.symbolTypeParameter);
  byKind.set(25, codicons.Codicon.account);
  byKind.set(26, codicons.Codicon.issues);
  function toIcon(kind) {
    let codicon = byKind.get(kind);
    if (!codicon) {
      console.info("No codicon found for CompletionItemKind " + kind);
      codicon = codicons.Codicon.symbolProperty;
    }
    return codicon;
  }
  CompletionItemKinds.toIcon = toIcon;
  const data = /* @__PURE__ */ new Map();
  data.set(
    "method",
    0
    /* Method */
  );
  data.set(
    "function",
    1
    /* Function */
  );
  data.set(
    "constructor",
    2
    /* Constructor */
  );
  data.set(
    "field",
    3
    /* Field */
  );
  data.set(
    "variable",
    4
    /* Variable */
  );
  data.set(
    "class",
    5
    /* Class */
  );
  data.set(
    "struct",
    6
    /* Struct */
  );
  data.set(
    "interface",
    7
    /* Interface */
  );
  data.set(
    "module",
    8
    /* Module */
  );
  data.set(
    "property",
    9
    /* Property */
  );
  data.set(
    "event",
    10
    /* Event */
  );
  data.set(
    "operator",
    11
    /* Operator */
  );
  data.set(
    "unit",
    12
    /* Unit */
  );
  data.set(
    "value",
    13
    /* Value */
  );
  data.set(
    "constant",
    14
    /* Constant */
  );
  data.set(
    "enum",
    15
    /* Enum */
  );
  data.set(
    "enum-member",
    16
    /* EnumMember */
  );
  data.set(
    "enumMember",
    16
    /* EnumMember */
  );
  data.set(
    "keyword",
    17
    /* Keyword */
  );
  data.set(
    "snippet",
    27
    /* Snippet */
  );
  data.set(
    "text",
    18
    /* Text */
  );
  data.set(
    "color",
    19
    /* Color */
  );
  data.set(
    "file",
    20
    /* File */
  );
  data.set(
    "reference",
    21
    /* Reference */
  );
  data.set(
    "customcolor",
    22
    /* Customcolor */
  );
  data.set(
    "folder",
    23
    /* Folder */
  );
  data.set(
    "type-parameter",
    24
    /* TypeParameter */
  );
  data.set(
    "typeParameter",
    24
    /* TypeParameter */
  );
  data.set(
    "account",
    25
    /* User */
  );
  data.set(
    "issue",
    26
    /* Issue */
  );
  function fromString(value, strict) {
    let res = data.get(value);
    if (typeof res === "undefined" && !strict) {
      res = 9;
    }
    return res;
  }
  CompletionItemKinds.fromString = fromString;
})(exports.CompletionItemKinds || (exports.CompletionItemKinds = {}));
exports.InlineCompletionTriggerKind = void 0;
(function(InlineCompletionTriggerKind) {
  InlineCompletionTriggerKind[InlineCompletionTriggerKind["Automatic"] = 0] = "Automatic";
  InlineCompletionTriggerKind[InlineCompletionTriggerKind["Explicit"] = 1] = "Explicit";
})(exports.InlineCompletionTriggerKind || (exports.InlineCompletionTriggerKind = {}));
exports.SignatureHelpTriggerKind = void 0;
(function(SignatureHelpTriggerKind) {
  SignatureHelpTriggerKind[SignatureHelpTriggerKind["Invoke"] = 1] = "Invoke";
  SignatureHelpTriggerKind[SignatureHelpTriggerKind["TriggerCharacter"] = 2] = "TriggerCharacter";
  SignatureHelpTriggerKind[SignatureHelpTriggerKind["ContentChange"] = 3] = "ContentChange";
})(exports.SignatureHelpTriggerKind || (exports.SignatureHelpTriggerKind = {}));
exports.DocumentHighlightKind = void 0;
(function(DocumentHighlightKind) {
  DocumentHighlightKind[DocumentHighlightKind["Text"] = 0] = "Text";
  DocumentHighlightKind[DocumentHighlightKind["Read"] = 1] = "Read";
  DocumentHighlightKind[DocumentHighlightKind["Write"] = 2] = "Write";
})(exports.DocumentHighlightKind || (exports.DocumentHighlightKind = {}));
function isLocationLink(thing) {
  return thing && uri.URI.isUri(thing.uri) && range.Range.isIRange(thing.range) && (range.Range.isIRange(thing.originSelectionRange) || range.Range.isIRange(thing.targetSelectionRange));
}
exports.SymbolKinds = void 0;
(function(SymbolKinds) {
  const byKind = /* @__PURE__ */ new Map();
  byKind.set(0, codicons.Codicon.symbolFile);
  byKind.set(1, codicons.Codicon.symbolModule);
  byKind.set(2, codicons.Codicon.symbolNamespace);
  byKind.set(3, codicons.Codicon.symbolPackage);
  byKind.set(4, codicons.Codicon.symbolClass);
  byKind.set(5, codicons.Codicon.symbolMethod);
  byKind.set(6, codicons.Codicon.symbolProperty);
  byKind.set(7, codicons.Codicon.symbolField);
  byKind.set(8, codicons.Codicon.symbolConstructor);
  byKind.set(9, codicons.Codicon.symbolEnum);
  byKind.set(10, codicons.Codicon.symbolInterface);
  byKind.set(11, codicons.Codicon.symbolFunction);
  byKind.set(12, codicons.Codicon.symbolVariable);
  byKind.set(13, codicons.Codicon.symbolConstant);
  byKind.set(14, codicons.Codicon.symbolString);
  byKind.set(15, codicons.Codicon.symbolNumber);
  byKind.set(16, codicons.Codicon.symbolBoolean);
  byKind.set(17, codicons.Codicon.symbolArray);
  byKind.set(18, codicons.Codicon.symbolObject);
  byKind.set(19, codicons.Codicon.symbolKey);
  byKind.set(20, codicons.Codicon.symbolNull);
  byKind.set(21, codicons.Codicon.symbolEnumMember);
  byKind.set(22, codicons.Codicon.symbolStruct);
  byKind.set(23, codicons.Codicon.symbolEvent);
  byKind.set(24, codicons.Codicon.symbolOperator);
  byKind.set(25, codicons.Codicon.symbolTypeParameter);
  function toIcon(kind) {
    let icon = byKind.get(kind);
    if (!icon) {
      console.info("No codicon found for SymbolKind " + kind);
      icon = codicons.Codicon.symbolProperty;
    }
    return icon;
  }
  SymbolKinds.toIcon = toIcon;
})(exports.SymbolKinds || (exports.SymbolKinds = {}));
class FoldingRangeKind {
  /**
   * Creates a new {@link FoldingRangeKind}.
   *
   * @param value of the kind.
   */
  constructor(value) {
    this.value = value;
  }
}
FoldingRangeKind.Comment = new FoldingRangeKind("comment");
FoldingRangeKind.Imports = new FoldingRangeKind("imports");
FoldingRangeKind.Region = new FoldingRangeKind("region");
exports.Command = void 0;
(function(Command) {
  function is(obj) {
    if (!obj || typeof obj !== "object") {
      return false;
    }
    return typeof obj.id === "string" && typeof obj.title === "string";
  }
  Command.is = is;
})(exports.Command || (exports.Command = {}));
exports.InlayHintKind = void 0;
(function(InlayHintKind) {
  InlayHintKind[InlayHintKind["Type"] = 1] = "Type";
  InlayHintKind[InlayHintKind["Parameter"] = 2] = "Parameter";
})(exports.InlayHintKind || (exports.InlayHintKind = {}));
const TokenizationRegistry = new tokenizationRegistry.TokenizationRegistry();
exports.EncodedTokenizationResult = EncodedTokenizationResult;
exports.FoldingRangeKind = FoldingRangeKind;
exports.Token = Token;
exports.TokenMetadata = TokenMetadata;
exports.TokenizationRegistry = TokenizationRegistry;
exports.TokenizationResult = TokenizationResult;
exports.isLocationLink = isLocationLink;
