"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const lexer_public = require("./lib-src-scan-lexer_public.cjs");
const tokens = require("./lib-src-scan-tokens.cjs");
const isString = require("../lodash-es/isString.cjs");
const isUndefined = require("../lodash-es/isUndefined.cjs");
const has = require("../lodash-es/has.cjs");
function tokenLabel(tokType) {
  if (hasTokenLabel(tokType)) {
    return tokType.LABEL;
  } else {
    return tokType.name;
  }
}
function hasTokenLabel(obj) {
  return isString.default(obj.LABEL) && obj.LABEL !== "";
}
const PARENT = "parent";
const CATEGORIES = "categories";
const LABEL = "label";
const GROUP = "group";
const PUSH_MODE = "push_mode";
const POP_MODE = "pop_mode";
const LONGER_ALT = "longer_alt";
const LINE_BREAKS = "line_breaks";
const START_CHARS_HINT = "start_chars_hint";
function createToken(config) {
  return createTokenInternal(config);
}
function createTokenInternal(config) {
  const pattern = config.pattern;
  const tokenType = {};
  tokenType.name = config.name;
  if (!isUndefined.default(pattern)) {
    tokenType.PATTERN = pattern;
  }
  if (has.default(config, PARENT)) {
    throw "The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";
  }
  if (has.default(config, CATEGORIES)) {
    tokenType.CATEGORIES = config[CATEGORIES];
  }
  tokens.augmentTokenTypes([tokenType]);
  if (has.default(config, LABEL)) {
    tokenType.LABEL = config[LABEL];
  }
  if (has.default(config, GROUP)) {
    tokenType.GROUP = config[GROUP];
  }
  if (has.default(config, POP_MODE)) {
    tokenType.POP_MODE = config[POP_MODE];
  }
  if (has.default(config, PUSH_MODE)) {
    tokenType.PUSH_MODE = config[PUSH_MODE];
  }
  if (has.default(config, LONGER_ALT)) {
    tokenType.LONGER_ALT = config[LONGER_ALT];
  }
  if (has.default(config, LINE_BREAKS)) {
    tokenType.LINE_BREAKS = config[LINE_BREAKS];
  }
  if (has.default(config, START_CHARS_HINT)) {
    tokenType.START_CHARS_HINT = config[START_CHARS_HINT];
  }
  return tokenType;
}
const EOF = createToken({ name: "EOF", pattern: lexer_public.Lexer.NA });
tokens.augmentTokenTypes([EOF]);
function createTokenInstance(tokType, image, startOffset, endOffset, startLine, endLine, startColumn, endColumn) {
  return {
    image,
    startOffset,
    endOffset,
    startLine,
    endLine,
    startColumn,
    endColumn,
    tokenTypeIdx: tokType.tokenTypeIdx,
    tokenType: tokType
  };
}
function tokenMatcher(token, tokType) {
  return tokens.tokenStructuredMatcher(token, tokType);
}
exports.EOF = EOF;
exports.createToken = createToken;
exports.createTokenInstance = createTokenInstance;
exports.hasTokenLabel = hasTokenLabel;
exports.tokenLabel = tokenLabel;
exports.tokenMatcher = tokenMatcher;
//# sourceMappingURL=lib-src-scan-tokens_public.cjs.map
