turn size > 0 ? text.substring(pos - size, pos) : "";
    }
    function scanExpectedChar(ch) {
      if (charCodeChecked(pos) === ch) {
        pos++;
      } else {
        error2(Diagnostics._0_expected, pos, 0, String.fromCharCode(ch));
      }
    }
    scanDisjunction(
      /*isInGroup*/
      false
    );
    forEach(groupNameReferences, (reference) => {
      if (!(groupSpecifiers == null ? void 0 : groupSpecifiers.has(reference.name))) {
        error2(Diagnostics.There_is_no_capturing_group_named_0_in_this_regular_expression, reference.pos, reference.end - reference.pos, reference.name);
        if (groupSpecifiers) {
          const suggestion = getSpellingSuggestion(reference.name, groupSpecifiers, identity);
          if (suggestion) {
            error2(Diagnostics.Did_you_mean_0, reference.pos, reference.end - reference.pos, suggestion);
          }
        }
      }
    });
    forEach(decimalEscapes, (escape) => {
      if (escape.value > numberOfCapturingGroups) {
        if (numberOfCapturingGroups) {
          error2(Diagnostics.This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_regular_expression, escape.pos, escape.end - escape.pos, numberOfCapturingGroups);
        } else {
          error2(Diagnostics.This_backreference_refers_to_a_group_that_does_not_exist_There_are_no_capturing_groups_in_this_regular_expression, escape.pos, escape.end - escape.pos);
        }
      }
    });
  }
  function checkRegularExpressionFlagAvailability(flag, size) {
    const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
    if (availableFrom && languageVersion < availableFrom) {
      error2(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos, size, getNameOfScriptTarget(availableFrom));
    }
  }
  function appendIfCommentDirective(commentDirectives2, text2, commentDirectiveRegEx, lineStart) {
    const type = getDirectiveFromComment(text2.trimStart(), commentDirectiveRegEx);
    if (type === void 0) {
      return commentDirectives2;
    }
    return append(
      commentDirectives2,
      {
        range: { pos: lineStart, end: pos },
        type
      }
    );
  }
  function getDirectiveFromComment(text2, commentDirectiveRegEx) {
    const match = commentDirectiveRegEx.exec(text2);
    if (!match) {
      return void 0;
    }
    switch (match[1]) {
      case "ts-expect-error":
        return 0 /* ExpectError */;
      case "ts-ignore":
        return 1 /* Ignore */;
    }
    return void 0;
  }
  function reScanTemplateToken(isTaggedTemplate) {
    pos = tokenStart;
    return token = scanTemplateAndSetTokenValue(!isTaggedTemplate);
  }
  function reScanTemplateHeadOrNoSubstitutionTemplate() {
    pos = tokenStart;
    return token = scanTemplateAndSetTokenValue(
      /*shouldEmitInvalidEscapeError*/
      true
    );
  }
  function reScanJsxToken(allowMultilineJsxText = true) {
    pos = tokenStart = fullStartPos;
    return token = scanJsxToken(allowMultilineJsxText);
  }
  function reScanLessThanToken() {
    if (token === 48 /* LessThanLessThanToken */) {
      pos = tokenStart + 1;
      return token = 30 /* LessThanToken */;
    }
    return token;
  }
  function reScanHashToken() {
    if (token === 81 /* PrivateIdentifier */) {
      pos = tokenStart + 1;
      return token = 63 /* HashToken */;
    }
    return token;
  }
  function reScanQuestionToken() {
    Debug.assert(token === 61 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'");
    pos = tokenStart + 1;
    return token = 58 /* QuestionToken */;
  }
  function scanJsxToken(allowMultilineJsxText = true) {
    fullStartPos = tokenStart = pos;
    if (pos >= end) {
      return token = 1 /* EndOfFileToken */;
    }
    let char = charCodeUnchecked(pos);
    if (char === 60 /* lessThan */) {
      if (charCodeUnchecked(pos + 1) === 47 /* slash */) {
        pos += 2;
        return token = 31 /* LessThanSlashToken */;
      }
      pos++;
      return token = 30 /* LessThanToken */;
    }
    if (char === 123 /* openBrace */) {
      pos++;
      return token = 19 /* OpenBraceToken */;
    }
    let firstNonWhitespace = 0;
    while (pos < end) {
      char = charCodeUnchecked(pos);
      if (char === 123 /* openBrace */) {
        break;
      }
      if (char === 60 /* lessThan */) {
        if (isConflictMarkerTrivia(text, pos)) {
          pos = scanConflictMarkerTrivia(text, pos, error2);
          return token = 7 /* ConflictMarkerTrivia */;
        }
        break;
      }
      if (char === 62 /* greaterThan */) {
        error2(Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1);
      }
      if (char === 125 /* closeBrace */) {
        error2(Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1);
      }
      if (isLineBreak(char) && firstNonWhitespace === 0) {
        firstNonWhitespace = -1;
      } else if (!allowMultilineJsxText && isLineBreak(char) && firstNonWhitespace > 0) {
        break;
      } else if (!isWhiteSpaceLike(char)) {
        firstNonWhitespace = pos;
      }
      pos++;
    }
    tokenValue = text.substring(fullStartPos, pos);
    return firstNonWhitespace === -1 ? 13 /* JsxTextAllWhiteSpaces */ : 12 /* JsxText */;
  }
  function scanJsxIdentifier() {
    if (tokenIsIdentifierOrKeyword(token)) {
      while (pos < end) {
        const ch = charCodeUnchecked(pos);
        if (ch === 45 /* minus */) {
          tokenValue += "-";
          pos++;
          continue;
        }
        const oldPos = pos;
        tokenValue += scanIdentifierParts();
        if (pos === oldPos) {
          break;
        }
      }
      return getIdentifierToken();
    }
    return token;
  }
  function scanJsxAttributeValue() {
    fullStartPos = pos;
    switch (charCodeUnchecked(pos)) {
      case 34 /* doubleQuote */:
      case 39 /* singleQuote */:
        tokenValue = scanString(
          /*jsxAttributeString*/
          true
        );
        return token = 11 /* StringLiteral */;
      default:
        return scan();
    }
  }
  function reScanJsxAttributeValue() {
    pos = tokenStart = fullStartPos;
    return scanJsxAttributeValue();
  }
  function scanJSDocCommentTextToken(inBackticks) {
    fullStartPos = tokenStart = pos;
    tokenFlags = 0 /* None */;
    if (pos >= end) {
      return token = 1 /* EndOfFileToken */;
    }
    for (let ch = charCodeUnchecked(pos); pos < end && (!isLineBreak(ch) && ch !== 96 /* backtick */); ch = codePointUnchecked(++pos)) {
      if (!inBackticks) {
        if (ch === 123 /* openBrace */) {
          break;
        } else if (ch === 64 /* at */ && pos - 1 >= 0 && isWhiteSpaceSingleLine(charCodeUnchecked(pos - 1)) && !(pos + 1 < end && isWhiteSpaceLike(charCodeUnchecked(pos + 1)))) {
          break;
        }
      }
    }
    if (pos === tokenStart) {
      return scanJsDocToken();
    }
    tokenValue = text.substring(tokenStart, pos);
    return token = 82 /* JSDocCommentTextToken */;
  }
  function scanJsDocToken() {
    fullStartPos = tokenStart = pos;
    tokenFlags = 0 /* None */;
    if (pos >= end) {
      return token = 1 /* EndOfFileToken */;
    }
    const ch = codePointUnchecked(pos);
    pos += charSize(ch);
    switch (ch) {
      case 9 /* tab */:
      case 11 /* verticalTab */:
      case 12 /* formFeed */:
      case 32 /* space */:
        while (pos < end && isWhiteSpaceSingleLine(charCodeUnchecked(pos))) {
          pos++;
        }
        return token = 5 /* WhitespaceTrivia */;
      case 64 /* at */:
        return token = 60 /* AtToken */;
      case 13 /* carriageReturn */:
        if (charCodeUnchecked(pos) === 10 /* lineFeed */) {
          pos++;
        }
      // falls through
      case 10 /* lineFeed */:
        tokenFlags |= 1 /* PrecedingLineBreak */;
        return token = 4 /* NewLineTrivia */;
      case 42 /* asterisk */:
        return token = 42 /* AsteriskToken */;
      case 123 /* openBrace */:
        return token = 19 /* OpenBraceToken */;
      case 125 /* closeBrace */:
        return token = 20 /* CloseBraceToken */;
      case 91 /* openBracket */:
        return token = 23 /* OpenBracketToken */;
      case 93 /* closeBracket */:
        return token = 24 /* CloseBracketToken */;
      case 40 /* openParen */:
        return token = 21 /* OpenParenToken */;
      case 41 /* closeParen */:
        return token = 22 /* CloseParenToken */;
      case 60 /* lessThan */:
        return token = 30 /* LessThanToken */;
      case 62 /* greaterThan */:
        return token = 32 /* GreaterThanToken */;
      case 61 /* equals */:
        return token = 64 /* EqualsToken */;
      case 44 /* comma */:
        return token = 28 /* CommaToken */;
      case 46 /* dot */:
        return token = 25 /* DotToken */;
      case 96 /* backtick */:
        return token = 62 /* BacktickToken */;
      case 35 /* hash */:
        return token = 63 /* HashToken */;
      case 92 /* backslash */:
        pos--;
        const extendedCookedChar = peekExtendedUnicodeEscape();
        if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
          tokenValue = scanExtendedUnicodeEscape(
            /*shouldEmitInvalidEscapeError*/
            true
          ) + scanIdentifierParts();
          return token = getIdentifierToken();
        }
        const cookedChar = peekUnicodeEscape();
        if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
          pos += 6;
          tokenFlags |= 1024 /* UnicodeEscape */;
          tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
          return token = getIdentifierToken();
        }
        pos++;
        return token = 0 /* Unknown */;
    }
    if (isIdentifierStart(ch, languageVersion)) {
      let char = ch;
      while (pos < end && isIdentifierPart(char = codePointUnchecked(pos), languageVersion) || char === 45 /* minus */) pos += charSize(char);
      tokenValue = text.substring(tokenStart, pos);
      if (char === 92 /* backslash */) {
        tokenValue += scanIdentifierParts();
      }
      return token = getIdentifierToken();
    } else {
      return token = 0 /* Unknown */;
    }
  }
  function speculationHelper(callback, isLookahead) {
    const savePos = pos;
    const saveStartPos = fullStartPos;
    const saveTokenPos = tokenStart;
    const saveToken = token;
    const saveTokenValue = tokenValue;
    const saveTokenFlags = tokenFlags;
    const result = callback();
    if (!result || isLookahead) {
      pos = savePos;
      fullStartPos = saveStartPos;
      tokenStart = saveTokenPos;
      token = saveToken;
      tokenValue = saveTokenValue;
      tokenFlags = saveTokenFlags;
    }
    return result;
  }
  function scanRange(start2, length3, callback) {
    const saveEnd = end;
    const savePos = pos;
    const saveStartPos = fullStartPos;
    const saveTokenPos = tokenStart;
    const saveToken = token;
    const saveTokenValue = tokenValue;
    const saveTokenFlags = tokenFlags;
    const saveErrorExpectations = commentDirectives;
    setText(text, start2, length3);
    const result = callback();
    end = saveEnd;
    pos = savePos;
    fullStartPos = saveStartPos;
    tokenStart = saveTokenPos;
    token = saveToken;
    tokenValue = saveTokenValue;
    tokenFlags = saveTokenFlags;
    commentDirectives = saveErrorExpectations;
    return result;
  }
  function lookAhead(callback) {
    return speculationHelper(
      callback,
      /*isLookahead*/
      true
    );
  }
  function tryScan(callback) {
    return speculationHelper(
      callback,
      /*isLookahead*/
      false
    );
  }
  function getText() {
    return text;
  }
  function clearCommentDirectives() {
    commentDirectives = void 0;
  }
  function setText(newText, start2, length3) {
    text = newText || "";
    end = length3 === void 0 ? text.length : start2 + length3;
    resetTokenState(start2 || 0);
  }
  function setOnError(errorCallback) {
    onError = errorCallback;
  }
  function setScriptTarget(scriptTarget) {
    languageVersion = scriptTarget;
  }
  function setLanguageVariant(variant) {
    languageVariant = variant;
  }
  function setScriptKind(kind) {
    scriptKind = kind;
  }
  function setJSDocParsingMode(kind) {
    jsDocParsingMode = kind;
  }
  function resetTokenState(position) {
    Debug.assert(position >= 0);
    pos = position;
    fullStartPos = position;
    tokenStart = position;
    token = 0 /* Unknown */;
    tokenValue = void 0;
    tokenFlags = 0 /* None */;
  }
  function setSkipJsDocLeadingAsterisks(skip) {
    skipJsDocLeadingAsterisks += skip ? 1 : -1;
  }
}
function codePointAt(s, i) {
  return s.codePointAt(i);
}
function charSize(ch) {
  if (ch >= 65536) {
    return 2;
  }
  if (ch === -1 /* EOF */) {
    return 0;
  }
  return 1;
}
function utf16EncodeAsStringFallback(codePoint) {
  Debug.assert(0 <= codePoint && codePoint <= 1114111);
  if (codePoint <= 65535) {
    return String.fromCharCode(codePoint);
  }
  const codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 55296;
  const codeUnit2 = (codePoint - 65536) % 1024 + 56320;
  return String.fromCharCode(codeUnit1, codeUnit2);
}
var utf16EncodeAsStringWorker = String.fromCodePoint ? (codePoint) => String.fromCodePoint(codePoint) : utf16EncodeAsStringFallback;
function utf16EncodeAsString(codePoint) {
  return utf16EncodeAsStringWorker(codePoint);
}
var nonBinaryUnicodeProperties = new Map(Object.entries({
  General_Category: "General_Category",
  gc: "General_Category",
  Script: "Script",
  sc: "Script",
  Script_Extensions: "Script_Extensions",
  scx: "Script_Extensions"
}));
var binaryUnicodeProperties = /* @__PURE__ */ new Set(["ASCII", "ASCII_Hex_Digit", "AHex", "Alphabetic", "Alpha", "Any", "Assigned", "Bidi_Control", "Bidi_C", "Bidi_Mirrored", "Bidi_M", "Case_Ignorable", "CI", "Cased", "Changes_When_Casefolded", "CWCF", "Changes_When_Casemapped", "CWCM", "Changes_When_Lowercased", "CWL", "Changes_When_NFKC_Casefolded", "CWKCF", "Changes_When_Titlecased", "CWT", "Changes_When_Uppercased", "CWU", "Dash", "Default_Ignorable_Code_Point", "DI", "Deprecated", "Dep", "Diacritic", "Dia", "Emoji", "Emoji_Component", "EComp", "Emoji_Modifier", "EMod", "Emoji_Modifier_Base", "EBase", "Emoji_Presentation", "EPres", "Extended_Pictographic", "ExtPict", "Extender", "Ext", "Grapheme_Base", "Gr_Base", "Grapheme_Extend", "Gr_Ext", "Hex_Digit", "Hex", "IDS_Binary_Operator", "IDSB", "IDS_Trinary_Operator", "IDST", "ID_Continue", "IDC", "ID_Start", "IDS", "Ideographic", "Ideo", "Join_Control", "Join_C", "Logical_Order_Exception", "LOE", "Lowercase", "Lower", "Math", "Noncharacter_Code_Point", "NChar", "Pattern_Syntax", "Pat_Syn", "Pattern_White_Space", "Pat_WS", "Quotation_Mark", "QMark", "Radical", "Regional_Indicator", "RI", "Sentence_Terminal", "STerm", "Soft_Dotted", "SD", "Terminal_Punctuation", "Term", "Unified_Ideograph", "UIdeo", "Uppercase", "Upper", "Variation_Selector", "VS", "White_Space", "space", "XID_Continue", "XIDC", "XID_Start", "XIDS"]);
var binaryUnicodePropertiesOfStrings = /* @__PURE__ */ new Set(["Basic_Emoji", "Emoji_Keycap_Sequence", "RGI_Emoji_Modifier_Sequence", "RGI_Emoji_Flag_Sequence", "RGI_Emoji_Tag_Sequence", "RGI_Emoji_ZWJ_Sequence", "RGI_Emoji"]);
var valuesOfNonBinaryUnicodeProperties = {
  General_Category: /* @__PURE__ */ new Set(["C", "Other", "Cc", "Control", "cntrl", "Cf", "Format", "Cn", "Unassigned", "Co", "Private_Use", "Cs", "Surrogate", "L", "Letter", "LC", "Cased_Letter", "Ll", "Lowercase_Letter", "Lm", "Modifier_Letter", "Lo", "Other_Letter", "Lt", "Titlecase_Letter", "Lu", "Uppercase_Letter", "M", "Mark", "Combining_Mark", "Mc", "Spacing_Mark", "Me", "Enclosing_Mark", "Mn", "Nonspacing_Mark", "N", "Number", "Nd", "Decimal_Number", "digit", "Nl", "Letter_Number", "No", "Other_Number", "P", "Punctuation", "punct", "Pc", "Connector_Punctuation", "Pd", "Dash_Punctuation", "Pe", "Close_Punctuation", "Pf", "Final_Punctuation", "Pi", "Initial_Punctuation", "Po", "Other_Punctuation", "Ps", "Open_Punctuation", "S", "Symbol", "Sc", "Currency_Symbol", "Sk", "Modifier_Symbol", "Sm", "Math_Symbol", "So", "Other_Symbol", "Z", "Separator", "Zl", "Line_Separator", "Zp", "Paragraph_Separator", "Zs", "Space_Separator"]),
  Script: /* @__PURE__ */ new Set(["Adlm", "Adlam", "Aghb", "Caucasian_Albanian", "Ahom", "Arab", "Arabic", "Armi", "Imperial_Aramaic", "Armn", "Armenian", "Avst", "Avestan", "Bali", "Balinese", "Bamu", "Bamum", "Bass", "Bassa_Vah", "Batk", "Batak", "Beng", "Bengali", "Bhks", "Bhaiksuki", "Bopo", "Bopomofo", "Brah", "Brahmi", "Brai", "Braille", "Bugi", "Buginese", "Buhd", "Buhid", "Cakm", "Chakma", "Cans", "Canadian_Aboriginal", "Cari", "Carian", "Cham", "Cher", "Cherokee", "Chrs", "Chorasmian", "Copt", "Coptic", "Qaac", "Cpmn", "Cypro_Minoan", "Cprt", "Cypriot", "Cyrl", "Cyrillic", "Deva", "Devanagari", "Diak", "Dives_Akuru", "Dogr", "Dogra", "Dsrt", "Deseret", "Dupl", "Duployan", "Egyp", "Egyptian_Hieroglyphs", "Elba", "Elbasan", "Elym", "Elymaic", "Ethi", "Ethiopic", "Geor", "Georgian", "Glag", "Glagolitic", "Gong", "Gunjala_Gondi", "Gonm", "Masaram_Gondi", "Goth", "Gothic", "Gran", "Grantha", "Grek", "Greek", "Gujr", "Gujarati", "Guru", "Gurmukhi", "Hang", "Hangul", "Hani", "Han", "Hano", "Hanunoo", "Hatr", "Hatran", "Hebr", "Hebrew", "Hira", "Hiragana", "Hluw", "Anatolian_Hieroglyphs", "Hmng", "Pahawh_Hmong", "Hmnp", "Nyiakeng_Puachue_Hmong", "Hrkt", "Katakana_Or_Hiragana", "Hung", "Old_Hungarian", "Ital", "Old_Italic", "Java", "Javanese", "Kali", "Kayah_Li", "Kana", "Katakana", "Kawi", "Khar", "Kharoshthi", "Khmr", "Khmer", "Khoj", "Khojki", "Kits", "Khitan_Small_Script", "Knda", "Kannada", "Kthi", "Kaithi", "Lana", "Tai_Tham", "Laoo", "Lao", "Latn", "Latin", "Lepc", "Lepcha", "Limb", "Limbu", "Lina", "Linear_A", "Linb", "Linear_B", "Lisu", "Lyci", "Lycian", "Lydi", "Lydian", "Mahj", "Mahajani", "Maka", "Makasar", "Mand", "Mandaic", "Mani", "Manichaean", "Marc", "Marchen", "Medf", "Medefaidrin", "Mend", "Mende_Kikakui", "Merc", "Meroitic_Cursive", "Mero", "Meroitic_Hieroglyphs", "Mlym", "Malayalam", "Modi", "Mong", "Mongolian", "Mroo", "Mro", "Mtei", "Meetei_Mayek", "Mult", "Multani", "Mymr", "Myanmar", "Nagm", "Nag_Mundari", "Nand", "Nandinagari", "Narb", "Old_North_Arabian", "Nbat", "Nabataean", "Newa", "Nkoo", "Nko", "Nshu", "Nushu", "Ogam", "Ogham", "Olck", "Ol_Chiki", "Orkh", "Old_Turkic", "Orya", "Oriya", "Osge", "Osage", "Osma", "Osmanya", "Ougr", "Old_Uyghur", "Palm", "Palmyrene", "Pauc", "Pau_Cin_Hau", "Perm", "Old_Permic", "Phag", "Phags_Pa", "Phli", "Inscriptional_Pahlavi", "Phlp", "Psalter_Pahlavi", "Phnx", "Phoenician", "Plrd", "Miao", "Prti", "Inscriptional_Parthian", "Rjng", "Rejang", "Rohg", "Hanifi_Rohingya", "Runr", "Runic", "Samr", "Samaritan", "Sarb", "Old_South_Arabian", "Saur", "Saurashtra", "Sgnw", "SignWriting", "Shaw", "Shavian", "Shrd", "Sharada", "Sidd", "Siddham", "Sind", "Khudawadi", "Sinh", "Sinhala", "Sogd", "Sogdian", "Sogo", "Old_Sogdian", "Sora", "Sora_Sompeng", "Soyo", "Soyombo", "Sund", "Sundanese", "Sylo", "Syloti_Nagri", "Syrc", "Syriac", "Tagb", "Tagbanwa", "Takr", "Takri", "Tale", "Tai_Le", "Talu", "New_Tai_Lue", "Taml", "Tamil", "Tang", "Tangut", "Tavt", "Tai_Viet", "Telu", "Telugu", "Tfng", "Tifinagh", "Tglg", "Tagalog", "Thaa", "Thaana", "Thai", "Tibt", "Tibetan", "Tirh", "Tirhuta", "Tnsa", "Tangsa", "Toto", "Ugar", "Ugaritic", "Vaii", "Vai", "Vith", "Vithkuqi", "Wara", "Warang_Citi", "Wcho", "Wancho", "Xpeo", "Old_Persian", "Xsux", "Cuneiform", "Yezi", "Yezidi", "Yiii", "Yi", "Zanb", "Zanabazar_Square", "Zinh", "Inherited", "Qaai", "Zyyy", "Common", "Zzzz", "Unknown"]),
  Script_Extensions: void 0
};
valuesOfNonBinaryUnicodeProperties.Script_Extensions = valuesOfNonBinaryUnicodeProperties.Script;

// src/compiler/utilitiesPublic.ts
function isExternalModuleNameRelative(moduleName) {
  return pathIsRelative(moduleName) || isRootedDiskPath(moduleName);
}
function sortAndDeduplicateDiagnostics(diagnostics) {
  return sortAndDeduplicate(diagnostics, compareDiagnostics, diagnosticsEqualityComparer);
}
var targetToLibMap = /* @__PURE__ */ new Map([
  [99 /* ESNext */, "lib.esnext.full.d.ts"],
  [11 /* ES2024 */, "lib.es2024.full.d.ts"],
  [10 /* ES2023 */, "lib.es2023.full.d.ts"],
  [9 /* ES2022 */, "lib.es2022.full.d.ts"],
  [8 /* ES2021 */, "lib.es2021.full.d.ts"],
  [7 /* ES2020 */, "lib.es2020.full.d.ts"],
  [6 /* ES2019 */, "lib.es2019.full.d.ts"],
  [5 /* ES2018 */, "lib.es2018.full.d.ts"],
  [4 /* ES2017 */, "lib.es2017.full.d.ts"],
  [3 /* ES2016 */, "lib.es2016.full.d.ts"],
  [2 /* ES2015 */, "lib.es6.d.ts"]
  // We don't use lib.es2015.full.d.ts due to breaking change.
]);
function getDefaultLibFileName(options) {
  const target = getEmitScriptTarget(options);
  switch (target) {
    case 99 /* ESNext */:
    case 11 /* ES2024 */:
    case 10 /* ES2023 */:
    case 9 /* ES2022 */:
    case 8 /* ES2021 */:
    case 7 /* ES2020 */:
    case 6 /* ES2019 */:
    case 5 /* ES2018 */:
    case 4 /* ES2017 */:
    case 3 /* ES2016 */:
    case 2 /* ES2015 */:
      return targetToLibMap.get(target);
    default:
      return "lib.d.ts";
  }
}
function textSpanEnd(span) {
  return span.start + span.length;
}
function textSpanIsEmpty(span) {
  return span.length === 0;
}
function textSpanContainsPosition(span, position) {
  return position >= span.start && position < textSpanEnd(span);
}
function textRangeContainsPositionInclusive(range, position) {
  return position >= range.pos && position <= range.end;
}
function textSpanContainsTextSpan(span, other) {
  return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
}
function textSpanContainsTextRange(span, range) {
  return range.pos >= span.start && range.end <= textSpanEnd(span);
}
function textRangeContainsTextSpan(range, span) {
  return span.start >= range.pos && textSpanEnd(span) <= range.end;
}
function textSpanOverlapsWith(span, other) {
  return textSpanOverlap(span, other) !== void 0;
}
function textSpanOverlap(span1, span2) {
  const overlap = textSpanIntersection(span1, span2);
  return overlap && overlap.length === 0 ? void 0 : overlap;
}
function textSpanIntersectsWithTextSpan(span, other) {
  return decodedTextSpanIntersectsWith(span.start, span.length, other.start, other.length);
}
function textSpanIntersectsWith(span, start, length2) {
  return decodedTextSpanIntersectsWith(span.start, span.length, start, length2);
}
function decodedTextSpanIntersectsWith(start1, length1, start2, length2) {
  const end1 = start1 + length1;
  const end2 = start2 + length2;
  return start2 <= end1 && end2 >= start1;
}
function textSpanIntersectsWithPosition(span, position) {
  return position <= textSpanEnd(span) && position >= span.start;
}
function textRangeIntersectsWithTextSpan(range, span) {
  return textSpanIntersectsWith(span, range.pos, range.end - range.pos);
}
function textSpanIntersection(span1, span2) {
  const start = Math.max(span1.start, span2.start);
  const end = Math.min(textSpanEnd(span1), textSpanEnd(span2));
  return start <= end ? createTextSpanFromBounds(start, end) : void 0;
}
function normalizeSpans(spans) {
  spans = spans.filter((span) => span.length > 0).sort((a, b) => {
    return a.start !== b.start ? a.start - b.start : a.length - b.length;
  });
  const result = [];
  let i = 0;
  while (i < spans.length) {
    let span = spans[i];
    let j = i + 1;
    while (j < spans.length && textSpanIntersectsWithTextSpan(span, spans[j])) {
      const start = Math.min(span.start, spans[j].start);
      const end = Math.max(textSpanEnd(span), textSpanEnd(spans[j]));
      span = createTextSpanFromBounds(start, end);
      j++;
    }
    i = j;
    result.push(span);
  }
  return result;
}
function createTextSpan(start, length2) {
  if (start < 0) {
    throw new Error("start < 0");
  }
  if (length2 < 0) {
    throw new Error("length < 0");
  }
  return { start, length: length2 };
}
function createTextSpanFromBounds(start, end) {
  return createTextSpan(start, end - start);
}
function textChangeRangeNewSpan(range) {
  return createTextSpan(range.span.start, range.newLength);
}
function textChangeRangeIsUnchanged(range) {
  return textSpanIsEmpty(range.span) && range.newLength === 0;
}
function createTextChangeRange(span, newLength) {
  if (newLength < 0) {
    throw new Error("newLength < 0");
  }
  return { span, newLength };
}
var unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
function collapseTextChangeRangesAcrossMultipleVersions(changes) {
  if (changes.length === 0) {
    return unchangedTextChangeRange;
  }
  if (changes.length === 1) {
    return changes[0];
  }
  const change0 = changes[0];
  let oldStartN = change0.span.start;
  let oldEndN = textSpanEnd(change0.span);
  let newEndN = oldStartN + change0.newLength;
  for (let i = 1; i < changes.length; i++) {
    const nextChange = changes[i];
    const oldStart1 = oldStartN;
    const oldEnd1 = oldEndN;
    const newEnd1 = newEndN;
    const oldStart2 = nextChange.span.start;
    const oldEnd2 = textSpanEnd(nextChange.span);
    const newEnd2 = oldStart2 + nextChange.newLength;
    oldStartN = Math.min(oldStart1, oldStart2);
    oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
    newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
  }
  return createTextChangeRange(
    createTextSpanFromBounds(oldStartN, oldEndN),
    /*newLength*/
    newEndN - oldStartN
  );
}
function getTypeParameterOwner(d) {
  if (d && d.kind === 168 /* TypeParameter */) {
    for (let current = d; current; current = current.parent) {
      if (isFunctionLike(current) || isClassLike(current) || current.kind === 264 /* InterfaceDeclaration */) {
        return current;
      }
    }
  }
}
function isParameterPropertyDeclaration(node, parent2) {
  return isParameter(node) && hasSyntacticModifier(node, 31 /* ParameterPropertyModifier */) && parent2.kind === 176 /* Constructor */;
}
function isEmptyBindingPattern(node) {
  if (isBindingPattern(node)) {
    return every(node.elements, isEmptyBindingElement);
  }
  return false;
}
function isEmptyBindingElement(node) {
  if (isOmittedExpression(node)) {
    return true;
  }
  return isEmptyBindingPattern(node.name);
}
function walkUpBindingElementsAndPatterns(binding) {
  let node = binding.parent;
  while (isBindingElement(node.parent)) {
    node = node.parent.parent;
  }
  return node.parent;
}
function getCombinedFlags(node, getFlags) {
  if (isBindingElement(node)) {
    node = walkUpBindingElementsAndPatterns(node);
  }
  let flags = getFlags(node);
  if (node.kind === 260 /* VariableDeclaration */) {
    node = node.parent;
  }
  if (node && node.kind === 261 /* VariableDeclarationList */) {
    flags |= getFlags(node);
    node = node.parent;
  }
  if (node && node.kind === 243 /* VariableStatement */) {
    flags |= getFlags(node);
  }
  return flags;
}
function getCombinedModifierFlags(node) {
  return getCombinedFlags(node, getEffectiveModifierFlags);
}
function getCombinedNodeFlagsAlwaysIncludeJSDoc(node) {
  return getCombinedFlags(node, getEffectiveModifierFlagsAlwaysIncludeJSDoc);
}
function getCombinedNodeFlags(node) {
  return getCombinedFlags(node, getNodeFlags);
}
function getNodeFlags(node) {
  return node.flags;
}
var supportedLocaleDirectories = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-br", "ru", "tr", "zh-cn", "zh-tw"];
function validateLocaleAndSetLanguage(locale, sys2, errors) {
  const lowerCaseLocale = locale.toLowerCase();
  const matchResult = /^([a-z]+)(?:[_-]([a-z]+))?$/.exec(lowerCaseLocale);
  if (!matchResult) {
    if (errors) {
      errors.push(createCompilerDiagnostic(Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp"));
    }
    return;
  }
  const language = matchResult[1];
  const territory = matchResult[2];
  if (contains(supportedLocaleDirectories, lowerCaseLocale) && !trySetLanguageAndTerritory(language, territory, errors)) {
    trySetLanguageAndTerritory(
      language,
      /*territory*/
      void 0,
      errors
    );
  }
  setUILocale(locale);
  function trySetLanguageAndTerritory(language2, territory2, errors2) {
    const compilerFilePath = normalizePath(sys2.getExecutingFilePath());
    const containingDirectoryPath = getDirectoryPath(compilerFilePath);
    let filePath = combinePaths(containingDirectoryPath, language2);
    if (territory2) {
      filePath = filePath + "-" + territory2;
    }
    filePath = sys2.resolvePath(combinePaths(filePath, "diagnosticMessages.generated.json"));
    if (!sys2.fileExists(filePath)) {
      return false;
    }
    let fileContents = "";
    try {
      fileContents = sys2.readFile(filePath);
    } catch {
      if (errors2) {
        errors2.push(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, filePath));
      }
      return false;
    }
    try {
      setLocalizedDiagnosticMessages(JSON.parse(fileContents));
    } catch {
      if (errors2) {
        errors2.push(createCompilerDiagnostic(Diagnostics.Corrupted_locale_file_0, filePath));
      }
      return false;
    }
    return true;
  }
}
function getOriginalNode(node, nodeTest) {
  if (node) {
    while (node.original !== void 0) {
      node = node.original;
    }
  }
  if (!node || !nodeTest) {
    return node;
  }
  return nodeTest(node) ? node : void 0;
}
function findAncestor(node, callback) {
  while (node) {
    const result = callback(node);
    if (result === "quit") {
      return void 0;
    } else if (result) {
      return node;
    }
    node = node.parent;
  }
  return void 0;
}
function isParseTreeNode(node) {
  return (node.flags & 16 /* Synthesized */) === 0;
}
function getParseTreeNode(node, nodeTest) {
  if (node === void 0 || isParseTreeNode(node)) {
    return node;
  }
  node = node.original;
  while (node) {
    if (isParseTreeNode(node)) {
      return !nodeTest || nodeTest(node) ? node : void 0;
    }
    node = node.original;
  }
}
function escapeLeadingUnderscores(identifier) {
  return identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier;
}
function unescapeLeadingUnderscores(identifier) {
  const id = identifier;
  return id.length >= 3 && id.charCodeAt(0) === 95 /* _ */ && id.charCodeAt(1) === 95 /* _ */ && id.charCodeAt(2) === 95 /* _ */ ? id.substr(1) : id;
}
function idText(identifierOrPrivateName) {
  return unescapeLeadingUnderscores(identifierOrPrivateName.escapedText);
}
function identifierToKeywordKind(node) {
  const token = stringToToken(node.escapedText);
  return token ? tryCast(token, isKeyword) : void 0;
}
function symbolName(symbol) {
  if (symbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) {
    return idText(symbol.valueDeclaration.name);
  }
  return unescapeLeadingUnderscores(symbol.escapedName);
}
function nameForNamelessJSDocTypedef(declaration) {
  const hostNode = declaration.parent.parent;
  if (!hostNode) {
    return void 0;
  }
  if (isDeclaration(hostNode)) {
    return getDeclarationIdentifier(hostNode);
  }
  switch (hostNode.kind) {
    case 243 /* VariableStatement */:
      if (hostNode.declarationList && hostNode.declarationList.declarations[0]) {
        return getDeclarationIdentifier(hostNode.declarationList.declarations[0]);
      }
      break;
    case 244 /* ExpressionStatement */:
      let expr = hostNode.expression;
      if (expr.kind === 226 /* BinaryExpression */ && expr.operatorToken.kind === 64 /* EqualsToken */) {
        expr = expr.left;
      }
      switch (expr.kind) {
        case 211 /* PropertyAccessExpression */:
          return expr.name;
        case 212 /* ElementAccessExpression */:
          const arg = expr.argumentExpression;
          if (isIdentifier(arg)) {
            return arg;
          }
      }
      break;
    case 217 /* ParenthesizedExpression */: {
      return getDeclarationIdentifier(hostNode.expression);
    }
    case 256 /* LabeledStatement */: {
      if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) {
        return getDeclarationIdentifier(hostNode.statement);
      }
      break;
    }
  }
}
function getDeclarationIdentifier(node) {
  const name = getNameOfDeclaration(node);
  return name && isIdentifier(name) ? name : void 0;
}
function nodeHasName(statement, name) {
  if (isNamedDeclaration(statement) && isIdentifier(statement.name) && idText(statement.name) === idText(name)) {
    return true;
  }
  if (isVariableStatement(statement) && some(statement.declarationList.declarations, (d) => nodeHasName(d, name))) {
    return true;
  }
  return false;
}
function getNameOfJSDocTypedef(declaration) {
  return declaration.name || nameForNamelessJSDocTypedef(declaration);
}
function isNamedDeclaration(node) {
  return !!node.name;
}
function getNonAssignedNameOfDeclaration(declaration) {
  switch (declaration.kind) {
    case 80 /* Identifier */:
      return declaration;
    case 348 /* JSDocPropertyTag */:
    case 341 /* JSDocParameterTag */: {
      const { name } = declaration;
      if (name.kind === 166 /* QualifiedName */) {
        return name.right;
      }
      break;
    }
    case 213 /* CallExpression */:
    case 226 /* BinaryExpression */: {
      const expr2 = declaration;
      switch (getAssignmentDeclarationKind(expr2)) {
        case 1 /* ExportsProperty */:
        case 4 /* ThisProperty */:
        case 5 /* Property */:
        case 3 /* PrototypeProperty */:
          return getElementOrPropertyAccessArgumentExpressionOrName(expr2.left);
        case 7 /* ObjectDefinePropertyValue */:
        case 8 /* ObjectDefinePropertyExports */:
        case 9 /* ObjectDefinePrototypeProperty */:
          return expr2.arguments[1];
        default:
          return void 0;
      }
    }
    case 346 /* JSDocTypedefTag */:
      return getNameOfJSDocTypedef(declaration);
    case 340 /* JSDocEnumTag */:
      return nameForNamelessJSDocTypedef(declaration);
    case 277 /* ExportAssignment */: {
      const { expression } = declaration;
      return isIdentifier(expression) ? expression : void 0;
    }
    case 212 /* ElementAccessExpression */:
      const expr = declaration;
      if (isBindableStaticElementAccessExpression(expr)) {
        return expr.argumentExpression;
      }
  }
  return declaration.name;
}
function getNameOfDeclaration(declaration) {
  if (declaration === void 0) return void 0;
  return getNonAssignedNameOfDeclaration(declaration) || (isFunctionExpression(declaration) || isArrowFunction(declaration) || isClassExpression(declaration) ? getAssignedName(declaration) : void 0);
}
function getAssignedName(node) {
  if (!node.parent) {
    return void 0;
  } else if (isPropertyAssignment(node.parent) || isBindingElement(node.parent)) {
    return node.parent.name;
  } else if (isBinaryExpression(node.parent) && node === node.parent.right) {
    if (isIdentifier(node.parent.left)) {
      return node.parent.left;
    } else if (isAccessExpression(node.parent.left)) {
      return getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left);
    }
  } else if (isVariableDeclaration(node.parent) && isIdentifier(node.parent.name)) {
    return node.parent.name;
  }
}
function getDecorators(node) {
  if (hasDecorators(node)) {
    return filter(node.modifiers, isDecorator);
  }
}
function getModifiers(node) {
  if (hasSyntacticModifier(node, 98303 /* Modifier */)) {
    return filter(node.modifiers, isModifier);
  }
}
function getJSDocParameterTagsWorker(param, noCache) {
  if (param.name) {
    if (isIdentifier(param.name)) {
      const name = param.name.escapedText;
      return getJSDocTagsWorker(param.parent, noCache).filter((tag) => isJSDocParameterTag(tag) && isIdentifier(tag.name) && tag.name.escapedText === name);
    } else {
      const i = param.parent.parameters.indexOf(param);
      Debug.assert(i > -1, "Parameters should always be in their parents' parameter list");
      const paramTags = getJSDocTagsWorker(param.parent, noCache).filter(isJSDocParameterTag);
      if (i < paramTags.length) {
        return [paramTags[i]];
      }
    }
  }
  return emptyArray;
}
function getJSDocParameterTags(param) {
  return getJSDocParameterTagsWorker(
    param,
    /*noCache*/
    false
  );
}
function getJSDocParameterTagsNoCache(param) {
  return getJSDocParameterTagsWorker(
    param,
    /*noCache*/
    true
  );
}
function getJSDocTypeParameterTagsWorker(param, noCache) {
  const name = param.name.escapedText;
  return getJSDocTagsWorker(param.parent, noCache).filter((tag) => isJSDocTemplateTag(tag) && tag.typeParameters.some((tp) => tp.name.escapedText === name));
}
function getJSDocTypeParameterTags(param) {
  return getJSDocTypeParameterTagsWorker(
    param,
    /*noCache*/
    false
  );
}
function getJSDocTypeParameterTagsNoCache(param) {
  return getJSDocTypeParameterTagsWorker(
    param,
    /*noCache*/
    true
  );
}
function hasJSDocParameterTags(node) {
  return !!getFirstJSDocTag(node, isJSDocParameterTag);
}
function getJSDocAugmentsTag(node) {
  return getFirstJSDocTag(node, isJSDocAugmentsTag);
}
function getJSDocImplementsTags(node) {
  return getAllJSDocTags(node, isJSDocImplementsTag);
}
function getJSDocClassTag(node) {
  return getFirstJSDocTag(node, isJSDocClassTag);
}
function getJSDocPublicTag(node) {
  return getFirstJSDocTag(node, isJSDocPublicTag);
}
function getJSDocPublicTagNoCache(node) {
  return getFirstJSDocTag(
    node,
    isJSDocPublicTag,
    /*noCache*/
    true
  );
}
function getJSDocPrivateTag(node) {
  return getFirstJSDocTag(node, isJSDocPrivateTag);
}
function getJSDocPrivateTagNoCache(node) {
  return getFirstJSDocTag(
    node,
    isJSDocPrivateTag,
    /*noCache*/
    true
  );
}
function getJSDocProtectedTag(node) {
  return getFirstJSDocTag(node, isJSDocProtectedTag);
}
function getJSDocProtectedTagNoCache(node) {
  return getFirstJSDocTag(
    node,
    isJSDocProtectedTag,
    /*noCache*/
    true
  );
}
function getJSDocReadonlyTag(node) {
  return getFirstJSDocTag(node, isJSDocReadonlyTag);
}
function getJSDocReadonlyTagNoCache(node) {
  return getFirstJSDocTag(
    node,
    isJSDocReadonlyTag,
    /*noCache*/
    true
  );
}
function getJSDocOverrideTagNoCache(node) {
  return getFirstJSDocTag(
    node,
    isJSDocOverrideTag,
    /*noCache*/
    true
  );
}
function getJSDocDeprecatedTag(node) {
  return getFirstJSDocTag(node, isJSDocDeprecatedTag);
}
function getJSDocDeprecatedTagNoCache(node) {
  return getFirstJSDocTag(
    node,
    isJSDocDeprecatedTag,
    /*noCache*/
    true
  );
}
function getJSDocEnumTag(node) {
  return getFirstJSDocTag(node, isJSDocEnumTag);
}
function getJSDocThisTag(node) {
  return getFirstJSDocTag(node, isJSDocThisTag);
}
function getJSDocReturnTag(node) {
  return getFirstJSDocTag(node, isJSDocReturnTag);
}
function getJSDocTemplateTag(node) {
  return getFirstJSDocTag(node, isJSDocTemplateTag);
}
function getJSDocSatisfiesTag(node) {
  return getFirstJSDocTag(node, isJSDocSatisfiesTag);
}
function getJSDocTypeTag(node) {
  const tag = getFirstJSDocTag(node, isJSDocTypeTag);
  if (tag && tag.typeExpression && tag.typeExpression.type) {
    return tag;
  }
  return void 0;
}
function getJSDocType(node) {
  let tag = getFirstJSDocTag(node, isJSDocTypeTag);
  if (!tag && isParameter(node)) {
    tag = find(getJSDocParameterTags(node), (tag2) => !!tag2.typeExpression);
  }
  return tag && tag.typeExpression && tag.typeExpression.type;
}
function getJSDocReturnType(node) {
  const returnTag = getJSDocReturnTag(node);
  if (returnTag && returnTag.typeExpression) {
    return returnTag.typeExpression.type;
  }
  const typeTag = getJSDocTypeTag(node);
  if (typeTag && typeTag.typeExpression) {
    const type = typeTag.typeExpression.type;
    if (isTypeLiteralNode(type)) {
      const sig = find(type.members, isCallSignatureDeclaration);
      return sig && sig.type;
    }
    if (isFunctionTypeNode(type) || isJSDocFunctionType(type)) {
      return type.type;
    }
  }
}
function getJSDocTagsWorker(node, noCache) {
  var _a;
  if (!canHaveJSDoc(node)) return emptyArray;
  let tags = (_a = node.jsDoc) == null ? void 0 : _a.jsDocCache;
  if (tags === void 0 || noCache) {
    const comments = getJSDocCommentsAndTags(node, noCache);
    Debug.assert(comments.length < 2 || comments[0] !== comments[1]);
    tags = flatMap(comments, (j) => isJSDoc(j) ? j.tags : j);
    if (!noCache) {
      node.jsDoc ?? (node.jsDoc = []);
      node.jsDoc.jsDocCache = tags;
    }
  }
  return tags;
}
function getJSDocTags(node) {
  return getJSDocTagsWorker(
    node,
    /*noCache*/
    false
  );
}
function getFirstJSDocTag(node, predicate, noCache) {
  return find(getJSDocTagsWorker(node, noCache), predicate);
}
function getAllJSDocTags(node, predicate) {
  return getJSDocTags(node).filter(predicate);
}
function getAllJSDocTagsOfKind(node, kind) {
  return getJSDocTags(node).filter((doc) => doc.kind === kind);
}
function getTextOfJSDocComment(comment) {
  return typeof comment === "string" ? comment : comment == null ? void 0 : comment.map((c) => c.kind === 321 /* JSDocText */ ? c.text : formatJSDocLink(c)).join("");
}
function formatJSDocLink(link) {
  const kind = link.kind === 324 /* JSDocLink */ ? "link" : link.kind === 325 /* JSDocLinkCode */ ? "linkcode" : "linkplain";
  const name = link.name ? entityNameToString(link.name) : "";
  const space = link.name && (link.text === "" || link.text.startsWith("://")) ? "" : " ";
  return `{@${kind} ${name}${space}${link.text}}`;
}
function getEffectiveTypeParameterDeclarations(node) {
  if (isJSDocSignature(node)) {
    if (isJSDocOverloadTag(node.parent)) {
      const jsDoc = getJSDocRoot(node.parent);
      if (jsDoc && length(jsDoc.tags)) {
        return flatMap(jsDoc.tags, (tag) => isJSDocTemplateTag(tag) ? tag.typeParameters : void 0);
      }
    }
    return emptyArray;
  }
  if (isJSDocTypeAlias(node)) {
    Debug.assert(node.parent.kind === 320 /* JSDoc */);
    return flatMap(node.parent.tags, (tag) => isJSDocTemplateTag(tag) ? tag.typeParameters : void 0);
  }
  if (node.typeParameters) {
    return node.typeParameters;
  }
  if (canHaveIllegalTypeParameters(node) && node.typeParameters) {
    return node.typeParameters;
  }
  if (isInJSFile(node)) {
    const decls = getJSDocTypeParameterDeclarations(node);
    if (decls.length) {
      return decls;
    }
    const typeTag = getJSDocType(node);
    if (typeTag && isFunctionTypeNode(typeTag) && typeTag.typeParameters) {
      return typeTag.typeParameters;
    }
  }
  return emptyArray;
}
function getEffectiveConstraintOfTypeParameter(node) {
  return node.constraint ? node.constraint : isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : void 0;
}
function isMemberName(node) {
  return node.kind === 80 /* Identifier */ || node.kind === 81 /* PrivateIdentifier */;
}
function isGetOrSetAccessorDeclaration(node) {
  return node.kind === 178 /* SetAccessor */ || node.kind === 177 /* GetAccessor */;
}
function isPropertyAccessChain(node) {
  return isPropertyAccessExpression(node) && !!(node.flags & 64 /* OptionalChain */);
}
function isElementAccessChain(node) {
  return isElementAccessExpression(node) && !!(node.flags & 64 /* OptionalChain */);
}
function isCallChain(node) {
  return isCallExpression(node) && !!(node.flags & 64 /* OptionalChain */);
}
function isOptionalChain(node) {
  const kind = node.kind;
  return !!(node.flags & 64 /* OptionalChain */) && (kind === 211 /* PropertyAccessExpression */ || kind === 212 /* ElementAccessExpression */ || kind === 213 /* CallExpression */ || kind === 235 /* NonNullExpression */);
}
function isOptionalChainRoot(node) {
  return isOptionalChain(node) && !isNonNullExpression(node) && !!node.questionDotToken;
}
function isExpressionOfOptionalChainRoot(node) {
  return isOptionalChainRoot(node.parent) && node.parent.expression === node;
}
function isOutermostOptionalChain(node) {
  return !isOptionalChain(node.parent) || isOptionalChainRoot(node.parent) || node !== node.parent.expression;
}
function isNullishCoalesce(node) {
  return node.kind === 226 /* BinaryExpression */ && node.operatorToken.kind === 61 /* QuestionQuestionToken */;
}
function isConstTypeReference(node) {
  return isTypeReferenceNode(node) && isIdentifier(node.typeName) && node.typeName.escapedText === "const" && !node.typeArguments;
}
function skipPartiallyEmittedExpressions(node) {
  return skipOuterExpressions(node, 8 /* PartiallyEmittedExpressions */);
}
function isNonNullChain(node) {
  return isNonNullExpression(node) && !!(node.flags & 64 /* OptionalChain */);
}
function isBreakOrContinueStatement(node) {
  return node.kind === 252 /* BreakStatement */ || node.kind === 251 /* ContinueStatement */;
}
function isNamedExportBindings(node) {
  return node.kind === 280 /* NamespaceExport */ || node.kind === 279 /* NamedExports */;
}
function isJSDocPropertyLikeTag(node) {
  return node.kind === 348 /* JSDocPropertyTag */ || node.kind === 341 /* JSDocParameterTag */;
}
function isNodeKind(kind) {
  return kind >= 166 /* FirstNode */;
}
function isTokenKind(kind) {
  return kind >= 0 /* FirstToken */ && kind <= 165 /* LastToken */;
}
function isToken(n) {
  return isTokenKind(n.kind);
}
function isNodeArray(array) {
  return hasProperty(array, "pos") && hasProperty(array, "end");
}
function isLiteralKind(kind) {
  return 9 /* FirstLiteralToken */ <= kind && kind <= 15 /* LastLiteralToken */;
}
function isLiteralExpression(node) {
  return isLiteralKind(node.kind);
}
function isLiteralExpressionOfObject(node) {
  switch (node.kind) {
    case 210 /* ObjectLiteralExpression */:
    case 209 /* ArrayLiteralExpression */:
    case 14 /* RegularExpressionLiteral */:
    case 218 /* FunctionExpression */:
    case 231 /* ClassExpression */:
      return true;
  }
  return false;
}
function isTemplateLiteralKind(kind) {
  return 15 /* FirstTemplateToken */ <= kind && kind <= 18 /* LastTemplateToken */;
}
function isTemplateLiteralToken(node) {
  return isTemplateLiteralKind(node.kind);
}
function isTemplateMiddleOrTemplateTail(node) {
  const kind = node.kind;
  return kind === 17 /* TemplateMiddle */ || kind === 18 /* TemplateTail */;
}
function isImportOrExportSpecifier(node) {
  return isImportSpecifier(node) || isExportSpecifier(node);
}
function isTypeOnlyImportDeclaration(node) {
  switch (node.kind) {
    case 276 /* ImportSpecifier */:
      return node.isTypeOnly || node.parent.parent.isTypeOnly;
    case 274 /* NamespaceImport */:
      return node.parent.isTypeOnly;
    case 273 /* ImportClause */:
    case 271 /* ImportEqualsDeclaration */:
      return node.isTypeOnly;
  }
  return false;
}
function isTypeOnlyExportDeclaration(node) {
  switch (node.kind) {
    case 281 /* ExportSpecifier */:
      return node.isTypeOnly || node.parent.parent.isTypeOnly;
    case 278 /* ExportDeclaration */:
      return node.isTypeOnly && !!node.moduleSpecifier && !node.exportClause;
    case 280 /* NamespaceExport */:
      return node.parent.isTypeOnly;
  }
  return false;
}
function isTypeOnlyImportOrExportDeclaration(node) {
  return isTypeOnlyImportDeclaration(node) || isTypeOnlyExportDeclaration(node);
}
function isPartOfTypeOnlyImportOrExportDeclaration(node) {
  return findAncestor(node, isTypeOnlyImportOrExportDeclaration) !== void 0;
}
function isStringTextContainingNode(node) {
  return node.kind === 11 /* StringLiteral */ || isTemplateLiteralKind(node.kind);
}
function isImportAttributeName(node) {
  return isStringLiteral(node) || isIdentifier(node);
}
function isGeneratedIdentifier(node) {
  var _a;
  return isIdentifier(node) && ((_a = node.emitNode) == null ? void 0 : _a.autoGenerate) !== void 0;
}
function isGeneratedPrivateIdentifier(node) {
  var _a;
  return isPrivateIdentifier(node) && ((_a = node.emitNode) == null ? void 0 : _a.autoGenerate) !== void 0;
}
function isFileLevelReservedGeneratedIdentifier(node) {
  const flags = node.emitNode.autoGenerate.flags;
  return !!(flags & 32 /* FileLevel */) && !!(flags & 16 /* Optimistic */) && !!(flags & 8 /* ReservedInNestedScopes */);
}
function isPrivateIdentifierClassElementDeclaration(node) {
  return (isPropertyDeclaration(node) || isMethodOrAccessor(node)) && isPrivateIdentifier(node.name);
}
function isPrivateIdentifierPropertyAccessExpression(node) {
  return isPropertyAccessExpression(node) && isPrivateIdentifier(node.name);
}
function isModifierKind(token) {
  switch (token) {
    case 128 /* AbstractKeyword */:
    case 129 /* AccessorKeyword */:
    case 134 /* AsyncKeyword */:
    case 87 /* ConstKeyword */:
    case 138 /* DeclareKeyword */:
    case 90 /* DefaultKeyword */:
    case 95 /* ExportKeyword */:
    case 103 /* InKeyword */:
    case 125 /* PublicKeyword */:
    case 123 /* PrivateKeyword */:
    case 124 /* ProtectedKeyword */:
    case 148 /* ReadonlyKeyword */:
    case 126 /* StaticKeyword */:
    case 147 /* OutKeyword */:
    case 164 /* OverrideKeyword */:
      return true;
  }
  return false;
}
function isParameterPropertyModifier(kind) {
  return !!(modifierToFlag(kind) & 31 /* ParameterPropertyModifier */);
}
function isClassMemberModifier(idToken) {
  return isParameterPropertyModifier(idToken) || idToken === 126 /* StaticKeyword */ || idToken === 164 /* OverrideKeyword */ || idToken === 129 /* AccessorKeyword */;
}
function isModifier(node) {
  return isModifierKind(node.kind);
}
function isEntityName(node) {
  const kind = node.kind;
  return kind === 166 /* QualifiedName */ || kind === 80 /* Identifier */;
}
function isPropertyName(node) {
  const kind = node.kind;
  return kind === 80 /* Identifier */ || kind === 81 /* PrivateIdentifier */ || kind === 11 /* StringLiteral */ || kind === 9 /* NumericLiteral */ || kind === 167 /* ComputedPropertyName */;
}
function isBindingName(node) {
  const kind = node.kind;
  return kind === 80 /* Identifier */ || kind === 206 /* ObjectBindingPattern */ || kind === 207 /* ArrayBindingPattern */;
}
function isFunctionLike(node) {
  return !!node && isFunctionLikeKind(node.kind);
}
function isFunctionLikeOrClassStaticBlockDeclaration(node) {
  return !!node && (isFunctionLikeKind(node.kind) || isClassStaticBlockDeclaration(node));
}
function isFunctionLikeDeclaration(node) {
  return node && isFunctionLikeDeclarationKind(node.kind);
}
function isBooleanLiteral(node) {
  return node.kind === 112 /* TrueKeyword */ || node.kind === 97 /* FalseKeyword */;
}
function isFunctionLikeDeclarationKind(kind) {
  switch (kind) {
    case 262 /* FunctionDeclaration */:
    case 174 /* MethodDeclaration */:
    case 176 /* Constructor */:
    case 177 /* GetAccessor */:
    case 178 /* SetAccessor */:
    case 218 /* FunctionExpression */:
    case 219 /* ArrowFunction */:
      return true;
    default:
      return false;
  }
}
function isFunctionLikeKind(kind) {
  switch (kind) {
    case 173 /* MethodSignature */:
    case 179 /* CallSignature */:
    case 323 /* JSDocSignature */:
    case 180 /* ConstructSignature */:
    case 181 /* IndexSignature */:
    case 184 /* FunctionType */:
    case 317 /* JSDocFunctionType */:
    case 185 /* ConstructorType */:
      return true;
    default:
      return isFunctionLikeDeclarationKind(kind);
  }
}
function isFunctionOrModuleBlock(node) {
  return isSourceFile(node) || isModuleBlock(node) || isBlock(node) && isFunctionLike(node.parent);
}
function isClassElement(node) {
  const kind = node.kind;
  return kind === 176 /* Constructor */ || kind === 172 /* PropertyDeclaration */ || kind === 174 /* MethodDeclaration */ || kind === 177 /* GetAccessor */ || kind === 178 /* SetAccessor */ || kind === 181 /* IndexSignature */ || kind === 175 /* ClassStaticBlockDeclaration */ || kind === 240 /* SemicolonClassElement */;
}
function isClassLike(node) {
  return node && (node.kind === 263 /* ClassDeclaration */ || node.kind === 231 /* ClassExpression */);
}
function isAccessor(node) {
  return node && (node.kind === 177 /* GetAccessor */ || node.kind === 178 /* SetAccessor */);
}
function isAutoAccessorPropertyDeclaration(node) {
  return isPropertyDeclaration(node) && hasAccessorModifier(node);
}
function isClassInstanceProperty(node) {
  if (isInJSFile(node) && isExpandoPropertyDeclaration(node)) {
    return (!isBindableStaticAccessExpression(node) || !isPrototypeAccess(node.expression)) && !isBindableStaticNameExpression(
      node,
      /*excludeThisKeyword*/
      true
    );
  }
  return node.parent && isClassLike(node.parent) && isPropertyDeclaration(node) && !hasAccessorModifier(node);
}
function isMethodOrAccessor(node) {
  switch (node.kind) {
    case 174 /* MethodDeclaration */:
    case 177 /* GetAccessor */:
    case 178 /* SetAccessor */:
      return true;
    default:
      return false;
  }
}
function isModifierLike(node) {
  return isModifier(node) || isDecorator(node);
}
function isTypeElement(node) {
  const kind = node.kind;
  return kind === 180 /* ConstructSignature */ || kind === 179 /* CallSignature */ || kind === 171 /* PropertySignature */ || kind === 173 /* MethodSignature */ || kind === 181 /* IndexSignature */ || kind === 177 /* GetAccessor */ || kind === 178 /* SetAccessor */ || kind === 354 /* NotEmittedTypeElement */;
}
function isClassOrTypeElement(node) {
  return isTypeElement(node) || isClassElement(node);
}
function isObjectLiteralElementLike(node) {
  const kind = node.kind;
  return kind === 303 /* PropertyAssignment */ || kind === 304 /* ShorthandPropertyAssignment */ || kind === 305 /* SpreadAssignment */ || kind === 174 /* MethodDeclaration */ || kind === 177 /* GetAccessor */ || kind === 178 /* SetAccessor */;
}
function isTypeNode(node) {
  return isTypeNodeKind(node.kind);
}
function isFunctionOrConstructorTypeNode(node) {
  switch (node.kind) {
    case 184 /* FunctionType */:
    case 185 /* ConstructorType */:
      return true;
  }
  return false;
}
function isBindingPattern(node) {
  if (node) {
    const kind = node.kind;
    return kind === 207 /* ArrayBindingPattern */ || kind === 206 /* ObjectBindingPattern */;
  }
  return false;
}
function isAssignmentPattern(node) {
  const kind = node.kind;
  return kind === 209 /* ArrayLiteralExpression */ || kind === 210 /* ObjectLiteralExpression */;
}
function isArrayBindingElement(node) {
  const kind = node.kind;
  return kind === 208 /* BindingElement */ || kind === 232 /* OmittedExpression */;
}
function isDeclarationBindingElement(bindingElement) {
  switch (bindingElement.kind) {
    case 260 /* VariableDeclaration */:
    case 169 /* Parameter */:
    case 208 /* BindingElement */:
      return true;
  }
  return false;
}
function isBindingOrAssignmentElement(node) {
  return isVariableDeclaration(node) || isParameter(node) || isObjectBindingOrAssignmentElement(node) || isArrayBindingOrAssignmentElement(node);
}
function isBindingOrAssignmentPattern(node) {
  return isObjectBindingOrAssignmentPattern(node) || isArrayBindingOrAssignmentPattern(node);
}
function isObjectBindingOrAssignmentPattern(node) {
  switch (node.kind) {
    case 206 /* ObjectBindingPattern */:
    case 210 /* ObjectLiteralExpression */:
      return true;
  }
  return false;
}
function isObjectBindingOrAssignmentElement(node) {
  switch (node.kind) {
    case 208 /* BindingElement */:
    case 303 /* PropertyAssignment */:
    // AssignmentProperty
    case 304 /* ShorthandPropertyAssignment */:
    // AssignmentProperty
    case 305 /* SpreadAssignment */:
      return true;
  }
  return false;
}
function isArrayBindingOrAssignmentPattern(node) {
  switch (node.kind) {
    case 207 /* ArrayBindingPattern */:
    case 209 /* ArrayLiteralExpression */:
      return true;
  }
  return false;
}
function isArrayBindingOrAssignmentElement(node) {
  switch (node.kind) {
    case 208 /* BindingElement */:
    case 232 /* OmittedExpression */:
    // Elision
    case 230 /* SpreadElement */:
    // AssignmentRestElement
    case 209 /* ArrayLiteralExpression */:
    // ArrayAssignmentPattern
    case 210 /* ObjectLiteralExpression */:
    // ObjectAssignmentPattern
    case 80 /* Identifier */:
    // DestructuringAssignmentTarget
    case 211 /* PropertyAccessExpression */:
    // DestructuringAssignmentTarget
    case 212 /* ElementAccessExpression */:
      return true;
  }
  return isAssignmentExpression(
    node,
    /*excludeCompoundAssignment*/
    true
  );
}
function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) {
  const kind = node.kind;
  return kind === 211 /* PropertyAccessExpression */ || kind === 166 /* QualifiedName */ || kind === 205 /* ImportType */;
}
function isPropertyAccessOrQualifiedName(node) {
  const kind = node.kind;
  return kind === 211 /* PropertyAccessExpression */ || kind === 166 /* QualifiedName */;
}
function isCallLikeOrFunctionLikeExpression(node) {
  return isCallLikeExpression(node) || isFunctionExpressionOrArrowFunction(node);
}
function isCallLikeExpression(node) {
  switch (node.kind) {
    case 213 /* CallExpression */:
    case 214 /* NewExpression */:
    case 215 /* TaggedTemplateExpression */:
    case 170 /* Decorator */:
    case 286 /* JsxOpeningElement */:
    case 285 /* JsxSelfClosingElement */:
    case 289 /* JsxOpeningFragment */:
      return true;
    case 226 /* BinaryExpression */:
      return node.operatorToken.kind === 104 /* InstanceOfKeyword */;
    default:
      return false;
  }
}
function isCallOrNewExpression(node) {
  return node.kind === 213 /* CallExpression */ || node.kind === 214 /* NewExpression */;
}
function isTemplateLiteral(node) {
  const kind = node.kind;
  return kind === 228 /* TemplateExpression */ || kind === 15 /* NoSubstitutionTemplateLiteral */;
}
function isLeftHandSideExpression(node) {
  return isLeftHandSideExpressionKind(skipPartiallyEmittedExpressions(node).kind);
}
function isLeftHandSideExpressionKind(kind) {
  switch (kind) {
    case 211 /* PropertyAccessExpression */:
    case 212 /* ElementAccessExpression */:
    case 214 /* NewExpression */:
    case 213 /* CallExpression */:
    case 284 /* JsxElement */:
    case 285 /* JsxSelfClosingElement */:
    case 288 /* JsxFragment */:
    case 215 /* TaggedTemplateExpression */:
    case 209 /* ArrayLiteralExpression */:
    case 217 /* ParenthesizedExpression */:
    case 210 /* ObjectLiteralExpression */:
    case 231 /* ClassExpression */:
    case 218 /* FunctionExpression */:
    case 80 /* Identifier */:
    case 81 /* PrivateIdentifier */:
    // technically this is only an Expression if it's in a `#field in expr` BinaryExpression
    case 14 /* RegularExpressionLiteral */:
    case 9 /* NumericLiteral */:
    case 10 /* BigIntLiteral */:
    case 11 /* StringLiteral */:
    case 15 /* NoSubstitutionTemplateLiteral */:
    case 228 /* TemplateExpression */:
    case 97 /* FalseKeyword */:
    case 106 /* NullKeyword */:
    case 110 /* ThisKeyword */:
    case 112 /* TrueKeyword */:
    case 108 /* SuperKeyword */:
    case 235 /* NonNullExpression */:
    case 233 /* ExpressionWithTypeArguments */:
    case 236 /* MetaProperty */:
    case 102 /* ImportKeyword */:
    // technically this is only an Expression if it's in a CallExpression
    case 282 /* MissingDeclaration */:
      return true;
    default:
      return false;
  }
}
function isUnaryExpression(node) {
  return isUnaryExpressionKind(skipPartiallyEmittedExpressions(node).kind);
}
function isUnaryExpressionKind(kind) {
  switch (kind) {
    case 224 /* PrefixUnaryExpression */:
    case 225 /* PostfixUnaryExpression */:
    case 220 /* DeleteExpression */:
    case 221 /* TypeOfExpression */:
    case 222 /* VoidExpression */:
    case 223 /* AwaitExpression */:
    case 216 /* TypeAssertionExpression */:
      return true;
    default:
      return isLeftHandSideExpressionKind(kind);
  }
}
function isUnaryExpressionWithWrite(expr) {
  switch (expr.kind) {
    case 225 /* PostfixUnaryExpression */:
      return true;
    case 224 /* PrefixUnaryExpression */:
      return expr.operator === 46 /* PlusPlusToken */ || expr.operator === 47 /* MinusMinusToken */;
    default:
      return false;
  }
}
function isLiteralTypeLiteral(node) {
  switch (node.kind) {
    case 106 /* NullKeyword */:
    case 112 /* TrueKeyword */:
    case 97 /* FalseKeyword */:
    case 224 /* PrefixUnaryExpression */:
      return true;
    default:
      return isLiteralExpression(node);
  }
}
function isExpression(node) {
  return isExpressionKind(skipPartiallyEmittedExpressions(node).kind);
}
function isExpressionKind(kind) {
  switch (kind) {
    case 227 /* ConditionalExpression */:
    case 229 /* YieldExpression */:
    case 219 /* ArrowFunction */:
    case 226 /* BinaryExpression */:
    case 230 /* SpreadElement */:
    case 234 /* AsExpression */:
    case 232 /* OmittedExpression */:
    case 356 /* CommaListExpression */:
    case 355 /* PartiallyEmittedExpression */:
    case 238 /* SatisfiesExpression */:
      return true;
    default:
      return isUnaryExpressionKind(kind);
  }
}
function isAssertionExpression(node) {
  const kind = node.kind;
  return kind === 216 /* TypeAssertionExpression */ || kind === 234 /* AsExpression */;
}
function isIterationStatement(node, lookInLabeledStatements) {
  switch (node.kind) {
    case 248 /* ForStatement */:
    case 249 /* ForInStatement */:
    case 250 /* ForOfStatement */:
    case 246 /* DoStatement */:
    case 247 /* WhileStatement */:
      return true;
    case 256 /* LabeledStatement */:
      return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements);
  }
  return false;
}
function isScopeMarker(node) {
  return isExportAssignment(node) || isExportDeclaration(node);
}
function hasScopeMarker(statements) {
  return some(statements, isScopeMarker);
}
function needsScopeMarker(result) {
  return !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasSyntacticModifier(result, 32 /* Export */) && !isAmbientModule(result);
}
function isExternalModuleIndicator(result) {
  return isAnyImportOrReExport(result) || isExportAssignment(result) || hasSyntacticModifier(result, 32 /* Export */);
}
function isForInOrOfStatement(node) {
  return node.kind === 249 /* ForInStatement */ || node.kind === 250 /* ForOfStatement */;
}
function isConciseBody(node) {
  return isBlock(node) || isExpression(node);
}
function isFunctionBody(node) {
  return isBlock(node);
}
function isForInitializer(node) {
  return isVariableDeclarationList(node) || isExpression(node);
}
function isModuleBody(node) {
  const kind = node.kind;
  return kind === 268 /* ModuleBlock */ || kind === 267 /* ModuleDeclaration */ || kind === 80 /* Identifier */;
}
function isNamespaceBody(node) {
  const kind = node.kind;
  return kind === 268 /* ModuleBlock */ || kind === 267 /* ModuleDeclaration */;
}
function isJSDocNamespaceBody(node) {
  const kind = node.kind;
  return kind === 80 /* Identifier */ || kind === 267 /* ModuleDeclaration */;
}
function isNamedImportBindings(node) {
  const kind = node.kind;
  return kind === 275 /* NamedImports */ || kind === 274 /* NamespaceImport */;
}
function isModuleOrEnumDeclaration(node) {
  return node.kind === 267 /* ModuleDeclaration */ || node.kind === 266 /* EnumDeclaration */;
}
function canHaveSymbol(node) {
  switch (node.kind) {
    case 219 /* ArrowFunction */:
    case 226 /* BinaryExpression */:
    case 208 /* BindingElement */:
    case 213 /* CallExpression */:
    case 179 /* CallSignature */:
    case 263 /* ClassDeclaration */:
    case 231 /* ClassExpression */:
    case 175 /* ClassStaticBlockDeclaration */:
    case 176 /* Constructor */:
    case 185 /* ConstructorType */:
    case 180 /* ConstructSignature */:
    case 212 /* ElementAccessExpression */:
    case 266 /* EnumDeclaration */:
    case 306 /* EnumMember */:
    case 277 /* ExportAssignment */:
    case 278 /* ExportDeclaration */:
    case 281 /* ExportSpecifier */:
    case 262 /* FunctionDeclaration */:
    case 218 /* FunctionExpression */:
    case 184 /* FunctionType */:
    case 177 /* GetAccessor */:
    case 80 /* Identifier */:
    case 273 /* ImportClause */:
    case 271 /* ImportEqualsDeclaration */:
    case 276 /* ImportSpecifier */:
    case 181 /* IndexSignature */:
    case 264 /* InterfaceDeclaration */:
    case 338 /* JSDocCallbackTag */:
    case 340 /* JSDocEnumTag */:
    case 317 /* JSDocFunctionType */:
    case 341 /* JSDocParameterTag */:
    case 348 /* JSDocPropertyTag */:
    case 323 /* JSDocSignature */:
    case 346 /* JSDocTypedefTag */:
    case 322 /* JSDocTypeLiteral */:
    case 291 /* JsxAttribute */:
    case 292 /* JsxAttributes */:
    case 293 /* JsxSpreadAttribute */:
    case 200 /* MappedType */:
    case 174 /* MethodDeclaration */:
    case 173 /* MethodSignature */:
    case 267 /* ModuleDeclaration */:
    case 202 /* NamedTupleMember */:
    case 280 /* NamespaceExport */:
    case 270 /* NamespaceExportDeclaration */:
    case 274 /* NamespaceImport */:
    case 214 /* NewExpression */:
    case 15 /* NoSubstitutionTemplateLiteral */:
    case 9 /* NumericLiteral */:
    case 210 /* ObjectLiteralExpression */:
    case 169 /* Parameter */:
    case 211 /* PropertyAccessExpression */:
    case 303 /* PropertyAssignment */:
    case 172 /* PropertyDeclaration */:
    case 171 /* PropertySignature */:
    case 178 /* SetAccessor */:
    case 304 /* ShorthandPropertyAssignment */:
    case 307 /* SourceFile */:
    case 305 /* SpreadAssignment */:
    case 11 /* StringLiteral */:
    case 265 /* TypeAliasDeclaration */:
    case 187 /* TypeLiteral */:
    case 168 /* TypeParameter */:
    case 260 /* VariableDeclaration */:
      return true;
    default:
      return false;
  }
}
function canHaveLocals(node) {
  switch (node.kind) {
    case 219 /* ArrowFunction */:
    case 241 /* Block */:
    case 179 /* CallSignature */:
    case 269 /* CaseBlock */:
    case 299 /* CatchClause */:
    case 175 /* ClassStaticBlockDeclaration */:
    case 194 /* ConditionalType */:
    case 176 /* Constructor */:
    case 185 /* ConstructorType */:
    case 180 /* ConstructSignature */:
    case 248 /* ForStatement */:
    case 249 /* ForInStatement */:
    case 250 /* ForOfStatement */:
    case 262 /* FunctionDeclaration */:
    case 218 /* FunctionExpression */:
    case 184 /* FunctionType */:
    case 177 /* GetAccessor */:
    case 181 /* IndexSignature */:
    case 338 /* JSDocCallbackTag */:
    case 340 /* JSDocEnumTag */:
    case 317 /* JSDocFunctionType */:
    case 323 /* JSDocSignature */:
    case 346 /* JSDocTypedefTag */:
    case 200 /* MappedType */:
    case 174 /* MethodDeclaration */:
    case 173 /* MethodSignature */:
    case 267 /* ModuleDeclaration */:
    case 178 /* SetAccessor */:
    case 307 /* SourceFile */:
    case 265 /* TypeAliasDeclaration */:
      return true;
    default:
      return false;
  }
}
function isDeclarationKind(kind) {
  return kind === 219 /* ArrowFunction */ || kind === 208 /* BindingElement */ || kind === 263 /* ClassDeclaration */ || kind === 231 /* ClassExpression */ || kind === 175 /* ClassStaticBlockDeclaration */ || kind === 176 /* Constructor */ || kind === 266 /* EnumDeclaration */ || kind === 306 /* EnumMember */ || kind === 281 /* ExportSpecifier */ || kind === 262 /* FunctionDeclaration */ || kind === 218 /* FunctionExpression */ || kind === 177 /* GetAccessor */ || kind === 273 /* ImportClause */ || kind === 271 /* ImportEqualsDeclaration */ || kind === 276 /* ImportSpecifier */ || kind === 264 /* InterfaceDeclaration */ || kind === 291 /* JsxAttribute */ || kind === 174 /* MethodDeclaration */ || kind === 173 /* MethodSignature */ || kind === 267 /* ModuleDeclaration */ || kind === 270 /* NamespaceExportDeclaration */ || kind === 274 /* NamespaceImport */ || kind === 280 /* NamespaceExport */ || kind === 169 /* Parameter */ || kind === 303 /* PropertyAssignment */ || kind === 172 /* PropertyDeclaration */ || kind === 171 /* PropertySignature */ || kind === 178 /* SetAccessor */ || kind === 304 /* ShorthandPropertyAssignment */ || kind === 265 /* TypeAliasDeclaration */ || kind === 168 /* TypeParameter */ || kind === 260 /* VariableDeclaration */ || kind === 346 /* JSDocTypedefTag */ || kind === 338 /* JSDocCallbackTag */ || kind === 348 /* JSDocPropertyTag */ || kind === 202 /* NamedTupleMember */;
}
function isDeclarationStatementKind(kind) {
  return kind === 262 /* FunctionDeclaration */ || kind === 282 /* MissingDeclaration */ || kind === 263 /* ClassDeclaration */ || kind === 264 /* InterfaceDeclaration */ || kind === 265 /* TypeAliasDeclaration */ || kind === 266 /* EnumDeclaration */ || kind === 267 /* ModuleDeclaration */ || kind === 272 /* ImportDeclaration */ || kind === 271 /* ImportEqualsDeclaration */ || kind === 278 /* ExportDeclaration */ || kind === 277 /* ExportAssignment */ || kind === 270 /* NamespaceExportDeclaration */;
}
function isStatementKindButNotDeclarationKind(kind) {
  return kind === 252 /* BreakStatement */ || kind === 251 /* ContinueStatement */ || kind === 259 /* DebuggerStatement */ || kind === 246 /* DoStatement */ || kind === 244 /* ExpressionStatement */ || kind === 242 /* EmptyStatement */ || kind === 249 /* ForInStatement */ || kind === 250 /* ForOfStatement */ || kind === 248 /* ForStatement */ || kind === 245 /* IfStatement */ || kind === 256 /* LabeledStatement */ || kind === 253 /* ReturnStatement */ || kind === 255 /* SwitchStatement */ || kind === 257 /* ThrowStatement */ || kind === 258 /* TryStatement */ || kind === 243 /* VariableStatement */ || kind === 247 /* WhileStatement */ || kind === 254 /* WithStatement */ || kind === 353 /* NotEmittedStatement */;
}
function isDeclaration(node) {
  if (node.kind === 168 /* TypeParameter */) {
    return node.parent && node.parent.kind !== 345 /* JSDocTemplateTag */ || isInJSFile(node);
  }
  return isDeclarationKind(node.kind);
}
function isDeclarationStatement(node) {
  return isDeclarationStatementKind(node.kind);
}
function isStatementButNotDeclaration(node) {
  return isStatementKindButNotDeclarationKind(node.kind);
}
function isStatement(node) {
  const kind = node.kind;
  return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) || isBlockStatement(node);
}
function isBlockStatement(node) {
  if (node.kind !== 241 /* Block */) return false;
  if (node.parent !== void 0) {
    if (node.parent.kind === 258 /* TryStatement */ || node.parent.kind === 299 /* CatchClause */) {
      return false;
    }
  }
  return !isFunctionBlock(node);
}
function isStatementOrBlock(node) {
  const kind = node.kind;
  return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) || kind === 241 /* Block */;
}
function isModuleReference(node) {
  const kind = node.kind;
  return kind === 283 /* ExternalModuleReference */ || kind === 166 /* QualifiedName */ || kind === 80 /* Identifier */;
}
function isJsxTagNameExpression(node) {
  const kind = node.kind;
  return kind === 110 /* ThisKeyword */ || kind === 80 /* Identifier */ || kind === 211 /* PropertyAccessExpression */ || kind === 295 /* JsxNamespacedName */;
}
function isJsxChild(node) {
  const kind = node.kind;
  return kind === 284 /* JsxElement */ || kind === 294 /* JsxExpression */ || kind === 285 /* JsxSelfClosingElement */ || kind === 12 /* JsxText */ || kind === 288 /* JsxFragment */;
}
function isJsxAttributeLike(node) {
  const kind = node.kind;
  return kind === 291 /* JsxAttribute */ || kind === 293 /* JsxSpreadAttribute */;
}
function isStringLiteralOrJsxExpression(node) {
  const kind = node.kind;
  return kind === 11 /* StringLiteral */ || kind === 294 /* JsxExpression */;
}
function isJsxOpeningLikeElement(node) {
  const kind = node.kind;
  return kind === 286 /* JsxOpeningElement */ || kind === 285 /* JsxSelfClosingElement */;
}
function isJsxCallLike(node) {
  const kind = node.kind;
  return kind === 286 /* JsxOpeningElement */ || kind === 285 /* JsxSelfClosingElement */ || kind === 289 /* JsxOpeningFragment */;
}
function isCaseOrDefaultClause(node) {
  const kind = node.kind;
  return kind === 296 /* CaseClause */ || kind === 297 /* DefaultClause */;
}
function isJSDocNode(node) {
  return node.kind >= 309 /* FirstJSDocNode */ && node.kind <= 351 /* LastJSDocNode */;
}
function isJSDocCommentContainingNode(node) {
  return node.kind === 320 /* JSDoc */ || node.kind === 319 /* JSDocNamepathType */ || node.kind === 321 /* JSDocText */ || isJSDocLinkLike(node) || isJSDocTag(node) || isJSDocTypeLiteral(node) || isJSDocSignature(node);
}
function isJSDocTag(node) {
  return node.kind >= 327 /* FirstJSDocTagNode */ && node.kind <= 351 /* LastJSDocTagNode */;
}
function isSetAccessor(node) {
  return node.kind === 178 /* SetAccessor */;
}
function isGetAccessor(node) {
  return node.kind === 177 /* GetAccessor */;
}
function hasJSDocNodes(node) {
  if (!canHaveJSDoc(node)) return false;
  const { jsDoc } = node;
  return !!jsDoc && jsDoc.length > 0;
}
function hasType(node) {
  return !!node.type;
}
function hasInitializer(node) {
  return !!node.initializer;
}
function hasOnlyExpressionInitializer(node) {
  switch (node.kind) {
    case 260 /* VariableDeclaration */:
    case 169 /* Parameter */:
    case 208 /* BindingElement */:
    case 172 /* PropertyDeclaration */:
    case 303 /* PropertyAssignment */:
    case 306 /* EnumMember */:
      return true;
    default:
      return false;
  }
}
function isObjectLiteralElement(node) {
  return node.kind === 291 /* JsxAttribute */ || node.kind === 293 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node);
}
function isTypeReferenceType(node) {
  return node.kind === 183 /* TypeReference */ || node.kind === 233 /* ExpressionWithTypeArguments */;
}
var MAX_SMI_X86 = 1073741823;
function guessIndentation(lines) {
  let indentation = MAX_SMI_X86;
  for (const line of lines) {
    if (!line.length) {
      continue;
    }
    let i = 0;
    for (; i < line.length && i < indentation; i++) {
      if (!isWhiteSpaceLike(line.charCodeAt(i))) {
        break;
      }
    }
    if (i < indentation) {
      indentation = i;
    }
    if (indentation === 0) {
      return 0;
    }
  }
  return indentation === MAX_SMI_X86 ? void 0 : indentation;
}
function isStringLiteralLike(node) {
  return node.kind === 11 /* StringLiteral */ || node.kind === 15 /* NoSubstitutionTemplateLiteral */;
}
function isJSDocLinkLike(node) {
  return node.kind === 324 /* JSDocLink */ || node.kind === 325 /* JSDocLinkCode */ || node.kind === 326 /* JSDocLinkPlain */;
}
function hasRestParameter(s) {
  const last2 = lastOrUndefined(s.parameters);
  return !!last2 && isRestParameter(last2);
}
function isRestParameter(node) {
  const type = isJSDocParameterTag(node) ? node.typeExpression && node.typeExpression.type : node.type;
  return node.dotDotDotToken !== void 0 || !!type && type.kind === 318 /* JSDocVariadicType */;
}
function hasInternalAnnotation(range, sourceFile) {
  const comment = sourceFile.text.substring(range.pos, range.end);
  return comment.includes("@internal");
}
function isInternalDeclaration(node, sourceFile) {
  sourceFile ?? (sourceFile = getSourceFileOfNode(node));
  const parseTreeNode = getParseTreeNode(node);
  if (parseTreeNode && parseTreeNode.kind === 169 /* Parameter */) {
    const paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode);
    const previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : void 0;
    const text = sourceFile.text;
    const commentRanges = previousSibling ? concatenate(
      // to handle
      // ... parameters, /** @internal */
      // public param: string
      getTrailingCommentRanges(text, skipTrivia(
        text,
        previousSibling.end + 1,
        /*stopAfterLineBreak*/
        false,
        /*stopAtComments*/
        true
      )),
      getLeadingCommentRanges(text, node.pos)
    ) : getTrailingCommentRanges(text, skipTrivia(
      text,
      node.pos,
      /*stopAfterLineBreak*/
      false,
      /*stopAtComments*/
      true
    ));
    return some(commentRanges) && hasInternalAnnotation(last(commentRanges), sourceFile);
  }
  const leadingCommentRanges = parseTreeNode && getLeadingCommentRangesOfNode(parseTreeNode, sourceFile);
  return !!forEach(leadingCommentRanges, (range) => {
    return hasInternalAnnotation(range, sourceFile);
  });
}

// src/compiler/utilities.ts
var resolvingEmptyArray = [];
var externalHelpersModuleNameText = "tslib";
var defaultMaximumTruncationLength = 160;
var noTruncationMaximumTruncationLength = 1e6;
function getDeclarationOfKind(symbol, kind) {
  const declarations = symbol.declarations;
  if (declarations) {
    for (const declaration of declarations) {
      if (declaration.kind === kind) {
        return declaration;
      }
    }
  }
  return void 0;
}
function getDeclarationsOfKind(symbol, kind) {
  return filter(symbol.declarations || emptyArray, (d) => d.kind === kind);
}
function createSymbolTable(symbols) {
  const result = /* @__PURE__ */ new Map();
  if (symbols) {
    for (const symbol of symbols) {
      result.set(symbol.escapedName, symbol);
    }
  }
  return result;
}
function isTransientSymbol(symbol) {
  return (symbol.flags & 33554432 /* Transient */) !== 0;
}
function isExternalModuleSymbol(moduleSymbol) {
  return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.escapedName.charCodeAt(0) === 34 /* doubleQuote */;
}
var stringWriter = createSingleLineStringWriter();
function createSingleLineStringWriter() {
  var str = "";
  const writeText = (text) => str += text;
  return {
    getText: () => str,
    write: writeText,
    rawWrite: writeText,
    writeKeyword: writeText,
    writeOperator: writeText,
    writePunctuation: writeText,
    writeSpace: writeText,
    writeStringLiteral: writeText,
    writeLiteral: writeText,
    writeParameter: writeText,
    writeProperty: writeText,
    writeSymbol: (s, _) => writeText(s),
    writeTrailingSemicolon: writeText,
    writeComment: writeText,
    getTextPos: () => str.length,
    getLine: () => 0,
    getColumn: () => 0,
    getIndent: () => 0,
    isAtStartOfLine: () => false,
    hasTrailingComment: () => false,
    hasTrailingWhitespace: () => !!str.length && isWhiteSpaceLike(str.charCodeAt(str.length - 1)),
    // Completely ignore indentation for string writers.  And map newlines to
    // a single space.
    writeLine: () => str += " ",
    increaseIndent: noop,
    decreaseIndent: noop,
    clear: () => str = ""
  };
}
function changesAffectModuleResolution(oldOptions, newOptions) {
  return oldOptions.configFilePath !== newOptions.configFilePath || optionsHaveModuleResolutionChanges(oldOptions, newOptions);
}
function optionsHaveModuleResolutionChanges(oldOptions, newOptions) {
  return optionsHaveChanges(oldOptions, newOptions, moduleResolutionOptionDeclarations);
}
function changesAffectingProgramStructure(oldOptions, newOptions) {
  return optionsHaveChanges(oldOptions, newOptions, optionsAffectingProgramStructure);
}
function optionsHaveChanges(oldOptions, newOptions, optionDeclarations2) {
  return oldOptions !== newOptions && optionDeclarations2.some((o) => !isJsonEqual(getCompilerOptionValue(oldOptions, o), getCompilerOptionValue(newOptions, o)));
}
function forEachAncestor(node, callback) {
  while (true) {
    const res = callback(node);
    if (res === "quit") return void 0;
    if (res !== void 0) return res;
    if (isSourceFile(node)) return void 0;
    node = node.parent;
  }
}
function forEachEntry(map2, callback) {
  const iterator = map2.entries();
  for (const [key, value] of iterator) {
    const result = callback(value, key);
    if (result) {
      return result;
    }
  }
  return void 0;
}
function forEachKey(map2, callback) {
  const iterator = map2.keys();
  for (const key of iterator) {
    const result = callback(key);
    if (result) {
      return result;
    }
  }
  return void 0;
}
function copyEntries(source, target) {
  source.forEach((value, key) => {
    target.set(key, value);
  });
}
function usingSingleLineStringWriter(action) {
  const oldString = stringWriter.getText();
  try {
    action(stringWriter);
    return stringWriter.getText();
  } finally {
    stringWriter.clear();
    stringWriter.writeKeyword(oldString);
  }
}
function getFullWidth(node) {
  return node.end - node.pos;
}
function projectReferenceIsEqualTo(oldRef, newRef) {
  return oldRef.path === newRef.path && !oldRef.prepend === !newRef.prepend && !oldRef.circular === !newRef.circular;
}
function moduleResolutionIsEqualTo(oldResolution, newResolution) {
  return oldResolution === newResolution || oldResolution.resolvedModule === newResolution.resolvedModule || !!oldResolution.resolvedModule && !!newResolution.resolvedModule && oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport && oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension && oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName && oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath && packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId) && oldResolution.alternateResult === newResolution.alternateResult;
}
function getResolvedModuleFromResolution(resolution) {
  return resolution.resolvedModule;
}
function getResolvedTypeReferenceDirectiveFromResolution(resolution) {
  return resolution.resolvedTypeReferenceDirective;
}
function createModuleNotFoundChain(sourceFile, host, moduleReference, mode, packageName) {
  var _a;
  const alternateResult = (_a = host.getResolvedModule(sourceFile, moduleReference, mode)) == null ? void 0 : _a.alternateResult;
  const alternateResultMessage = alternateResult && (getEmitModuleResolutionKind(host.getCompilerOptions()) === 2 /* Node10 */ ? [Diagnostics.There_are_types_at_0_but_this_result_could_not_be_resolved_under_your_current_moduleResolution_setting_Consider_updating_to_node16_nodenext_or_bundler, [alternateResult]] : [
    Diagnostics.There_are_types_at_0_but_this_result_could_not_be_resolved_when_respecting_package_json_exports_The_1_library_may_need_to_update_its_package_json_or_typings,
    [alternateResult, alternateResult.includes(nodeModulesPathPart + "@types/") ? `@types/${mangleScopedPackageName(packageName)}` : packageName]
  ]);
  const result = alternateResultMessage ? chainDiagnosticMessages(
    /*details*/
    void 0,
    alternateResultMessage[0],
    ...alternateResultMessage[1]
  ) : host.typesPackageExists(packageName) ? chainDiagnosticMessages(
    /*details*/
    void 0,
    Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1,
    packageName,
    mangleScopedPackageName(packageName)
  ) : host.packageBundlesTypes(packageName) ? chainDiagnosticMessages(
    /*details*/
    void 0,
    Diagnostics.If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_declare_module_1,
    packageName,
    moduleReference
  ) : chainDiagnosticMessages(
    /*details*/
    void 0,
    Diagnostics.Try_npm_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0,
    moduleReference,
    mangleScopedPackageName(packageName)
  );
  if (result) result.repopulateInfo = () => ({ moduleReference, mode, packageName: packageName === moduleReference ? void 0 : packageName });
  return result;
}
function createModeMismatchDetails(currentSourceFile) {
  const ext = tryGetExtensionFromPath2(currentSourceFile.fileName);
  const scope = currentSourceFile.packageJsonScope;
  const targetExt = ext === ".ts" /* Ts */ ? ".mts" /* Mts */ : ext === ".js" /* Js */ ? ".mjs" /* Mjs */ : void 0;
  const result = scope && !scope.contents.packageJsonContent.type ? targetExt ? chainDiagnosticMessages(
    /*details*/
    void 0,
    Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1,
    targetExt,
    combinePaths(scope.packageDirectory, "package.json")
  ) : chainDiagnosticMessages(
    /*details*/
    void 0,
    Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0,
    combinePaths(scope.packageDirectory, "package.json")
  ) : targetExt ? chainDiagnosticMessages(
    /*details*/
    void 0,
    Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module,
    targetExt
  ) : chainDiagnosticMessages(
    /*details*/
    void 0,
    Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module
  );
  result.repopulateInfo = () => true;
  return result;
}
function packageIdIsEqual(a, b) {
  return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version && a.peerDependencies === b.peerDependencies;
}
function packageIdToPackageName({ name, subModuleName }) {
  return subModuleName ? `${name}/${subModuleName}` : name;
}
function packageIdToString(packageId) {
  return `${packageIdToPackageName(packageId)}@${packageId.version}${packageId.peerDependencies ?? ""}`;
}
function typeDirectiveIsEqualTo(oldResolution, newResolution) {
  return oldResolution === newResolution || oldResolution.resolvedTypeReferenceDirective === newResolution.resolvedTypeReferenceDirective || !!oldResolution.resolvedTypeReferenceDirective && !!newResolution.resolvedTypeReferenceDirective && oldResolution.resolvedTypeReferenceDirective.resolvedFileName === newResolution.resolvedTypeReferenceDirective.resolvedFileName && !!oldResolution.resolvedTypeReferenceDirective.primary === !!newResolution.resolvedTypeReferenceDirective.primary && oldResolution.resolvedTypeReferenceDirective.originalPath === newResolution.resolvedTypeReferenceDirective.originalPath;
}
function hasChangesInResolutions(names, newResolutions, getOldResolution, comparer) {
  Debug.assert(names.length === newResolutions.length);
  for (let i = 0; i < names.length; i++) {
    const newResolution = newResolutions[i];
    const entry = names[i];
    const oldResolution = getOldResolution(entry);
    const changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) : newResolution;
    if (changed) {
      return true;
    }
  }
  return false;
}
function containsParseError(node) {
  aggregateChildData(node);
  return (node.flags & 1048576 /* ThisNodeOrAnySubNodesHasError */) !== 0;
}
function aggregateChildData(node) {
  if (!(node.flags & 2097152 /* HasAggregatedChildData */)) {
    const thisNodeOrAnySubNodesHasError = (node.flags & 262144 /* ThisNodeHasError */) !== 0 || forEachChild(node, containsParseError);
    if (thisNodeOrAnySubNodesHasError) {
      node.flags |= 1048576 /* ThisNodeOrAnySubNodesHasError */;
    }
    node.flags |= 2097152 /* HasAggregatedChildData */;
  }
}
function getSourceFileOfNode(node) {
  while (node && node.kind !== 307 /* SourceFile */) {
    node = node.parent;
  }
  return node;
}
function getSourceFileOfModule(module2) {
  return getSourceFileOfNode(module2.valueDeclaration || getNonAugmentationDeclaration(module2));
}
function isPlainJsFile(file, checkJs) {
  return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === void 0;
}
function isStatementWithLocals(node) {
  switch (node.kind) {
    case 241 /* Block */:
    case 269 /* CaseBlock */:
    case 248 /* ForStatement */:
    case 249 /* ForInStatement */:
    case 250 /* ForOfStatement */:
      return true;
  }
  return false;
}
function getStartPositionOfLine(line, sourceFile) {
  Debug.assert(line >= 0);
  return getLineStarts(sourceFile)[line];
}
function nodePosToString(node) {
  const file = getSourceFileOfNode(node);
  const loc = getLineAndCharacterOfPosition(file, node.pos);
  return `${file.fileName}(${loc.line + 1},${loc.character + 1})`;
}
function getEndLinePosition(line, sourceFile) {
  Debug.assert(line >= 0);
  const lineStarts = getLineStarts(sourceFile);
  const lineIndex = line;
  const sourceText = sourceFile.text;
  if (lineIndex + 1 === lineStarts.length) {
    return sourceText.length - 1;
  } else {
    const start = lineStarts[lineIndex];
    let pos = lineStarts[lineIndex + 1] - 1;
    Debug.assert(isLineBreak(sourceText.charCodeAt(pos)));
    while (start <= pos && isLineBreak(sourceText.charCodeAt(pos))) {
      pos--;
    }
    return pos;
  }
}
function isFileLevelUniqueName(sourceFile, name, hasGlobalName) {
  return !(hasGlobalName && hasGlobalName(name)) && !sourceFile.identifiers.has(name);
}
function nodeIsMissing(node) {
  if (node === void 0) {
    return true;
  }
  return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */;
}
function nodeIsPresent(node) {
  return !nodeIsMissing(node);
}
function isGrammarError(parent2, child) {
  if (isTypeParameterDeclaration(parent2)) return child === parent2.expression;
  if (isClassStaticBlockDeclaration(parent2)) return child === parent2.modifiers;
  if (isPropertySignature(parent2)) return child === parent2.initializer;
  if (isPropertyDeclaration(parent2)) return child === parent2.questionToken && isAutoAccessorPropertyDeclaration(parent2);
  if (isPropertyAssignment(parent2)) return child === parent2.modifiers || child === parent2.questionToken || child === parent2.exclamationToken || isGrammarErrorElement(parent2.modifiers, child, isModifierLike);
  if (isShorthandPropertyAssignment(parent2)) return child === parent2.equalsToken || child === parent2.modifiers || child === parent2.questionToken || child === parent2.exclamationToken || isGrammarErrorElement(parent2.modifiers, child, isModifierLike);
  if (isMethodDeclaration(parent2)) return child === parent2.exclamationToken;
  if (isConstructorDeclaration(parent2)) return child === parent2.typeParameters || child === parent2.type || isGrammarErrorElement(parent2.typeParameters, child, isTypeParameterDeclaration);
  if (isGetAccessorDeclaration(parent2)) return child === parent2.typeParameters || isGrammarErrorElement(parent2.typeParameters, child, isTypeParameterDeclaration);
  if (isSetAccessorDeclaration(parent2)) return child === parent2.typeParameters || child === parent2.type || isGrammarErrorElement(parent2.typeParameters, child, isTypeParameterDeclaration);
  if (isNamespaceExportDeclaration(parent2)) return child === parent2.modifiers || isGrammarErrorElement(parent2.modifiers, child, isModifierLike);
  return false;
}
function isGrammarErrorElement(nodeArray, child, isElement) {
  if (!nodeArray || isArray(child) || !isElement(child)) return false;
  return contains(nodeArray, child);
}
function insertStatementsAfterPrologue(to, from, isPrologueDirective2) {
  if (from === void 0 || from.length === 0) return to;
  let statementIndex = 0;
  for (; statementIndex < to.length; ++statementIndex) {
    if (!isPrologueDirective2(to[statementIndex])) {
      break;
    }
  }
  to.splice(statementIndex, 0, ...from);
  return to;
}
function insertStatementAfterPrologue(to, statement, isPrologueDirective2) {
  if (statement === void 0) return to;
  let statementIndex = 0;
  for (; statementIndex < to.length; ++statementIndex) {
    if (!isPrologueDirective2(to[statementIndex])) {
      break;
    }
  }
  to.splice(statementIndex, 0, statement);
  return to;
}
function isAnyPrologueDirective(node) {
  return isPrologueDirective(node) || !!(getEmitFlags(node) & 2097152 /* CustomPrologue */);
}
function insertStatementsAfterStandardPrologue(to, from) {
  return insertStatementsAfterPrologue(to, from, isPrologueDirective);
}
function insertStatementsAfterCustomPrologue(to, from) {
  return insertStatementsAfterPrologue(to, from, isAnyPrologueDirective);
}
function insertStatementAfterStandardPrologue(to, statement) {
  return insertStatementAfterPrologue(to, statement, isPrologueDirective);
}
function insertStatementAfterCustomPrologue(to, statement) {
  return insertStatementAfterPrologue(to, statement, isAnyPrologueDirective);
}
function isRecognizedTripleSlashComment(text, commentPos, commentEnd) {
  if (text.charCodeAt(commentPos + 1) === 47 /* slash */ && commentPos + 2 < commentEnd && text.charCodeAt(commentPos + 2) === 47 /* slash */) {
    const textSubStr = text.substring(commentPos, commentEnd);
    return fullTripleSlashReferencePathRegEx.test(textSubStr) || fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || fullTripleSlashAMDModuleRegEx.test(textSubStr) || fullTripleSlashReferenceTypeReferenceDirectiveRegEx.test(textSubStr) || fullTripleSlashLibReferenceRegEx.test(textSubStr) || defaultLibReferenceRegEx.test(textSubStr) ? true : false;
  }
  return false;
}
function isPinnedComment(text, start) {
  return text.charCodeAt(start + 1) === 42 /* asterisk */ && text.charCodeAt(start + 2) === 33 /* exclamation */;
}
function createCommentDirectivesMap(sourceFile, commentDirectives) {
  const directivesByLine = new Map(
    commentDirectives.map((commentDirective) => [
      `${getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line}`,
      commentDirective
    ])
  );
  const usedLines = /* @__PURE__ */ new Map();
  return { getUnusedExpectations, markUsed };
  function getUnusedExpectations() {
    return arrayFrom(directivesByLine.entries()).filter(([line, directive]) => directive.type === 0 /* ExpectError */ && !usedLines.get(line)).map(([_, directive]) => directive);
  }
  function markUsed(line) {
    if (!directivesByLine.has(`${line}`)) {
      return false;
    }
    usedLines.set(`${line}`, true);
    return true;
  }
}
function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
  if (nodeIsMissing(node)) {
    return node.pos;
  }
  if (isJSDocNode(node) || node.kind === 12 /* JsxText */) {
    return skipTrivia(
      (sourceFile ?? getSourceFileOfNode(node)).text,
      node.pos,
      /*stopAfterLineBreak*/
      false,
      /*stopAtComments*/
      true
    );
  }
  if (includeJsDoc && hasJSDocNodes(node)) {
    return getTokenPosOfNode(node.jsDoc[0], sourceFile);
  }
  if (node.kind === 352 /* SyntaxList */) {
    sourceFile ?? (sourceFile = getSourceFileOfNode(node));
    const first2 = firstOrUndefined(getNodeChildren(node, sourceFile));
    if (first2) {
      return getTokenPosOfNode(first2, sourceFile, includeJsDoc);
    }
  }
  return skipTrivia(
    (sourceFile ?? getSourceFileOfNode(node)).text,
    node.pos,
    /*stopAfterLineBreak*/
    false,
    /*stopAtComments*/
    false,
    isInJSDoc(node)
  );
}
function getNonDecoratorTokenPosOfNode(node, sourceFile) {
  const lastDecorator = !nodeIsMissing(node) && canHaveModifiers(node) ? findLast(node.modifiers, isDecorator) : void 0;
  if (!lastDecorator) {
    return getTokenPosOfNode(node, sourceFile);
  }
  return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, lastDecorator.end);
}
function getNonModifierTokenPosOfNode(node, sourceFile) {
  const lastModifier = !nodeIsMissing(node) && canHaveModifiers(node) && node.modifiers ? last(node.modifiers) : void 0;
  if (!lastModifier) {
    return getTokenPosOfNode(node, sourceFile);
  }
  return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, lastModifier.end);
}
function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia = false) {
  return getTextOfNodeFromSourceText(sourceFile.text, node, includeTrivia);
}
function isJSDocTypeExpressionOrChild(node) {
  return !!findAncestor(node, isJSDocTypeExpression);
}
function isExportNamespaceAsDefaultDeclaration(node) {
  return !!(isExportDeclaration(node) && node.exportClause && isNamespaceExport(node.exportClause) && moduleExportNameIsDefault(node.exportClause.name));
}
function moduleExportNameTextUnescaped(node) {
  return node.kind === 11 /* StringLiteral */ ? node.text : unescapeLeadingUnderscores(node.escapedText);
}
function moduleExportNameTextEscaped(node) {
  return node.kind === 11 /* StringLiteral */ ? escapeLeadingUnderscores(node.text) : node.escapedText;
}
function moduleExportNameIsDefault(node) {
  return (node.kind === 11 /* StringLiteral */ ? node.text : node.escapedText) === "default" /* Default */;
}
function getTextOfNodeFromSourceText(sourceText, node, includeTrivia = false) {
  if (nodeIsMissing(node)) {
    return "";
  }
  let text = sourceText.substring(includeTrivia ? node.pos : skipTrivia(sourceText, node.pos), node.end);
  if (isJSDocTypeExpressionOrChild(node)) {
    text = text.split(/\r\n|\n|\r/).map((line) => line.replace(/^\s*\*/, "").trimStart()).join("\n");
  }
  return text;
}
function getTextOfNode(node, includeTrivia = false) {
  return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia);
}
function getPos(range) {
  return range.pos;
}
function indexOfNode(nodeArray, node) {
  return binarySearch(nodeArray, node, getPos, compareValues);
}
function getEmitFlags(node) {
  const emitNode = node.emitNode;
  return emitNode && emitNode.flags || 0;
}
function getInternalEmitFlags(node) {
  const emitNode = node.emitNode;
  return emitNode && emitNode.internalFlags || 0;
}
var getScriptTargetFeatures = /* @__PURE__ */ memoize(
  () => new Map(Object.entries({
    Array: new Map(Object.entries({
      es2015: [
        "find",
        "findIndex",
        "fill",
        "copyWithin",
        "entries",
        "keys",
        "values"
      ],
      es2016: [
        "includes"
      ],
      es2019: [
        "flat",
        "flatMap"
      ],
      es2022: [
        "at"
      ],
      es2023: [
        "findLastIndex",
        "findLast",
        "toReversed",
        "toSorted",
        "toSpliced",
        "with"
      ]
    })),
    Iterator: new Map(Object.entries({
      es2015: emptyArray
    })),
    AsyncIterator: new Map(Object.entries({
      es2015: emptyArray
    })),
    ArrayBuffer: new Map(Object.entries({
      es2024: [
        "maxByteLength",
        "resizable",
        "resize",
        "detached",
        "transfer",
        "transferToFixedLength"
      ]
    })),
    Atomics: new Map(Object.entries({
      es2017: [
        "add",
        "and",
        "compareExchange",
        "exchange",
        "isLockFree",
        "load",
        "or",
        "store",
        "sub",
        "wait",
        "notify",
        "xor"
      ],
      es2024: [
        "waitAsync"
      ]
    })),
    SharedArrayBuffer: new Map(Object.entries({
      es2017: [
        "byteLength",
        "slice"
      ],
      es2024: [
        "growable",
        "maxByteLength",
        "grow"
      ]
    })),
    AsyncIterable: new Map(Object.entries({
      es2018: emptyArray
    })),
    AsyncIterableIterator: new Map(Object.entries({
      es2018: emptyArray
    })),
    AsyncGenerator: new Map(Object.entries({
      es2018: emptyArray
    })),
    AsyncGeneratorFunction: new Map(Object.entries({
      es2018: emptyArray
    })),
    RegExp: new Map(Object.entries({
      es2015: [
        "flags",
        "sticky",
        "unicode"
      ],
      es2018: [
        "dotAll"
      ],
      es2024: [
        "unicodeSets"
      ]
    })),
    Reflect: new Map(Object.entries({
      es2015: [
        "apply",
        "construct",
        "defineProperty",
        "deleteProperty",
        "get",
        "getOwnPropertyDescriptor",
        "getPrototypeOf",
        "has",
        "isExtensible",
        "ownKeys",
        "preventExtensions",
        "set",
        "setPrototypeOf"
      ]
    })),
    ArrayConstructor: new Map(Object.entries({
      es2015: [
        "from",
        "of"
      ],
      esnext: [
        "fromAsync"
      ]
    })),
    ObjectConstructor: new Map(Object.entries({
      es2015: [
        "assign",
        "getOwnPropertySymbols",
        "keys",
        "is",
        "setPrototypeOf"
      ],
      es2017: [
        "values",
        "entries",
        "getOwnPropertyDescriptors"
      ],
      es2019: [
        "fromEntries"
      ],
      es2022: [
        "hasOwn"
      ],
      es2024: [
        "groupBy"
      ]
    })),
    NumberConstructor: new Map(Object.entries({
      es2015: [
        "isFinite",
        "isInteger",
        "isNaN",
        "isSafeInteger",
        "parseFloat",
        "parseInt"
      ]
    })),
    Math: new Map(Object.entries({
      es2015: [
        "clz32",
        "imul",
        "sign",
        "log10",
        "log2",
        "log1p",
        "expm1",
        "cosh",
        "sinh",
        "tanh",
        "acosh",
        "asinh",
        "atanh",
        "hypot",
        "trunc",
        "fround",
        "cbrt"
      ]
    })),
    Map: new Map(Object.entries({
      es2015: [
        "entries",
        "keys",
        "values"
      ]
    })),
    MapConstructor: new Map(Object.entries({
      es2024: [
        "groupBy"
      ]
    })),
    Set: new Map(Object.entries({
      es2015: [
        "entries",
        "keys",
        "values"
      ],
      esnext: [
        "union",
        "intersection",
        "difference",
        "symmetricDifference",
        "isSubsetOf",
        "isSupersetOf",
        "isDisjointFrom"
      ]
    })),
    PromiseConstructor: new Map(Object.entries({
      es2015: [
        "all",
        "race",
        "reject",
        "resolve"
      ],
      es2020: [
        "allSettled"
      ],
      es2021: [
        "any"
      ],
      es2024: [
        "withResolvers"
      ]
    })),
    Symbol: new Map(Object.entries({
      es2015: [
        "for",
        "keyFor"
      ],
      es2019: [
        "description"
      ]
    })),
    WeakMap: new Map(Object.entries({
      es2015: [
        "entries",
        "keys",
        "values"
      ]
    })),
    WeakSet: new Map(Object.entries({
      es2015: [
        "entries",
        "keys",
        "values"
      ]
    })),
    String: new Map(Object.entries({
      es2015: [
        "codePointAt",
        "includes",
        "endsWith",
        "normalize",
        "repeat",
        "startsWith",
        "anchor",
        "big",
        "blink",
        "bold",
        "fixed",
        "fontcolor",
        "fontsize",
        "italics",
        "link",
        "small",
        "strike",
        "sub",
        "sup"
      ],
      es2017: [
        "padStart",
        "padEnd"
      ],
      es2019: [
        "trimStart",
        "trimEnd",
        "trimLeft",
        "trimRight"
      ],
      es2020: [
        "matchAll"
      ],
      es2021: [
        "replaceAll"
      ],
      es2022: [
        "at"
      ],
      es2024: [
        "isWellFormed",
        "toWellFormed"
      ]
    })),
    StringConstructor: new Map(Object.entries({
      es2015: [
        "fromCodePoint",
        "raw"
      ]
    })),
    DateTimeFormat: new Map(Object.entries({
      es2017: [
        "formatToParts"
      ]
    })),
    Promise: new Map(Object.entries({
      es2015: emptyArray,
      es2018: [
        "finally"
      ]
    })),
    RegExpMatchArray: new Map(Object.entries({
      es2018: [
        "groups"
      ]
    })),
    RegExpExecArray: new Map(Object.entries({
      es2018: [
        "groups"
      ]
    })),
    Intl: new Map(Object.entries({
      es2018: [
        "PluralRules"
      ]
    })),
    NumberFormat: new Map(Object.entries({
      es2018: [
        "formatToParts"
      ]
    })),
    SymbolConstructor: new Map(Object.entries({
      es2020: [
        "matchAll"
      ],
      esnext: [
        "metadata",
        "dispose",
        "asyncDispose"
      ]
    })),
    DataView: new Map(Object.entries({
      es2020: [
        "setBigInt64",
        "setBigUint64",
        "getBigInt64",
        "getBigUint64"
      ]
    })),
    BigInt: new Map(Object.entries({
      es2020: emptyArray
    })),
    RelativeTimeFormat: new Map(Object.entries({
      es2020: [
        "format",
        "formatToParts",
        "resolvedOptions"
      ]
    })),
    Int8Array: new Map(Object.entries({
      es2022: [
        "at"
      ],
      es2023: [
        "findLastIndex",
        "findLast",
        "toReversed",
        "toSorted",
        "toSpliced",
        "with"
      ]
    })),
    Uint8Array: new Map(Object.entries({
      es2022: [
        "at"
      ],
      es2023: [
        "findLastIndex",
        "findLast",
        "toReversed",
        "toSorted",
        "toSpliced",
        "with"
      ]
    })),
    Uint8ClampedArray: new Map(Object.entries({
      es2022: [
        "at"
      ],
      es2023: [
        "findLastIndex",
        "findLast",
        "toReversed",
        "toSorted",
        "toSpliced",
        "with"
      ]
    })),
    Int16Array: new Map(Object.entries({
      es2022: [
        "at"
      ],
      es2023: [
        "findLastIndex",
        "findLast",
        "toReversed",
        "toSorted",
        "toSpliced",
        "with"
      ]
    })),
    Uint16Array: new Map(Object.entries({
      es2022: [
        "at"
      ],
      es2023: [
        "findLastIndex",
        "findLast",
        "toReversed",
        "toSorted",
        "toSpliced",
        "with"
      ]
    })),
    Int32Array: new Map(Object.entries({
      es2022: [
        "at"
      ],
      es2023: [
        "findLastIndex",
        "findLast",
        "toReversed",
        "toSorted",
        "toSpliced",
        "with"
      ]
    })),
    Uint32Array: new Map(Object.entries({
      es2022: [
        "at"
      ],
      es2023: [
        "findLastIndex",
        "findLast",
        "toReversed",
        "toSorted",
        "toSpliced",
        "with"
      ]
    })),
    Float32Array: new Map(Object.entries({
      es2022: [
        "at"
      ],
      es2023: [
        "findLastIndex",
        "findLast",
        "toReversed",
        "toSorted",
        "toSpliced",
        "with"
      ]
    })),
    Float64Array: new Map(Object.entries({
      es2022: [
        "at"
      ],
      es2023: [
        "findLastIndex",
        "findLast",
        "toReversed",
        "toSorted",
        "toSpliced",
        "with"
      ]
    })),
    BigInt64Array: new Map(Object.entries({
      es2020: emptyArray,
      es2022: [
        "at"
      ],
      es2023: [
        "findLastIndex",
        "findLast",
        "toReversed",
        "toSorted",
        "toSpliced",
        "with"
      ]
    })),
    BigUint64Array: new Map(Object.entries({
      es2020: emptyArray,
      es2022: [
        "at"
      ],
      es2023: [
        "findLastIndex",
        "findLast",
        "toReversed",
        "toSorted",
        "toSpliced",
        "with"
      ]
    })),
    Error: new Map(Object.entries({
      es2022: [
        "cause"
      ]
    }))
  }))
);
var GetLiteralTextFlags = /* @__PURE__ */ ((GetLiteralTextFlags2) => {
  GetLiteralTextFlags2[GetLiteralTextFlags2["None"] = 0] = "None";
  GetLiteralTextFlags2[GetLiteralTextFlags2["NeverAsciiEscape"] = 1] = "NeverAsciiEscape";
  GetLiteralTextFlags2[GetLiteralTextFlags2["JsxAttributeEscape"] = 2] = "JsxAttributeEscape";
  GetLiteralTextFlags2[GetLiteralTextFlags2["TerminateUnterminatedLiterals"] = 4] = "TerminateUnterminatedLiterals";
  GetLiteralTextFlags2[GetLiteralTextFlags2["AllowNumericSeparator"] = 8] = "AllowNumericSeparator";
  return GetLiteralTextFlags2;
})(GetLiteralTextFlags || {});
function getLiteralText(node, sourceFile, flags) {
  if (sourceFile && canUseOriginalText(node, flags)) {
    return getSourceTextOfNodeFromSourceFile(sourceFile, node);
  }
  switch (node.kind) {
    case 11 /* StringLiteral */: {
      const escapeText = flags & 2 /* JsxAttributeEscape */ ? escapeJsxAttributeString : flags & 1 /* NeverAsciiEscape */ || getEmitFlags(node) & 16777216 /* NoAsciiEscaping */ ? escapeString : escapeNonAsciiString;
      if (node.singleQuote) {
        return "'" + escapeText(node.text, 39 /* singleQuote */) + "'";
      } else {
        return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"';
      }
    }
    case 15 /* NoSubstitutionTemplateLiteral */:
    case 16 /* TemplateHead */:
    case 17 /* TemplateMiddle */:
    case 18 /* TemplateTail */: {
      const escapeText = flags & 1 /* NeverAsciiEscape */ || getEmitFlags(node) & 16777216 /* NoAsciiEscaping */ ? escapeString : escapeNonAsciiString;
      const rawText = node.rawText ?? escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */));
      switch (node.kind) {
        case 15 /* NoSubstitutionTemplateLiteral */:
          return "`" + rawText + "`";
        case 16 /* TemplateHead */:
          return "`" + rawText + "${";
        case 17 /* TemplateMiddle */:
          return "}" + rawText + "${";
        case 18 /* TemplateTail */:
          return "}" + rawText + "`";
      }
      break;
    }
    case 9 /* NumericLiteral */:
    case 10 /* BigIntLiteral */:
      return node.text;
    case 14 /* RegularExpressionLiteral */:
      if (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) {
        return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* backslash */ ? " /" : "/");
      }
      return node.text;
  }
  return Debug.fail(`Literal kind '${node.kind}' not accounted for.`);
}
function canUseOriginalText(node, flags) {
  if (nodeIsSynthesized(node) || !node.parent || flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) {
    return false;
  }
  if (isNumericLiteral(node)) {
    if (node.numericLiteralFlags & 26656 /* IsInvalid */) {
      return false;
    }
    if (node.numericLiteralFlags & 512 /* ContainsSeparator */) {
      return !!(flags & 8 /* AllowNumericSeparator */);
    }
  }
  return !isBigIntLiteral(node);
}
function getTextOfConstantValue(value) {
  return isString(value) ? `"${escapeString(value)}"` : "" + value;
}
function makeIdentifierFromModuleName(moduleName) {
  return getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_");
}
function isBlockOrCatchScoped(declaration) {
  return (getCombinedNodeFlags(declaration) & 7 /* BlockScoped */) !== 0 || isCatchClauseVariableDeclarationOrBindingElement(declaration);
}
function isCatchClauseVariableDeclarationOrBindingElement(declaration) {
  const node = getRootDeclaration(declaration);
  return node.kind === 260 /* VariableDeclaration */ && node.parent.kind === 299 /* CatchClause */;
}
function isAmbientModule(node) {
  return isModuleDeclaration(node) && (node.name.kind === 11 /* StringLiteral */ || isGlobalScopeAugmentation(node));
}
function isModuleWithStringLiteralName(node) {
  return isModuleDeclaration(node) && node.name.kind === 11 /* StringLiteral */;
}
function isNonGlobalAmbientModule(node) {
  return isModuleDeclaration(node) && isStringLiteral(node.name);
}
function isEffectiveModuleDeclaration(node) {
  return isModuleDeclaration(node) || isIdentifier(node);
}
function isShorthandAmbientModuleSymbol(moduleSymbol) {
  return isShorthandAmbientModule(moduleSymbol.valueDeclaration);
}
function isShorthandAmbientModule(node) {
  return !!node && node.kind === 267 /* ModuleDeclaration */ && !node.body;
}
function isBlockScopedContainerTopLevel(node) {
  return node.kind === 307 /* SourceFile */ || node.kind === 267 /* ModuleDeclaration */ || isFunctionLikeOrClassStaticBlockDeclaration(node);
}
function isGlobalScopeAugmentation(module2) {
  return !!(module2.flags & 2048 /* GlobalAugmentation */);
}
function isExternalModuleAugmentation(node) {
  return isAmbientModule(node) && isModuleAugmentationExternal(node);
}
function isModuleAugmentationExternal(node) {
  switch (node.parent.kind) {
    case 307 /* SourceFile */:
      return isExternalModule(node.parent);
    case 268 /* ModuleBlock */:
      return isAmbientModule(node.parent.parent) && isSourceFile(node.parent.parent.parent) && !isExternalModule(node.parent.parent.parent);
  }
  return false;
}
function getNonAugmentationDeclaration(symbol) {
  var _a;
  return (_a = symbol.declarations) == null ? void 0 : _a.find((d) => !isExternalModuleAugmentation(d) && !(isModuleDeclaration(d) && isGlobalScopeAugmentation(d)));
}
function isCommonJSContainingModuleKind(kind) {
  return kind === 1 /* CommonJS */ || kind === 100 /* Node16 */ || kind === 199 /* NodeNext */;
}
function isEffectiveExternalModule(node, compilerOptions) {
  return isExternalModule(node) || isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator;
}
function isEffectiveStrictModeSourceFile(node, compilerOptions) {
  switch (node.scriptKind) {
    case 1 /* JS */:
    case 3 /* TS */:
    case 2 /* JSX */:
    case 4 /* TSX */:
      break;
    default:
      return false;
  }
  if (node.isDeclarationFile) {
    return false;
  }
  if (getStrictOptionValue(compilerOptions, "alwaysStrict")) {
    return true;
  }
  if (startsWithUseStrict(node.statements)) {
    return true;
  }
  if (isExternalModule(node) || getIsolatedModules(compilerOptions)) {
    return true;
  }
  return false;
}
function isAmbientPropertyDeclaration(node) {
  return !!(node.flags & 33554432 /* Ambient */) || hasSyntacticModifier(node, 128 /* Ambient */);
}
function isBlockScope(node, parentNode) {
  switch (node.kind) {
    case 307 /* SourceFile */:
    case 269 /* CaseBlock */:
    case 299 /* CatchClause */:
    case 267 /* ModuleDeclaration */:
    case 248 /* ForStatement */:
    case 249 /* ForInStatement */:
    case 250 /* ForOfStatement */:
    case 176 /* Constructor */:
    case 174 /* MethodDeclaration */:
    case 177 /* GetAccessor */:
    case 178 /* SetAccessor */:
    case 262 /* FunctionDeclaration */:
    case 218 /* FunctionExpression */:
    case 219 /* ArrowFunction */:
    case 172 /* PropertyDeclaration */:
    case 175 /* ClassStaticBlockDeclaration */:
      return true;
    case 241 /* Block */:
      return !isFunctionLikeOrClassStaticBlockDeclaration(parentNode);
  }
  return false;
}
function isDeclarationWithTypeParameters(node) {
  Debug.type(node);
  switch (node.kind) {
    case 338 /* JSDocCallbackTag */:
    case 346 /* JSDocTypedefTag */:
    case 323 /* JSDocSignature */:
      return true;
    default:
      assertType(node);
      return isDeclarationWithTypeParameterChildren(node);
  }
}
function isDeclarationWithTypeParameterChildren(node) {
  Debug.type(node);
  switch (node.kind) {
    case 179 /* CallSignature */:
    case 180 /* ConstructSignature */:
    case 173 /* MethodSignature */:
    case 181 /* IndexSignature */:
    case 184 /* FunctionType */:
    case 185 /* ConstructorType */:
    case 317 /* JSDocFunctionType */:
    case 263 /* ClassDeclaration */:
    case 231 /* ClassExpression */:
    case 264 /* InterfaceDeclaration */:
    case 265 /* TypeAliasDeclaration */:
    case 345 /* JSDocTemplateTag */:
    case 262 /* FunctionDeclaration */:
    case 174 /* MethodDeclaration */:
    case 176 /* Constructor */:
    case 177 /* GetAccessor */:
    case 178 /* SetAccessor */:
    case 218 /* FunctionExpression */:
    case 219 /* ArrowFunction */:
      return true;
    default:
      assertType(node);
      return false;
  }
}
function isAnyImportSyntax(node) {
  switch (node.kind) {
    case 272 /* ImportDeclaration */:
    case 271 /* ImportEqualsDeclaration */:
      return true;
    default:
      return false;
  }
}
function isAnyImportOrBareOrAccessedRequire(node) {
  return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
}
function isAnyImportOrRequireStatement(node) {
  return isAnyImportSyntax(node) || isRequireVariableStatement(node);
}
function isLateVisibilityPaintedStatement(node) {
  switch (node.kind) {
    case 272 /* ImportDeclaration */:
    case 271 /* ImportEqualsDeclaration */:
    case 243 /* VariableStatement */:
    case 263 /* ClassDeclaration */:
    case 262 /* FunctionDeclaration */:
    case 267 /* ModuleDeclaration */:
    case 265 /* TypeAliasDeclaration */:
    case 264 /* InterfaceDeclaration */:
    case 266 /* EnumDeclaration */:
      return true;
    default:
      return false;
  }
}
function hasPossibleExternalModuleReference(node) {
  return isAnyImportOrReExport(node) || isModuleDeclaration(node) || isImportTypeNode(node) || isImportCall(node);
}
function isAnyImportOrReExport(node) {
  return isAnyImportSyntax(node) || isExportDeclaration(node);
}
function getEnclosingContainer(node) {
  return findAncestor(node.parent, (n) => !!(getContainerFlags(n) & 1 /* IsContainer */));
}
function getEnclosingBlockScopeContainer(node) {
  return findAncestor(node.parent, (current) => isBlockScope(current, current.parent));
}
function forEachEnclosingBlockScopeContainer(node, cb) {
  let container = getEnclosingBlockScopeContainer(node);
  while (container) {
    cb(container);
    container = getEnclosingBlockScopeContainer(container);
  }
}
function declarationNameToString(name) {
  return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
}
function getNameFromIndexInfo(info) {
  return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : void 0;
}
function isComputedNonLiteralName(name) {
  return name.kind === 167 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression);
}
function tryGetTextOfPropertyName(name) {
  var _a;
  switch (name.kind) {
    case 80 /* Identifier */:
    case 81 /* PrivateIdentifier */:
      return ((_a = name.emitNode) == null ? void 0 : _a.autoGenerate) ? void 0 : name.escapedText;
    case 11 /* StringLiteral */:
    case 9 /* NumericLiteral */:
    case 10 /* BigIntLiteral */:
    case 15 /* NoSubstitutionTemplateLiteral */:
      return escapeLeadingUnderscores(name.text);
    case 167 /* ComputedPropertyName */:
      if (isStringOrNumericLiteralLike(name.expression)) return escapeLeadingUnderscores(name.expression.text);
      return void 0;
    case 295 /* JsxNamespacedName */:
      return getEscapedTextOfJsxNamespacedName(name);
    default:
      return Debug.assertNever(name);
  }
}
function getTextOfPropertyName(name) {
  return Debug.checkDefined(tryGetTextOfPropertyName(name));
}
function entityNameToString(name) {
  switch (name.kind) {
    case 110 /* ThisKeyword */:
      return "this";
    case 81 /* PrivateIdentifier */:
    case 80 /* Identifier */:
      return getFullWidth(name) === 0 ? idText(name) : getTextOfNode(name);
    case 166 /* QualifiedName */:
      return entityNameToString(name.left) + "." + entityNameToString(name.right);
    case 211 /* PropertyAccessExpression */:
      if (isIdentifier(name.name) || isPrivateIdentifier(name.name)) {
        return entityNameToString(name.expression) + "." + entityNameToString(name.name);
      } else {
        return Debug.assertNever(name.name);
      }
    case 311 /* JSDocMemberName */:
      return entityNameToString(name.left) + "#" + entityNameToString(name.right);
    case 295 /* JsxNamespacedName */:
      return entityNameToString(name.namespace) + ":" + entityNameToString(name.name);
    default:
      return Debug.assertNever(name);
  }
}
function createDiagnosticForNode(node, message, ...args) {
  const sourceFile = getSourceFileOfNode(node);
  return createDiagnosticForNodeInSourceFile(sourceFile, node, message, ...args);
}
function createDiagnosticForNodeArray(sourceFile, nodes, message, ...args) {
  const start = skipTrivia(sourceFile.text, nodes.pos);
  return createFileDiagnostic(sourceFile, start, nodes.end - start, message, ...args);
}
function createDiagnosticForNodeInSourceFile(sourceFile, node, message, ...args) {
  const span = getErrorSpanForNode(sourceFile, node);
  return createFileDiagnostic(sourceFile, span.start, span.length, message, ...args);
}
function createDiagnosticForNodeFromMessageChain(sourceFile, node, messageChain, relatedInformation) {
  const span = getErrorSpanForNode(sourceFile, node);
  return createFileDiagnosticFromMessageChain(sourceFile, span.start, span.length, messageChain, relatedInformation);
}
function createDiagnosticForNodeArrayFromMessageChain(sourceFile, nodes, messageChain, relatedInformation) {
  const start = skipTrivia(sourceFile.text, nodes.pos);
  return createFileDiagnosticFromMessageChain(sourceFile, start, nodes.end - start, messageChain, relatedInformation);
}
function assertDiagnosticLocation(sourceText, start, length2) {
  Debug.assertGreaterThanOrEqual(start, 0);
  Debug.assertGreaterThanOrEqual(length2, 0);
  Debug.assertLessThanOrEqual(start, sourceText.length);
  Debug.assertLessThanOrEqual(start + length2, sourceText.length);
}
function createFileDiagnosticFromMessageChain(file, start, length2, messageChain, relatedInformation) {
  assertDiagnosticLocation(file.text, start, length2);
  return {
    file,
    start,
    length: length2,
    code: messageChain.code,
    category: messageChain.category,
    messageText: messageChain.next ? messageChain : messageChain.messageText,
    relatedInformation,
    canonicalHead: messageChain.canonicalHead
  };
}
function createDiagnosticForFileFromMessageChain(sourceFile, messageChain, relatedInformation) {
  return {
    file: sourceFile,
    start: 0,
    length: 0,
    code: messageChain.code,
    category: messageChain.category,
    messageText: messageChain.next ? messageChain : messageChain.messageText,
    relatedInformation
  };
}
function createDiagnosticMessageChainFromDiagnostic(diagnostic) {
  return typeof diagnostic.messageText === "string" ? {
    code: diagnostic.code,
    category: diagnostic.category,
    messageText: diagnostic.messageText,
    next: diagnostic.next
  } : diagnostic.messageText;
}
function createDiagnosticForRange(sourceFile, range, message) {
  return {
    file: sourceFile,
    start: range.pos,
    length: range.end - range.pos,
    code: message.code,
    category: message.category,
    messageText: message.message
  };
}
function getCanonicalDiagnostic(message, ...args) {
  return {
    code: message.code,
    messageText: formatMessage(message, ...args)
  };
}
function getSpanOfTokenAtPosition(sourceFile, pos) {
  const scanner2 = createScanner(
    sourceFile.languageVersion,
    /*skipTrivia*/
    true,
    sourceFile.languageVariant,
    sourceFile.text,
    /*onError*/
    void 0,
    pos
  );
  scanner2.scan();
  const start = scanner2.getTokenStart();
  return createTextSpanFromBounds(start, scanner2.getTokenEnd());
}
function scanTokenAtPosition(sourceFile, pos) {
  const scanner2 = createScanner(
    sourceFile.languageVersion,
    /*skipTrivia*/
    true,
    sourceFile.languageVariant,
    sourceFile.text,
    /*onError*/
    void 0,
    pos
  );
  scanner2.scan();
  return scanner2.getToken();
}
function getErrorSpanForArrowFunction(sourceFile, node) {
  const pos = skipTrivia(sourceFile.text, node.pos);
  if (node.body && node.body.kind === 241 /* Block */) {
    const { line: startLine } = getLineAndCharacterOfPosition(sourceFile, node.body.pos);
    const { line: endLine } = getLineAndCharacterOfPosition(sourceFile, node.body.end);
    if (startLine < endLine) {
      return createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1);
    }
  }
  return createTextSpanFromBounds(pos, node.end);
}
function getErrorSpanForNode(sourceFile, node) {
  let errorNode = node;
  switch (node.kind) {
    case 307 /* SourceFile */: {
      const pos2 = skipTrivia(
        sourceFile.text,
        0,
        /*stopAfterLineBreak*/
        false
      );
      if (pos2 === sourceFile.text.length) {
        return createTextSpan(0, 0);
      }
      return getSpanOfTokenAtPosition(sourceFile, pos2);
    }
    // This list is a work in progress. Add missing node kinds to improve their error
    // spans.
    case 260 /* VariableDeclaration */:
    case 208 /* BindingElement */:
    case 263 /* ClassDeclaration */:
    case 231 /* ClassExpression */:
    case 264 /* InterfaceDeclaration */:
    case 267 /* ModuleDeclaration */:
    case 266 /* EnumDeclaration */:
    case 306 /* EnumMember */:
    case 262 /* FunctionDeclaration */:
    case 218 /* FunctionExpression */:
    case 174 /* MethodDeclaration */:
    case 177 /* GetAccessor */:
    case 178 /* SetAccessor */:
    case 265 /* TypeAliasDeclaration */:
    case 172 /* PropertyDeclaration */:
    case 171 /* PropertySignature */:
    case 274 /* NamespaceImport */:
      errorNode = node.name;
      break;
    case 219 /* ArrowFunction */:
      return getErrorSpanForArrowFunction(sourceFile, node);
    case 296 /* CaseClause */:
    case 297 /* DefaultClause */: {
      const start = skipTrivia(sourceFile.text, node.pos);
      const end = node.statements.length > 0 ? node.statements[0].pos : node.end;
      return createTextSpanFromBounds(start, end);
    }
    case 253 /* ReturnStatement */:
    case 229 /* YieldExpression */: {
      const pos2 = skipTrivia(sourceFile.text, node.pos);
      return getSpanOfTokenAtPosition(sourceFile, pos2);
    }
    case 238 /* SatisfiesExpression */: {
      const pos2 = skipTrivia(sourceFile.text, node.expression.end);
      return getSpanOfTokenAtPosition(sourceFile, pos2);
    }
    case 350 /* JSDocSatisfiesTag */: {
      const pos2 = skipTrivia(sourceFile.text, node.tagName.pos);
      return getSpanOfTokenAtPosition(sourceFile, pos2);
    }
    case 176 /* Constructor */: {
      const constructorDeclaration = node;
      const start = skipTrivia(sourceFile.text, constructorDeclaration.pos);
      const scanner2 = createScanner(
        sourceFile.languageVersion,
        /*skipTrivia*/
        true,
        sourceFile.languageVariant,
        sourceFile.text,
        /*onError*/
        void 0,
        start
      );
      let token = scanner2.scan();
      while (token !== 137 /* ConstructorKeyword */ && token !== 1 /* EndOfFileToken */) {
        token = scanner2.scan();
      }
      const end = scanner2.getTokenEnd();
      return createTextSpanFromBounds(start, end);
    }
  }
  if (errorNode === void 0) {
    return getSpanOfTokenAtPosition(sourceFile, node.pos);
  }
  Debug.assert(!isJSDoc(errorNode));
  const isMissing = nodeIsMissing(errorNode);
  const pos = isMissing || isJsxText(node) ? errorNode.pos : skipTrivia(sourceFile.text, errorNode.pos);
  if (isMissing) {
    Debug.assert(pos === errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
    Debug.assert(pos === errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
  } else {
    Debug.assert(pos >= errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
    Debug.assert(pos <= errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
  }
  return createTextSpanFromBounds(pos, errorNode.end);
}
function isGlobalSourceFile(node) {
  return node.kind === 307 /* SourceFile */ && !isExternalOrCommonJsModule(node);
}
function isExternalOrCommonJsModule(file) {
  return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== void 0;
}
function isJsonSourceFile(file) {
  return file.scriptKind === 6 /* JSON */;
}
function isEnumConst(node) {
  return !!(getCombinedModifierFlags(node) & 4096 /* Const */);
}
function isDeclarationReadonly(declaration) {
  return !!(getCombinedModifierFlags(declaration) & 8 /* Readonly */ && !isParameterPropertyDeclaration(declaration, declaration.parent));
}
function isVarAwaitUsing(node) {
  return (getCombinedNodeFlags(node) & 7 /* BlockScoped */) === 6 /* AwaitUsing */;
}
function isVarUsing(node) {
  return (getCombinedNodeFlags(node) & 7 /* BlockScoped */) === 4 /* Using */;
}
function isVarConst(node) {
  return (getCombinedNodeFlags(node) & 7 /* BlockScoped */) === 2 /* Const */;
}
function isVarConstLike(node) {
  const blockScopeKind = getCombinedNodeFlags(node) & 7 /* BlockScoped */;
  return blockScopeKind === 2 /* Const */ || blockScopeKind === 4 /* Using */ || blockScopeKind === 6 /* AwaitUsing */;
}
function isLet(node) {
  return (getCombinedNodeFlags(node) & 7 /* BlockScoped */) === 1 /* Let */;
}
function isSuperCall(n) {
  return n.kind === 213 /* CallExpression */ && n.expression.kind === 108 /* SuperKeyword */;
}
function isImportCall(n) {
  return n.kind === 213 /* CallExpression */ && n.expression.kind === 102 /* ImportKeyword */;
}
function isImportMeta(n) {
  return isMetaProperty(n) && n.keywordToken === 102 /* ImportKeyword */ && n.name.escapedText === "meta";
}
function isLiteralImportTypeNode(n) {
  return isImportTypeNode(n) && isLiteralTypeNode(n.argument) && isStringLiteral(n.argument.literal);
}
function isPrologueDirective(node) {
  return node.kind === 244 /* ExpressionStatement */ && node.expression.kind === 11 /* StringLiteral */;
}
function isCustomPrologue(node) {
  return !!(getEmitFlags(node) & 2097152 /* CustomPrologue */);
}
function isHoistedFunction(node) {
  return isCustomPrologue(node) && isFunctionDeclaration(node);
}
function isHoistedVariable(node) {
  return isIdentifier(node.name) && !node.initializer;
}
function isHoistedVariableStatement(node) {
  return isCustomPrologue(node) && isVariableStatement(node) && every(node.declarationList.declarations, isHoistedVariable);
}
function getLeadingCommentRangesOfNode(node, sourceFileOfNode) {
  return node.kind !== 12 /* JsxText */ ? getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : void 0;
}
function getJSDocCommentRanges(node, text) {
  const commentRanges = node.kind === 169 /* Parameter */ || node.kind === 168 /* TypeParameter */ || node.kind === 218 /* FunctionExpression */ || node.kind === 219 /* ArrowFunction */ || node.kind === 217 /* ParenthesizedExpression */ || node.kind === 260 /* VariableDeclaration */ || node.kind === 281 /* ExportSpecifier */ ? concatenate(getTrailingCommentRanges(text, node.pos), getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRanges(text, node.pos);
  return filter(commentRanges, (comment) => comment.end <= node.end && // Due to parse errors sometime empty parameter may get comments assigned to it that end up not in parameter range
  text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && text.charCodeAt(comment.pos + 3) !== 47 /* slash */);
}
var fullTripleSlashReferencePathRegEx = /^\/\/\/\s*<reference\s+path\s*=\s*(?:'[^']*'|"[^"]*").*?\/>/;
var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^\/\/\/\s*<reference\s+types\s*=\s*(?:'[^']*'|"[^"]*").*?\/>/;
var fullTripleSlashLibReferenceRegEx = /^\/\/\/\s*<reference\s+lib\s*=\s*(?:'[^']*'|"[^"]*").*?\/>/;
var fullTripleSlashAMDReferencePathRegEx = /^\/\/\/\s*<amd-dependency\s+path\s*=\s*(?:'[^']*'|"[^"]*").*?\/>/;
var fullTripleSlashAMDModuleRegEx = /^\/\/\/\s*<amd-module\s+(?:\S.*?)??\/>/;
var defaultLibReferenceRegEx = /^\/\/\/\s*<reference\s+no-default-lib\s*=\s*(?:'[^']*'|"[^"]*")\s*\/>/;
function isPartOfTypeNode(node) {
  if (182 /* FirstTypeNode */ <= node.kind && node.kind <= 205 /* LastTypeNode */) {
    return true;
  }
  switch (node.kind) {
    case 133 /* AnyKeyword */:
    case 159 /* UnknownKeyword */:
    case 150 /* NumberKeyword */:
    case 163 /* BigIntKeyword */:
    case 154 /* StringKeyword */:
    case 136 /* BooleanKeyword */:
    case 155 /* SymbolKeyword */:
    case 151 /* ObjectKeyword */:
    case 157 /* UndefinedKeyword */:
    case 106 /* NullKeyword */:
    case 146 /* NeverKeyword */:
      return true;
    case 116 /* VoidKeyword */:
      return node.parent.kind !== 222 /* VoidExpression */;
    case 233 /* ExpressionWithTypeArguments */:
      return isPartOfTypeExpressionWithTypeArguments(node);
    case 168 /* TypeParameter */:
      return node.parent.kind === 200 /* MappedType */ || node.parent.kind === 195 /* InferType */;
    // Identifiers and qualified names may be type nodes, depending on their context. Climb
    // above them to find the lowest container
    case 80 /* Identifier */:
      if (node.parent.kind === 166 /* QualifiedName */ && node.parent.right === node) {
        node = node.parent;
      } else if (node.parent.kind === 211 /* PropertyAccessExpression */ && node.parent.name === node) {
        node = node.parent;
      }
      Debug.assert(node.kind === 80 /* Identifier */ || node.kind === 166 /* QualifiedName */ || node.kind === 211 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'.");
    // falls through
    case 166 /* QualifiedName */:
    case 211 /* PropertyAccessExpression */:
    case 110 /* ThisKeyword */: {
      const { parent: parent2 } = node;
      if (parent2.kind === 186 /* TypeQuery */) {
        return false;
      }
      if (parent2.kind === 205 /* ImportType */) {
        return !parent2.isTypeOf;
      }
      if (182 /* FirstTypeNode */ <= parent2.kind && parent2.kind <= 205 /* LastTypeNode */) {
        return true;
      }
      switch (parent2.kind) {
        case 233 /* ExpressionWithTypeArguments */:
          return isPartOfTypeExpressionWithTypeArguments(parent2);
        case 168 /* TypeParameter */:
          return node === parent2.constraint;
        case 345 /* JSDocTemplateTag */:
          return node === parent2.constraint;
        case 172 /* PropertyDeclaration */:
        case 171 /* PropertySignature */:
        case 169 /* Parameter */:
        case 260 /* VariableDeclaration */:
          return node === parent2.type;
        case 262 /* FunctionDeclaration */:
        case 218 /* FunctionExpression */:
        case 219 /* ArrowFunction */:
        case 176 /* Constructor */:
        case 174 /* MethodDeclaration */:
        case 173 /* MethodSignature */:
        case 177 /* GetAccessor */:
        case 178 /* SetAccessor */:
          return node === parent2.type;
        case 179 /* CallSignature */:
        case 180 /* ConstructSignature */:
        case 181 /* IndexSignature */:
          return node === parent2.type;
        case 216 /* TypeAssertionExpression */:
          return node === parent2.type;
        case 213 /* CallExpression */:
        case 214 /* NewExpression */:
        case 215 /* TaggedTemplateExpression */:
          return contains(parent2.typeArguments, node);
      }
    }
  }
  return false;
}
function isPartOfTypeExpressionWithTypeArguments(node) {
  return isJSDocImplementsTag(node.parent) || isJSDocAugmentsTag(node.parent) || isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
}
function forEachReturnStatement(body, visitor) {
  return traverse(body);
  function traverse(node) {
    switch (node.kind) {
      case 253 /* ReturnStatement */:
        return visitor(node);
      case 269 /* CaseBlock */:
      case 241 /* Block */:
      case 245 /* IfStatement */:
      case 246 /* DoStatement */:
      case 247 /* WhileStatement */:
      case 248 /* ForStatement */:
      case 249 /* ForInStatement */:
      case 250 /* ForOfStatement */:
      case 254 /* WithStatement */:
      case 255 /* SwitchStatement */:
      case 296 /* CaseClause */:
      case 297 /* DefaultClause */:
      case 256 /* LabeledStatement */:
      case 258 /* TryStatement */:
      case 299 /* CatchClause */:
        return forEachChild(node, traverse);
    }
  }
}
function forEachYieldExpression(body, visitor) {
  return traverse(body);
  function traverse(node) {
    switch (node.kind) {
      case 229 /* YieldExpression */:
        visitor(node);
        const operand = node.expression;
        if (operand) {
          traverse(operand);
        }
        return;
      case 266 /* EnumDeclaration */:
      case 264 /* InterfaceDeclaration */:
      case 267 /* ModuleDeclaration */:
      case 265 /* TypeAliasDeclaration */:
        return;
      default:
        if (isFunctionLike(node)) {
          if (node.name && node.name.kind === 167 /* ComputedPropertyName */) {
            traverse(node.name.expression);
            return;
          }
        } else if (!isPartOfTypeNode(node)) {
          forEachChild(node, traverse);
        }
    }
  }
}
function getRestParameterElementType(node) {
  if (node && node.kind === 188 /* ArrayType */) {
    return node.elementType;
  } else if (node && node.kind === 183 /* TypeReference */) {
    return singleOrUndefined(node.typeArguments);
  } else {
    return void 0;
  }
}
function getMembersOfDeclaration(node) {
  switch (node.kind) {
    case 264 /* InterfaceDeclaration */:
    case 263 /* ClassDeclaration */:
    case 231 /* ClassExpression */:
    case 187 /* TypeLiteral */:
      return node.members;
    case 210 /* ObjectLiteralExpression */:
      return node.properties;
  }
}
function isVariableLike(node) {
  if (node) {
    switch (node.kind) {
      case 208 /* BindingElement */:
      case 306 /* EnumMember */:
      case 169 /* Parameter */:
      case 303 /* PropertyAssignment */:
      case 172 /* PropertyDeclaration */:
      case 171 /* PropertySignature */:
      case 304 /* ShorthandPropertyAssignment */:
      case 260 /* VariableDeclaration */:
        return true;
    }
  }
  return false;
}
function isVariableDeclarationInVariableStatement(node) {
  return node.parent.kind === 261 /* VariableDeclarationList */ && node.parent.parent.kind === 243 /* VariableStatement */;
}
function isCommonJsExportedExpression(node) {
  if (!isInJSFile(node)) return false;
  return isObjectLiteralExpression(node.parent) && isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */ || isCommonJsExportPropertyAssignment(node.parent);
}
function isCommonJsExportPropertyAssignment(node) {
  if (!isInJSFile(node)) return false;
  return isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */;
}
function isValidESSymbolDeclaration(node) {
  return (isVariableDeclaration(node) ? isVarConst(node) && isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : isPropertyDeclaration(node) ? hasEffectiveReadonlyModifier(node) && hasStaticModifier(node) : isPropertySignature(node) && hasEffectiveReadonlyModifier(node)) || isCommonJsExportPropertyAssignment(node);
}
function introducesArgumentsExoticObject(node) {
  switch (node.kind) {
    case 174 /* MethodDeclaration */:
    case 173 /* MethodSignature */:
    case 176 /* Constructor */:
    case 177 /* GetAccessor */:
    case 178 /* SetAccessor */:
    case 262 /* FunctionDeclaration */:
    case 218 /* FunctionExpression */:
      return true;
  }
  return false;
}
function unwrapInnermostStatementOfLabel(node, beforeUnwrapLabelCallback) {
  while (true) {
    if (beforeUnwrapLabelCallback) {
      beforeUnwrapLabelCallback(node);
    }
    if (node.statement.kind !== 256 /* LabeledStatement */) {
      return node.statement;
    }
    node = node.statement;
  }
}
function isFunctionBlock(node) {
  return node && node.kind === 241 /* Block */ && isFunctionLike(node.parent);
}
function isObjectLiteralMethod(node) {
  return node && node.kind === 174 /* MethodDeclaration */ && node.parent.kind === 210 /* ObjectLiteralExpression */;
}
function isObjectLiteralOrClassExpressionMethodOrAccessor(node) {
  return (node.kind === 174 /* MethodDeclaration */ || node.kind === 177 /* GetAccessor */ || node.kind === 178 /* SetAccessor */) && (node.parent.kind === 210 /* ObjectLiteralExpression */ || node.parent.kind === 231 /* ClassExpression */);
}
function isIdentifierTypePredicate(predicate) {
  return predicate && predicate.kind === 1 /* Identifier */;
}
function isThisTypePredicate(predicate) {
  return predicate && predicate.kind === 0 /* This */;
}
function forEachPropertyAssignment(objectLiteral, key, callback, key2) {
  return forEach(objectLiteral == null ? void 0 : objectLiteral.properties, (property) => {
    if (!isPropertyAssignment(property)) return void 0;
    const propName = tryGetTextOfPropertyName(property.name);
    return key === propName || key2 && key2 === propName ? callback(property) : void 0;
  });
}
function getPropertyArrayElementValue(objectLiteral, propKey, elementValue) {
  return forEachPropertyAssignment(objectLiteral, propKey, (property) => isArrayLiteralExpression(property.initializer) ? find(property.initializer.elements, (element) => isStringLiteral(element) && element.text === elementValue) : void 0);
}
function getTsConfigObjectLiteralExpression(tsConfigSourceFile) {
  if (tsConfigSourceFile && tsConfigSourceFile.statements.length) {
    const expression = tsConfigSourceFile.statements[0].expression;
    return tryCast(expression, isObjectLiteralExpression);
  }
}
function getTsConfigPropArrayElementValue(tsConfigSourceFile, propKey, elementValue) {
  return forEachTsConfigPropArray(tsConfigSourceFile, propKey, (property) => isArrayLiteralExpression(property.initializer) ? find(property.initializer.elements, (element) => isStringLiteral(element) && element.text === elementValue) : void 0);
}
function forEachTsConfigPropArray(tsConfigSourceFile, propKey, callback) {
  return forEachPropertyAssignment(getTsConfigObjectLiteralExpression(tsConfigSourceFile), propKey, callback);
}
function getContainingFunction(node) {
  return findAncestor(node.parent, isFunctionLike);
}
function getContainingFunctionDeclaration(node) {
  return findAncestor(node.parent, isFunctionLikeDeclaration);
}
function getContainingClass(node) {
  return findAncestor(node.parent, isClassLike);
}
function getContainingClassStaticBlock(node) {
  return findAncestor(node.parent, (n) => {
    if (isClassLike(n) || isFunctionLike(n)) {
      return "quit";
    }
    return isClassStaticBlockDeclaration(n);
  });
}
function getContainingFunctionOrClassStaticBlock(node) {
  return findAncestor(node.parent, isFunctionLikeOrClassStaticBlockDeclaration);
}
function getContainingClassExcludingClassDecorators(node) {
  const decorator = findAncestor(node.parent, (n) => isClassLike(n) ? "quit" : isDecorator(n));
  return decorator && isClassLike(decorator.parent) ? getContainingClass(decorator.parent) : getContainingClass(decorator ?? node);
}
function getThisContainer(node, includeArrowFunctions, includeClassComputedPropertyName) {
  Debug.assert(node.kind !== 307 /* SourceFile */);
  while (true) {
    node = node.parent;
    if (!node) {
      return Debug.fail();
    }
    switch (node.kind) {
      case 167 /* ComputedPropertyName */:
        if (includeClassComputedPropertyName && isClassLike(node.parent.parent)) {
          return node;
        }
        node = node.parent.parent;
        break;
      case 170 /* Decorator */:
        if (node.parent.kind === 169 /* Parameter */ && isClassElement(node.parent.parent)) {
          node = node.parent.parent;
        } else if (isClassElement(node.parent)) {
          node = node.parent;
        }
        break;
      case 219 /* ArrowFunction */:
        if (!includeArrowFunctions) {
          continue;
        }
      // falls through
      case 262 /* FunctionDeclaration */:
      case 218 /* FunctionExpression */:
      case 267 /* ModuleDeclaration */:
      case 175 /* ClassStaticBlockDeclaration */:
      case 172 /* PropertyDeclaration */:
      case 171 /* PropertySignature */:
      case 174 /* MethodDeclaration */:
      case 173 /* MethodSignature */:
      case 176 /* Constructor */:
      case 177 /* GetAccessor */:
      case 178 /* SetAccessor */:
      case 179 /* CallSignature */:
      case 180 /* ConstructSignature */:
      case 181 /* IndexSignature */:
      case 266 /* EnumDeclaration */:
      case 307 /* SourceFile */:
        return node;
    }
  }
}
function isThisContainerOrFunctionBlock(node) {
  switch (node.kind) {
    // Arrow functions use the same scope, but may do so in a "delayed" manner
    // For example, `const getThis = () => this` may be before a super() call in a derived constructor
    case 219 /* ArrowFunction */:
    case 262 /* FunctionDeclaration */:
    case 218 /* FunctionExpression */:
    case 172 /* PropertyDeclaration */:
      return true;
    case 241 /* Block */:
      switch (node.parent.kind) {
        case 176 /* Constructor */:
        case 174 /* MethodDeclaration */:
        case 177 /* GetAccessor */:
        case 178 /* SetAccessor */:
          return true;
        default:
          return false;
      }
    default:
      return false;
  }
}
function isInTopLevelContext(node) {
  if (isIdentifier(node) && (isClassDeclaration(node.parent) || isFunctionDeclaration(node.parent)) && node.parent.name === node) {
    node = node.parent;
  }
  const container = getThisContainer(
    node,
    /*includeArrowFunctions*/
    true,
    /*includeClassComputedPropertyName*/
    false
  );
  return isSourceFile(container);
}
function getNewTargetContainer(node) {
  const container = getThisContainer(
    node,
    /*includeArrowFunctions*/
    false,
    /*includeClassComputedPropertyName*/
    false
  );
  if (container) {
    switch (container.kind) {
      case 176 /* Constructor */:
      case 262 /* FunctionDeclaration */:
      case 218 /* FunctionExpression */:
        return container;
    }
  }
  return void 0;
}
function getSuperContainer(node, stopOnFunctions) {
  while (true) {
    node = node.parent;
    if (!node) {
      return void 0;
    }
    switch (node.kind) {
      case 167 /* ComputedPropertyName */:
        node = node.parent;
        break;
      case 262 /* FunctionDeclaration */:
      case 218 /* FunctionExpression */:
      case 219 /* ArrowFunction */:
        if (!stopOnFunctions) {
          continue;
        }
      // falls through
      case 172 /* PropertyDeclaration */:
      case 171 /* PropertySignature */:
      case 174 /* MethodDeclaration */:
      case 173 /* MethodSignature */:
      case 176 /* Constructor */:
      case 177 /* GetAccessor */:
      case 178 /* SetAccessor */:
      case 175 /* ClassStaticBlockDeclaration */:
        return node;
      case 170 /* Decorator */:
        if (node.parent.kind === 169 /* Parameter */ && isClassElement(node.parent.parent)) {
          node = node.parent.parent;
        } else if (isClassElement(node.parent)) {
          node = node.parent;
        }
        break;
    }
  }
}
function getImmediatelyInvokedFunctionExpression(func) {
  if (func.kind === 218 /* FunctionExpression */ || func.kind === 219 /* ArrowFunction */) {
    let prev = func;
    let parent2 = func.parent;
    while (parent2.kind === 217 /* ParenthesizedExpression */) {
      prev = parent2;
      parent2 = parent2.parent;
    }
    if (parent2.kind === 213 /* CallExpression */ && parent2.expression === prev) {
      return parent2;
    }
  }
}
function isSuperProperty(node) {
  const kind = node.kind;
  return (kind === 211 /* PropertyAccessExpression */ || kind === 212 /* ElementAccessExpression */) && node.expression.kind === 108 /* SuperKeyword */;
}
function isThisProperty(node) {
  const kind = node.kind;
  return (kind === 211 /* PropertyAccessExpression */ || kind === 212 /* ElementAccessExpression */) && node.expression.kind === 110 /* ThisKeyword */;
}
function isThisInitializedDeclaration(node) {
  var _a;
  return !!node && isVariableDeclaration(node) && ((_a = node.initializer) == null ? void 0 : _a.kind) === 110 /* ThisKeyword */;
}
function isThisInitializedObjectBindingExpression(node) {
  return !!node && (isShorthandPropertyAssignment(node) || isPropertyAssignment(node)) && isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 64 /* EqualsToken */ && node.parent.parent.right.kind === 110 /* ThisKeyword */;
}
function getEntityNameFromTypeNode(node) {
  switch (node.kind) {
    case 183 /* TypeReference */:
      return node.typeName;
    case 233 /* ExpressionWithTypeArguments */:
      return isEntityNameExpression(node.expression) ? node.expression : void 0;
    // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s.
    case 80 /* Identifier */:
    case 166 /* QualifiedName */:
      return node;
  }
  return void 0;
}
function getInvokedExpression(node) {
  switch (node.kind) {
    case 215 /* TaggedTemplateExpression */:
      return node.tag;
    case 286 /* JsxOpeningElement */:
    case 285 /* JsxSelfClosingElement */:
      return node.tagName;
    case 226 /* BinaryExpression */:
      return node.right;
    case 289 /* JsxOpeningFragment */:
      return node;
    default:
      return node.expression;
  }
}
function nodeCanBeDecorated(useLegacyDecorators, node, parent2, grandparent) {
  if (useLegacyDecorators && isNamedDeclaration(node) && isPrivateIdentifier(node.name)) {
    return false;
  }
  switch (node.kind) {
    case 263 /* ClassDeclaration */:
      return true;
    case 231 /* ClassExpression */:
      return !useLegacyDecorators;
    case 172 /* PropertyDeclaration */:
      return parent2 !== void 0 && (useLegacyDecorators ? isClassDeclaration(parent2) : isClassLike(parent2) && !hasAbstractModifier(node) && !hasAmbientModifier(node));
    case 177 /* GetAccessor */:
    case 178 /* SetAccessor */:
    case 174 /* MethodDeclaration */:
      return node.body !== void 0 && parent2 !== void 0 && (useLegacyDecorators ? isClassDeclaration(parent2) : isClassLike(parent2));
    case 169 /* Parameter */:
      if (!useLegacyDecorators) return false;
      return parent2 !== void 0 && parent2.body !== void 0 && (parent2.kind === 176 /* Constructor */ || parent2.kind === 174 /* MethodDeclaration */ || parent2.kind === 178 /* SetAccessor */) && getThisParameter(parent2) !== node && grandparent !== void 0 && grandparent.kind === 263 /* ClassDeclaration */;
  }
  return false;
}
function nodeIsDecorated(useLegacyDecorators, node, parent2, grandparent) {
  return hasDecorators(node) && nodeCanBeDecorated(useLegacyDecorators, node, parent2, grandparent);
}
function nodeOrChildIsDecorated(useLegacyDecorators, node, parent2, grandparent) {
  return nodeIsDecorated(useLegacyDecorators, node, parent2, grandparent) || childIsDecorated(useLegacyDecorators, node, parent2);
}
function childIsDecorated(useLegacyDecorators, node, parent2) {
  switch (node.kind) {
    case 263 /* ClassDeclaration */:
      return some(node.members, (m) => nodeOrChildIsDecorated(useLegacyDecorators, m, node, parent2));
    case 231 /* ClassExpression */:
      return !useLegacyDecorators && some(node.members, (m) => nodeOrChildIsDecorated(useLegacyDecorators, m, node, parent2));
    case 174 /* MethodDeclaration */:
    case 178 /* SetAccessor */:
    case 176 /* Constructor */:
      return some(node.parameters, (p) => nodeIsDecorated(useLegacyDecorators, p, node, parent2));
    default:
      return false;
  }
}
function classOrConstructorParameterIsDecorated(useLegacyDecorators, node) {
  if (nodeIsDecorated(useLegacyDecorators, node)) return true;
  const constructor = getFirstConstructorWithBody(node);
  return !!constructor && childIsDecorated(useLegacyDecorators, constructor, node);
}
function classElementOrClassElementParameterIsDecorated(useLegacyDecorators, node, parent2) {
  let parameters;
  if (isAccessor(node)) {
    const { firstAccessor, secondAccessor, setAccessor } = getAllAccessorDeclarations(parent2.members, node);
    const firstAccessorWithDecorators = hasDecorators(firstAccessor) ? firstAccessor : secondAccessor && hasDecorators(secondAccessor) ? secondAccessor : void 0;
    if (!firstAccessorWithDecorators || node !== firstAccessorWithDecorators) {
      return false;
    }
    parameters = setAccessor == null ? void 0 : setAccessor.parameters;
  } else if (isMethodDeclaration(node)) {
    parameters = node.parameters;
  }
  if (nodeIsDecorated(useLegacyDecorators, node, parent2)) {
    return true;
  }
  if (parameters) {
    for (const parameter of parameters) {
      if (parameterIsThisKeyword(parameter)) continue;
      if (nodeIsDecorated(useLegacyDecorators, parameter, node, parent2)) return true;
    }
  }
  return false;
}
function isEmptyStringLiteral(node) {
  if (node.textSourceNode) {
    switch (node.textSourceNode.kind) {
      case 11 /* StringLiteral */:
        return isEmptyStringLiteral(node.textSourceNode);
      case 15 /* NoSubstitutionTemplateLiteral */:
        return node.text === "";
    }
    return false;
  }
  return node.text === "";
}
function isJSXTagName(node) {
  const { parent: parent2 } = node;
  if (parent2.kind === 286 /* JsxOpeningElement */ || parent2.kind === 285 /* JsxSelfClosingElement */ || parent2.kind === 287 /* JsxClosingElement */) {
    return parent2.tagName === node;
  }
  return false;
}
function isExpressionNode(node) {
  switch (node.kind) {
    case 108 /* SuperKeyword */:
    case 106 /* NullKeyword */:
    case 112 /* TrueKeyword */:
    case 97 /* FalseKeyword */:
    case 14 /* RegularExpressionLiteral */:
    case 209 /* ArrayLiteralExpression */:
    case 210 /* ObjectLiteralExpression */:
    case 211 /* PropertyAccessExpression */:
    case 212 /* ElementAccessExpression */:
    case 213 /* CallExpression */:
    case 214 /* NewExpression */:
    case 215 /* TaggedTemplateExpression */:
    case 234 /* AsExpression */:
    case 216 /* TypeAssertionExpression */:
    case 238 /* SatisfiesExpression */:
    case 235 /* NonNullExpression */:
    case 217 /* ParenthesizedExpression */:
    case 218 /* FunctionExpression */:
    case 231 /* ClassExpression */:
    case 219 /* ArrowFunction */:
    case 222 /* VoidExpression */:
    case 220 /* DeleteExpression */:
    case 221 /* TypeOfExpression */:
    case 224 /* PrefixUnaryExpression */:
    case 225 /* PostfixUnaryExpression */:
    case 226 /* BinaryExpression */:
    case 227 /* ConditionalExpression */:
    case 230 /* SpreadElement */:
    case 228 /* TemplateExpression */:
    case 232 /* OmittedExpression */:
    case 284 /* JsxElement */:
    case 285 /* JsxSelfClosingElement */:
    case 288 /* JsxFragment */:
    case 229 /* YieldExpression */:
    case 223 /* AwaitExpression */:
    case 236 /* MetaProperty */:
      return true;
    case 233 /* ExpressionWithTypeArguments */:
      return !isHeritageClause(node.parent) && !isJSDocAugmentsTag(node.parent);
    case 166 /* QualifiedName */:
      while (node.parent.kind === 166 /* QualifiedName */) {
        node = node.parent;
      }
      return node.parent.kind === 186 /* TypeQuery */ || isJSDocLinkLike(node.parent) || isJSDocNameReference(node.parent) || isJSDocMemberName(node.parent) || isJSXTagName(node);
    case 311 /* JSDocMemberName */:
      while (isJSDocMemberName(node.parent)) {
        node = node.parent;
      }
      return node.parent.kind === 186 /* TypeQuery */ || isJSDocLinkLike(node.parent) || isJSDocNameReference(node.parent) || isJSDocMemberName(node.parent) || isJSXTagName(node);
    case 81 /* PrivateIdentifier */:
      return isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 103 /* InKeyword */;
    case 80 /* Identifier */:
      if (node.parent.kind === 186 /* TypeQuery */ || isJSDocLinkLike(node.parent) || isJSDocNameReference(node.parent) || isJSDocMemberName(node.parent) || isJSXTagName(node)) {
        return true;
      }
    // falls through
    case 9 /* NumericLiteral */:
    case 10 /* BigIntLiteral */:
    case 11 /* StringLiteral */:
    case 15 /* NoSubstitutionTemplateLiteral */:
    case 110 /* ThisKeyword */:
      return isInExpressionContext(node);
    default:
      return false;
  }
}
function isInExpressionContext(node) {
  const { parent: parent2 } = node;
  switch (parent2.kind) {
    case 260 /* VariableDeclaration */:
    case 169 /* Parameter */:
    case 172 /* PropertyDeclaration */:
    case 171 /* PropertySignature */:
    case 306 /* EnumMember */:
    case 303 /* PropertyAssignment */:
    case 208 /* BindingElement */:
      return parent2.initializer === node;
    case 244 /* ExpressionStatement */:
    case 245 /* IfStatement */:
    case 246 /* DoStatement */:
    case 247 /* WhileStatement */:
    case 253 /* ReturnStatement */:
    case 254 /* WithStatement */:
    case 255 /* SwitchStatement */:
    case 296 /* CaseClause */:
    case 257 /* ThrowStatement */:
      return parent2.expression === node;
    case 248 /* ForStatement */:
      const forStatement = parent2;
      return forStatement.initializer === node && forStatement.initializer.kind !== 261 /* VariableDeclarationList */ || forStatement.condition === node || forStatement.incrementor === node;
    case 249 /* ForInStatement */:
    case 250 /* ForOfStatement */:
      const forInOrOfStatement = parent2;
      return forInOrOfStatement.initializer === node && forInOrOfStatement.initializer.kind !== 261 /* VariableDeclarationList */ || forInOrOfStatement.expression === node;
    case 216 /* TypeAssertionExpression */:
    case 234 /* AsExpression */:
      return node === parent2.expression;
    case 239 /* TemplateSpan */:
      return node === parent2.expression;
    case 167 /* ComputedPropertyName */:
      return node === parent2.expression;
    case 170 /* Decorator */:
    case 294 /* JsxExpression */:
    case 293 /* JsxSpreadAttribute */:
    case 305 /* SpreadAssignment */:
      return true;
    case 233 /* ExpressionWithTypeArguments */:
      return parent2.expression === node && !isPartOfTypeNode(parent2);
    case 304 /* ShorthandPropertyAssignment */:
      return parent2.objectAssignmentInitializer === node;
    case 238 /* SatisfiesExpression */:
      return node === parent2.expression;
    default:
      return isExpressionNode(parent2);
  }
}
function isPartOfTypeQuery(node) {
  while (node.kind === 166 /* QualifiedName */ || node.kind === 80 /* Identifier */) {
    node = node.parent;
  }
  return node.kind === 186 /* TypeQuery */;
}
function isNamespaceReexportDeclaration(node) {
  return isNamespaceExport(node) && !!node.parent.moduleSpecifier;
}
function isExternalModuleImportEqualsDeclaration(node) {
  return node.kind === 271 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 283 /* ExternalModuleReference */;
}
function getExternalModuleImportEqualsDeclarationExpression(node) {
  Debug.assert(isExternalModuleImportEqualsDeclaration(node));
  return node.moduleReference.expression;
}
function getExternalModuleRequireArgument(node) {
  return isVariableDeclarationInitializedToBareOrAccessedRequire(node) && getLeftmostAccessExpression(node.initializer).arguments[0];
}
function isInternalModuleImportEqualsDeclaration(node) {
  return node.kind === 271 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 283 /* ExternalModuleReference */;
}
function isFullSourceFile(sourceFile) {
  return (sourceFile == null ? void 0 : sourceFile.kind) === 307 /* SourceFile */;
}
function isSourceFileJS(file) {
  return isInJSFile(file);
}
function isInJSFile(node) {
  return !!node && !!(node.flags & 524288 /* JavaScriptFile */);
}
function isInJsonFile(node) {
  return !!node && !!(node.flags & 134217728 /* JsonFile */);
}
function isSourceFileNotJson(file) {
  return !isJsonSourceFile(file);
}
function isInJSDoc(node) {
  return !!node && !!(node.flags & 16777216 /* JSDoc */);
}
function isJSDocIndexSignature(node) {
  return isTypeReferenceNode(node) && isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && (node.typeArguments[0].kind === 154 /* StringKeyword */ || node.typeArguments[0].kind === 150 /* NumberKeyword */);
}
function isRequireCall(callExpression, requireStringLiteralLikeArgument) {
  if (callExpression.kind !== 213 /* CallExpression */) {
    return false;
  }
  const { expression, arguments: args } = callExpression;
  if (expression.kind !== 80 /* Identifier */ || expression.escapedText !== "require") {
    return false;
  }
  if (args.length !== 1) {
    return false;
  }
  const arg = args[0];
  return !requireStringLiteralLikeArgument || isStringLiteralLike(arg);
}
function isVariableDeclarationInitializedToRequire(node) {
  return isVariableDeclarationInitializedWithRequireHelper(
    node,
    /*allowAccessedRequire*/
    false
  );
}
function isVariableDeclarationInitializedToBareOrAccessedRequire(node) {
  return isVariableDeclarationInitializedWithRequireHelper(
    node,
    /*allowAccessedRequire*/
    true
  );
}
function isBindingElementOfBareOrAccessedRequire(node) {
  return isBindingElement(node) && isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
}
function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
  return isVariableDeclaration(node) && !!node.initializer && isRequireCall(
    allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer,
    /*requireStringLiteralLikeArgument*/
    true
  );
}
function isRequireVariableStatement(node) {
  return isVariableStatement(node) && node.declarationList.declarations.length > 0 && every(node.declarationList.declarations, (decl) => isVariableDeclarationInitializedToRequire(decl));
}
function isSingleOrDoubleQuote(charCode) {
  return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */;
}
function isStringDoubleQuoted(str, sourceFile) {
  return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */;
}
function isAssignmentDeclaration(decl) {
  return isBinaryExpression(decl) || isAccessExpression(decl) || isIdentifier(decl) || isCallExpression(decl);
}
function getEffectiveInitializer(node) {
  if (isInJSFile(node) && node.initializer && isBinaryExpression(node.initializer) && (node.initializer.operatorToken.kind === 57 /* BarBarToken */ || node.initializer.operatorToken.kind === 61 /* QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) {
    return node.initializer.right;
  }
  return node.initializer;
}
function getDeclaredExpandoInitializer(node) {
  const init = getEffectiveInitializer(node);
  return init && getExpandoInitializer(init, isPrototypeAccess(node.name));
}
function hasExpandoValueProperty(node, isPrototypeAssignment) {
  return forEach(node.properties, (p) => isPropertyAssignment(p) && isIdentifier(p.name) && p.name.escapedText === "value" && p.initializer && getExpandoInitializer(p.initializer, isPrototypeAssignment));
}
function getAssignedExpandoInitializer(node) {
  if (node && node.parent && isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 64 /* EqualsToken */) {
    const isPrototypeAssignment = isPrototypeAccess(node.parent.left);
    return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment);
  }
  if (node && isCallExpression(node) && isBindableObjectDefinePropertyCall(node)) {
    const result = hasExpandoValueProperty(node.arguments[2], node.arguments[1].text === "prototype");
    if (result) {
      return result;
    }
  }
}
function getExpandoInitializer(initializer, isPrototypeAssignment) {
  if (isCallExpression(initializer)) {
    const e = skipParentheses(initializer.expression);
    return e.kind === 218 /* FunctionExpression */ || e.kind === 219 /* ArrowFunction */ ? initializer : void 0;
  }
  if (initializer.kind === 218 /* FunctionExpression */ || initializer.kind === 231 /* ClassExpression */ || initializer.kind === 219 /* ArrowFunction */) {
    return initializer;
  }
  if (isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) {
    return initializer;
  }
}
function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) {
  const e = isBinaryExpression(initializer) && (initializer.operatorToken.kind === 57 /* BarBarToken */ || initializer.operatorToken.kind === 61 /* QuestionQuestionToken */) && getExpandoInitializer(initializer.right, isPrototypeAssignment);
  if (e && isSameEntityName(name, initializer.left)) {
    return e;
  }
}
function isDefaultedExpandoInitializer(node) {
  const name = isVariableDeclaration(node.parent) ? node.parent.name : isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 64 /* EqualsToken */ ? node.parent.left : void 0;
  return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left);
}
function getNameOfExpando(node) {
  if (isBinaryExpression(node.parent)) {
    const parent2 = (node.parent.operatorToken.kind === 57 /* BarBarToken */ || node.parent.operatorToken.kind === 61 /* QuestionQuestionToken */) && isBinaryExpression(node.parent.parent) ? node.parent.parent : node.parent;
    if (parent2.operatorToken.kind === 64 /* EqualsToken */ && isIdentifier(parent2.left)) {
      return parent2.left;
    }
  } else if (isVariableDeclaration(node.parent)) {
    return node.parent.name;
  }
}
function isSameEntityName(name, initializer) {
  if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
    return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
  }
  if (isMemberName(name) && isLiteralLikeAccess(initializer) && (initializer.expression.kind === 110 /* ThisKeyword */ || isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global"))) {
    return isSameEntityName(name, getNameOrArgument(initializer));
  }
  if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
    return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) && isSameEntityName(name.expression, initializer.expression);
  }
  return false;
}
function getRightMostAssignedExpression(node) {
  while (isAssignmentExpression(
    node,
    /*excludeCompoundAssignment*/
    true
  )) {
    node = node.right;
  }
  return node;
}
function isExportsIdentifier(node) {
  return isIdentifier(node) && node.escapedText === "exports";
}
function isModuleIdentifier(node) {
  return isIdentifier(node) && node.escapedText === "module";
}
function isModuleExportsAccessExpression(node) {
  return (isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) && isModuleIdentifier(node.expression) && getElementOrPropertyAccessName(node) === "exports";
}
function getAssignmentDeclarationKind(expr) {
  const special = getAssignmentDeclarationKindWorker(expr);
  return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */;
}
function isBindableObjectDefinePropertyCall(expr) {
  return length(expr.arguments) === 3 && isPropertyAccessExpression(expr.expression) && isIdentifier(expr.expression.expression) && idText(expr.expression.expression) === "Object" && idText(expr.expression.name) === "defineProperty" && isStringOrNumericLiteralLike(expr.arguments[1]) && isBindableStaticNameExpression(
    expr.arguments[0],
    /*excludeThisKeyword*/
    true
  );
}
function isLiteralLikeAccess(node) {
  return isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node);
}
function isLiteralLikeElementAccess(node) {
  return isElementAccessExpression(node) && isStringOrNumericLiteralLike(node.argumentExpression);
}
function isBindableStaticAccessExpression(node, excludeThisKeyword) {
  return isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 110 /* ThisKeyword */ || isIdentifier(node.name) && isBindableStaticNameExpression(
    node.expression,
    /*excludeThisKeyword*/
    true
  )) || isBindableStaticElementAccessExpression(node, excludeThisKeyword);
}
function isBindableStaticElementAccessExpression(node, excludeThisKeyword) {
  return isLiteralLikeElementAccess(node) && (!excludeThisKeyword && node.expression.kind === 110 /* ThisKeyword */ || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(
    node.expression,
    /*excludeThisKeyword*/
    true
  ));
}
function isBindableStaticNameExpression(node, excludeThisKeyword) {
  return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword);
}
function getNameOrArgument(expr) {
  if (isPropertyAccessExpression(expr)) {
    return expr.name;
  }
  return expr.argumentExpression;
}
function getAssignmentDeclarationKindWorker(expr) {
  if (isCallExpression(expr)) {
    if (!isBindableObjectDefinePropertyCall(expr)) {
      return 0 /* None */;
    }
    const entityName = expr.arguments[0];
    if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) {
      return 8 /* ObjectDefinePropertyExports */;
    }
    if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") {
      return 9 /* ObjectDefinePrototypeProperty */;
    }
    return 7 /* ObjectDefinePropertyValue */;
  }
  if (expr.operatorToken.kind !== 64 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) {
    return 0 /* None */;
  }
  if (isBindableStaticNameExpression(
    expr.left.expression,
    /*excludeThisKeyword*/
    true
  ) && getElementOrPropertyAccessName(expr.left) === "prototype" && isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) {
    return 6 /* Prototype */;
  }
  return getAssignmentDeclarationPropertyAccessKind(expr.left);
}
function isVoidZero(node) {
  return isVoidExpression(node) && isNumericLiteral(node.expression) && node.expression.text === "0";
}
function getElementOrPropertyAccessArgumentExpressionOrName(node) {
  if (isPropertyAccessExpression(node)) {
    return node.name;
  }
  const arg = skipParentheses(node.argumentExpression);
  if (isNumericLiteral(arg) || isStringLiteralLike(arg)) {
    return arg;
  }
  return node;
}
function getElementOrPropertyAccessName(node) {
  const name = getElementOrPropertyAccessArgumentExpressionOrName(node);
  if (name) {
    if (isIdentifier(name)) {
      return name.escapedText;
    }
    if (isStringLiteralLike(name) || isNumericLiteral(name)) {
      return escapeLeadingUnderscores(name.text);
    }
  }
  return void 0;
}
function getAssignmentDeclarationPropertyAccessKind(lhs) {
  if (lhs.expression.kind === 110 /* ThisKeyword */) {
    return 4 /* ThisProperty */;
  } else if (isModuleExportsAccessExpression(lhs)) {
    return 2 /* ModuleExports */;
  } else if (isBindableStaticNameExpression(
    lhs.expression,
    /*excludeThisKeyword*/
    true
  )) {
    if (isPrototypeAccess(lhs.expression)) {
      return 3 /* PrototypeProperty */;
    }
    let nextToLast = lhs;
    while (!isIdentifier(nextToLast.expression)) {
      nextToLast = nextToLast.expression;
    }
    const id = nextToLast.expression;
    if ((id.escapedText === "exports" || id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") && // ExportsProperty does not support binding with computed names
    isBindableStaticAccessExpression(lhs)) {
      return 1 /* ExportsProperty */;
    }
    if (isBindableStaticNameExpression(
      lhs,
      /*excludeThisKeyword*/
      true
    ) || isElementAccessExpression(lhs) && isDynamicName(lhs)) {
      return 5 /* Property */;
    }
  }
  return 0 /* None */;
}
function getInitializerOfBinaryExpression(expr) {
  while (isBinaryExpression(expr.right)) {
    expr = expr.right;
  }
  return expr.right;
}
function isPrototypePropertyAssignment(node) {
  return isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* PrototypeProperty */;
}
function isSpecialPropertyDeclaration(expr) {
  return isInJSFile(expr) && expr.parent && expr.parent.kind === 244 /* ExpressionStatement */ && (!isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!getJSDocTypeTag(expr.parent);
}
function setValueDeclaration(symbol, node) {
  const { valueDeclaration } = symbol;
  if (!valueDeclaration || !(node.flags & 33554432 /* Ambient */ && !isInJSFile(node) && !(valueDeclaration.flags & 33554432 /* Ambient */)) && (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration)) {
    symbol.valueDeclaration = node;
  }
}
function isFunctionSymbol(symbol) {
  if (!symbol || !symbol.valueDeclaration) {
    return false;
  }
  const decl = symbol.valueDeclaration;
  return decl.kind === 262 /* FunctionDeclaration */ || isVariableDeclaration(decl) && decl.initializer && isFunctionLike(decl.initializer);
}
function canHaveModuleSpecifier(node) {
  switch (node == null ? void 0 : node.kind) {
    case 260 /* VariableDeclaration */:
    case 208 /* BindingElement */:
    case 272 /* ImportDeclaration */:
    case 278 /* ExportDeclaration */:
    case 271 /* ImportEqualsDeclaration */:
    case 273 /* ImportClause */:
    case 280 /* NamespaceExport */:
    case 274 /* NamespaceImport */:
    case 281 /* ExportSpecifier */:
    case 276 /* ImportSpecifier */:
    case 205 /* ImportType */:
      return true;
  }
  return false;
}
function tryGetModuleSpecifierFromDeclaration(node) {
  var _a, _b;
  switch (node.kind) {
    case 260 /* VariableDeclaration */:
    case 208 /* BindingElement */:
      return (_a = findAncestor(node.initializer, (node2) => isRequireCall(
        node2,
        /*requireStringLiteralLikeArgument*/
        true
      ))) == null ? void 0 : _a.arguments[0];
    case 272 /* ImportDeclaration */:
    case 278 /* ExportDeclaration */:
    case 351 /* JSDocImportTag */:
      return tryCast(node.moduleSpecifier, isStringLiteralLike);
    case 271 /* ImportEqualsDeclaration */:
      return tryCast((_b = tryCast(node.moduleReference, isExternalModuleReference)) == null ? void 0 : _b.expression, isStringLiteralLike);
    case 273 /* ImportClause */:
    case 280 /* NamespaceExport */:
      return tryCast(node.parent.moduleSpecifier, isStringLiteralLike);
    case 274 /* NamespaceImport */:
    case 281 /* ExportSpecifier */:
      return tryCast(node.parent.parent.moduleSpecifier, isStringLiteralLike);
    case 276 /* ImportSpecifier */:
      return tryCast(node.parent.parent.parent.moduleSpecifier, isStringLiteralLike);
    case 205 /* ImportType */:
      return isLiteralImportTypeNode(node) ? node.argument.literal : void 0;
    default:
      Debug.assertNever(node);
  }
}
function importFromModuleSpecifier(node) {
  return tryGetImportFromModuleSpecifier(node) || Debug.failBadSyntaxKind(node.parent);
}
function tryGetImportFromModuleSpecifier(node) {
  switch (node.parent.kind) {
    case 272 /* ImportDeclaration */:
    case 278 /* ExportDeclaration */:
    case 351 /* JSDocImportTag */:
      return node.parent;
    case 283 /* ExternalModuleReference */:
      return node.parent.parent;
    case 213 /* CallExpression */:
      return isImportCall(node.parent) || isRequireCall(
        node.parent,
        /*requireStringLiteralLikeArgument*/
        false
      ) ? node.parent : void 0;
    case 201 /* LiteralType */:
      if (!isStringLiteral(node)) {
        break;
      }
      return tryCast(node.parent.parent, isImportTypeNode);
    default:
      return void 0;
  }
}
function shouldRewriteModuleSpecifier(specifier, compilerOptions) {
  return !!compilerOptions.rewriteRelativeImportExtensions && pathIsRelative(specifier) && !isDeclarationFileName(specifier) && hasTSFileExtension(specifier);
}
function getExternalModuleName(node) {
  switch (node.kind) {
    case 272 /* ImportDeclaration */:
    case 278 /* ExportDeclaration */:
    case 351 /* JSDocImportTag */:
      return node.moduleSpecifier;
    case 271 /* ImportEqualsDeclaration */:
      return node.moduleReference.kind === 283 /* ExternalModuleReference */ ? node.moduleReference.expression : void 0;
    case 205 /* ImportType */:
      return isLiteralImportTypeNode(node) ? node.argument.literal : void 0;
    case 213 /* CallExpression */:
      return node.arguments[0];
    case 267 /* ModuleDeclaration */:
      return node.name.kind === 11 /* StringLiteral */ ? node.name : void 0;
    default:
      return Debug.assertNever(node);
  }
}
function getNamespaceDeclarationNode(node) {
  switch (node.kind) {
    case 272 /* ImportDeclaration */:
      return node.importClause && tryCast(node.importClause.namedBindings, isNamespaceImport);
    case 271 /* ImportEqualsDeclaration */:
      return node;
    case 278 /* ExportDeclaration */:
      return node.exportClause && tryCast(node.exportClause, isNamespaceExport);
    default:
      return Debug.assertNever(node);
  }
}
function isDefaultImport(node) {
  return (node.kind === 272 /* ImportDeclaration */ || node.kind === 351 /* JSDocImportTag */) && !!node.importClause && !!node.importClause.name;
}
function forEachImportClauseDeclaration(node, action) {
  if (node.name) {
    const result = action(node);
    if (result) return result;
  }
  if (node.namedBindings) {
    const result = isNamespaceImport(node.namedBindings) ? action(node.namedBindings) : forEach(node.namedBindings.elements, action);
    if (result) return result;
  }
}
function hasQuestionToken(node) {
  switch (node.kind) {
    case 169 /* Parameter */:
    case 174 /* MethodDeclaration */:
    case 173 /* MethodSignature */:
    case 304 /* ShorthandPropertyAssignment */:
    case 303 /* PropertyAssignment */:
    case 172 /* PropertyDeclaration */:
    case 171 /* PropertySignature */:
      return node.questionToken !== void 0;
  }
  return false;
}
function isJSDocConstructSignature(node) {
  const param = isJSDocFunctionType(node) ? firstOrUndefined(node.parameters) : void 0;
  const name = tryCast(param && param.name, isIdentifier);
  return !!name && name.escapedText === "new";
}
function isJSDocTypeAlias(node) {
  return node.kind === 346 /* JSDocTypedefTag */ || node.kind === 338 /* JSDocCallbackTag */ || node.kind === 340 /* JSDocEnumTag */;
}
function isTypeAlias(node) {
  return isJSDocTypeAlias(node) || isTypeAliasDeclaration(node);
}
function getSourceOfAssignment(node) {
  return isExpressionStatement(node) && isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 64 /* EqualsToken */ ? getRightMostAssignedExpression(node.expression) : void 0;
}
function getSourceOfDefaultedAssignment(node) {
  return isExpressionStatement(node) && isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && isBinaryExpression(node.expression.right) && (node.expression.right.operatorToken.kind === 57 /* BarBarToken */ || node.expression.right.operatorToken.kind === 61 /* QuestionQuestionToken */) ? node.expression.right.right : void 0;
}
function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) {
  switch (node.kind) {
    case 243 /* VariableStatement */:
      const v = getSingleVariableOfVariableStatement(node);
      return v && v.initializer;
    case 172 /* PropertyDeclaration */:
      return node.initializer;
    case 303 /* PropertyAssignment */:
      return node.initializer;
  }
}
function getSingleVariableOfVariableStatement(node) {
  return isVariableStatement(node) ? firstOrUndefined(node.declarationList.declarations) : void 0;
}
function getNestedModuleDeclaration(node) {
  return isModuleDeclaration(node) && node.body && node.body.kind === 267 /* ModuleDeclaration */ ? node.body : void 0;
}
function canHaveFlowNode(node) {
  if (node.kind >= 243 /* FirstStatement */ && node.kind <= 259 /* LastStatement */) {
    return true;
  }
  switch (node.kind) {
    case 80 /* Identifier */:
    case 110 /* ThisKeyword */:
    case 108 /* SuperKeyword */:
    case 166 /* QualifiedName */:
    case 236 /* MetaProperty */:
    case 212 /* ElementAccessExpression */:
    case 211 /* PropertyAccessExpression */:
    case 208 /* BindingElement */:
    case 218 /* FunctionExpression */:
    case 219 /* ArrowFunction */:
    case 174 /* MethodDeclaration */:
    case 177 /* GetAccessor */:
    case 178 /* SetAccessor */:
      return true;
    default:
      return false;
  }
}
function canHaveJSDoc(node) {
  switch (node.kind) {
    case 219 /* ArrowFunction */:
    case 226 /* BinaryExpression */:
    case 241 /* Block */:
    case 252 /* BreakStatement */:
    case 179 /* CallSignature */:
    case 296 /* CaseClause */:
    case 263 /* ClassDeclaration */:
    case 231 /* ClassExpression */:
    case 175 /* ClassStaticBlockDeclaration */:
    case 176 /* Constructor */:
    case 185 /* ConstructorType */:
    case 180 /* ConstructSignature */:
    case 251 /* ContinueStatement */:
    case 259 /* DebuggerStatement */:
    case 246 /* DoStatement */:
    case 212 /* ElementAccessExpression */:
    case 242 /* EmptyStatement */:
    case 1 /* EndOfFileToken */:
    case 266 /* EnumDeclaration */:
    case 306 /* EnumMember */:
    case 277 /* ExportAssignment */:
    case 278 /* ExportDeclaration */:
    case 281 /* ExportSpecifier */:
    case 244 /* ExpressionStatement */:
    case 249 /* ForInStatement */:
    case 250 /* ForOfStatement */:
    case 248 /* ForStatement */:
    case 262 /* FunctionDeclaration */:
    case 218 /* FunctionExpression */:
    case 184 /* FunctionType */:
    case 177 /* GetAccessor */:
    case 80 /* Identifier */:
    case 245 /* IfStatement */:
    case 272 /* ImportDeclaration */:
    case 271 /* ImportEqualsDeclaration */:
    case 181 /* IndexSignature */:
    case 264 /* InterfaceDeclaration */:
    case 317 /* JSDocFunctionType */:
    case 323 /* JSDocSignature */:
    case 256 /* LabeledStatement */:
    case 174 /* MethodDeclaration */:
    case 173 /* MethodSignature */:
    case 267 /* ModuleDeclaration */:
    case 202 /* NamedTupleMember */:
    case 270 /* NamespaceExportDeclaration */:
    case 210 /* ObjectLiteralExpression */:
    case 169 /* Parameter */:
    case 217 /* ParenthesizedExpression */:
    case 211 /* PropertyAccessExpression */:
    case 303 /* PropertyAssignment */:
    case 172 /* PropertyDeclaration */:
    case 171 /* PropertySignature */:
    case 253 /* ReturnStatement */:
    case 240 /* SemicolonClassElement */:
    case 178 /* SetAccessor */:
    case 304 /* ShorthandPropertyAssignment */:
    case 305 /* SpreadAssignment */:
    case 255 /* SwitchStatement */:
    case 257 /* ThrowStatement */:
    case 258 /* TryStatement */:
    case 265 /* TypeAliasDeclaration */:
    case 168 /* TypeParameter */:
    case 260 /* VariableDeclaration */:
    case 243 /* VariableStatement */:
    case 247 /* WhileStatement */:
    case 254 /* WithStatement */:
      return true;
    default:
      return false;
  }
}
function getJSDocCommentsAndTags(hostNode, noCache) {
  let result;
  if (isVariableLike(hostNode) && hasInitializer(hostNode) && hasJSDocNodes(hostNode.initializer)) {
    result = addRange(result, filterOwnedJSDocTags(hostNode, hostNode.initializer.jsDoc));
  }
  let node = hostNode;
  while (node && node.parent) {
    if (hasJSDocNodes(node)) {
      result = addRange(result, filterOwnedJSDocTags(hostNode, node.jsDoc));
    }
    if (node.kind === 169 /* Parameter */) {
      result = addRange(result, (noCache ? getJSDocParameterTagsNoCache : getJSDocParameterTags)(node));
      break;
    }
    if (node.kind === 168 /* TypeParameter */) {
      result = addRange(result, (noCache ? getJSDocTypeParameterTagsNoCache : getJSDocTypeParameterTags)(node));
      break;
    }
    node = getNextJSDocCommentLocation(node);
  }
  return result || emptyArray;
}
function filterOwnedJSDocTags(hostNode, comments) {
  const lastJsDoc = last(comments);
  return flatMap(comments, (jsDoc) => {
    if (jsDoc === lastJsDoc) {
      const ownedTags = filter(jsDoc.tags, (tag) => ownsJSDocTag(hostNode, tag));
      return jsDoc.tags === ownedTags ? [jsDoc] : ownedTags;
    } else {
      return filter(jsDoc.tags, isJSDocOverloadTag);
    }
  });
}
function ownsJSDocTag(hostNode, tag) {
  return !(isJSDocTypeTag(tag) || isJSDocSatisfiesTag(tag)) || !tag.parent || !isJSDoc(tag.parent) || !isParenthesizedExpression(tag.parent.parent) || tag.parent.parent === hostNode;
}
function getNextJSDocCommentLocation(node) {
  const parent2 = node.parent;
  if (parent2.kind === 303 /* PropertyAssignment */ || parent2.kind === 277 /* ExportAssignment */ || parent2.kind === 172 /* PropertyDeclaration */ || parent2.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent2.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent2) || isAssignmentExpression(node)) {
    return parent2;
  } else if (parent2.parent && (getSingleVariableOfVariableStatement(parent2.parent) === node || isAssignmentExpression(parent2))) {
    return parent2.parent;
  } else if (parent2.parent && parent2.parent.parent && (getSingleVariableOfVariableStatement(parent2.parent.parent) || getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent2.parent.parent) === node || getSourceOfDefaultedAssignment(parent2.parent.parent))) {
    return parent2.parent.parent;
  }
}
function getParameterSymbolFromJSDoc(node) {
  if (node.symbol) {
    return node.symbol;
  }
  if (!isIdentifier(node.name)) {
    return void 0;
  }
  const name = node.name.escapedText;
  const decl = getHostSignatureFromJSDoc(node);
  if (!decl) {
    return void 0;
  }
  const parameter = find(decl.parameters, (p) => p.name.kind === 80 /* Identifier */ && p.name.escapedText === name);
  return parameter && parameter.symbol;
}
function getEffectiveContainerForJSDocTemplateTag(node) {
  if (isJSDoc(node.parent) && node.parent.tags) {
    const typeAlias = find(node.parent.tags, isJSDocTypeAlias);
    if (typeAlias) {
      return typeAlias;
    }
  }
  return getHostSignatureFromJSDoc(node);
}
function getJSDocOverloadTags(node) {
  return getAllJSDocTags(node, isJSDocOverloadTag);
}
function getHostSignatureFromJSDoc(node) {
  const host = getEffectiveJSDocHost(node);
  if (host) {
    return isPropertySignature(host) && host.type && isFunctionLike(host.type) ? host.type : isFunctionLike(host) ? host : void 0;
  }
  return void 0;
}
function getEffectiveJSDocHost(node) {
  const host = getJSDocHost(node);
  if (host) {
    return getSourceOfDefaultedAssignment(host) || getSourceOfAssignment(host) || getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) || getSingleVariableOfVariableStatement(host) || getNestedModuleDeclaration(host) || host;
  }
}
function getJSDocHost(node) {
  const jsDoc = getJSDocRoot(node);
  if (!jsDoc) {
    return void 0;
  }
  const host = jsDoc.parent;
  if (host && host.jsDoc && jsDoc === lastOrUndefined(host.jsDoc)) {
    return host;
  }
}
function getJSDocRoot(node) {
  return findAncestor(node.parent, isJSDoc);
}
function getTypeParameterFromJsDoc(node) {
  const name = node.name.escapedText;
  const { typeParameters } = node.parent.parent.parent;
  return typeParameters && find(typeParameters, (p) => p.name.escapedText === name);
}
function hasTypeArguments(node) {
  return !!node.typeArguments;
}
var AssignmentKind = /* @__PURE__ */ ((AssignmentKind2) => {
  AssignmentKind2[AssignmentKind2["None"] = 0] = "None";
  AssignmentKind2[AssignmentKind2["Definite"] = 1] = "Definite";
  AssignmentKind2[AssignmentKind2["Compound"] = 2] = "Compound";
  return AssignmentKind2;
})(AssignmentKind || {});
function getAssignmentTarget(node) {
  let parent2 = node.parent;
  while (true) {
    switch (parent2.kind) {
      case 226 /* BinaryExpression */:
        const binaryExpression = parent2;
        const binaryOperator = binaryExpression.operatorToken.kind;
        return isAssignmentOperator(binaryOperator) && binaryExpression.left === node ? binaryExpression : void 0;
      case 224 /* PrefixUnaryExpression */:
      case 225 /* PostfixUnaryExpression */:
        const unaryExpression = parent2;
        const unaryOperator = unaryExpression.operator;
        return unaryOperator === 46 /* PlusPlusToken */ || unaryOperator === 47 /* MinusMinusToken */ ? unaryExpression : void 0;
      case 249 /* ForInStatement */:
      case 250 /* ForOfStatement */:
        const forInOrOfStatement = parent2;
        return forInOrOfStatement.initializer === node ? forInOrOfStatement : void 0;
      case 217 /* ParenthesizedExpression */:
      case 209 /* ArrayLiteralExpression */:
      case 230 /* SpreadElement */:
      case 235 /* NonNullExpression */:
        node = parent2;
        break;
      case 305 /* SpreadAssignment */:
        node = parent2.parent;
        break;
      case 304 /* ShorthandPropertyAssignment */:
        if (parent2.name !== node) {
          return void 0;
        }
        node = parent2.parent;
        break;
      case 303 /* PropertyAssignment */:
        if (parent2.name === node) {
          return void 0;
        }
        node = parent2.parent;
        break;
      default:
        return void 0;
    }
    parent2 = node.parent;
  }
}
function getAssignmentTargetKind(node) {
  const target = getAssignmentTarget(node);
  if (!target) {
    return 0 /* None */;
  }
  switch (target.kind) {
    case 226 /* BinaryExpression */:
      const binaryOperator = target.operatorToken.kind;
      return binaryOperator === 64 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */;
    case 224 /* PrefixUnaryExpression */:
    case 225 /* PostfixUnaryExpression */:
      return 2 /* Compound */;
    case 249 /* ForInStatement */:
    case 250 /* ForOfStatement */:
      return 1 /* Definite */;
  }
}
function isAssignmentTarget(node) {
  return !!getAssignmentTarget(node);
}
function isCompoundLikeAssignment(assignment) {
  const right = skipParentheses(assignment.right);
  return right.kind === 226 /* BinaryExpression */ && isShiftOperatorOrHigher(right.operatorToken.kind);
}
function isInCompoundLikeAssignment(node) {
  const target = getAssignmentTarget(node);
  return !!target && isAssignmentExpression(
    target,
    /*excludeCompoundAssignment*/
    true
  ) && isCompoundLikeAssignment(target);
}
function isNodeWithPossibleHoistedDeclaration(node) {
  switch (node.kind) {
    case 241 /* Block */:
    case 243 /* VariableStatement */:
    case 254 /* WithStatement */:
    case 245 /* IfStatement */:
    case 255 /* SwitchStatement */:
    case 269 /* CaseBlock */:
    case 296 /* CaseClause */:
    case 297 /* DefaultClause */:
    case 256 /* LabeledStatement */:
    case 248 /* ForStatement */:
    case 249 /* ForInStatement */:
    case 250 /* ForOfStatement */:
    case 246 /* DoStatement */:
    case 247 /* WhileStatement */:
    case 258 /* TryStatement */:
    case 299 /* CatchClause */:
      return true;
  }
  return false;
}
function isValueSignatureDeclaration(node) {
  return isFunctionExpression(node) || isArrowFunction(node) || isMethodOrAccessor(node) || isFunctionDeclaration(node) || isConstructorDeclaration(node);
}
function walkUp(node, kind) {
  while (node && node.kind === kind) {
    node = node.parent;
  }
  return node;
}
function walkUpParenthesizedTypes(node) {
  return walkUp(node, 196 /* ParenthesizedType */);
}
function walkUpParenthesizedExpressions(node) {
  return walkUp(node, 217 /* ParenthesizedExpression */);
}
function walkUpParenthesizedTypesAndGetParentAndChild(node) {
  let child;
  while (node && node.kind === 196 /* ParenthesizedType */) {
    child = node;
    node = node.parent;
  }
  return [child, node];
}
function skipTypeParentheses(node) {
  while (isParenthesizedTypeNode(node)) node = node.type;
  return node;
}
function skipParentheses(node, excludeJSDocTypeAssertions) {
  const flags = excludeJSDocTypeAssertions ? 1 /* Parentheses */ | -2147483648 /* ExcludeJSDocTypeAssertion */ : 1 /* Parentheses */;
  return skipOuterExpressions(node, flags);
}
function isDeleteTarget(node) {
  if (node.kind !== 211 /* PropertyAccessExpression */ && node.kind !== 212 /* ElementAccessExpression */) {
    return false;
  }
  node = walkUpParenthesizedExpressions(node.parent);
  return node && node.kind === 220 /* DeleteExpression */;
}
function isNodeDescendantOf(node, ancestor) {
  while (node) {
    if (node === ancestor) return true;
    node = node.parent;
  }
  return false;
}
function isDeclarationName(name) {
  return !isSourceFile(name) && !isBindingPattern(name) && isDeclaration(name.parent) && name.parent.name === name;
}
function getDeclarationFromName(name) {
  const parent2 = name.parent;
  switch (name.kind) {
    case 11 /* StringLiteral */:
    case 15 /* NoSubstitutionTemplateLiteral */:
    case 9 /* NumericLiteral */:
      if (isComputedPropertyName(parent2)) return parent2.parent;
    // falls through
    case 80 /* Identifier */:
      if (isDeclaration(parent2)) {
        return parent2.name === name ? parent2 : void 0;
      } else if (isQualifiedName(parent2)) {
        const tag = parent2.parent;
        return isJSDocParameterTag(tag) && tag.name === parent2 ? tag : void 0;
      } else {
        const binExp = parent2.parent;
        return isBinaryExpression(binExp) && getAssignmentDeclarationKind(binExp) !== 0 /* None */ && (binExp.left.symbol || binExp.symbol) && getNameOfDeclaration(binExp) === name ? binExp : void 0;
      }
    case 81 /* PrivateIdentifier */:
      return isDeclaration(parent2) && parent2.name === name ? parent2 : void 0;
    default:
      return void 0;
  }
}
function isLiteralComputedPropertyDeclarationName(node) {
  return isStringOrNumericLiteralLike(node) && node.parent.kind === 167 /* ComputedPropertyName */ && isDeclaration(node.parent.parent);
}
function isIdentifierName(node) {
  const parent2 = node.parent;
  switch (parent2.kind) {
    case 172 /* PropertyDeclaration */:
    case 171 /* PropertySignature */:
    case 174 /* MethodDeclaration */:
    case 173 /* MethodSignature */:
    case 177 /* GetAccessor */:
    case 178 /* SetAccessor */:
    case 306 /* EnumMember */:
    case 303 /* PropertyAssignment */:
    case 211 /* PropertyAccessExpression */:
      return parent2.name === node;
    case 166 /* QualifiedName */:
      return parent2.right === node;
    case 208 /* BindingElement */:
    case 276 /* ImportSpecifier */:
      return parent2.propertyName === node;
    case 281 /* ExportSpecifier */:
    case 291 /* JsxAttribute */:
    case 285 /* JsxSelfClosingElement */:
    case 286 /* JsxOpeningElement */:
    case 287 /* JsxClosingElement */:
      return true;
  }
  return false;
}
function getAliasDeclarationFromName(node) {
  switch (node.parent.kind) {
    case 273 /* ImportClause */:
    case 276 /* ImportSpecifier */:
    case 274 /* NamespaceImport */:
    case 281 /* ExportSpecifier */:
    case 277 /* ExportAssignment */:
    case 271 /* ImportEqualsDeclaration */:
    case 280 /* NamespaceExport */:
      return node.parent;
    case 166 /* QualifiedName */:
      do {
        node = node.parent;
      } while (node.parent.kind === 166 /* QualifiedName */);
      return getAliasDeclarationFromName(node);
  }
}
function isAliasableExpression(e) {
  return isEntityNameExpression(e) || isClassExpression(e);
}
function exportAssignmentIsAlias(node) {
  const e = getExportAssignmentExpression(node);
  return isAliasableExpression(e);
}
function getExportAssignmentExpression(node) {
  return isExportAssignment(node) ? node.expression : node.right;
}
function getPropertyAssignmentAliasLikeExpression(node) {
  return node.kind === 304 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 303 /* PropertyAssignment */ ? node.initializer : node.parent.right;
}
function getEffectiveBaseTypeNode(node) {
  const baseType = getClassExtendsHeritageElement(node);
  if (baseType && isInJSFile(node)) {
    const tag = getJSDocAugmentsTag(node);
    if (tag) {
      return tag.class;
    }
  }
  return baseType;
}
function getClassExtendsHeritageElement(node) {
  const heritageClause = getHeritageClause(node.heritageClauses, 96 /* ExtendsKeyword */);
  return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : void 0;
}
function getEffectiveImplementsTypeNodes(node) {
  if (isInJSFile(node)) {
    return getJSDocImplementsTags(node).map((n) => n.class);
  } else {
    const heritageClause = getHeritageClause(node.heritageClauses, 119 /* ImplementsKeyword */);
    return heritageClause == null ? void 0 : heritageClause.types;
  }
}
function getAllSuperTypeNodes(node) {
  return isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || emptyArray : isClassLike(node) ? concatenate(singleElementArray(getEffectiveBaseTypeNode(node)), getEffectiveImplementsTypeNodes(node)) || emptyArray : emptyArray;
}
function getInterfaceBaseTypeNodes(node) {
  const heritageClause = getHeritageClause(node.heritageClauses, 96 /* ExtendsKeyword */);
  return heritageClause ? heritageClause.types : void 0;
}
function getHeritageClause(clauses, kind) {
  if (clauses) {
    for (const clause of clauses) {
      if (clause.token === kind) {
        return clause;
      }
    }
  }
  return void 0;
}
function getAncestor(node, kind) {
  while (node) {
    if (node.kind === kind) {
      return node;
    }
    node = node.parent;
  }
  return void 0;
}
function isKeyword(token) {
  return 83 /* FirstKeyword */ <= token && token <= 165 /* LastKeyword */;
}
function isPunctuation(token) {
  return 19 /* FirstPunctuation */ <= token && token <= 79 /* LastPunctuation */;
}
function isKeywordOrPunctuation(token) {
  return isKeyword(token) || isPunctuation(token);
}
function isContextualKeyword(token) {
  return 128 /* FirstContextualKeyword */ <= token && token <= 165 /* LastContextualKeyword */;
}
function isNonContextualKeyword(token) {
  return isKeyword(token) && !isContextualKeyword(token);
}
function isStringANonContextualKeyword(name) {
  const token = stringToToken(name);
  return token !== void 0 && isNonContextualKeyword(token);
}
function isIdentifierANonContextualKeyword(node) {
  const originalKeywordKind = identifierToKeywordKind(node);
  return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind);
}
function isTrivia(token) {
  return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */;
}
var FunctionFlags = /* @__PURE__ */ ((FunctionFlags2) => {
  FunctionFlags2[FunctionFlags2["Normal"] = 0] = "Normal";
  FunctionFlags2[FunctionFlags2["Generator"] = 1] = "Generator";
  FunctionFlags2[FunctionFlags2["Async"] = 2] = "Async";
  FunctionFlags2[FunctionFlags2["Invalid"] = 4] = "Invalid";
  FunctionFlags2[FunctionFlags2["AsyncGenerator"] = 3] = "AsyncGenerator";
  return FunctionFlags2;
})(FunctionFlags || {});
function getFunctionFlags(node) {
  if (!node) {
    return 4 /* Invalid */;
  }
  let flags = 0 /* Normal */;
  switch (node.kind) {
    case 262 /* FunctionDeclaration */:
    case 218 /* FunctionExpression */:
    case 174 /* MethodDeclaration */:
      if (node.asteriskToken) {
        flags |= 1 /* Generator */;
      }
    // falls through
    case 219 /* ArrowFunction */:
      if (hasSyntacticModifier(node, 1024 /* Async */)) {
        flags |= 2 /* Async */;
      }
      break;
  }
  if (!node.body) {
    flags |= 4 /* Invalid */;
  }
  return flags;
}
function isAsyncFunction(node) {
  switch (node.kind) {
    case 262 /* FunctionDeclaration */:
    case 218 /* FunctionExpression */:
    case 219 /* ArrowFunction */:
    case 174 /* MethodDeclaration */:
      return node.body !== void 0 && node.asteriskToken === void 0 && hasSyntacticModifier(node, 1024 /* Async */);
  }
  return false;
}
function isStringOrNumericLiteralLike(node) {
  return isStringLiteralLike(node) || isNumericLiteral(node);
}
function isSignedNumericLiteral(node) {
  return isPrefixUnaryExpression(node) && (node.operator === 40 /* PlusToken */ || node.operator === 41 /* MinusToken */) && isNumericLiteral(node.operand);
}
function hasDynamicName(declaration) {
  const name = getNameOfDeclaration(declaration);
  return !!name && isDynamicName(name);
}
function isDynamicName(name) {
  if (!(name.kind === 167 /* ComputedPropertyName */ || name.kind === 212 /* ElementAccessExpression */)) {
    return false;
  }
  const expr = isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression;
  return !isStringOrNumericLiteralLike(expr) && !isSignedNumericLiteral(expr);
}
function getPropertyNameForPropertyNameNode(name) {
  switch (name.kind) {
    case 80 /* Identifier */:
    case 81 /* PrivateIdentifier */:
      return name.escapedText;
    case 11 /* StringLiteral */:
    case 15 /* NoSubstitutionTemplateLiteral */:
    case 9 /* NumericLiteral */:
    case 10 /* BigIntLiteral */:
      return escapeLeadingUnderscores(name.text);
    case 167 /* ComputedPropertyName */:
      const nameExpression = name.expression;
      if (isStringOrNumericLiteralLike(nameExpression)) {
        return escapeLeadingUnderscores(nameExpression.text);
      } else if (isSignedNumericLiteral(nameExpression)) {
        if (nameExpression.operator === 41 /* MinusToken */) {
          return tokenToString(nameExpression.operator) + nameExpression.operand.text;
        }
        return nameExpression.operand.text;
      }
      return void 0;
    case 295 /* JsxNamespacedName */:
      return getEscapedTextOfJsxNamespacedName(name);
    default:
      return Debug.assertNever(name);
  }
}
function isPropertyNameLiteral(node) {
  switch (node.kind) {
    case 80 /* Identifier */:
    case 11 /* StringLiteral */:
    case 15 /* NoSubstitutionTemplateLiteral */:
    case 9 /* NumericLiteral */:
      return true;
    default:
      return false;
  }
}
function getTextOfIdentifierOrLiteral(node) {
  return isMemberName(node) ? idText(node) : isJsxNamespacedName(node) ? getTextOfJsxNamespacedName(node) : node.text;
}
function getEscapedTextOfIdentifierOrLiteral(node) {
  return isMemberName(node) ? node.escapedText : isJsxNamespacedName(node) ? getEscapedTextOfJsxNamespacedName(node) : escapeLeadingUnderscores(node.text);
}
function getSymbolNameForPrivateIdentifier(containingClassSymbol, description3) {
  return `__#${getSymbolId(containingClassSymbol)}@${description3}`;
}
function isKnownSymbol(symbol) {
  return startsWith(symbol.escapedName, "__@");
}
function isPrivateIdentifierSymbol(symbol) {
  return startsWith(symbol.escapedName, "__#");
}
function isProtoSetter(node) {
  return isIdentifier(node) ? idText(node) === "__proto__" : isStringLiteral(node) && node.text === "__proto__";
}
function isAnonymousFunctionDefinition(node, cb) {
  node = skipOuterExpressions(node);
  switch (node.kind) {
    case 231 /* ClassExpression */:
      if (classHasDeclaredOrExplicitlyAssignedName(node)) {
        return false;
      }
      break;
    case 218 /* FunctionExpression */:
      if (node.name) {
        return false;
      }
      break;
    case 219 /* ArrowFunction */:
      break;
    default:
      return false;
  }
  return typeof cb === "function" ? cb(node) : true;
}
function isNamedEvaluationSource(node) {
  switch (node.kind) {
    case 303 /* PropertyAssignment */:
      return !isProtoSetter(node.name);
    case 304 /* ShorthandPropertyAssignment */:
      return !!node.objectAssignmentInitializer;
    case 260 /* VariableDeclaration */:
      return isIdentifier(node.name) && !!node.initializer;
    case 169 /* Parameter */:
      return isIdentifier(node.name) && !!node.initializer && !node.dotDotDotToken;
    case 208 /* BindingElement */:
      return isIdentifier(node.name) && !!node.initializer && !node.dotDotDotToken;
    case 172 /* PropertyDeclaration */:
      return !!node.initializer;
    case 226 /* BinaryExpression */:
      switch (node.operatorToken.kind) {
        case 64 /* EqualsToken */:
        case 77 /* AmpersandAmpersandEqualsToken */:
        case 76 /* BarBarEqualsToken */:
        case 78 /* QuestionQuestionEqualsToken */:
          return isIdentifier(node.left);
      }
      break;
    case 277 /* ExportAssignment */:
      return true;
  }
  return false;
}
function isNamedEvaluation(node, cb) {
  if (!isNamedEvaluationSource(node)) return false;
  switch (node.kind) {
    case 303 /* PropertyAssignment */:
      return isAnonymousFunctionDefinition(node.initializer, cb);
    case 304 /* ShorthandPropertyAssignment */:
      return isAnonymousFunctionDefinition(node.objectAssignmentInitializer, cb);
    case 260 /* VariableDeclaration */:
    case 169 /* Parameter */:
    case 208 /* BindingElement */:
    case 172 /* PropertyDeclaration */:
      return isAnonymousFunctionDefinition(node.initializer, cb);
    case 226 /* BinaryExpression */:
      return isAnonymousFunctionDefinition(node.right, cb);
    case 277 /* ExportAssignment */:
      return isAnonymousFunctionDefinition(node.expression, cb);
  }
}
function isPushOrUnshiftIdentifier(node) {
  return node.escapedText === "push" || node.escapedText === "unshift";
}
function isPartOfParameterDeclaration(node) {
  const root = getRootDeclaration(node);
  return root.kind === 169 /* Parameter */;
}
function getRootDeclaration(node) {
  while (node.kind === 208 /* BindingElement */) {
    node = node.parent.parent;
  }
  return node;
}
function nodeStartsNewLexicalEnvironment(node) {
  const kind = node.kind;
  return kind === 176 /* Constructor */ || kind === 218 /* FunctionExpression */ || kind === 262 /* FunctionDeclaration */ || kind === 219 /* ArrowFunction */ || kind === 174 /* MethodDeclaration */ || kind === 177 /* GetAccessor */ || kind === 178 /* SetAccessor */ || kind === 267 /* ModuleDeclaration */ || kind === 307 /* SourceFile */;
}
function nodeIsSynthesized(range) {
  return positionIsSynthesized(range.pos) || positionIsSynthesized(range.end);
}
var Associativity = /* @__PURE__ */ ((Associativity2) => {
  Associativity2[Associativity2["Left"] = 0] = "Left";
  Associativity2[Associativity2["Right"] = 1] = "Right";
  return Associativity2;
})(Associativity || {});
function getExpressionAssociativity(expression) {
  const operator = getOperator(expression);
  const hasArguments = expression.kind === 214 /* NewExpression */ && expression.arguments !== void 0;
  return getOperatorAssociativity(expression.kind, operator, hasArguments);
}
function getOperatorAssociativity(kind, operator, hasArguments) {
  switch (kind) {
    case 214 /* NewExpression */:
      return hasArguments ? 0 /* Left */ : 1 /* Right */;
    case 224 /* PrefixUnaryExpression */:
    case 221 /* TypeOfExpression */:
    case 222 /* VoidExpression */:
    case 220 /* DeleteExpression */:
    case 223 /* AwaitExpression */:
    case 227 /* ConditionalExpression */:
    case 229 /* YieldExpression */:
      return 1 /* Right */;
    case 226 /* BinaryExpression */:
      switch (operator) {
        case 43 /* AsteriskAsteriskToken */:
        case 64 /* EqualsToken */:
        case 65 /* PlusEqualsToken */:
        case 66 /* MinusEqualsToken */:
        case 68 /* AsteriskAsteriskEqualsToken */:
        case 67 /* AsteriskEqualsToken */:
        case 69 /* SlashEqualsToken */:
        case 70 /* PercentEqualsToken */:
        case 71 /* LessThanLessThanEqualsToken */:
        case 72 /* GreaterThanGreaterThanEqualsToken */:
        case 73 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
        case 74 /* AmpersandEqualsToken */:
        case 79 /* CaretEqualsToken */:
        case 75 /* BarEqualsToken */:
        case 76 /* BarBarEqualsToken */:
        case 77 /* AmpersandAmpersandEqualsToken */:
        case 78 /* QuestionQuestionEqualsToken */:
          return 1 /* Right */;
      }
  }
  return 0 /* Left */;
}
function getExpressionPrecedence(expression) {
  const operator = getOperator(expression);
  const hasArguments = expression.kind === 214 /* NewExpression */ && expression.arguments !== void 0;
  return getOperatorPrecedence(expression.kind, operator, hasArguments);
}
function getOperator(expression) {
  if (expression.kind === 226 /* BinaryExpression */) {
    return expression.operatorToken.kind;
  } else if (expression.kind === 224 /* PrefixUnaryExpression */ || expression.kind === 225 /* PostfixUnaryExpression */) {
    return expression.operator;
  } else {
    return expression.kind;
  }
}
var OperatorPrecedence = /* @__PURE__ */ ((OperatorPrecedence2) => {
  OperatorPrecedence2[OperatorPrecedence2["Comma"] = 0] = "Comma";
  OperatorPrecedence2[OperatorPrecedence2["Spread"] = 1] = "Spread";
  OperatorPrecedence2[OperatorPrecedence2["Yield"] = 2] = "Yield";
  OperatorPrecedence2[OperatorPrecedence2["Assignment"] = 3] = "Assignment";
  OperatorPrecedence2[OperatorPrecedence2["Conditional"] = 4] = "Conditional";
  OperatorPrecedence2[OperatorPrecedence2["Coalesce"] = 4 /* Conditional */] = "Coalesce";
  OperatorPrecedence2[OperatorPrecedence2["LogicalOR"] = 5] = "LogicalOR";
  OperatorPrecedence2[OperatorPrecedence2["LogicalAND"] = 6] = "LogicalAND";
  OperatorPrecedence2[OperatorPrecedence2["BitwiseOR"] = 7] = "BitwiseOR";
  OperatorPrecedence2[OperatorPrecedence2["BitwiseXOR"] = 8] = "BitwiseXOR";
  OperatorPrecedence2[OperatorPrecedence2["BitwiseAND"] = 9] = "BitwiseAND";
  OperatorPrecedence2[OperatorPrecedence2["Equality"] = 10] = "Equality";
  OperatorPrecedence2[OperatorPrecedence2["Relational"] = 11] = "Relational";
  OperatorPrecedence2[OperatorPrecedence2["Shift"] = 12] = "Shift";
  OperatorPrecedence2[OperatorPrecedence2["Additive"] = 13] = "Additive";
  OperatorPrecedence2[OperatorPrecedence2["Multiplicative"] = 14] = "Multiplicative";
  OperatorPrecedence2[OperatorPrecedence2["Exponentiation"] = 15] = "Exponentiation";
  OperatorPrecedence2[OperatorPrecedence2["Unary"] = 16] = "Unary";
  OperatorPrecedence2[OperatorPrecedence2["Update"] = 17] = "Update";
  OperatorPrecedence2[OperatorPrecedence2["LeftHandSide"] = 18] = "LeftHandSide";
  OperatorPrecedence2[OperatorPrecedence2["Member"] = 19] = "Member";
  OperatorPrecedence2[OperatorPrecedence2["Primary"] = 20] = "Primary";
  OperatorPrecedence2[OperatorPrecedence2["Highest"] = 20 /* Primary */] = "Highest";
  OperatorPrecedence2[OperatorPrecedence2["Lowest"] = 0 /* Comma */] = "Lowest";
  OperatorPrecedence2[OperatorPrecedence2["Invalid"] = -1] = "Invalid";
  return OperatorPrecedence2;
})(OperatorPrecedence || {});
function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
  switch (nodeKind) {
    case 356 /* CommaListExpression */:
      return 0 /* Comma */;
    case 230 /* SpreadElement */:
      return 1 /* Spread */;
    case 229 /* YieldExpression */:
      return 2 /* Yield */;
    case 227 /* ConditionalExpression */:
      return 4 /* Conditional */;
    case 226 /* BinaryExpression */:
      switch (operatorKind) {
        case 28 /* CommaToken */:
          return 0 /* Comma */;
        case 64 /* EqualsToken */:
        case 65 /* PlusEqualsToken */:
        case 66 /* MinusEqualsToken */:
        case 68 /* AsteriskAsteriskEqualsToken */:
        case 67 /* AsteriskEqualsToken */:
        case 69 /* SlashEqualsToken */:
        case 70 /* PercentEqualsToken */:
        case 71 /* LessThanLessThanEqualsToken */:
        case 72 /* GreaterThanGreaterThanEqualsToken */:
        case 73 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
        case 74 /* AmpersandEqualsToken */:
        case 79 /* CaretEqualsToken */:
        case 75 /* BarEqualsToken */:
        case 76 /* BarBarEqualsToken */:
        case 77 /* AmpersandAmpersandEqualsToken */:
        case 78 /* QuestionQuestionEqualsToken */:
          return 3 /* Assignment */;
        default:
          return getBinaryOperatorPrecedence(operatorKind);
      }
    // TODO: Should prefix `++` and `--` be moved to the `Update` precedence?
    case 216 /* TypeAssertionExpression */:
    case 235 /* NonNullExpression */:
    case 224 /* PrefixUnaryExpression */:
    case 221 /* TypeOfExpression */:
    case 222 /* VoidExpression */:
    case 220 /* DeleteExpression */:
    case 223 /* AwaitExpression */:
      return 16 /* Unary */;
    case 225 /* PostfixUnaryExpression */:
      return 17 /* Update */;
    case 213 /* CallExpression */:
      return 18 /* LeftHandSide */;
    case 214 /* NewExpression */:
      return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */;
    case 215 /* TaggedTemplateExpression */:
    case 211 /* PropertyAccessExpression */:
    case 212 /* ElementAccessExpression */:
    case 236 /* MetaProperty */:
      return 19 /* Member */;
    case 234 /* AsExpression */:
    case 238 /* SatisfiesExpression */:
      return 11 /* Relational */;
    case 110 /* ThisKeyword */:
    case 108 /* SuperKeyword */:
    case 80 /* Identifier */:
    case 81 /* PrivateIdentifier */:
    case 106 /* NullKeyword */:
    case 112 /* TrueKeyword */:
    case 97 /* FalseKeyword */:
    case 9 /* NumericLiteral */:
    case 10 /* BigIntLiteral */:
    case 11 /* StringLiteral */:
    case 209 /* ArrayLiteralExpression */:
    case 210 /* ObjectLiteralExpression */:
    case 218 /* FunctionExpression */:
    case 219 /* ArrowFunction */:
    case 231 /* ClassExpression */:
    case 14 /* RegularExpressionLiteral */:
    case 15 /* NoSubstitutionTemplateLiteral */:
    case 228 /* TemplateExpression */:
    case 217 /* ParenthesizedExpression */:
    case 232 /* OmittedExpression */:
    case 284 /* JsxElement */:
    case 285 /* JsxSelfClosingElement */:
    case 288 /* JsxFragment */:
      return 20 /* Primary */;
    default:
      return -1 /* Invalid */;
  }
}
function getBinaryOperatorPrecedence(kind) {
  switch (kind) {
    case 61 /* QuestionQuestionToken */:
      return 4 /* Coalesce */;
    case 57 /* BarBarToken */:
      return 5 /* LogicalOR */;
    case 56 /* AmpersandAmpersandToken */:
      return 6 /* LogicalAND */;
    case 52 /* BarToken */:
      return 7 /* BitwiseOR */;
    case 53 /* CaretToken */:
      return 8 /* BitwiseXOR */;
    case 51 /* AmpersandToken */:
      return 9 /* BitwiseAND */;
    case 35 /* EqualsEqualsToken */:
    case 36 /* ExclamationEqualsToken */:
    case 37 /* EqualsEqualsEqualsToken */:
    case 38 /* ExclamationEqualsEqualsToken */:
      return 10 /* Equality */;
    case 30 /* LessThanToken */:
    case 32 /* GreaterThanToken */:
    case 33 /* LessThanEqualsToken */:
    case 34 /* GreaterThanEqualsToken */:
    case 104 /* InstanceOfKeyword */:
    case 103 /* InKeyword */:
    case 130 /* AsKeyword */:
    case 152 /* SatisfiesKeyword */:
      return 11 /* Relational */;
    case 48 /* LessThanLessThanToken */:
    case 49 /* GreaterThanGreaterThanToken */:
    case 50 /* GreaterThanGreaterThanGreaterThanToken */:
      return 12 /* Shift */;
    case 40 /* PlusToken */:
    case 41 /* MinusToken */:
      return 13 /* Additive */;
    case 42 /* AsteriskToken */:
    case 44 /* SlashToken */:
    case 45 /* PercentToken */:
      return 14 /* Multiplicative */;
    case 43 /* AsteriskAsteriskToken */:
      return 15 /* Exponentiation */;
  }
  return -1;
}
function getSemanticJsxChildren(children) {
  return filter(children, (i) => {
    switch (i.kind) {
      case 294 /* JsxExpression */:
        return !!i.expression;
      case 12 /* JsxText */:
        return !i.containsOnlyTriviaWhiteSpaces;
      default:
        return true;
    }
  });
}
function createDiagnosticCollection() {
  let nonFileDiagnostics = [];
  const filesWithDiagnostics = [];
  const fileDiagnostics = /* @__PURE__ */ new Map();
  let hasReadNonFileDiagnostics = false;
  return {
    add,
    lookup,
    getGlobalDiagnostics,
    getDiagnostics: getDiagnostics2
  };
  function lookup(diagnostic) {
    let diagnostics;
    if (diagnostic.file) {
      diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
    } else {
      diagnostics = nonFileDiagnostics;
    }
    if (!diagnostics) {
      return void 0;
    }
    const result = binarySearch(diagnostics, diagnostic, identity, compareDiagnosticsSkipRelatedInformation);
    if (result >= 0) {
      return diagnostics[result];
    }
    if (~result > 0 && diagnosticsEqualityComparer(diagnostic, diagnostics[~result - 1])) {
      return diagnostics[~result - 1];
    }
    return void 0;
  }
  function add(diagnostic) {
    let diagnostics;
    if (diagnostic.file) {
      diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
      if (!diagnostics) {
        diagnostics = [];
        fileDiagnostics.set(diagnostic.file.fileName, diagnostics);
        insertSorted(filesWithDiagnostics, diagnostic.file.fileName, compareStringsCaseSensitive);
      }
    } else {
      if (hasReadNonFileDiagnostics) {
        hasReadNonFileDiagnostics = false;
        nonFileDiagnostics = nonFileDiagnostics.slice();
      }
      diagnostics = nonFileDiagnostics;
    }
    insertSorted(diagnostics, diagnostic, compareDiagnosticsSkipRelatedInformation, diagnosticsEqualityComparer);
  }
  function getGlobalDiagnostics() {
    hasReadNonFileDiagnostics = true;
    return nonFileDiagnostics;
  }
  function getDiagnostics2(fileName) {
    if (fileName) {
      return fileDiagnostics.get(fileName) || [];
    }
    const fileDiags = flatMapToMutable(filesWithDiagnostics, (f) => fileDiagnostics.get(f));
    if (!nonFileDiagnostics.length) {
      return fileDiags;
    }
    fileDiags.unshift(...nonFileDiagnostics);
    return fileDiags;
  }
}
var templateSubstitutionRegExp = /\$\{/g;
function escapeTemplateSubstitution(str) {
  return str.replace(templateSubstitutionRegExp, "\\${");
}
function containsInvalidEscapeFlag(node) {
  return !!((node.templateFlags || 0) & 2048 /* ContainsInvalidEscape */);
}
function hasInvalidEscape(template) {
  return template && !!(isNoSubstitutionTemplateLiteral(template) ? containsInvalidEscapeFlag(template) : containsInvalidEscapeFlag(template.head) || some(template.templateSpans, (span) => containsInvalidEscapeFlag(span.literal)));
}
var doubleQuoteEscapedCharsRegExp = /[\\"\u0000-\u001f\u2028\u2029\u0085]/g;
var singleQuoteEscapedCharsRegExp = /[\\'\u0000-\u001f\u2028\u2029\u0085]/g;
var backtickQuoteEscapedCharsRegExp = /\r\n|[\\`\u0000-\u0009\u000b-\u001f\u2028\u2029\u0085]/g;
var escapedCharsMap = new Map(Object.entries({
  "	": "\\t",
  "\v": "\\v",
  "\f": "\\f",
  "\b": "\\b",
  "\r": "\\r",
  "\n": "\\n",
  "\\": "\\\\",
  '"': '\\"',
  "'": "\\'",
  "`": "\\`",
  "\u2028": "\\u2028",
  // lineSeparator
  "\u2029": "\\u2029",
  // paragraphSeparator
  "\x85": "\\u0085",
  // nextLine
  "\r\n": "\\r\\n"
  // special case for CRLFs in backticks
}));
function encodeUtf16EscapeSequence(charCode) {
  const hexCharCode = charCode.toString(16).toUpperCase();
  const paddedHexCode = ("0000" + hexCharCode).slice(-4);
  return "\\u" + paddedHexCode;
}
function getReplacement(c, offset, input) {
  if (c.charCodeAt(0) === 0 /* nullCharacter */) {
    const lookAhead = input.charCodeAt(offset + c.length);
    if (lookAhead >= 48 /* _0 */ && lookAhead <= 57 /* _9 */) {
      return "\\x00";
    }
    return "\\0";
  }
  return escapedCharsMap.get(c) || encodeUtf16EscapeSequence(c.charCodeAt(0));
}
function escapeString(s, quoteChar) {
  const escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp : quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp;
  return s.replace(escapedCharsRegExp, getReplacement);
}
var nonAsciiCharacters = /[^\u0000-\u007F]/g;
function escapeNonAsciiString(s, quoteChar) {
  s = escapeString(s, quoteChar);
  return nonAsciiCharacters.test(s) ? s.replace(nonAsciiCharacters, (c) => encodeUtf16EscapeSequence(c.charCodeAt(0))) : s;
}
var jsxDoubleQuoteEscapedCharsRegExp = /["\u0000-\u001f\u2028\u2029\u0085]/g;
var jsxSingleQuoteEscapedCharsRegExp = /['\u0000-\u001f\u2028\u2029\u0085]/g;
var jsxEscapedCharsMap = new Map(Object.entries({
  '"': "&quot;",
  "'": "&apos;"
}));
function encodeJsxCharacterEntity(charCode) {
  const hexCharCode = charCode.toString(16).toUpperCase();
  return "&#x" + hexCharCode + ";";
}
function getJsxAttributeStringReplacement(c) {
  if (c.charCodeAt(0) === 0 /* nullCharacter */) {
    return "&#0;";
  }
  return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0));
}
function escapeJsxAttributeString(s, quoteChar) {
  const escapedCharsRegExp = quoteChar === 39 /* singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : jsxDoubleQuoteEscapedCharsRegExp;
  return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement);
}
function stripQuotes(name) {
  const length2 = name.length;
  if (length2 >= 2 && name.charCodeAt(0) === name.charCodeAt(length2 - 1) && isQuoteOrBacktick(name.charCodeAt(0))) {
    return name.substring(1, length2 - 1);
  }
  return name;
}
function isQuoteOrBacktick(charCode) {
  return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */ || charCode === 96 /* backtick */;
}
function isIntrinsicJsxName(name) {
  const ch = name.charCodeAt(0);
  return ch >= 97 /* a */ && ch <= 122 /* z */ || name.includes("-");
}
var indentStrings = ["", "    "];
function getIndentString(level) {
  const singleLevel = indentStrings[1];
  for (let current = indentStrings.length; current <= level; current++) {
    indentStrings.push(indentStrings[current - 1] + singleLevel);
  }
  return indentStrings[level];
}
function getIndentSize() {
  return indentStrings[1].length;
}
function createTextWriter(newLine) {
  var output;
  var indent3;
  var lineStart;
  var lineCount;
  var linePos;
  var hasTrailingComment = false;
  function updateLineCountAndPosFor(s) {
    const lineStartsOfS = computeLineStarts(s);
    if (lineStartsOfS.length > 1) {
      lineCount = lineCount + lineStartsOfS.length - 1;
      linePos = output.length - s.length + last(lineStartsOfS);
      lineStart = linePos - output.length === 0;
    } else {
      lineStart = false;
    }
  }
  function writeText(s) {
    if (s && s.length) {
      if (lineStart) {
        s = getIndentString(indent3) + s;
        lineStart = false;
      }
      output += s;
      updateLineCountAndPosFor(s);
    }
  }
  function write(s) {
    if (s) hasTrailingComment = false;
    writeText(s);
  }
  function writeComment(s) {
    if (s) hasTrailingComment = true;
    writeText(s);
  }
  function reset2() {
    output = "";
    indent3 = 0;
    lineStart = true;
    lineCount = 0;
    linePos = 0;
    hasTrailingComment = false;
  }
  function rawWrite(s) {
    if (s !== void 0) {
      output += s;
      updateLineCountAndPosFor(s);
      hasTrailingComment = false;
    }
  }
  function writeLiteral(s) {
    if (s && s.length) {
      write(s);
    }
  }
  function writeLine(force) {
    if (!lineStart || force) {
      output += newLine;
      lineCount++;
      linePos = output.length;
      lineStart = true;
      hasTrailingComment = false;
    }
  }
  reset2();
  return {
    write,
    rawWrite,
    writeLiteral,
    writeLine,
    increaseIndent: () => {
      indent3++;
    },
    decreaseIndent: () => {
      indent3--;
    },
    getIndent: () => indent3,
    getTextPos: () => output.length,
    getLine: () => lineCount,
    getColumn: () => lineStart ? indent3 * getIndentSize() : output.length - linePos,
    getText: () => output,
    isAtStartOfLine: () => lineStart,
    hasTrailingComment: () => hasTrailingComment,
    hasTrailingWhitespace: () => !!output.length && isWhiteSpaceLike(output.charCodeAt(output.length - 1)),
    clear: reset2,
    writeKeyword: write,
    writeOperator: write,
    writeParameter: write,
    writeProperty: write,
    writePunctuation: write,
    writeSpace: write,
    writeStringLiteral: write,
    writeSymbol: (s, _) => write(s),
    writeTrailingSemicolon: write,
    writeComment
  };
}
function getTrailingSemicolonDeferringWriter(writer) {
  let pendingTrailingSemicolon = false;
  function commitPendingTrailingSemicolon() {
    if (pendingTrailingSemicolon) {
      writer.writeTrailingSemicolon(";");
      pendingTrailingSemicolon = false;
    }
  }
  return {
    ...writer,
    writeTrailingSemicolon() {
      pendingTrailingSemicolon = true;
    },
    writeLiteral(s) {
      commitPendingTrailingSemicolon();
      writer.writeLiteral(s);
    },
    writeStringLiteral(s) {
      commitPendingTrailingSemicolon();
      writer.writeStringLiteral(s);
    },
    writeSymbol(s, sym) {
      commitPendingTrailingSemicolon();
      writer.writeSymbol(s, sym);
    },
    writePunctuation(s) {
      commitPendingTrailingSemicolon();
      writer.writePunctuation(s);
    },
    writeKeyword(s) {
      commitPendingTrailingSemicolon();
      writer.writeKeyword(s);
    },
    writeOperator(s) {
      commitPendingTrailingSemicolon();
      writer.writeOperator(s);
    },
    writeParameter(s) {
      commitPendingTrailingSemicolon();
      writer.writeParameter(s);
    },
    writeSpace(s) {
      commitPendingTrailingSemicolon();
      writer.writeSpace(s);
    },
    writeProperty(s) {
      commitPendingTrailingSemicolon();
      writer.writeProperty(s);
    },
    writeComment(s) {
      commitPendingTrailingSemicolon();
      writer.writeComment(s);
    },
    writeLine() {
      commitPendingTrailingSemicolon();
      writer.writeLine();
    },
    increaseIndent() {
      commitPendingTrailingSemicolon();
      writer.increaseIndent();
    },
    decreaseIndent() {
      commitPendingTrailingSemicolon();
      writer.decreaseIndent();
    }
  };
}
function hostUsesCaseSensitiveFileNames(host) {
  return host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : false;
}
function hostGetCanonicalFileName(host) {
  return createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host));
}
function getResolvedExternalModuleName(host, file, referenceFile) {
  return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName);
}
function getCanonicalAbsolutePath(host, path) {
  return host.getCanonicalFileName(getNormalizedAbsolutePath(path, host.getCurrentDirectory()));
}
function getExternalModuleNameFromDeclaration(host, resolver, declaration) {
  const file = resolver.getExternalModuleFileFromDeclaration(declaration);
  if (!file || file.isDeclarationFile) {
    return void 0;
  }
  const specifier = getExternalModuleName(declaration);
  if (specifier && isStringLiteralLike(specifier) && !pathIsRelative(specifier.text) && !getCanonicalAbsolutePath(host, file.path).includes(getCanonicalAbsolutePath(host, ensureTrailingDirectorySeparator(host.getCommonSourceDirectory())))) {
    return void 0;
  }
  return getResolvedExternalModuleName(host, file);
}
function getExternalModuleNameFromPath(host, fileName, referencePath) {
  const getCanonicalFileName = (f) => host.getCanonicalFileName(f);
  const dir = toPath(referencePath ? getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
  const filePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
  const relativePath = getRelativePathToDirectoryOrUrl(
    dir,
    filePath,
    dir,
    getCanonicalFileName,
    /*isAbsolutePathAnUrl*/
    false
  );
  const extensionless = removeFileExtension(relativePath);
  return referencePath ? ensurePathIsNonModuleName(extensionless) : extensionless;
}
function getOwnEmitOutputFilePath(fileName, host, extension) {
  const compilerOptions = host.getCompilerOptions();
  let emitOutputFilePathWithoutExtension;
  if (compilerOptions.outDir) {
    emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(fileName, host, compilerOptions.outDir));
  } else {
    emitOutputFilePathWithoutExtension = removeFileExtension(fileName);
  }
  return emitOutputFilePathWithoutExtension + extension;
}
function getDeclarationEmitOutputFilePath(fileName, host) {
  return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host);
}
function getDeclarationEmitOutputFilePathWorker(fileName, options, host) {
  const outputDir = options.declarationDir || options.outDir;
  const path = outputDir ? getSourceFilePathInNewDirWorker(fileName, outputDir, host.getCurrentDirectory(), host.getCommonSourceDirectory(), (f) => host.getCanonicalFileName(f)) : fileName;
  const declarationExtension = getDeclarationEmitExtensionForPath(path);
  return removeFileExtension(path) + declarationExtension;
}
function getDeclarationEmitExtensionForPath(path) {
  return fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : fileExtensionIsOneOf(path, [".json" /* Json */]) ? `.d.json.ts` : (
    // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well
    ".d.ts" /* Dts */
  );
}
function getPossibleOriginalInputExtensionForExtension(path) {
  return fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] : fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] : fileExtensionIsOneOf(path, [`.d.json.ts`]) ? [".json" /* Json */] : [".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */];
}
function getPossibleOriginalInputPathWithoutChangingExt(filePath, ignoreCase, outputDir, getCommonSourceDirectory2) {
  return outputDir ? resolvePath(
    getCommonSourceDirectory2(),
    getRelativePathFromDirectory(outputDir, filePath, ignoreCase)
  ) : filePath;
}
function getPathsBasePath(options, host) {
  var _a;
  if (!options.paths) return void 0;
  return options.baseUrl ?? Debug.checkDefined(options.pathsBasePath || ((_a = host.getCurrentDirectory) == null ? void 0 : _a.call(host)), "Encountered 'paths' without a 'baseUrl', config file, or host 'getCurrentDirectory'.");
}
function getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit) {
  const options = host.getCompilerOptions();
  if (options.outFile) {
    const moduleKind = getEmitModuleKind(options);
    const moduleEmitEnabled = options.emitDeclarationOnly || moduleKind === 2 /* AMD */ || moduleKind === 4 /* System */;
    return filter(
      host.getSourceFiles(),
      (sourceFile) => (moduleEmitEnabled || !isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit)
    );
  } else {
    const sourceFiles = targetSourceFile === void 0 ? host.getSourceFiles() : [targetSourceFile];
    return filter(
      sourceFiles,
      (sourceFile) => sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit)
    );
  }
}
function sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit) {
  const options = host.getCompilerOptions();
  if (options.noEmitForJsFiles && isSourceFileJS(sourceFile)) return false;
  if (sourceFile.isDeclarationFile) return false;
  if (host.isSourceFileFromExternalLibrary(sourceFile)) return false;
  if (forceDtsEmit) return true;
  if (host.isSourceOfProjectReferenceRedirect(sourceFile.fileName)) return false;
  if (!isJsonSourceFile(sourceFile)) return true;
  if (host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) return false;
  if (options.outFile) return true;
  if (!options.outDir) return false;
  if (options.rootDir || options.composite && options.configFilePath) {
    const commonDir = getNormalizedAbsolutePath(getCommonSourceDirectory(options, () => [], host.getCurrentDirectory(), host.getCanonicalFileName), host.getCurrentDirectory());
    const outputPath = getSourceFilePathInNewDirWorker(sourceFile.fileName, options.outDir, host.getCurrentDirectory(), commonDir, host.getCanonicalFileName);
    if (comparePaths(sourceFile.fileName, outputPath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */) return false;
  }
  return true;
}
function getSourceFilePathInNewDir(fileName, host, newDirPath) {
  return getSourceFilePathInNewDirWorker(fileName, newDirPath, host.getCurrentDirectory(), host.getCommonSourceDirectory(), (f) => host.getCanonicalFileName(f));
}
function getSourceFilePathInNewDirWorker(fileName, newDirPath, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
  let sourceFilePath = getNormalizedAbsolutePath(fileName, currentDirectory);
  const isSourceFileInCommonSourceDirectory = getCanonicalFileName(sourceFilePath).indexOf(getCanonicalFileName(commonSourceDirectory)) === 0;
  sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath;
  return combinePaths(newDirPath, sourceFilePath);
}
function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
  host.writeFile(
    fileName,
    text,
    writeByteOrderMark,
    (hostErrorMessage) => {
      diagnostics.add(createCompilerDiagnostic(Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
    },
    sourceFiles,
    data
  );
}
function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
  if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
    const parentDirectory = getDirectoryPath(directoryPath);
    ensureDirectoriesExist(parentDirectory, createDirectory, directoryExists);
    createDirectory(directoryPath);
  }
}
function writeFileEnsuringDirectories(path, data, writeByteOrderMark, writeFile2, createDirectory, directoryExists) {
  try {
    writeFile2(path, data, writeByteOrderMark);
  } catch {
    ensureDirectoriesExist(getDirectoryPath(normalizePath(path)), createDirectory, directoryExists);
    writeFile2(path, data, writeByteOrderMark);
  }
}
function getLineOfLocalPosition(sourceFile, pos) {
  const lineStarts = getLineStarts(sourceFile);
  return computeLineOfPosition(lineStarts, pos);
}
function getLineOfLocalPositionFromLineMap(lineMap, pos) {
  return computeLineOfPosition(lineMap, pos);
}
function getFirstConstructorWithBody(node) {
  return find(node.members, (member) => isConstructorDeclaration(member) && nodeIsPresent(member.body));
}
function getSetAccessorValueParameter(accessor) {
  if (accessor && accessor.parameters.length > 0) {
    const hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]);
    return accessor.parameters[hasThis ? 1 : 0];
  }
}
function getSetAccessorTypeAnnotationNode(accessor) {
  const parameter = getSetAccessorValueParameter(accessor);
  return parameter && parameter.type;
}
function getThisParameter(signature) {
  if (signature.parameters.length && !isJSDocSignature(signature)) {
    const thisParameter = signature.parameters[0];
    if (parameterIsThisKeyword(thisParameter)) {
      return thisParameter;
    }
  }
}
function parameterIsThisKeyword(parameter) {
  return isThisIdentifier(parameter.name);
}
function isThisIdentifier(node) {
  return !!node && node.kind === 80 /* Identifier */ && identifierIsThisKeyword(node);
}
function isInTypeQuery(node) {
  return !!findAncestor(
    node,
    (n) => n.kind === 186 /* TypeQuery */ ? true : n.kind === 80 /* Identifier */ || n.kind === 166 /* QualifiedName */ ? false : "quit"
  );
}
function isThisInTypeQuery(node) {
  if (!isThisIdentifier(node)) {
    return false;
  }
  while (isQualifiedName(node.parent) && node.parent.left === node) {
    node = node.parent;
  }
  return node.parent.kind === 186 /* TypeQuery */;
}
function identifierIsThisKeyword(id) {
  return id.escapedText === "this";
}
function getAllAccessorDeclarations(declarations, accessor) {
  let firstAccessor;
  let secondAccessor;
  let getAccessor;
  let setAccessor;
  if (hasDynamicName(accessor)) {
    firstAccessor = accessor;
    if (accessor.kind === 177 /* GetAccessor */) {
      getAccessor = accessor;
    } else if (accessor.kind === 178 /* SetAccessor */) {
      setAccessor = accessor;
    } else {
      Debug.fail("Accessor has wrong kind");
    }
  } else {
    forEach(declarations, (member) => {
      if (isAccessor(member) && isStatic(member) === isStatic(accessor)) {
        const memberName = getPropertyNameForPropertyNameNode(member.name);
        const accessorName = getPropertyNameForPropertyNameNode(accessor.name);
        if (memberName === accessorName) {
          if (!firstAccessor) {
            firstAccessor = member;
          } else if (!secondAccessor) {
            secondAccessor = member;
          }
          if (member.kind === 177 /* GetAccessor */ && !getAccessor) {
            getAccessor = member;
          }
          if (member.kind === 178 /* SetAccessor */ && !setAccessor) {
            setAccessor = member;
          }
        }
      }
    });
  }
  return {
    firstAccessor,
    secondAccessor,
    getAccessor,
    setAccessor
  };
}
function getEffectiveTypeAnnotationNode(node) {
  if (!isInJSFile(node) && isFunctionDeclaration(node)) return void 0;
  if (isTypeAliasDeclaration(node)) return void 0;
  const type = node.type;
  if (type || !isInJSFile(node)) return type;
  return isJSDocPropertyLikeTag(node) ? node.typeExpression && node.typeExpression.type : getJSDocType(node);
}
function getTypeAnnotationNode(node) {
  return node.type;
}
function getEffectiveReturnTypeNode(node) {
  return isJSDocSignature(node) ? node.type && node.type.typeExpression && node.type.typeExpression.type : node.type || (isInJSFile(node) ? getJSDocReturnType(node) : void 0);
}
function getJSDocTypeParameterDeclarations(node) {
  return flatMap(getJSDocTags(node), (tag) => isNonTypeAliasTemplate(tag) ? tag.typeParameters : void 0);
}
function isNonTypeAliasTemplate(tag) {
  return isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* JSDoc */ && (tag.parent.tags.some(isJSDocTypeAlias) || tag.parent.tags.some(isJSDocOverloadTag)));
}
function getEffectiveSetAccessorTypeAnnotationNode(node) {
  const parameter = getSetAccessorValueParameter(node);
  return parameter && getEffectiveTypeAnnotationNode(parameter);
}
function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) {
  emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments);
}
function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) {
  if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos && getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) {
    writer.writeLine();
  }
}
function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) {
  if (pos !== commentPos && getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) {
    writer.writeLine();
  }
}
function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) {
  if (comments && comments.length > 0) {
    if (leadingSeparator) {
      writer.writeSpace(" ");
    }
    let emitInterveningSeparator = false;
    for (const comment of comments) {
      if (emitInterveningSeparator) {
        writer.writeSpace(" ");
        emitInterveningSeparator = false;
      }
      writeComment(text, lineMap, writer, comment.pos, comment.end, newLine);
      if (comment.hasTrailingNewLine) {
        writer.writeLine();
      } else {
        emitInterveningSeparator = true;
      }
    }
    if (emitInterveningSeparator && trailingSeparator) {
      writer.writeSpace(" ");
    }
  }
}
function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) {
  let leadingComments;
  let currentDetachedCommentInfo;
  if (removeComments) {
    if (node.pos === 0) {
      leadingComments = filter(getLeadingCommentRanges(text, node.pos), isPinnedCommentLocal);
    }
  } else {
    leadingComments = getLeadingCommentRanges(text, node.pos);
  }
  if (leadingComments) {
    const detachedComments = [];
    let lastComment;
    for (const comment of leadingComments) {
      if (lastComment) {
        const lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end);
        const commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos);
        if (commentLine >= lastCommentLine + 2) {
          break;
        }
      }
      detachedComments.push(comment);
      lastComment = comment;
    }
    if (detachedComments.length) {
      const lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, last(detachedComments).end);
      const nodeLine = getLineOfLocalPositionFromLineMap(lineMap, skipTrivia(text, node.pos));
      if (nodeLine >= lastCommentLine + 2) {
        emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments);
        emitComments(
          text,
          lineMap,
          writer,
          detachedComments,
          /*leadingSeparator*/
          false,
          /*trailingSeparator*/
          true,
          newLine,
          writeComment
        );
        currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: last(detachedComments).end };
      }
    }
  }
  return currentDetachedCommentInfo;
  function isPinnedCommentLocal(comment) {
    return isPinnedComment(text, comment.pos);
  }
}
function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) {
  if (text.charCodeAt(commentPos + 1) === 42 /* asterisk */) {
    const firstCommentLineAndCharacter = computeLineAndCharacterOfPosition(lineMap, commentPos);
    const lineCount = lineMap.length;
    let firstCommentLineIndent;
    for (let pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) {
      const nextLineStart = currentLine + 1 === lineCount ? text.length + 1 : lineMap[currentLine + 1];
      if (pos !== commentPos) {
        if (firstCommentLineIndent === void 0) {
          firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos);
        }
        const currentWriterIndentSpacing = writer.getIndent() * getIndentSize();
        const spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart);
        if (spacesToEmit > 0) {
          let numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize();
          const indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
          writer.rawWrite(indentSizeSpaceString);
          while (numberOfSingleSpacesToEmit) {
            writer.rawWrite(" ");
            numberOfSingleSpacesToEmit--;
          }
        } else {
          writer.rawWrite("");
        }
      }
      writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart);
      pos = nextLineStart;
    }
  } else {
    writer.writeComment(text.substring(commentPos, commentEnd));
  }
}
function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) {
  const end = Math.min(commentEnd, nextLineStart - 1);
  const currentLineText = text.substring(pos, end).trim();
  if (currentLineText) {
    writer.writeComment(currentLineText);
    if (end !== commentEnd) {
      writer.writeLine();
    }
  } else {
    writer.rawWrite(newLine);
  }
}
function calculateIndent(text, pos, end) {
  let currentLineIndent = 0;
  for (; pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) {
    if (text.charCodeAt(pos) === 9 /* tab */) {
      currentLineIndent += getIndentSize() - currentLineIndent % getIndentSize();
    } else {
      currentLineIndent++;
    }
  }
  return currentLineIndent;
}
function hasEffectiveModifiers(node) {
  return getEffectiveModifierFlags(node) !== 0 /* None */;
}
function hasSyntacticModifiers(node) {
  return getSyntacticModifierFlags(node) !== 0 /* None */;
}
function hasEffectiveModifier(node, flags) {
  return !!getSelectedEffectiveModifierFlags(node, flags);
}
function hasSyntacticModifier(node, flags) {
  return !!getSelectedSyntacticModifierFlags(node, flags);
}
function isStatic(node) {
  return isClassElement(node) && hasStaticModifier(node) || isClassStaticBlockDeclaration(node);
}
function hasStaticModifier(node) {
  return hasSyntacticModifier(node, 256 /* Static */);
}
function hasOverrideModifier(node) {
  return hasEffectiveModifier(node, 16 /* Override */);
}
function hasAbstractModifier(node) {
  return hasSyntacticModifier(node, 64 /* Abstract */);
}
function hasAmbientModifier(node) {
  return hasSyntacticModifier(node, 128 /* Ambient */);
}
function hasAccessorModifier(node) {
  return hasSyntacticModifier(node, 512 /* Accessor */);
}
function hasEffectiveReadonlyModifier(node) {
  return hasEffectiveModifier(node, 8 /* Readonly */);
}
function hasDecorators(node) {
  return hasSyntacticModifier(node, 32768 /* Decorator */);
}
function getSelectedEffectiveModifierFlags(node, flags) {
  return getEffectiveModifierFlags(node) & flags;
}
function getSelectedSyntacticModifierFlags(node, flags) {
  return getSyntacticModifierFlags(node) & flags;
}
function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) {
  if (node.kind >= 0 /* FirstToken */ && node.kind <= 165 /* LastToken */) {
    return 0 /* None */;
  }
  if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) {
    node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */;
  }
  if (alwaysIncludeJSDoc || includeJSDoc && isInJSFile(node)) {
    if (!(node.modifierFlagsCache & 268435456 /* HasComputedJSDocModifiers */) && node.parent) {
      node.modifierFlagsCache |= getRawJSDocModifierFlagsNoCache(node) | 268435456 /* HasComputedJSDocModifiers */;
    }
    return selectEffectiveModifierFlags(node.modifierFlagsCache);
  }
  return selectSyntacticModifierFlags(node.modifierFlagsCache);
}
function getEffectiveModifierFlags(node) {
  return getModifierFlagsWorker(
    node,
    /*includeJSDoc*/
    true
  );
}
function getEffectiveModifierFlagsAlwaysIncludeJSDoc(node) {
  return getModifierFlagsWorker(
    node,
    /*includeJSDoc*/
    true,
    /*alwaysIncludeJSDoc*/
    true
  );
}
function getSyntacticModifierFlags(node) {
  return getModifierFlagsWorker(
    node,
    /*includeJSDoc*/
    false
  );
}
function getRawJSDocModifierFlagsNoCache(node) {
  let flags = 0 /* None */;
  if (!!node.parent && !isParameter(node)) {
    if (isInJSFile(node)) {
      if (getJSDocPublicTagNoCache(node)) flags |= 8388608 /* JSDocPublic */;
      if (getJSDocPrivateTagNoCache(node)) flags |= 16777216 /* JSDocPrivate */;
      if (getJSDocProtectedTagNoCache(node)) flags |= 33554432 /* JSDocProtected */;
      if (getJSDocReadonlyTagNoCache(node)) flags |= 67108864 /* JSDocReadonly */;
      if (getJSDocOverrideTagNoCache(node)) flags |= 134217728 /* JSDocOverride */;
    }
    if (getJSDocDeprecatedTagNoCache(node)) flags |= 65536 /* Deprecated */;
  }
  return flags;
}
function selectSyntacticModifierFlags(flags) {
  return flags & 65535 /* SyntacticModifiers */;
}
function selectEffectiveModifierFlags(flags) {
  return flags & 131071 /* NonCacheOnlyModifiers */ | (flags & 260046848 /* JSDocCacheOnlyModifiers */) >>> 23;
}
function getJSDocModifierFlagsNoCache(node) {
  return selectEffectiveModifierFlags(getRawJSDocModifierFlagsNoCache(node));
}
function getEffectiveModifierFlagsNoCache(node) {
  return getSyntacticModifierFlagsNoCache(node) | getJSDocModifierFlagsNoCache(node);
}
function getSyntacticModifierFlagsNoCache(node) {
  let flags = canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0 /* None */;
  if (node.flags & 8 /* NestedNamespace */ || node.kind === 80 /* Identifier */ && node.flags & 4096 /* IdentifierIsInJSDocNamespace */) {
    flags |= 32 /* Export */;
  }
  return flags;
}
function modifiersToFlags(modifiers) {
  let flags = 0 /* None */;
  if (modifiers) {
    for (const modifier of modifiers) {
      flags |= modifierToFlag(modifier.kind);
    }
  }
  return flags;
}
function modifierToFlag(token) {
  switch (token) {
    case 126 /* StaticKeyword */:
      return 256 /* Static */;
    case 125 /* PublicKeyword */:
      return 1 /* Public */;
    case 124 /* ProtectedKeyword */:
      return 4 /* Protected */;
    case 123 /* PrivateKeyword */:
      return 2 /* Private */;
    case 128 /* AbstractKeyword */:
      return 64 /* Abstract */;
    case 129 /* AccessorKeyword */:
      return 512 /* Accessor */;
    case 95 /* ExportKeyword */:
      return 32 /* Export */;
    case 138 /* DeclareKeyword */:
      return 128 /* Ambient */;
    case 87 /* ConstKeyword */:
      return 4096 /* Const */;
    case 90 /* DefaultKeyword */:
      return 2048 /* Default */;
    case 134 /* AsyncKeyword */:
      return 1024 /* Async */;
    case 148 /* ReadonlyKeyword */:
      return 8 /* Readonly */;
    case 164 /* OverrideKeyword */:
      return 16 /* Override */;
    case 103 /* InKeyword */:
      return 8192 /* In */;
    case 147 /* OutKeyword */:
      return 16384 /* Out */;
    case 170 /* Decorator */:
      return 32768 /* Decorator */;
  }
  return 0 /* None */;
}
function isBinaryLogicalOperator(token) {
  return token === 57 /* BarBarToken */ || token === 56 /* AmpersandAmpersandToken */;
}
function isLogicalOperator(token) {
  return isBinaryLogicalOperator(token) || token === 54 /* ExclamationToken */;
}
function isLogicalOrCoalescingAssignmentOperator(token) {
  return token === 76 /* BarBarEqualsToken */ || token === 77 /* AmpersandAmpersandEqualsToken */ || token === 78 /* QuestionQuestionEqualsToken */;
}
function isLogicalOrCoalescingAssignmentExpression(expr) {
  return isBinaryExpression(expr) && isLogicalOrCoalescingAssignmentOperator(expr.operatorToken.kind);
}
function isLogicalOrCoalescingBinaryOperator(token) {
  return isBinaryLogicalOperator(token) || token === 61 /* QuestionQuestionToken */;
}
function isLogicalOrCoalescingBinaryExpression(expr) {
  return isBinaryExpression(expr) && isLogicalOrCoalescingBinaryOperator(expr.operatorToken.kind);
}
function isAssignmentOperator(token) {
  return token >= 64 /* FirstAssignment */ && token <= 79 /* LastAssignment */;
}
function tryGetClassExtendingExpressionWithTypeArguments(node) {
  const cls = tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node);
  return cls && !cls.isImplements ? cls.class : void 0;
}
function tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node) {
  if (isExpressionWithTypeArguments(node)) {
    if (isHeritageClause(node.parent) && isClassLike(node.parent.parent)) {
      return { class: node.parent.parent, isImplements: node.parent.token === 119 /* ImplementsKeyword */ };
    }
    if (isJSDocAugmentsTag(node.parent)) {
      const host = getEffectiveJSDocHost(node.parent);
      if (host && isClassLike(host)) {
        return { class: host, isImplements: false };
      }
    }
  }
  return void 0;
}
function isAssignmentExpression(node, excludeCompoundAssignment) {
  return isBinaryExpression(node) && (excludeCompoundAssignment ? node.operatorToken.kind === 64 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && isLeftHandSideExpression(node.left);
}
function isDestructuringAssignment(node) {
  if (isAssignmentExpression(
    node,
    /*excludeCompoundAssignment*/
    true
  )) {
    const kind = node.left.kind;
    return kind === 210 /* ObjectLiteralExpression */ || kind === 209 /* ArrayLiteralExpression */;
  }
  return false;
}
function isExpressionWithTypeArgumentsInClassExtendsClause(node) {
  return tryGetClassExtendingExpressionWithTypeArguments(node) !== void 0;
}
function isEntityNameExpression(node) {
  return node.kind === 80 /* Identifier */ || isPropertyAccessEntityNameExpression(node);
}
function getFirstIdentifier(node) {
  switch (node.kind) {
    case 80 /* Identifier */:
      return node;
    case 166 /* QualifiedName */:
      do {
        node = node.left;
      } while (node.kind !== 80 /* Identifier */);
      return node;
    case 211 /* PropertyAccessExpression */:
      do {
        node = node.expression;
      } while (node.kind !== 80 /* Identifier */);
      return node;
  }
}
function isDottedName(node) {
  return node.kind === 80 /* Identifier */ || node.kind === 110 /* ThisKeyword */ || node.kind === 108 /* SuperKeyword */ || node.kind === 236 /* MetaProperty */ || node.kind === 211 /* PropertyAccessExpression */ && isDottedName(node.expression) || node.kind === 217 /* ParenthesizedExpression */ && isDottedName(node.expression);
}
function isPropertyAccessEntityNameExpression(node) {
  return isPropertyAccessExpression(node) && isIdentifier(node.name) && isEntityNameExpression(node.expression);
}
function tryGetPropertyAccessOrIdentifierToString(expr) {
  if (isPropertyAccessExpression(expr)) {
    const baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression);
    if (baseStr !== void 0) {
      return baseStr + "." + entityNameToString(expr.name);
    }
  } else if (isElementAccessExpression(expr)) {
    const baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression);
    if (baseStr !== void 0 && isPropertyName(expr.argumentExpression)) {
      return baseStr + "." + getPropertyNameForPropertyNameNode(expr.argumentExpression);
    }
  } else if (isIdentifier(expr)) {
    return unescapeLeadingUnderscores(expr.escapedText);
  } else if (isJsxNamespacedName(expr)) {
    return getTextOfJsxNamespacedName(expr);
  }
  return void 0;
}
function isPrototypeAccess(node) {
  return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype";
}
function isRightSideOfQualifiedNameOrPropertyAccess(node) {
  return node.parent.kind === 166 /* QualifiedName */ && node.parent.right === node || node.parent.kind === 211 /* PropertyAccessExpression */ && node.parent.name === node || node.parent.kind === 236 /* MetaProperty */ && node.parent.name === node;
}
function isRightSideOfAccessExpression(node) {
  return !!node.parent && (isPropertyAccessExpression(node.parent) && node.parent.name === node || isElementAccessExpression(node.parent) && node.parent.argumentExpression === node);
}
function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
  return isQualifiedName(node.parent) && node.parent.right === node || isPropertyAccessExpression(node.parent) && node.parent.name === node || isJSDocMemberName(node.parent) && node.parent.right === node;
}
function isInstanceOfExpression(node) {
  return isBinaryExpression(node) && node.operatorToken.kind === 104 /* InstanceOfKeyword */;
}
function isRightSideOfInstanceofExpression(node) {
  return isInstanceOfExpression(node.parent) && node === node.parent.right;
}
function isEmptyObjectLiteral(expression) {
  return expression.kind === 210 /* ObjectLiteralExpression */ && expression.properties.length === 0;
}
function isEmptyArrayLiteral(expression) {
  return expression.kind === 209 /* ArrayLiteralExpression */ && expression.elements.length === 0;
}
function getLocalSymbolForExportDefault(symbol) {
  if (!isExportDefaultSymbol(symbol) || !symbol.declarations) return void 0;
  for (const decl of symbol.declarations) {
    if (decl.localSymbol) return decl.localSymbol;
  }
  return void 0;
}
function isExportDefaultSymbol(symbol) {
  return symbol && length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 2048 /* Default */);
}
function tryExtractTSExtension(fileName) {
  return find(supportedTSExtensionsForExtractExtension, (extension) => fileExtensionIs(fileName, extension));
}
function getExpandedCharCodes(input) {
  const output = [];
  const length2 = input.length;
  for (let i = 0; i < length2; i++) {
    const charCode = input.charCodeAt(i);
    if (charCode < 128) {
      output.push(charCode);
    } else if (charCode < 2048) {
      output.push(charCode >> 6 | 192);
      output.push(charCode & 63 | 128);
    } else if (charCode < 65536) {
      output.push(charCode >> 12 | 224);
      output.push(charCode >> 6 & 63 | 128);
      output.push(charCode & 63 | 128);
    } else if (charCode < 131072) {
      output.push(charCode >> 18 | 240);
      output.push(charCode >> 12 & 63 | 128);
      output.push(charCode >> 6 & 63 | 128);
      output.push(charCode & 63 | 128);
    } else {
      Debug.assert(false, "Unexpected code point");
    }
  }
  return output;
}
var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function convertToBase64(input) {
  let result = "";
  const charCodes = getExpandedCharCodes(input);
  let i = 0;
  const length2 = charCodes.length;
  let byte1, byte2, byte3, byte4;
  while (i < length2) {
    byte1 = charCodes[i] >> 2;
    byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4;
    byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6;
    byte4 = charCodes[i + 2] & 63;
    if (i + 1 >= length2) {
      byte3 = byte4 = 64;
    } else if (i + 2 >= length2) {
      byte4 = 64;
    }
    result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4);
    i += 3;
  }
  return result;
}
function getStringFromExpandedCharCodes(codes) {
  let output = "";
  let i = 0;
  const length2 = codes.length;
  while (i < length2) {
    const charCode = codes[i];
    if (charCode < 128) {
      output += String.fromCharCode(charCode);
      i++;
    } else if ((charCode & 192) === 192) {
      let value = charCode & 63;
      i++;
      let nextCode = codes[i];
      while ((nextCode & 192) === 128) {
        value = value << 6 | nextCode & 63;
        i++;
        nextCode = codes[i];
      }
      output += String.fromCharCode(value);
    } else {
      output += String.fromCharCode(charCode);
      i++;
    }
  }
  return output;
}
function base64encode(host, input) {
  if (host && host.base64encode) {
    return host.base64encode(input);
  }
  return convertToBase64(input);
}
function base64decode(host, input) {
  if (host && host.base64decode) {
    return host.base64decode(input);
  }
  const length2 = input.length;
  const expandedCharCodes = [];
  let i = 0;
  while (i < length2) {
    if (input.charCodeAt(i) === base64Digits.charCodeAt(64)) {
      break;
    }
    const ch1 = base64Digits.indexOf(input[i]);
    const ch2 = base64Digits.indexOf(input[i + 1]);
    const ch3 = base64Digits.indexOf(input[i + 2]);
    const ch4 = base64Digits.indexOf(input[i + 3]);
    const code1 = (ch1 & 63) << 2 | ch2 >> 4 & 3;
    const code2 = (ch2 & 15) << 4 | ch3 >> 2 & 15;
    const code3 = (ch3 & 3) << 6 | ch4 & 63;
    if (code2 === 0 && ch3 !== 0) {
      expandedCharCodes.push(code1);
    } else if (code3 === 0 && ch4 !== 0) {
      expandedCharCodes.push(code1, code2);
    } else {
      expandedCharCodes.push(code1, code2, code3);
    }
    i += 4;
  }
  return getStringFromExpandedCharCodes(expandedCharCodes);
}
function readJsonOrUndefined(path, hostOrText) {
  const jsonText = isString(hostOrText) ? hostOrText : hostOrText.readFile(path);
  if (!jsonText) return void 0;
  const result = parseConfigFileTextToJson(path, jsonText);
  return !result.error ? result.config : void 0;
}
function readJson(path, host) {
  return readJsonOrUndefined(path, host) || {};
}
function tryParseJson(text) {
  try {
    return JSON.parse(text);
  } catch {
    return void 0;
  }
}
function directoryProbablyExists(directoryName, host) {
  return !host.directoryExists || host.directoryExists(directoryName);
}
var carriageReturnLineFeed = "\r\n";
var lineFeed = "\n";
function getNewLineCharacter(options) {
  switch (options.newLine) {
    case 0 /* CarriageReturnLineFeed */:
      return carriageReturnLineFeed;
    case 1 /* LineFeed */:
    case void 0:
      return lineFeed;
  }
}
function createRange(pos, end = pos) {
  Debug.assert(end >= pos || end === -1);
  return { pos, end };
}
function moveRangeEnd(range, end) {
  return createRange(range.pos, end);
}
function moveRangePos(range, pos) {
  return createRange(pos, range.end);
}
function moveRangePastDecorators(node) {
  const lastDecorator = canHaveModifiers(node) ? findLast(node.modifiers, isDecorator) : void 0;
  return lastDecorator && !positionIsSynthesized(lastDecorator.end) ? moveRangePos(node, lastDecorator.end) : node;
}
function moveRangePastModifiers(node) {
  if (isPropertyDeclaration(node) || isMethodDeclaration(node)) {
    return moveRangePos(node, node.name.pos);
  }
  const lastModifier = canHaveModifiers(node) ? lastOrUndefined(node.modifiers) : void 0;
  return lastModifier && !positionIsSynthesized(lastModifier.end) ? moveRangePos(node, lastModifier.end) : moveRangePastDecorators(node);
}
function createTokenRange(pos, token) {
  return createRange(pos, pos + tokenToString(token).length);
}
function rangeIsOnSingleLine(range, sourceFile) {
  return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile);
}
function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) {
  return positionsAreOnSameLine(
    getStartPositionOfRange(
      range1,
      sourceFile,
      /*includeComments*/
      false
    ),
    getStartPositionOfRange(
      range2,
      sourceFile,
      /*includeComments*/
      false
    ),
    sourceFile
  );
}
function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) {
  return positionsAreOnSameLine(range1.end, range2.end, sourceFile);
}
function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) {
  return positionsAreOnSameLine(getStartPositionOfRange(
    range1,
    sourceFile,
    /*includeComments*/
    false
  ), range2.end, sourceFile);
}
function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) {
  return positionsAreOnSameLine(range1.end, getStartPositionOfRange(
    range2,
    sourceFile,
    /*includeComments*/
    false
  ), sourceFile);
}
function getLinesBetweenRangeEndAndRangeStart(range1, range2, sourceFile, includeSecondRangeComments) {
  const range2Start = getStartPositionOfRange(range2, sourceFile, includeSecondRangeComments);
  return getLinesBetweenPositions(sourceFile, range1.end, range2Start);
}
function getLinesBetweenRangeEndPositions(range1, range2, sourceFile) {
  return getLinesBetweenPositions(sourceFile, range1.end, range2.end);
}
function isNodeArrayMultiLine(list, sourceFile) {
  return !positionsAreOnSameLine(list.pos, list.end, sourceFile);
}
function positionsAreOnSameLine(pos1, pos2, sourceFile) {
  return getLinesBetweenPositions(sourceFile, pos1, pos2) === 0;
}
function getStartPositionOfRange(range, sourceFile, includeComments) {
  return positionIsSynthesized(range.pos) ? -1 : skipTrivia(
    sourceFile.text,
    range.pos,
    /*stopAfterLineBreak*/
    false,
    includeComments
  );
}
function getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) {
  const startPos = skipTrivia(
    sourceFile.text,
    pos,
    /*stopAfterLineBreak*/
    false,
    includeComments
  );
  const prevPos = getPreviousNonWhitespacePosition(startPos, stopPos, sourceFile);
  return getLinesBetweenPositions(sourceFile, prevPos ?? stopPos, startPos);
}
function getLinesBetweenPositionAndNextNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) {
  const nextPos = skipTrivia(
    sourceFile.text,
    pos,
    /*stopAfterLineBreak*/
    false,
    includeComments
  );
  return getLinesBetweenPositions(sourceFile, pos, Math.min(stopPos, nextPos));
}
function rangeContainsRange(r1, r2) {
  return startEndContainsRange(r1.pos, r1.end, r2);
}
function startEndContainsRange(start, end, range) {
  return start <= range.pos && end >= range.end;
}
function getPreviousNonWhitespacePosition(pos, stopPos = 0, sourceFile) {
  while (pos-- > stopPos) {
    if (!isWhiteSpaceLike(sourceFile.text.charCodeAt(pos))) {
      return pos;
    }
  }
}
function isDeclarationNameOfEnumOrNamespace(node) {
  const parseNode = getParseTreeNode(node);
  if (parseNode) {
    switch (parseNode.parent.kind) {
      case 266 /* EnumDeclaration */:
      case 267 /* ModuleDeclaration */:
        return parseNode === parseNode.parent.name;
    }
  }
  return false;
}
function getInitializedVariables(node) {
  return filter(node.declarations, isInitializedVariable);
}
function isInitializedVariable(node) {
  return isVariableDeclaration(node) && node.initializer !== void 0;
}
function isWatchSet(options) {
  return options.watch && hasProperty(options, "watch");
}
function closeFileWatcher(watcher) {
  watcher.close();
}
function getCheckFlags(symbol) {
  return symbol.flags & 33554432 /* Transient */ ? symbol.links.checkFlags : 0;
}
function getDeclarationModifierFlagsFromSymbol(s, isWrite = false) {
  if (s.valueDeclaration) {
    const declaration = isWrite && s.declarations && find(s.declarations, isSetAccessorDeclaration) || s.flags & 32768 /* GetAccessor */ && find(s.declarations, isGetAccessorDeclaration) || s.valueDeclaration;
    const flags = getCombinedModifierFlags(declaration);
    return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~7 /* AccessibilityModifier */;
  }
  if (getCheckFlags(s) & 6 /* Synthetic */) {
    const checkFlags = s.links.checkFlags;
    const accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 2 /* Private */ : checkFlags & 256 /* ContainsPublic */ ? 1 /* Public */ : 4 /* Protected */;
    const staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 256 /* Static */ : 0;
    return accessModifier | staticModifier;
  }
  if (s.flags & 4194304 /* Prototype */) {
    return 1 /* Public */ | 256 /* Static */;
  }
  return 0;
}
function skipAlias(symbol, checker) {
  return symbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(symbol) : symbol;
}
function getCombinedLocalAndExportSymbolFlags(symbol) {
  return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags;
}
function isWriteOnlyAccess(node) {
  return accessKind(node) === 1 /* Write */;
}
function isWriteAccess(node) {
  return accessKind(node) !== 0 /* Read */;
}
function accessKind(node) {
  const { parent: parent2 } = node;
  switch (parent2 == null ? void 0 : parent2.kind) {
    case 217 /* ParenthesizedExpression */:
      return accessKind(parent2);
    case 225 /* PostfixUnaryExpression */:
    case 224 /* PrefixUnaryExpression */:
      const { operator } = parent2;
      return operator === 46 /* PlusPlusToken */ || operator === 47 /* MinusMinusToken */ ? 2 /* ReadWrite */ : 0 /* Read */;
    case 226 /* BinaryExpression */:
      const { left, operatorToken } = parent2;
      return left === node && isAssignmentOperator(operatorToken.kind) ? operatorToken.kind === 64 /* EqualsToken */ ? 1 /* Write */ : 2 /* ReadWrite */ : 0 /* Read */;
    case 211 /* PropertyAccessExpression */:
      return parent2.name !== node ? 0 /* Read */ : accessKind(parent2);
    case 303 /* PropertyAssignment */: {
      const parentAccess = accessKind(parent2.parent);
      return node === parent2.name ? reverseAccessKind(parentAccess) : parentAccess;
    }
    case 304 /* ShorthandPropertyAssignment */:
      return node === parent2.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent2.parent);
    case 209 /* ArrayLiteralExpression */:
      return accessKind(parent2);
    case 249 /* ForInStatement */:
    case 250 /* ForOfStatement */:
      return node === parent2.initializer ? 1 /* Write */ : 0 /* Read */;
    default:
      return 0 /* Read */;
  }
}
function reverseAccessKind(a) {
  switch (a) {
    case 0 /* Read */:
      return 1 /* Write */;
    case 1 /* Write */:
      return 0 /* Read */;
    case 2 /* ReadWrite */:
      return 2 /* ReadWrite */;
    default:
      return Debug.assertNever(a);
  }
}
function compareDataObjects(dst, src) {
  if (!dst || !src || Object.keys(dst).length !== Object.keys(src).length) {
    return false;
  }
  for (const e in dst) {
    if (typeof dst[e] === "object") {
      if (!compareDataObjects(dst[e], src[e])) {
        return false;
      }
    } else if (typeof dst[e] !== "function") {
      if (dst[e] !== src[e]) {
        return false;
      }
    }
  }
  return true;
}
function clearMap(map2, onDeleteValue) {
  map2.forEach(onDeleteValue);
  map2.clear();
}
function mutateMapSkippingNewValues(map2, newMap, options) {
  const { onDeleteValue, onExistingValue } = options;
  map2.forEach((existingValue, key) => {
    var _a;
    if (!(newMap == null ? void 0 : newMap.has(key))) {
      map2.delete(key);
      onDeleteValue(existingValue, key);
    } else if (onExistingValue) {
      onExistingValue(existingValue, (_a = newMap.get) == null ? void 0 : _a.call(newMap, key), key);
    }
  });
}
function mutateMap(map2, newMap, options) {
  mutateMapSkippingNewValues(map2, newMap, options);
  const { createNewValue } = options;
  newMap == null ? void 0 : newMap.forEach((valueInNewMap, key) => {
    if (!map2.has(key)) {
      map2.set(key, createNewValue(key, valueInNewMap));
    }
  });
}
function isAbstractConstructorSymbol(symbol) {
  if (symbol.flags & 32 /* Class */) {
    const declaration = getClassLikeDeclarationOfSymbol(symbol);
    return !!declaration && hasSyntacticModifier(declaration, 64 /* Abstract */);
  }
  return false;
}
function getClassLikeDeclarationOfSymbol(symbol) {
  var _a;
  return (_a = symbol.declarations) == null ? void 0 : _a.find(isClassLike);
}
function getObjectFlags(type) {
  return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0;
}
function isUMDExportSymbol(symbol) {
  return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]);
}
function showModuleSpecifier({ moduleSpecifier }) {
  return isStringLiteral(moduleSpecifier) ? moduleSpecifier.text : getTextOfNode(moduleSpecifier);
}
function getLastChild(node) {
  let lastChild;
  forEachChild(node, (child) => {
    if (nodeIsPresent(child)) lastChild = child;
  }, (children) => {
    for (let i = children.length - 1; i >= 0; i--) {
      if (nodeIsPresent(children[i])) {
        lastChild = children[i];
        break;
      }
    }
  });
  return lastChild;
}
function addToSeen(seen, key) {
  if (seen.has(key)) {
    return false;
  }
  seen.add(key);
  return true;
}
function isObjectTypeDeclaration(node) {
  return isClassLike(node) || isInterfaceDeclaration(node) || isTypeLiteralNode(node);
}
function isTypeNodeKind(kind) {
  return kind >= 182 /* FirstTypeNode */ && kind <= 205 /* LastTypeNode */ || kind === 133 /* AnyKeyword */ || kind === 159 /* UnknownKeyword */ || kind === 150 /* NumberKeyword */ || kind === 163 /* BigIntKeyword */ || kind === 151 /* ObjectKeyword */ || kind === 136 /* BooleanKeyword */ || kind === 154 /* StringKeyword */ || kind === 155 /* SymbolKeyword */ || kind === 116 /* VoidKeyword */ || kind === 157 /* UndefinedKeyword */ || kind === 146 /* NeverKeyword */ || kind === 141 /* IntrinsicKeyword */ || kind === 233 /* ExpressionWithTypeArguments */ || kind === 312 /* JSDocAllType */ || kind === 313 /* JSDocUnknownType */ || kind === 314 /* JSDocNullableType */ || kind === 315 /* JSDocNonNullableType */ || kind === 316 /* JSDocOptionalType */ || kind === 317 /* JSDocFunctionType */ || kind === 318 /* JSDocVariadicType */;
}
function isAccessExpression(node) {
  return node.kind === 211 /* PropertyAccessExpression */ || node.kind === 212 /* ElementAccessExpression */;
}
function getNameOfAccessExpression(node) {
  if (node.kind === 211 /* PropertyAccessExpression */) {
    return node.name;
  }
  Debug.assert(node.kind === 212 /* ElementAccessExpression */);
  return node.argumentExpression;
}
function isNamedImportsOrExports(node) {
  return node.kind === 275 /* NamedImports */ || node.kind === 279 /* NamedExports */;
}
function getLeftmostAccessExpression(expr) {
  while (isAccessExpression(expr)) {
    expr = expr.expression;
  }
  return expr;
}
function forEachNameInAccessChainWalkingLeft(name, action) {
  if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) {
    return walkAccessExpression(name.parent);
  }
  function walkAccessExpression(access) {
    if (access.kind === 211 /* PropertyAccessExpression */) {
      const res = action(access.name);
      if (res !== void 0) {
        return res;
      }
    } else if (access.kind === 212 /* ElementAccessExpression */) {
      if (isIdentifier(access.argumentExpression) || isStringLiteralLike(access.argumentExpression)) {
        const res = action(access.argumentExpression);
        if (res !== void 0) {
          return res;
        }
      } else {
        return void 0;
      }
    }
    if (isAccessExpression(access.expression)) {
      return walkAccessExpression(access.expression);
    }
    if (isIdentifier(access.expression)) {
      return action(access.expression);
    }
    return void 0;
  }
}
function getLeftmostExpression(node, stopAtCallExpressions) {
  while (true) {
    switch (node.kind) {
      case 225 /* PostfixUnaryExpression */:
        node = node.operand;
        continue;
      case 226 /* BinaryExpression */:
        node = node.left;
        continue;
      case 227 /* ConditionalExpression */:
        node = node.condition;
        continue;
      case 215 /* TaggedTemplateExpression */:
        node = node.tag;
        continue;
      case 213 /* CallExpression */:
        if (stopAtCallExpressions) {
          return node;
        }
      // falls through
      case 234 /* AsExpression */:
      case 212 /* ElementAccessExpression */:
      case 211 /* PropertyAccessExpression */:
      case 235 /* NonNullExpression */:
      case 355 /* PartiallyEmittedExpression */:
      case 238 /* SatisfiesExpression */:
        node = node.expression;
        continue;
    }
    return node;
  }
}
function Symbol4(flags, name) {
  this.flags = flags;
  this.escapedName = name;
  this.declarations = void 0;
  this.valueDeclaration = void 0;
  this.id = 0;
  this.mergeId = 0;
  this.parent = void 0;
  this.members = void 0;
  this.exports = void 0;
  this.exportSymbol = void 0;
  this.constEnumOnlyModule = void 0;
  this.isReferenced = void 0;
  this.lastAssignmentPos = void 0;
  this.links = void 0;
}
function Type3(checker, flags) {
  this.flags = flags;
  if (Debug.isDebugging || tracing) {
    this.checker = checker;
  }
}
function Signature2(checker, flags) {
  this.flags = flags;
  if (Debug.isDebugging) {
    this.checker = checker;
  }
}
function Node4(kind, pos, end) {
  this.pos = pos;
  this.end = end;
  this.kind = kind;
  this.id = 0;
  this.flags = 0 /* None */;
  this.modifierFlagsCache = 0 /* None */;
  this.transformFlags = 0 /* None */;
  this.parent = void 0;
  this.original = void 0;
  this.emitNode = void 0;
}
function Token(kind, pos, end) {
  this.pos = pos;
  this.end = end;
  this.kind = kind;
  this.id = 0;
  this.flags = 0 /* None */;
  this.transformFlags = 0 /* None */;
  this.parent = void 0;
  this.emitNode = void 0;
}
function Identifier2(kind, pos, end) {
  this.pos = pos;
  this.end = end;
  this.kind = kind;
  this.id = 0;
  this.flags = 0 /* None */;
  this.transformFlags = 0 /* None */;
  this.parent = void 0;
  this.original = void 0;
  this.emitNode = void 0;
}
function SourceMapSource(fileName, text, skipTrivia2) {
  this.fileName = fileName;
  this.text = text;
  this.skipTrivia = skipTrivia2 || ((pos) => pos);
}
var objectAllocator = {
  getNodeConstructor: () => Node4,
  getTokenConstructor: () => Token,
  getIdentifierConstructor: () => Identifier2,
  getPrivateIdentifierConstructor: () => Node4,
  getSourceFileConstructor: () => Node4,
  getSymbolConstructor: () => Symbol4,
  getTypeConstructor: () => Type3,
  getSignatureConstructor: () => Signature2,
  getSourceMapSourceConstructor: () => SourceMapSource
};
var objectAllocatorPatchers = [];
function addObjectAllocatorPatcher(fn) {
  objectAllocatorPatchers.push(fn);
  fn(objectAllocator);
}
function setObjectAllocator(alloc) {
  Object.assign(objectAllocator, alloc);
  forEach(objectAllocatorPatchers, (fn) => fn(objectAllocator));
}
function formatStringFromArgs(text, args) {
  return text.replace(/\{(\d+)\}/g, (_match, index) => "" + Debug.checkDefined(args[+index]));
}
var localizedDiagnosticMessages;
function setLocalizedDiagnosticMessages(messages) {
  localizedDiagnosticMessages = messages;
}
function maybeSetLocalizedDiagnosticMessages(getMessages) {
  if (!localizedDiagnosticMessages && getMessages) {
    localizedDiagnosticMessages = getMessages();
  }
}
function getLocaleSpecificMessage(message) {
  return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
}
function createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args) {
  if (start + length2 > sourceText.length) {
    length2 = sourceText.length - start;
  }
  assertDiagnosticLocation(sourceText, start, length2);
  let text = getLocaleSpecificMessage(message);
  if (some(args)) {
    text = formatStringFromArgs(text, args);
  }
  return {
    file: void 0,
    start,
    length: length2,
    messageText: text,
    category: message.category,
    code: message.code,
    reportsUnnecessary: message.reportsUnnecessary,
    fileName
  };
}
function isDiagnosticWithDetachedLocation(diagnostic) {
  return diagnostic.file === void 0 && diagnostic.start !== void 0 && diagnostic.length !== void 0 && typeof diagnostic.fileName === "string";
}
function attachFileToDiagnostic(diagnostic, file) {
  const fileName = file.fileName || "";
  const length2 = file.text.length;
  Debug.assertEqual(diagnostic.fileName, fileName);
  Debug.assertLessThanOrEqual(diagnostic.start, length2);
  Debug.assertLessThanOrEqual(diagnostic.start + diagnostic.length, length2);
  const diagnosticWithLocation = {
    file,
    start: diagnostic.start,
    length: diagnostic.length,
    messageText: diagnostic.messageText,
    category: diagnostic.category,
    code: diagnostic.code,
    reportsUnnecessary: diagnostic.reportsUnnecessary
  };
  if (diagnostic.relatedInformation) {
    diagnosticWithLocation.relatedInformation = [];
    for (const related of diagnostic.relatedInformation) {
      if (isDiagnosticWithDetachedLocation(related) && related.fileName === fileName) {
        Debug.assertLessThanOrEqual(related.start, length2);
        Debug.assertLessThanOrEqual(related.start + related.length, length2);
        diagnosticWithLocation.relatedInformation.push(attachFileToDiagnostic(related, file));
      } else {
        diagnosticWithLocation.relatedInformation.push(related);
      }
    }
  }
  return diagnosticWithLocation;
}
function attachFileToDiagnostics(diagnostics, file) {
  const diagnosticsWithLocation = [];
  for (const diagnostic of diagnostics) {
    diagnosticsWithLocation.push(attachFileToDiagnostic(diagnostic, file));
  }
  return diagnosticsWithLocation;
}
function createFileDiagnostic(file, start, length2, message, ...args) {
  assertDiagnosticLocation(file.text, start, length2);
  let text = getLocaleSpecificMessage(message);
  if (some(args)) {
    text = formatStringFromArgs(text, args);
  }
  return {
    file,
    start,
    length: length2,
    messageText: text,
    category: message.category,
    code: message.code,
    reportsUnnecessary: message.reportsUnnecessary,
    reportsDeprecated: message.reportsDeprecated
  };
}
function formatMessage(message, ...args) {
  let text = getLocaleSpecificMessage(message);
  if (some(args)) {
    text = formatStringFromArgs(text, args);
  }
  return text;
}
function createCompilerDiagnostic(message, ...args) {
  let text = getLocaleSpecificMessage(message);
  if (some(args)) {
    text = formatStringFromArgs(text, args);
  }
  return {
    file: void 0,
    start: void 0,
    length: void 0,
    messageText: text,
    category: message.category,
    code: message.code,
    reportsUnnecessary: message.reportsUnnecessary,
    reportsDeprecated: message.reportsDeprecated
  };
}
function createCompilerDiagnosticFromMessageChain(chain, relatedInformation) {
  return {
    file: void 0,
    start: void 0,
    length: void 0,
    code: chain.code,
    category: chain.category,
    messageText: chain.next ? chain : chain.messageText,
    relatedInformation
  };
}
function chainDiagnosticMessages(details, message, ...args) {
  let text = getLocaleSpecificMessage(message);
  if (some(args)) {
    text = formatStringFromArgs(text, args);
  }
  return {
    messageText: text,
    category: message.category,
    code: message.code,
    next: details === void 0 || Array.isArray(details) ? details : [details]
  };
}
function concatenateDiagnosticMessageChains(headChain, tailChain) {
  let lastChain = headChain;
  while (lastChain.next) {
    lastChain = lastChain.next[0];
  }
  lastChain.next = [tailChain];
}
function getDiagnosticFilePath(diagnostic) {
  return diagnostic.file ? diagnostic.file.path : void 0;
}
function compareDiagnostics(d1, d2) {
  return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || 0 /* EqualTo */;
}
function compareDiagnosticsSkipRelatedInformation(d1, d2) {
  const code1 = getDiagnosticCode(d1);
  const code2 = getDiagnosticCode(d2);
  return compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || compareValues(d1.start, d2.start) || compareValues(d1.length, d2.length) || compareValues(code1, code2) || compareMessageText(d1, d2) || 0 /* EqualTo */;
}
function compareRelatedInformation(d1, d2) {
  if (!d1.relatedInformation && !d2.relatedInformation) {
    return 0 /* EqualTo */;
  }
  if (d1.relatedInformation && d2.relatedInformation) {
    return compareValues(d2.relatedInformation.length, d1.relatedInformation.length) || forEach(d1.relatedInformation, (d1i, index) => {
      const d2i = d2.relatedInformation[index];
      return compareDiagnostics(d1i, d2i);
    }) || 0 /* EqualTo */;
  }
  return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */;
}
function compareMessageText(d1, d2) {
  let headMsg1 = getDiagnosticMessage(d1);
  let headMsg2 = getDiagnosticMessage(d2);
  if (typeof headMsg1 !== "string") {
    headMsg1 = headMsg1.messageText;
  }
  if (typeof headMsg2 !== "string") {
    headMsg2 = headMsg2.messageText;
  }
  const chain1 = typeof d1.messageText !== "string" ? d1.messageText.next : void 0;
  const chain2 = typeof d2.messageText !== "string" ? d2.messageText.next : void 0;
  let res = compareStringsCaseSensitive(headMsg1, headMsg2);
  if (res) {
    return res;
  }
  res = compareMessageChain(chain1, chain2);
  if (res) {
    return res;
  }
  if (d1.canonicalHead && !d2.canonicalHead) {
    return -1 /* LessThan */;
  }
  if (d2.canonicalHead && !d1.canonicalHead) {
    return 1 /* GreaterThan */;
  }
  return 0 /* EqualTo */;
}
function compareMessageChain(c1, c2) {
  if (c1 === void 0 && c2 === void 0) {
    return 0 /* EqualTo */;
  }
  if (c1 === void 0) {
    return 1 /* GreaterThan */;
  }
  if (c2 === void 0) {
    return -1 /* LessThan */;
  }
  return compareMessageChainSize(c1, c2) || compareMessageChainContent(c1, c2);
}
function compareMessageChainSize(c1, c2) {
  if (c1 === void 0 && c2 === void 0) {
    return 0 /* EqualTo */;
  }
  if (c1 === void 0) {
    return 1 /* GreaterThan */;
  }
  if (c2 === void 0) {
    return -1 /* LessThan */;
  }
  let res = compareValues(c2.length, c1.length);
  if (res) {
    return res;
  }
  for (let i = 0; i < c2.length; i++) {
    res = compareMessageChainSize(c1[i].next, c2[i].next);
    if (res) {
      return res;
    }
  }
  return 0 /* EqualTo */;
}
function compareMessageChainContent(c1, c2) {
  let res;
  for (let i = 0; i < c2.length; i++) {
    res = compareStringsCaseSensitive(c1[i].messageText, c2[i].messageText);
    if (res) {
      return res;
    }
    if (c1[i].next === void 0) {
      continue;
    }
    res = compareMessageChainContent(c1[i].next, c2[i].next);
    if (res) {
      return res;
    }
  }
  return 0 /* EqualTo */;
}
function diagnosticsEqualityComparer(d1, d2) {
  const code1 = getDiagnosticCode(d1);
  const code2 = getDiagnosticCode(d2);
  const msg1 = getDiagnosticMessage(d1);
  const msg2 = getDiagnosticMessage(d2);
  return compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) === 0 /* EqualTo */ && compareValues(d1.start, d2.start) === 0 /* EqualTo */ && compareValues(d1.length, d2.length) === 0 /* EqualTo */ && compareValues(code1, code2) === 0 /* EqualTo */ && messageTextEqualityComparer(msg1, msg2);
}
function getDiagnosticCode(d) {
  var _a;
  return ((_a = d.canonicalHead) == null ? void 0 : _a.code) || d.code;
}
function getDiagnosticMessage(d) {
  var _a;
  return ((_a = d.canonicalHead) == null ? void 0 : _a.messageText) || d.messageText;
}
function messageTextEqualityComparer(m1, m2) {
  const t1 = typeof m1 === "string" ? m1 : m1.messageText;
  const t2 = typeof m2 === "string" ? m2 : m2.messageText;
  return compareStringsCaseSensitive(t1, t2) === 0 /* EqualTo */;
}
function getLanguageVariant(scriptKind) {
  return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */;
}
function walkTreeForJSXTags(node) {
  if (!(node.transformFlags & 2 /* ContainsJsx */)) return void 0;
  return isJsxOpeningLikeElement(node) || isJsxFragment(node) ? node : forEachChild(node, walkTreeForJSXTags);
}
function isFileModuleFromUsingJSXTag(file) {
  return !file.isDeclarationFile ? walkTreeForJSXTags(file) : void 0;
}
function isFileForcedToBeModuleByFormat(file, options) {
  return (getImpliedNodeFormatForEmitWorker(file, options) === 99 /* ESNext */ || fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */])) && !file.isDeclarationFile ? true : void 0;
}
function getSetExternalModuleIndicator(options) {
  switch (getEmitModuleDetectionKind(options)) {
    case 3 /* Force */:
      return (file) => {
        file.externalModuleIndicator = isFileProbablyExternalModule(file) || !file.isDeclarationFile || void 0;
      };
    case 1 /* Legacy */:
      return (file) => {
        file.externalModuleIndicator = isFileProbablyExternalModule(file);
      };
    case 2 /* Auto */:
      const checks = [isFileProbablyExternalModule];
      if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
        checks.push(isFileModuleFromUsingJSXTag);
      }
      checks.push(isFileForcedToBeModuleByFormat);
      const combined = or(...checks);
      const callback = (file) => void (file.externalModuleIndicator = combined(file, options));
      return callback;
  }
}
function importSyntaxAffectsModuleResolution(options) {
  const moduleResolution = getEmitModuleResolutionKind(options);
  return 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */ || getResolvePackageJsonExports(options) || getResolvePackageJsonImports(options);
}
function createComputedCompilerOptions(options) {
  return options;
}
var _computedOptions = createComputedCompilerOptions({
  allowImportingTsExtensions: {
    dependencies: ["rewriteRelativeImportExtensions"],
    computeValue: (compilerOptions) => {
      return !!(compilerOptions.allowImportingTsExtensions || compilerOptions.rewriteRelativeImportExtensions);
    }
  },
  target: {
    dependencies: ["module"],
    computeValue: (compilerOptions) => {
      const target = compilerOptions.target === 0 /* ES3 */ ? void 0 : compilerOptions.target;
      return target ?? (compilerOptions.module === 100 /* Node16 */ && 9 /* ES2022 */ || compilerOptions.module === 199 /* NodeNext */ && 99 /* ESNext */ || 1 /* ES5 */);
    }
  },
  module: {
    dependencies: ["target"],
    computeValue: (compilerOptions) => {
      return typeof compilerOptions.module === "number" ? compilerOptions.module : _computedOptions.target.computeValue(compilerOptions) >= 2 /* ES2015 */ ? 5 /* ES2015 */ : 1 /* CommonJS */;
    }
  },
  moduleResolution: {
    dependencies: ["module", "target"],
    computeValue: (compilerOptions) => {
      let moduleResolution = compilerOptions.moduleResolution;
      if (moduleResolution === void 0) {
        switch (_computedOptions.module.computeValue(compilerOptions)) {
          case 1 /* CommonJS */:
            moduleResolution = 2 /* Node10 */;
            break;
          case 100 /* Node16 */:
            moduleResolution = 3 /* Node16 */;
            break;
          case 199 /* NodeNext */:
            moduleResolution = 99 /* NodeNext */;
            break;
          case 200 /* Preserve */:
            moduleResolution = 100 /* Bundler */;
            break;
          default:
            moduleResolution = 1 /* Classic */;
            break;
        }
      }
      return moduleResolution;
    }
  },
  moduleDetection: {
    dependencies: ["module", "target"],
    computeValue: (compilerOptions) => {
      return compilerOptions.moduleDetection || (_computedOptions.module.computeValue(compilerOptions) === 100 /* Node16 */ || _computedOptions.module.computeValue(compilerOptions) === 199 /* NodeNext */ ? 3 /* Force */ : 2 /* Auto */);
    }
  },
  isolatedModules: {
    dependencies: ["verbatimModuleSyntax"],
    computeValue: (compilerOptions) => {
      return !!(compilerOptions.isolatedModules || compilerOptions.verbatimModuleSyntax);
    }
  },
  esModuleInterop: {
    dependencies: ["module", "target"],
    computeValue: (compilerOptions) => {
      if (compilerOptions.esModuleInterop !== void 0) {
        return compilerOptions.esModuleInterop;
      }
      switch (_computedOptions.module.computeValue(compilerOptions)) {
        case 100 /* Node16 */:
        case 199 /* NodeNext */:
        case 200 /* Preserve */:
          return true;
      }
      return false;
    }
  },
  allowSyntheticDefaultImports: {
    dependencies: ["module", "target", "moduleResolution"],
    computeValue: (compilerOptions) => {
      if (compilerOptions.allowSyntheticDefaultImports !== void 0) {
        return compilerOptions.allowSyntheticDefaultImports;
      }
      return _computedOptions.esModuleInterop.computeValue(compilerOptions) || _computedOptions.module.computeValue(compilerOptions) === 4 /* System */ || _computedOptions.moduleResolution.computeValue(compilerOptions) === 100 /* Bundler */;
    }
  },
  resolvePackageJsonExports: {
    dependencies: ["moduleResolution"],
    computeValue: (compilerOptions) => {
      const moduleResolution = _computedOptions.moduleResolution.computeValue(compilerOptions);
      if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
        return false;
      }
      if (compilerOptions.resolvePackageJsonExports !== void 0) {
        return compilerOptions.resolvePackageJsonExports;
      }
      switch (moduleResolution) {
        case 3 /* Node16 */:
        case 99 /* NodeNext */:
        case 100 /* Bundler */:
          return true;
      }
      return false;
    }
  },
  resolvePackageJsonImports: {
    dependencies: ["moduleResolution", "resolvePackageJsonExports"],
    computeValue: (compilerOptions) => {
      const moduleResolution = _computedOptions.moduleResolution.computeValue(compilerOptions);
      if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
        return false;
      }
      if (compilerOptions.resolvePackageJsonExports !== void 0) {
        return compilerOptions.resolvePackageJsonExports;
      }
      switch (moduleResolution) {
        case 3 /* Node16 */:
        case 99 /* NodeNext */:
        case 100 /* Bundler */:
          return true;
      }
      return false;
    }
  },
  resolveJsonModule: {
    dependencies: ["moduleResolution", "module", "target"],
    computeValue: (compilerOptions) => {
      if (compilerOptions.resolveJsonModule !== void 0) {
        return compilerOptions.resolveJsonModule;
      }
      return _computedOptions.moduleResolution.computeValue(compilerOptions) === 100 /* Bundler */;
    }
  },
  declaration: {
    dependencies: ["composite"],
    computeValue: (compilerOptions) => {
      return !!(compilerOptions.declaration || compilerOptions.composite);
    }
  },
  preserveConstEnums: {
    dependencies: ["isolatedModules", "verbatimModuleSyntax"],
    computeValue: (compilerOptions) => {
      return !!(compilerOptions.preserveConstEnums || _computedOptions.isolatedModules.computeValue(compilerOptions));
    }
  },
  incremental: {
    dependencies: ["composite"],
    computeValue: (compilerOptions) => {
      return !!(compilerOptions.incremental || compilerOptions.composite);
    }
  },
  declarationMap: {
    dependencies: ["declaration", "composite"],
    computeValue: (compilerOptions) => {
      return !!(compilerOptions.declarationMap && _computedOptions.declaration.computeValue(compilerOptions));
    }
  },
  allowJs: {
    dependencies: ["checkJs"],
    computeValue: (compilerOptions) => {
      return compilerOptions.allowJs === void 0 ? !!compilerOptions.checkJs : compilerOptions.allowJs;
    }
  },
  useDefineForClassFields: {
    dependencies: ["target", "module"],
    computeValue: (compilerOptions) => {
      return compilerOptions.useDefineForClassFields === void 0 ? _computedOptions.target.computeValue(compilerOptions) >= 9 /* ES2022 */ : compilerOptions.useDefineForClassFields;
    }
  },
  noImplicitAny: {
    dependencies: ["strict"],
    computeValue: (compilerOptions) => {
      return getStrictOptionValue(compilerOptions, "noImplicitAny");
    }
  },
  noImplicitThis: {
    dependencies: ["strict"],
    computeValue: (compilerOptions) => {
      return getStrictOptionValue(compilerOptions, "noImplicitThis");
    }
  },
  strictNullChecks: {
    dependencies: ["strict"],
    computeValue: (compilerOptions) => {
      return getStrictOptionValue(compilerOptions, "strictNullChecks");
    }
  },
  strictFunctionTypes: {
    dependencies: ["strict"],
    computeValue: (compilerOptions) => {
      return getStrictOptionValue(compilerOptions, "strictFunctionTypes");
    }
  },
  strictBindCallApply: {
    dependencies: ["strict"],
    computeValue: (compilerOptions) => {
      return getStrictOptionValue(compilerOptions, "strictBindCallApply");
    }
  },
  strictPropertyInitialization: {
    dependencies: ["strict"],
    computeValue: (compilerOptions) => {
      return getStrictOptionValue(compilerOptions, "strictPropertyInitialization");
    }
  },
  strictBuiltinIteratorReturn: {
    dependencies: ["strict"],
    computeValue: (compilerOptions) => {
      return getStrictOptionValue(compilerOptions, "strictBuiltinIteratorReturn");
    }
  },
  alwaysStrict: {
    dependencies: ["strict"],
    computeValue: (compilerOptions) => {
      return getStrictOptionValue(compilerOptions, "alwaysStrict");
    }
  },
  useUnknownInCatchVariables: {
    dependencies: ["strict"],
    computeValue: (compilerOptions) => {
      return getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
    }
  }
});
var computedOptions = _computedOptions;
var getAllowImportingTsExtensions = _computedOptions.allowImportingTsExtensions.computeValue;
var getEmitScriptTarget = _computedOptions.target.computeValue;
var getEmitModuleKind = _computedOptions.module.computeValue;
var getEmitModuleResolutionKind = _computedOptions.moduleResolution.computeValue;
var getEmitModuleDetectionKind = _computedOptions.moduleDetection.computeValue;
var getIsolatedModules = _computedOptions.isolatedModules.computeValue;
var getESModuleInterop = _computedOptions.esModuleInterop.computeValue;
var getAllowSyntheticDefaultImports = _computedOptions.allowSyntheticDefaultImports.computeValue;
var getResolvePackageJsonExports = _computedOptions.resolvePackageJsonExports.computeValue;
var getResolvePackageJsonImports = _computedOptions.resolvePackageJsonImports.computeValue;
var getResolveJsonModule = _computedOptions.resolveJsonModule.computeValue;
var getEmitDeclarations = _computedOptions.declaration.computeValue;
var shouldPreserveConstEnums = _computedOptions.preserveConstEnums.computeValue;
var isIncrementalCompilation = _computedOptions.incremental.computeValue;
var getAreDeclarationMapsEnabled = _computedOptions.declarationMap.computeValue;
var getAllowJSCompilerOption = _computedOptions.allowJs.computeValue;
var getUseDefineForClassFields = _computedOptions.useDefineForClassFields.computeValue;
function emitModuleKindIsNonNodeESM(moduleKind) {
  return moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */;
}
function hasJsonModuleEmitEnabled(options) {
  switch (getEmitModuleKind(options)) {
    case 0 /* None */:
    case 4 /* System */:
    case 3 /* UMD */:
      return false;
  }
  return true;
}
function unreachableCodeIsError(options) {
  return options.allowUnreachableCode === false;
}
function unusedLabelIsError(options) {
  return options.allowUnusedLabels === false;
}
function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
  return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
}
function getStrictOptionValue(compilerOptions, flag) {
  return compilerOptions[flag] === void 0 ? !!compilerOptions.strict : !!compilerOptions[flag];
}
function getNameOfScriptTarget(scriptTarget) {
  return forEachEntry(targetOptionDeclaration.type, (value, key) => value === scriptTarget ? key : void 0);
}
function getEmitStandardClassFields(compilerOptions) {
  return compilerOptions.useDefineForClassFields !== false && getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */;
}
function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) {
  return optionsHaveChanges(oldOptions, newOptions, semanticDiagnosticsOptionDeclarations);
}
function compilerOptionsAffectEmit(newOptions, oldOptions) {
  return optionsHaveChanges(oldOptions, newOptions, affectsEmitOptionDeclarations);
}
function compilerOptionsAffectDeclarationPath(newOptions, oldOptions) {
  return optionsHaveChanges(oldOptions, newOptions, affectsDeclarationPathOptionDeclarations);
}
function getCompilerOptionValue(options, option) {
  return option.strictFlag ? getStrictOptionValue(options, option.name) : option.allowJsFlag ? getAllowJSCompilerOption(options) : options[option.name];
}
function getJSXTransformEnabled(options) {
  const jsx = options.jsx;
  return jsx === 2 /* React */ || jsx === 4 /* ReactJSX */ || jsx === 5 /* ReactJSXDev */;
}
function getJSXImplicitImportBase(compilerOptions, file) {
  const jsxImportSourcePragmas = file == null ? void 0 : file.pragmas.get("jsximportsource");
  const jsxImportSourcePragma = isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas;
  const jsxRuntimePragmas = file == null ? void 0 : file.pragmas.get("jsxruntime");
  const jsxRuntimePragma = isArray(jsxRuntimePragmas) ? jsxRuntimePragmas[jsxRuntimePragmas.length - 1] : jsxRuntimePragmas;
  if ((jsxRuntimePragma == null ? void 0 : jsxRuntimePragma.arguments.factory) === "classic") {
    return void 0;
  }
  return compilerOptions.jsx === 4 /* ReactJSX */ || compilerOptions.jsx === 5 /* ReactJSXDev */ || compilerOptions.jsxImportSource || jsxImportSourcePragma || (jsxRuntimePragma == null ? void 0 : jsxRuntimePragma.arguments.factory) === "automatic" ? (jsxImportSourcePragma == null ? void 0 : jsxImportSourcePragma.arguments.factory) || compilerOptions.jsxImportSource || "react" : void 0;
}
function getJSXRuntimeImport(base, options) {
  return base ? `${base}/${options.jsx === 5 /* ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime"}` : void 0;
}
function hasZeroOrOneAsteriskCharacter(str) {
  let seenAsterisk = false;
  for (let i = 0; i < str.length; i++) {
    if (str.charCodeAt(i) === 42 /* asterisk */) {
      if (!seenAsterisk) {
        seenAsterisk = true;
      } else {
        return false;
      }
    }
  }
  return true;
}
function createSymlinkCache(cwd, getCanonicalFileName) {
  let symlinkedDirectories;
  let symlinkedDirectoriesByRealpath;
  let symlinkedFiles;
  let hasProcessedResolutions = false;
  return {
    getSymlinkedFiles: () => symlinkedFiles,
    getSymlinkedDirectories: () => symlinkedDirectories,
    getSymlinkedDirectoriesByRealpath: () => symlinkedDirectoriesByRealpath,
    setSymlinkedFile: (path, real) => (symlinkedFiles || (symlinkedFiles = /* @__PURE__ */ new Map())).set(path, real),
    setSymlinkedDirectory: (symlink, real) => {
      let symlinkPath = toPath(symlink, cwd, getCanonicalFileName);
      if (!containsIgnoredPath(symlinkPath)) {
        symlinkPath = ensureTrailingDirectorySeparator(symlinkPath);
        if (real !== false && !(symlinkedDirectories == null ? void 0 : symlinkedDirectories.has(symlinkPath))) {
          (symlinkedDirectoriesByRealpath || (symlinkedDirectoriesByRealpath = createMultiMap())).add(real.realPath, symlink);
        }
        (symlinkedDirectories || (symlinkedDirectories = /* @__PURE__ */ new Map())).set(symlinkPath, real);
      }
    },
    setSymlinksFromResolutions(forEachResolvedModule, forEachResolvedTypeReferenceDirective, typeReferenceDirectives) {
      Debug.assert(!hasProcessedResolutions);
      hasProcessedResolutions = true;
      forEachResolvedModule((resolution) => processResolution(this, resolution.resolvedModule));
      forEachResolvedTypeReferenceDirective((resolution) => processResolution(this, resolution.resolvedTypeReferenceDirective));
      typeReferenceDirectives.forEach((resolution) => processResolution(this, resolution.resolvedTypeReferenceDirective));
    },
    hasProcessedResolutions: () => hasProcessedResolutions,
    setSymlinksFromResolution(resolution) {
      processResolution(this, resolution);
    },
    hasAnySymlinks
  };
  function hasAnySymlinks() {
    return !!(symlinkedFiles == null ? void 0 : symlinkedFiles.size) || !!symlinkedDirectories && !!forEachEntry(symlinkedDirectories, (value) => !!value);
  }
  function processResolution(cache, resolution) {
    if (!resolution || !resolution.originalPath || !resolution.resolvedFileName) return;
    const { resolvedFileName, originalPath } = resolution;
    cache.setSymlinkedFile(toPath(originalPath, cwd, getCanonicalFileName), resolvedFileName);
    const [commonResolved, commonOriginal] = guessDirectorySymlink(resolvedFileName, originalPath, cwd, getCanonicalFileName) || emptyArray;
    if (commonResolved && commonOriginal) {
      cache.setSymlinkedDirectory(
        commonOriginal,
        {
          real: ensureTrailingDirectorySeparator(commonResolved),
          realPath: ensureTrailingDirectorySeparator(toPath(commonResolved, cwd, getCanonicalFileName))
        }
      );
    }
  }
}
function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) {
  const aParts = getPathComponents(getNormalizedAbsolutePath(a, cwd));
  const bParts = getPathComponents(getNormalizedAbsolutePath(b, cwd));
  let isDirectory = false;
  while (aParts.length >= 2 && bParts.length >= 2 && !isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) {
    aParts.pop();
    bParts.pop();
    isDirectory = true;
  }
  return isDirectory ? [getPathFromPathComponents(aParts), getPathFromPathComponents(bParts)] : void 0;
}
function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) {
  return s !== void 0 && (getCanonicalFileName(s) === "node_modules" || startsWith(s, "@"));
}
function stripLeadingDirectorySeparator(s) {
  return isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : void 0;
}
function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) {
  const withoutPrefix = tryRemovePrefix(path, dirPath, getCanonicalFileName);
  return withoutPrefix === void 0 ? void 0 : stripLeadingDirectorySeparator(withoutPrefix);
}
var reservedCharacterPattern = /[^\w\s/]/g;
function regExpEscape(text) {
  return text.replace(reservedCharacterPattern, escapeRegExpCharacter);
}
function escapeRegExpCharacter(match) {
  return "\\" + match;
}
var wildcardCharCodes = [42 /* asterisk */, 63 /* question */];
var commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"];
var implicitExcludePathRegexPattern = `(?!(${commonPackageFolders.join("|")})(/|$))`;
var filesMatcher = {
  /**
   * Matches any single directory segment unless it is the last segment and a .min.js file
   * Breakdown:
   *  [^./]                   # matches everything up to the first . character (excluding directory separators)
   *  (\\.(?!min\\.js$))?     # matches . characters but not if they are part of the .min.js file extension
   */
  singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*",
  /**
   * Regex for the ** wildcard. Matches any number of subdirectories. When used for including
   * files or directories, does not match subdirectories that start with a . character
   */
  doubleAsteriskRegexFragment: `(/${implicitExcludePathRegexPattern}[^/.][^/]*)*?`,
  replaceWildcardCharacter: (match) => replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment)
};
var directoriesMatcher = {
  singleAsteriskRegexFragment: "[^/]*",
  /**
   * Regex for the ** wildcard. Matches any number of subdirectories. When used for including
   * files or directories, does not match subdirectories that start with a . character
   */
  doubleAsteriskRegexFragment: `(/${implicitExcludePathRegexPattern}[^/.][^/]*)*?`,
  replaceWildcardCharacter: (match) => replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment)
};
var excludeMatcher = {
  singleAsteriskRegexFragment: "[^/]*",
  doubleAsteriskRegexFragment: "(/.+?)?",
  replaceWildcardCharacter: (match) => replaceWildcardCharacter(match, excludeMatcher.singleAsteriskRegexFragment)
};
var wildcardMatchers = {
  files: filesMatcher,
  directories: directoriesMatcher,
  exclude: excludeMatcher
};
function getRegularExpressionForWildcard(specs, basePath, usage) {
  const patterns = getRegularExpressionsForWildcards(specs, basePath, usage);
  if (!patterns || !patterns.length) {
    return void 0;
  }
  const pattern = patterns.map((pattern2) => `(${pattern2})`).join("|");
  const terminator = usage === "exclude" ? "($|/)" : "$";
  return `^(${pattern})${terminator}`;
}
function getRegularExpressionsForWildcards(specs, basePath, usage) {
  if (specs === void 0 || specs.length === 0) {
    return void 0;
  }
  return flatMap(specs, (spec) => spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]));
}
function isImplicitGlob(lastPathComponent) {
  return !/[.*?]/.test(lastPathComponent);
}
function getPatternFromSpec(spec, basePath, usage) {
  const pattern = spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]);
  return pattern && `^(${pattern})${usage === "exclude" ? "($|/)" : "$"}`;
}
function getSubPatternFromSpec(spec, basePath, usage, { singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter: replaceWildcardCharacter2 } = wildcardMatchers[usage]) {
  let subpattern = "";
  let hasWrittenComponent = false;
  const components = getNormalizedPathComponents(spec, basePath);
  const lastComponent = last(components);
  if (usage !== "exclude" && lastComponent === "**") {
    return void 0;
  }
  components[0] = removeTrailingDirectorySeparator(components[0]);
  if (isImplicitGlob(lastComponent)) {
    components.push("**", "*");
  }
  let optionalCount = 0;
  for (let component of components) {
    if (component === "**") {
      subpattern += doubleAsteriskRegexFragment;
    } else {
      if (usage === "directories") {
        subpattern += "(";
        optionalCount++;
      }
      if (hasWrittenComponent) {
        subpattern += directorySeparator;
      }
      if (usage !== "exclude") {
        let componentPattern = "";
        if (component.charCodeAt(0) === 42 /* asterisk */) {
          componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?";
          component = component.substr(1);
        } else if (component.charCodeAt(0) === 63 /* question */) {
          componentPattern += "[^./]";
          component = component.substr(1);
        }
        componentPattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter2);
        if (componentPattern !== component) {
          subpattern += implicitExcludePathRegexPattern;
        }
        subpattern += componentPattern;
      } else {
        subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter2);
      }
    }
    hasWrittenComponent = true;
  }
  while (optionalCount > 0) {
    subpattern += ")?";
    optionalCount--;
  }
  return subpattern;
}
function replaceWildcardCharacter(match, singleAsteriskRegexFragment) {
  return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match;
}
function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames2, currentDirectory) {
  path = normalizePath(path);
  currentDirectory = normalizePath(currentDirectory);
  const absolutePath = combinePaths(currentDirectory, path);
  return {
    includeFilePatterns: map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), (pattern) => `^${pattern}$`),
    includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
    includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
    excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
    basePaths: getBasePaths(path, includes, useCaseSensitiveFileNames2)
  };
}
function getRegexFromPattern(pattern, useCaseSensitiveFileNames2) {
  return new RegExp(pattern, useCaseSensitiveFileNames2 ? "" : "i");
}
function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames2, currentDirectory, depth, getFileSystemEntries, realpath) {
  path = normalizePath(path);
  currentDirectory = normalizePath(currentDirectory);
  const patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames2, currentDirectory);
  const includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map((pattern) => getRegexFromPattern(pattern, useCaseSensitiveFileNames2));
  const includeDirectoryRegex = patterns.includeDirectoryPattern && getRegexFromPattern(patterns.includeDirectoryPattern, useCaseSensitiveFileNames2);
  const excludeRegex = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, useCaseSensitiveFileNames2);
  const results = includeFileRegexes ? includeFileRegexes.map(() => []) : [[]];
  const visited = /* @__PURE__ */ new Map();
  const toCanonical = createGetCanonicalFileName(useCaseSensitiveFileNames2);
  for (const basePath of patterns.basePaths) {
    visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth);
  }
  return flatten(results);
  function visitDirectory(path2, absolutePath, depth2) {
    const canonicalPath = toCanonical(realpath(absolutePath));
    if (visited.has(canonicalPath)) return;
    visited.set(canonicalPath, true);
    const { files, directories } = getFileSystemEntries(path2);
    for (const current of toSorted(files, compareStringsCaseSensitive)) {
      const name = combinePaths(path2, current);
      const absoluteName = combinePaths(absolutePath, current);
      if (extensions && !fileExtensionIsOneOf(name, extensions)) continue;
      if (excludeRegex && excludeRegex.test(absoluteName)) continue;
      if (!includeFileRegexes) {
        results[0].push(name);
      } else {
        const includeIndex = findIndex(includeFileRegexes, (re) => re.test(absoluteName));
        if (includeIndex !== -1) {
          results[includeIndex].push(name);
        }
      }
    }
    if (depth2 !== void 0) {
      depth2--;
      if (depth2 === 0) {
        return;
      }
    }
    for (const current of toSorted(directories, compareStringsCaseSensitive)) {
      const name = combinePaths(path2, current);
      const absoluteName = combinePaths(absolutePath, current);
      if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) {
        visitDirectory(name, absoluteName, depth2);
      }
    }
  }
}
function getBasePaths(path, includes, useCaseSensitiveFileNames2) {
  const basePaths = [path];
  if (includes) {
    const includeBasePaths = [];
    for (const include of includes) {
      const absolute = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include));
      includeBasePaths.push(getIncludeBasePath(absolute));
    }
    includeBasePaths.sort(getStringComparer(!useCaseSensitiveFileNames2));
    for (const includeBasePath of includeBasePaths) {
      if (every(basePaths, (basePath) => !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames2))) {
        basePaths.push(includeBasePath);
      }
    }
  }
  return basePaths;
}
function getIncludeBasePath(absolute) {
  const wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes);
  if (wildcardOffset < 0) {
    return !hasExtension(absolute) ? absolute : removeTrailingDirectorySeparator(getDirectoryPath(absolute));
  }
  return absolute.substring(0, absolute.lastIndexOf(directorySeparator, wildcardOffset));
}
function ensureScriptKind(fileName, scriptKind) {
  return scriptKind || getScriptKindFromFileName(fileName) || 3 /* TS */;
}
function getScriptKindFromFileName(fileName) {
  const ext = fileName.substr(fileName.lastIndexOf("."));
  switch (ext.toLowerCase()) {
    case ".js" /* Js */:
    case ".cjs" /* Cjs */:
    case ".mjs" /* Mjs */:
      return 1 /* JS */;
    case ".jsx" /* Jsx */:
      return 2 /* JSX */;
    case ".ts" /* Ts */:
    case ".cts" /* Cts */:
    case ".mts" /* Mts */:
      return 3 /* TS */;
    case ".tsx" /* Tsx */:
      return 4 /* TSX */;
    case ".json" /* Json */:
      return 6 /* JSON */;
    default:
      return 0 /* Unknown */;
  }
}
var supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]];
var supportedTSExtensionsFlat = flatten(supportedTSExtensions);
var supportedTSExtensionsWithJson = [...supportedTSExtensions, [".json" /* Json */]];
var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */];
var supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]];
var supportedJSExtensionsFlat = flatten(supportedJSExtensions);
var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]];
var allSupportedExtensionsWithJson = [...allSupportedExtensions, [".json" /* Json */]];
var supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */];
var supportedTSImplementationExtensions = [".ts" /* Ts */, ".cts" /* Cts */, ".mts" /* Mts */, ".tsx" /* Tsx */];
var extensionsNotSupportingExtensionlessResolution = [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */];
function getSupportedExtensions(options, extraFileExtensions) {
  const needJsExtensions = options && getAllowJSCompilerOption(options);
  if (!extraFileExtensions || extraFileExtensions.length === 0) {
    return needJsExtensions ? allSupportedExtensions : supportedTSExtensions;
  }
  const builtins = needJsExtensions ? allSupportedExtensions : supportedTSExtensions;
  const flatBuiltins = flatten(builtins);
  const extensions = [
    ...builtins,
    ...mapDefined(extraFileExtensions, (x) => x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && !flatBuiltins.includes(x.extension) ? [x.extension] : void 0)
  ];
  return extensions;
}
function getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions) {
  if (!options || !getResolveJsonModule(options)) return supportedExtensions;
  if (supportedExtensions === allSupportedExtensions) return allSupportedExtensionsWithJson;
  if (supportedExtensions === supportedTSExtensions) return supportedTSExtensionsWithJson;
  return [...supportedExtensions, [".json" /* Json */]];
}
function isJSLike(scriptKind) {
  return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */;
}
function hasJSFileExtension(fileName) {
  return some(supportedJSExtensionsFlat, (extension) => fileExtensionIs(fileName, extension));
}
function hasTSFileExtension(fileName) {
  return some(supportedTSExtensionsFlat, (extension) => fileExtensionIs(fileName, extension));
}
function hasImplementationTSFileExtension(fileName) {
  return some(supportedTSImplementationExtensions, (extension) => fileExtensionIs(fileName, extension)) && !isDeclarationFileName(fileName);
}
var ModuleSpecifierEnding = /* @__PURE__ */ ((ModuleSpecifierEnding2) => {
  ModuleSpecifierEnding2[ModuleSpecifierEnding2["Minimal"] = 0] = "Minimal";
  ModuleSpecifierEnding2[ModuleSpecifierEnding2["Index"] = 1] = "Index";
  ModuleSpecifierEnding2[ModuleSpecifierEnding2["JsExtension"] = 2] = "JsExtension";
  ModuleSpecifierEnding2[ModuleSpecifierEnding2["TsExtension"] = 3] = "TsExtension";
  return ModuleSpecifierEnding2;
})(ModuleSpecifierEnding || {});
function usesExtensionsOnImports({ imports }, hasExtension2 = or(hasJSFileExtension, hasTSFileExtension)) {
  return firstDefined(imports, ({ text }) => pathIsRelative(text) && !fileExtensionIsOneOf(text, extensionsNotSupportingExtensionlessResolution) ? hasExtension2(text) : void 0) || false;
}
function getModuleSpecifierEndingPreference(preference, resolutionMode, compilerOptions, sourceFile) {
  const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
  const moduleResolutionIsNodeNext = 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */;
  if (preference === "js" || resolutionMode === 99 /* ESNext */ && moduleResolutionIsNodeNext) {
    if (!shouldAllowImportingTsExtension(compilerOptions)) {
      return 2 /* JsExtension */;
    }
    return inferPreference() !== 2 /* JsExtension */ ? 3 /* TsExtension */ : 2 /* JsExtension */;
  }
  if (preference === "minimal") {
    return 0 /* Minimal */;
  }
  if (preference === "index") {
    return 1 /* Index */;
  }
  if (!shouldAllowImportingTsExtension(compilerOptions)) {
    return sourceFile && usesExtensionsOnImports(sourceFile) ? 2 /* JsExtension */ : 0 /* Minimal */;
  }
  return inferPreference();
  function inferPreference() {
    let usesJsExtensions = false;
    const specifiers = (sourceFile == null ? void 0 : sourceFile.imports.length) ? sourceFile.imports : sourceFile && isSourceFileJS(sourceFile) ? getRequiresAtTopOfFile(sourceFile).map((r) => r.arguments[0]) : emptyArray;
    for (const specifier of specifiers) {
      if (pathIsRelative(specifier.text)) {
        if (moduleResolutionIsNodeNext && resolutionMode === 1 /* CommonJS */ && getModeForUsageLocation(sourceFile, specifier, compilerOptions) === 99 /* ESNext */) {
          continue;
        }
        if (fileExtensionIsOneOf(specifier.text, extensionsNotSupportingExtensionlessResolution)) {
          continue;
        }
        if (hasTSFileExtension(specifier.text)) {
          return 3 /* TsExtension */;
        }
        if (hasJSFileExtension(specifier.text)) {
          usesJsExtensions = true;
        }
      }
    }
    return usesJsExtensions ? 2 /* JsExtension */ : 0 /* Minimal */;
  }
}
function getRequiresAtTopOfFile(sourceFile) {
  let nonRequireStatementCount = 0;
  let requires;
  for (const statement of sourceFile.statements) {
    if (nonRequireStatementCount > 3) {
      break;
    }
    if (isRequireVariableStatement(statement)) {
      requires = concatenate(requires, statement.declarationList.declarations.map((d) => d.initializer));
    } else if (isExpressionStatement(statement) && isRequireCall(
      statement.expression,
      /*requireStringLiteralLikeArgument*/
      true
    )) {
      requires = append(requires, statement.expression);
    } else {
      nonRequireStatementCount++;
    }
  }
  return requires || emptyArray;
}
function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) {
  if (!fileName) return false;
  const supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions);
  for (const extension of flatten(getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions))) {
    if (fileExtensionIs(fileName, extension)) {
      return true;
    }
  }
  return false;
}
function numberOfDirectorySeparators(str) {
  const match = str.match(/\//g);
  return match ? match.length : 0;
}
function compareNumberOfDirectorySeparators(path1, path2) {
  return compareValues(
    numberOfDirectorySeparators(path1),
    numberOfDirectorySeparators(path2)
  );
}
var extensionsToRemove = [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".mts" /* Mts */, ".cjs" /* Cjs */, ".cts" /* Cts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */];
function removeFileExtension(path) {
  for (const ext of extensionsToRemove) {
    const extensionless = tryRemoveExtension(path, ext);
    if (extensionless !== void 0) {
      return extensionless;
    }
  }
  return path;
}
function tryRemoveExtension(path, extension) {
  return fileExtensionIs(path, extension) ? removeExtension(path, extension) : void 0;
}
function removeExtension(path, extension) {
  return path.substring(0, path.length - extension.length);
}
function changeExtension(path, newExtension) {
  return changeAnyExtension(
    path,
    newExtension,
    extensionsToRemove,
    /*ignoreCase*/
    false
  );
}
function tryParsePattern(pattern) {
  const indexOfStar = pattern.indexOf("*");
  if (indexOfStar === -1) {
    return pattern;
  }
  return pattern.indexOf("*", indexOfStar + 1) !== -1 ? void 0 : {
    prefix: pattern.substr(0, indexOfStar),
    suffix: pattern.substr(indexOfStar + 1)
  };
}
var parsedPatternsCache = /* @__PURE__ */ new WeakMap();
function tryParsePatterns(paths) {
  let result = parsedPatternsCache.get(paths);
  if (result !== void 0) {
    return result;
  }
  let matchableStringSet;
  let patterns;
  const pathList = getOwnKeys(paths);
  for (const path of pathList) {
    const patternOrStr = tryParsePattern(path);
    if (patternOrStr === void 0) {
      continue;
    } else if (typeof patternOrStr === "string") {
      (matchableStringSet ?? (matchableStringSet = /* @__PURE__ */ new Set())).add(patternOrStr);
    } else {
      (patterns ?? (patterns = [])).push(patternOrStr);
    }
  }
  parsedPatternsCache.set(
    paths,
    result = {
      matchableStringSet,
      patterns
    }
  );
  return result;
}
function positionIsSynthesized(pos) {
  return !(pos >= 0);
}
function extensionIsTS(ext) {
  return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */ || startsWith(ext, ".d.") && endsWith(ext, ".ts");
}
function resolutionExtensionIsTSOrJson(ext) {
  return extensionIsTS(ext) || ext === ".json" /* Json */;
}
function extensionFromPath(path) {
  const ext = tryGetExtensionFromPath2(path);
  return ext !== void 0 ? ext : Debug.fail(`File ${path} has unknown extension.`);
}
function isAnySupportedFileExtension(path) {
  return tryGetExtensionFromPath2(path) !== void 0;
}
function tryGetExtensionFromPath2(path) {
  return find(extensionsToRemove, (e) => fileExtensionIs(path, e));
}
function isCheckJsEnabledForFile(sourceFile, compilerOptions) {
  return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs;
}
var emptyFileSystemEntries = {
  files: emptyArray,
  directories: emptyArray
};
function matchPatternOrExact(parsedPatterns, candidate) {
  const { matchableStringSet, patterns } = parsedPatterns;
  if (matchableStringSet == null ? void 0 : matchableStringSet.has(candidate)) {
    return candidate;
  }
  if (patterns === void 0 || patterns.length === 0) {
    return void 0;
  }
  return findBestPatternMatch(patterns, (_) => _, candidate);
}
function sliceAfter(arr, value) {
  const index = arr.indexOf(value);
  Debug.assert(index !== -1);
  return arr.slice(index);
}
function addRelatedInfo(diagnostic, ...relatedInformation) {
  if (!relatedInformation.length) {
    return diagnostic;
  }
  if (!diagnostic.relatedInformation) {
    diagnostic.relatedInformation = [];
  }
  Debug.assert(diagnostic.relatedInformation !== emptyArray, "Diagnostic had empty array singleton for related info, but is still being constructed!");
  diagnostic.relatedInformation.push(...relatedInformation);
  return diagnostic;
}
function minAndMax(arr, getValue) {
  Debug.assert(arr.length !== 0);
  let min2 = getValue(arr[0]);
  let max = min2;
  for (let i = 1; i < arr.length; i++) {
    const value = getValue(arr[i]);
    if (value < min2) {
      min2 = value;
    } else if (value > max) {
      max = value;
    }
  }
  return { min: min2, max };
}
function rangeOfNode(node) {
  return { pos: getTokenPosOfNode(node), end: node.end };
}
function rangeOfTypeParameters(sourceFile, typeParameters) {
  const pos = typeParameters.pos - 1;
  const end = Math.min(sourceFile.text.length, skipTrivia(sourceFile.text, typeParameters.end) + 1);
  return { pos, end };
}
function skipTypeChecking(sourceFile, options, host) {
  return skipTypeCheckingWorker(
    sourceFile,
    options,
    host,
    /*ignoreNoCheck*/
    false
  );
}
function skipTypeCheckingIgnoringNoCheck(sourceFile, options, host) {
  return skipTypeCheckingWorker(
    sourceFile,
    options,
    host,
    /*ignoreNoCheck*/
    true
  );
}
function skipTypeCheckingWorker(sourceFile, options, host, ignoreNoCheck) {
  return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib || !ignoreNoCheck && options.noCheck || host.isSourceOfProjectReferenceRedirect(sourceFile.fileName) || !canIncludeBindAndCheckDiagnostics(sourceFile, options);
}
function canIncludeBindAndCheckDiagnostics(sourceFile, options) {
  if (!!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false) return false;
  if (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || sourceFile.scriptKind === 5 /* External */) return true;
  const isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
  const isCheckJs = isJs && isCheckJsEnabledForFile(sourceFile, options);
  const isPlainJs = isPlainJsFile(sourceFile, options.checkJs);
  return isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */;
}
function isJsonEqual(a, b) {
  return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && equalOwnProperties(a, b, isJsonEqual);
}
function parsePseudoBigInt(stringValue) {
  let log2Base;
  switch (stringValue.charCodeAt(1)) {
    // "x" in "0x123"
    case 98 /* b */:
    case 66 /* B */:
      log2Base = 1;
      break;
    case 111 /* o */:
    case 79 /* O */:
      log2Base = 3;
      break;
    case 120 /* x */:
    case 88 /* X */:
      log2Base = 4;
      break;
    default:
      const nIndex = stringValue.length - 1;
      let nonZeroStart = 0;
      while (stringValue.charCodeAt(nonZeroStart) === 48 /* _0 */) {
        nonZeroStart++;
      }
      return stringValue.slice(nonZeroStart, nIndex) || "0";
  }
  const startIndex = 2, endIndex = stringValue.length - 1;
  const bitsNeeded = (endIndex - startIndex) * log2Base;
  const segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0));
  for (let i = endIndex - 1, bitOffset = 0; i >= startIndex; i--, bitOffset += log2Base) {
    const segment = bitOffset >>> 4;
    const digitChar = stringValue.charCodeAt(i);
    const digit = digitChar <= 57 /* _9 */ ? digitChar - 48 /* _0 */ : 10 + digitChar - (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */);
    const shiftedDigit = digit << (bitOffset & 15);
    segments[segment] |= shiftedDigit;
    const residual = shiftedDigit >>> 16;
    if (residual) segments[segment + 1] |= residual;
  }
  let base10Value = "";
  let firstNonzeroSegment = segments.length - 1;
  let segmentsRemaining = true;
  while (segmentsRemaining) {
    let mod10 = 0;
    segmentsRemaining = false;
    for (let segment = firstNonzeroSegment; segment >= 0; segment--) {
      const newSegment = mod10 << 16 | segments[segment];
      const segmentValue = newSegment / 10 | 0;
      segments[segment] = segmentValue;
      mod10 = newSegment - segmentValue * 10;
      if (segmentValue && !segmentsRemaining) {
        firstNonzeroSegment = segment;
        segmentsRemaining = true;
      }
    }
    base10Value = mod10 + base10Value;
  }
  return base10Value;
}
function pseudoBigIntToString({ negative, base10Value }) {
  return (negative && base10Value !== "0" ? "-" : "") + base10Value;
}
function parseBigInt(text) {
  if (!isValidBigIntString(
    text,
    /*roundTripOnly*/
    false
  )) {
    return void 0;
  }
  return parseValidBigInt(text);
}
function parseValidBigInt(text) {
  const negative = text.startsWith("-");
  const base10Value = parsePseudoBigInt(`${negative ? text.slice(1) : text}n`);
  return { negative, base10Value };
}
function isValidBigIntString(s, roundTripOnly) {
  if (s === "") return false;
  const scanner2 = createScanner(
    99 /* ESNext */,
    /*skipTrivia*/
    false
  );
  let success = true;
  scanner2.setOnError(() => success = false);
  scanner2.setText(s + "n");
  let result = scanner2.scan();
  const negative = result === 41 /* MinusToken */;
  if (negative) {
    result = scanner2.scan();
  }
  const flags = scanner2.getTokenFlags();
  return success && result === 10 /* BigIntLiteral */ && scanner2.getTokenEnd() === s.length + 1 && !(flags & 512 /* ContainsSeparator */) && (!roundTripOnly || s === pseudoBigIntToString({ negative, base10Value: parsePseudoBigInt(scanner2.getTokenValue()) }));
}
function isValidTypeOnlyAliasUseSite(useSite) {
  return !!(useSite.flags & 33554432 /* Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) || !(isExpressionNode(useSite) || isShorthandPropertyNameUseSite(useSite));
}
function isShorthandPropertyNameUseSite(useSite) {
  return isIdentifier(useSite) && isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite;
}
function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) {
  while (node.kind === 80 /* Identifier */ || node.kind === 211 /* PropertyAccessExpression */) {
    node = node.parent;
  }
  if (node.kind !== 167 /* ComputedPropertyName */) {
    return false;
  }
  if (hasSyntacticModifier(node.parent, 64 /* Abstract */)) {
    return true;
  }
  const containerKind = node.parent.parent.kind;
  return containerKind === 264 /* InterfaceDeclaration */ || containerKind === 187 /* TypeLiteral */;
}
function isIdentifierInNonEmittingHeritageClause(node) {
  if (node.kind !== 80 /* Identifier */) return false;
  const heritageClause = findAncestor(node.parent, (parent2) => {
    switch (parent2.kind) {
      case 298 /* HeritageClause */:
        return true;
      case 211 /* PropertyAccessExpression */:
      case 233 /* ExpressionWithTypeArguments */:
        return false;
      default:
        return "quit";
    }
  });
  return (heritageClause == null ? void 0 : heritageClause.token) === 119 /* ImplementsKeyword */ || (heritageClause == null ? void 0 : heritageClause.parent.kind) === 264 /* InterfaceDeclaration */;
}
function isIdentifierTypeReference(node) {
  return isTypeReferenceNode(node) && isIdentifier(node.typeName);
}
function arrayIsHomogeneous(array, comparer = equateValues) {
  if (array.length < 2) return true;
  const first2 = array[0];
  for (let i = 1, length2 = array.length; i < length2; i++) {
    const target = array[i];
    if (!comparer(first2, target)) return false;
  }
  return true;
}
function setTextRangePos(range, pos) {
  range.pos = pos;
  return range;
}
function setTextRangeEnd(range, end) {
  range.end = end;
  return range;
}
function setTextRangePosEnd(range, pos, end) {
  return setTextRangeEnd(setTextRangePos(range, pos), end);
}
function setTextRangePosWidth(range, pos, width) {
  return setTextRangePosEnd(range, pos, pos + width);
}
function setNodeFlags(node, newFlags) {
  if (node) {
    node.flags = newFlags;
  }
  return node;
}
function setParent(child, parent2) {
  if (child && parent2) {
    child.parent = parent2;
  }
  return child;
}
function setParentRecursive(rootNode, incremental) {
  if (!rootNode) return rootNode;
  forEachChildRecursively(rootNode, isJSDocNode(rootNode) ? bindParentToChildIgnoringJSDoc : bindParentToChild);
  return rootNode;
  function bindParentToChildIgnoringJSDoc(child, parent2) {
    if (incremental && child.parent === parent2) {
      return "skip";
    }
    setParent(child, parent2);
  }
  function bindJSDoc(child) {
    if (hasJSDocNodes(child)) {
      for (const doc of child.jsDoc) {
        bindParentToChildIgnoringJSDoc(doc, child);
        forEachChildRecursively(doc, bindParentToChildIgnoringJSDoc);
      }
    }
  }
  function bindParentToChild(child, parent2) {
    return bindParentToChildIgnoringJSDoc(child, parent2) || bindJSDoc(child);
  }
}
function isPackedElement(node) {
  return !isOmittedExpression(node);
}
function isPackedArrayLiteral(node) {
  return isArrayLiteralExpression(node) && every(node.elements, isPackedElement);
}
function expressionResultIsUnused(node) {
  Debug.assertIsDefined(node.parent);
  while (true) {
    const parent2 = node.parent;
    if (isParenthesizedExpression(parent2)) {
      node = parent2;
      continue;
    }
    if (isExpressionStatement(parent2) || isVoidExpression(parent2) || isForStatement(parent2) && (parent2.initializer === node || parent2.incrementor === node)) {
      return true;
    }
    if (isCommaListExpression(parent2)) {
      if (node !== last(parent2.elements)) return true;
      node = parent2;
      continue;
    }
    if (isBinaryExpression(parent2) && parent2.operatorToken.kind === 28 /* CommaToken */) {
      if (node === parent2.left) return true;
      node = parent2;
      continue;
    }
    return false;
  }
}
function containsIgnoredPath(path) {
  return some(ignoredPaths, (p) => path.includes(p));
}
function getContainingNodeArray(node) {
  if (!node.parent) return void 0;
  switch (node.kind) {
    case 168 /* TypeParameter */:
      const { parent: parent3 } = node;
      return parent3.kind === 195 /* InferType */ ? void 0 : parent3.typeParameters;
    case 169 /* Parameter */:
      return node.parent.parameters;
    case 204 /* TemplateLiteralTypeSpan */:
      return node.parent.templateSpans;
    case 239 /* TemplateSpan */:
      return node.parent.templateSpans;
    case 170 /* Decorator */: {
      const { parent: parent4 } = node;
      return canHaveDecorators(parent4) ? parent4.modifiers : void 0;
    }
    case 298 /* HeritageClause */:
      return node.parent.heritageClauses;
  }
  const { parent: parent2 } = node;
  if (isJSDocTag(node)) {
    return isJSDocTypeLiteral(node.parent) ? void 0 : node.parent.tags;
  }
  switch (parent2.kind) {
    case 187 /* TypeLiteral */:
    case 264 /* InterfaceDeclaration */:
      return isTypeElement(node) ? parent2.members : void 0;
    case 192 /* UnionType */:
    case 193 /* IntersectionType */:
      return parent2.types;
    case 189 /* TupleType */:
    case 209 /* ArrayLiteralExpression */:
    case 356 /* CommaListExpression */:
    case 275 /* NamedImports */:
    case 279 /* NamedExports */:
      return parent2.elements;
    case 210 /* ObjectLiteralExpression */:
    case 292 /* JsxAttributes */:
      return parent2.properties;
    case 213 /* CallExpression */:
    case 214 /* NewExpression */:
      return isTypeNode(node) ? parent2.typeArguments : parent2.expression === node ? void 0 : parent2.arguments;
    case 284 /* JsxElement */:
    case 288 /* JsxFragment */:
      return isJsxChild(node) ? parent2.children : void 0;
    case 286 /* JsxOpeningElement */:
    case 285 /* JsxSelfClosingElement */:
      return isTypeNode(node) ? parent2.typeArguments : void 0;
    case 241 /* Block */:
    case 296 /* CaseClause */:
    case 297 /* DefaultClause */:
    case 268 /* ModuleBlock */:
      return parent2.statements;
    case 269 /* CaseBlock */:
      return parent2.clauses;
    case 263 /* ClassDeclaration */:
    case 231 /* ClassExpression */:
      return isClassElement(node) ? parent2.members : void 0;
    case 266 /* EnumDeclaration */:
      return isEnumMember(node) ? parent2.members : void 0;
    case 307 /* SourceFile */:
      return parent2.statements;
  }
}
function hasContextSensitiveParameters(node) {
  if (!node.typeParameters) {
    if (some(node.parameters, (p) => !getEffectiveTypeAnnotationNode(p))) {
      return true;
    }
    if (node.kind !== 219 /* ArrowFunction */) {
      const parameter = firstOrUndefined(node.parameters);
      if (!(parameter && parameterIsThisKeyword(parameter))) {
        return true;
      }
    }
  }
  return false;
}
function isInfinityOrNaNString(name) {
  return name === "Infinity" || name === "-Infinity" || name === "NaN";
}
function isCatchClauseVariableDeclaration(node) {
  return node.kind === 260 /* VariableDeclaration */ && node.parent.kind === 299 /* CatchClause */;
}
function isFunctionExpressionOrArrowFunction(node) {
  return node.kind === 218 /* FunctionExpression */ || node.kind === 219 /* ArrowFunction */;
}
function escapeSnippetText(text) {
  return text.replace(/\$/g, () => "\\$");
}
function isNumericLiteralName(name) {
  return (+name).toString() === name;
}
function createPropertyNameNodeForIdentifierOrLiteral(name, target, singleQuote, stringNamed, isMethod) {
  const isMethodNamedNew = isMethod && name === "new";
  return !isMethodNamedNew && isIdentifierText(name, target) ? factory.createIdentifier(name) : !stringNamed && !isMethodNamedNew && isNumericLiteralName(name) && +name >= 0 ? factory.createNumericLiteral(+name) : factory.createStringLiteral(name, !!singleQuote);
}
function isThisTypeParameter(type) {
  return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
}
function getNodeModulePathParts(fullPath) {
  let topLevelNodeModulesIndex = 0;
  let topLevelPackageNameIndex = 0;
  let packageRootIndex = 0;
  let fileNameIndex = 0;
  let States;
  ((States2) => {
    States2[States2["BeforeNodeModules"] = 0] = "BeforeNodeModules";
    States2[States2["NodeModules"] = 1] = "NodeModules";
    States2[States2["Scope"] = 2] = "Scope";
    States2[States2["PackageContent"] = 3] = "PackageContent";
  })(States || (States = {}));
  let partStart = 0;
  let partEnd = 0;
  let state = 0 /* BeforeNodeModules */;
  while (partEnd >= 0) {
    partStart = partEnd;
    partEnd = fullPath.indexOf("/", partStart + 1);
    switch (state) {
      case 0 /* BeforeNodeModules */:
        if (fullPath.indexOf(nodeModulesPathPart, partStart) === partStart) {
          topLevelNodeModulesIndex = partStart;
          topLevelPackageNameIndex = partEnd;
          state = 1 /* NodeModules */;
        }
        break;
      case 1 /* NodeModules */:
      case 2 /* Scope */:
        if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
          state = 2 /* Scope */;
        } else {
          packageRootIndex = partEnd;
          state = 3 /* PackageContent */;
        }
        break;
      case 3 /* PackageContent */:
        if (fullPath.indexOf(nodeModulesPathPart, partStart) === partStart) {
          state = 1 /* NodeModules */;
        } else {
          state = 3 /* PackageContent */;
        }
        break;
    }
  }
  fileNameIndex = partStart;
  return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex, topLevelPackageNameIndex, packageRootIndex, fileNameIndex } : void 0;
}
function isTypeDeclaration(node) {
  switch (node.kind) {
    case 168 /* TypeParameter */:
    case 263 /* ClassDeclaration */:
    case 264 /* InterfaceDeclaration */:
    case 265 /* TypeAliasDeclaration */:
    case 266 /* EnumDeclaration */:
    case 346 /* JSDocTypedefTag */:
    case 338 /* JSDocCallbackTag */:
    case 340 /* JSDocEnumTag */:
      return true;
    case 273 /* ImportClause */:
      return node.isTypeOnly;
    case 276 /* ImportSpecifier */:
    case 281 /* ExportSpecifier */:
      return node.parent.parent.isTypeOnly;
    default:
      return false;
  }
}
function canHaveExportModifier(node) {
  return isEnumDeclaration(node) || isVariableStatement(node) || isFunctionDeclaration(node) || isClassDeclaration(node) || isInterfaceDeclaration(node) || isTypeDeclaration(node) || isModuleDeclaration(node) && !isExternalModuleAugmentation(node) && !isGlobalScopeAugmentation(node);
}
function isOptionalJSDocPropertyLikeTag(node) {
  if (!isJSDocPropertyLikeTag(node)) {
    return false;
  }
  const { isBracketed, typeExpression } = node;
  return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */;
}
function canUsePropertyAccess(name, languageVersion) {
  if (name.length === 0) {
    return false;
  }
  const firstChar = name.charCodeAt(0);
  return firstChar === 35 /* hash */ ? name.length > 1 && isIdentifierStart(name.charCodeAt(1), languageVersion) : isIdentifierStart(firstChar, languageVersion);
}
function hasTabstop(node) {
  var _a;
  return ((_a = getSnippetElement(node)) == null ? void 0 : _a.kind) === 0 /* TabStop */;
}
function isJSDocOptionalParameter(node) {
  return isInJSFile(node) && // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType
  (node.type && node.type.kind === 316 /* JSDocOptionalType */ || getJSDocParameterTags(node).some(isOptionalJSDocPropertyLikeTag));
}
function isOptionalDeclaration(declaration) {
  switch (declaration.kind) {
    case 172 /* PropertyDeclaration */:
    case 171 /* PropertySignature */:
      return !!declaration.questionToken;
    case 169 /* Parameter */:
      return !!declaration.questionToken || isJSDocOptionalParameter(declaration);
    case 348 /* JSDocPropertyTag */:
    case 341 /* JSDocParameterTag */:
      return isOptionalJSDocPropertyLikeTag(declaration);
    default:
      return false;
  }
}
function isNonNullAccess(node) {
  const kind = node.kind;
  return (kind === 211 /* PropertyAccessExpression */ || kind === 212 /* ElementAccessExpression */) && isNonNullExpression(node.expression);
}
function isJSDocSatisfiesExpression(node) {
  return isInJSFile(node) && isParenthesizedExpression(node) && hasJSDocNodes(node) && !!getJSDocSatisfiesTag(node);
}
function getJSDocSatisfiesExpressionType(node) {
  return Debug.checkDefined(tryGetJSDocSatisfiesTypeNode(node));
}
function tryGetJSDocSatisfiesTypeNode(node) {
  const tag = getJSDocSatisfiesTag(node);
  return tag && tag.typeExpression && tag.typeExpression.type;
}
function getEscapedTextOfJsxAttributeName(node) {
  return isIdentifier(node) ? node.escapedText : getEscapedTextOfJsxNamespacedName(node);
}
function getTextOfJsxAttributeName(node) {
  return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
}
function isJsxAttributeName(node) {
  const kind = node.kind;
  return kind === 80 /* Identifier */ || kind === 295 /* JsxNamespacedName */;
}
function getEscapedTextOfJsxNamespacedName(node) {
  return `${node.namespace.escapedText}:${idText(node.name)}`;
}
function getTextOfJsxNamespacedName(node) {
  return `${idText(node.namespace)}:${idText(node.name)}`;
}
function intrinsicTagNameToString(node) {
  return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
}
function isTypeUsableAsPropertyName(type) {
  return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
}
function getPropertyNameFromType(type) {
  if (type.flags & 8192 /* UniqueESSymbol */) {
    return type.escapedName;
  }
  if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
    return escapeLeadingUnderscores("" + type.value);
  }
  return Debug.fail();
}
function isExpandoPropertyDeclaration(declaration) {
  return !!declaration && (isPropertyAccessExpression(declaration) || isElementAccessExpression(declaration) || isBinaryExpression(declaration));
}
function hasResolutionModeOverride(node) {
  if (node === void 0) {
    return false;
  }
  return !!getResolutionModeOverride(node.attributes);
}
var stringReplace = String.prototype.replace;
function replaceFirstStar(s, replacement) {
  return stringReplace.call(s, "*", replacement);
}
function getNameFromImportAttribute(node) {
  return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
}
function isSourceElement(node) {
  switch (node.kind) {
    case 168 /* TypeParameter */:
    case 169 /* Parameter */:
    case 172 /* PropertyDeclaration */:
    case 171 /* PropertySignature */:
    case 185 /* ConstructorType */:
    case 184 /* FunctionType */:
    case 179 /* CallSignature */:
    case 180 /* ConstructSignature */:
    case 181 /* IndexSignature */:
    case 174 /* MethodDeclaration */:
    case 173 /* MethodSignature */:
    case 175 /* ClassStaticBlockDeclaration */:
    case 176 /* Constructor */:
    case 177 /* GetAccessor */:
    case 178 /* SetAccessor */:
    case 183 /* TypeReference */:
    case 182 /* TypePredicate */:
    case 186 /* TypeQuery */:
    case 187 /* TypeLiteral */:
    case 188 /* ArrayType */:
    case 189 /* TupleType */:
    case 192 /* UnionType */:
    case 193 /* IntersectionType */:
    case 196 /* ParenthesizedType */:
    case 190 /* OptionalType */:
    case 191 /* RestType */:
    case 197 /* ThisType */:
    case 198 /* TypeOperator */:
    case 194 /* ConditionalType */:
    case 195 /* InferType */:
    case 203 /* TemplateLiteralType */:
    case 205 /* ImportType */:
    case 202 /* NamedTupleMember */:
    case 328 /* JSDocAugmentsTag */:
    case 329 /* JSDocImplementsTag */:
    case 346 /* JSDocTypedefTag */:
    case 338 /* JSDocCallbackTag */:
    case 340 /* JSDocEnumTag */:
    case 345 /* JSDocTemplateTag */:
    case 344 /* JSDocTypeTag */:
    case 324 /* JSDocLink */:
    case 325 /* JSDocLinkCode */:
    case 326 /* JSDocLinkPlain */:
    case 341 /* JSDocParameterTag */:
    case 348 /* JSDocPropertyTag */:
    case 317 /* JSDocFunctionType */:
    case 315 /* JSDocNonNullableType */:
    case 314 /* JSDocNullableType */:
    case 312 /* JSDocAllType */:
    case 313 /* JSDocUnknownType */:
    case 322 /* JSDocTypeLiteral */:
    case 318 /* JSDocVariadicType */:
    case 309 /* JSDocTypeExpression */:
    case 333 /* JSDocPublicTag */:
    case 335 /* JSDocProtectedTag */:
    case 334 /* JSDocPrivateTag */:
    case 350 /* JSDocSatisfiesTag */:
    case 343 /* JSDocThisTag */:
    case 199 /* IndexedAccessType */:
    case 200 /* MappedType */:
    case 262 /* FunctionDeclaration */:
    case 241 /* Block */:
    case 268 /* ModuleBlock */:
    case 243 /* VariableStatement */:
    case 244 /* ExpressionStatement */:
    case 245 /* IfStatement */:
    case 246 /* DoStatement */:
    case 247 /* WhileStatement */:
    case 248 /* ForStatement */:
    case 249 /* ForInStatement */:
    case 250 /* ForOfStatement */:
    case 251 /* ContinueStatement */:
    case 252 /* BreakStatement */:
    case 253 /* ReturnStatement */:
    case 254 /* WithStatement */:
    case 255 /* SwitchStatement */:
    case 256 /* LabeledStatement */:
    case 257 /* ThrowStatement */:
    case 258 /* TryStatement */:
    case 260 /* VariableDeclaration */:
    case 208 /* BindingElement */:
    case 263 /* ClassDeclaration */:
    case 264 /* InterfaceDeclaration */:
    case 265 /* TypeAliasDeclaration */:
    case 266 /* EnumDeclaration */:
    case 267 /* ModuleDeclaration */:
    case 272 /* ImportDeclaration */:
    case 271 /* ImportEqualsDeclaration */:
    case 278 /* ExportDeclaration */:
    case 277 /* ExportAssignment */:
    case 242 /* EmptyStatement */:
    case 259 /* DebuggerStatement */:
    case 282 /* MissingDeclaration */:
      return true;
  }
  return false;
}
function evaluatorResult(value, isSyntacticallyString = false, resolvedOtherFiles = false, hasExternalReferences = false) {
  return { value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences };
}
function createEvaluator({ evaluateElementAccessExpression, evaluateEntityNameExpression }) {
  function evaluate(expr, location) {
    let isSyntacticallyString = false;
    let resolvedOtherFiles = false;
    let hasExternalReferences = false;
    expr = skipParentheses(expr);
    switch (expr.kind) {
      case 224 /* PrefixUnaryExpression */:
        const result = evaluate(expr.operand, location);
        resolvedOtherFiles = result.resolvedOtherFiles;
        hasExternalReferences = result.hasExternalReferences;
        if (typeof result.value === "number") {
          switch (expr.operator) {
            case 40 /* PlusToken */:
              return evaluatorResult(result.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
            case 41 /* MinusToken */:
              return evaluatorResult(-result.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
            case 55 /* TildeToken */:
              return evaluatorResult(~result.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
          }
        }
        break;
      case 226 /* BinaryExpression */: {
        const left = evaluate(expr.left, location);
        const right = evaluate(expr.right, location);
        isSyntacticallyString = (left.isSyntacticallyString || right.isSyntacticallyString) && expr.operatorToken.kind === 40 /* PlusToken */;
        resolvedOtherFiles = left.resolvedOtherFiles || right.resolvedOtherFiles;
        hasExternalReferences = left.hasExternalReferences || right.hasExternalReferences;
        if (typeof left.value === "number" && typeof right.value === "number") {
          switch (expr.operatorToken.kind) {
            case 52 /* BarToken */:
              return evaluatorResult(left.value | right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
            case 51 /* AmpersandToken */:
              return evaluatorResult(left.value & right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
            case 49 /* GreaterThanGreaterThanToken */:
              return evaluatorResult(left.value >> right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
            case 50 /* GreaterThanGreaterThanGreaterThanToken */:
              return evaluatorResult(left.value >>> right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
            case 48 /* LessThanLessThanToken */:
              return evaluatorResult(left.value << right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
            case 53 /* CaretToken */:
              return evaluatorResult(left.value ^ right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
            case 42 /* AsteriskToken */:
              return evaluatorResult(left.value * right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
            case 44 /* SlashToken */:
              return evaluatorResult(left.value / right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
            case 40 /* PlusToken */:
              return evaluatorResult(left.value + right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
            case 41 /* MinusToken */:
              return evaluatorResult(left.value - right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
            case 45 /* PercentToken */:
              return evaluatorResult(left.value % right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
            case 43 /* AsteriskAsteriskToken */:
              return evaluatorResult(left.value ** right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
          }
        } else if ((typeof left.value === "string" || typeof left.value === "number") && (typeof right.value === "string" || typeof right.value === "number") && expr.operatorToken.kind === 40 /* PlusToken */) {
          return evaluatorResult(
            "" + left.value + right.value,
            isSyntacticallyString,
            resolvedOtherFiles,
            hasExternalReferences
          );
        }
        break;
      }
      case 11 /* StringLiteral */:
      case 15 /* NoSubstitutionTemplateLiteral */:
        return evaluatorResult(
          expr.text,
          /*isSyntacticallyString*/
          true
        );
      case 228 /* TemplateExpression */:
        return evaluateTemplateExpression(expr, location);
      case 9 /* NumericLiteral */:
        return evaluatorResult(+expr.text);
      case 80 /* Identifier */:
        return evaluateEntityNameExpression(expr, location);
      case 211 /* PropertyAccessExpression */:
        if (isEntityNameExpression(expr)) {
          return evaluateEntityNameExpression(expr, location);
        }
        break;
      case 212 /* ElementAccessExpression */:
        return evaluateElementAccessExpression(expr, location);
    }
    return evaluatorResult(
      /*value*/
      void 0,
      isSyntacticallyString,
      resolvedOtherFiles,
      hasExternalReferences
    );
  }
  function evaluateTemplateExpression(expr, location) {
    let result = expr.head.text;
    let resolvedOtherFiles = false;
    let hasExternalReferences = false;
    for (const span of expr.templateSpans) {
      const spanResult = evaluate(span.expression, location);
      if (spanResult.value === void 0) {
        return evaluatorResult(
          /*value*/
          void 0,
          /*isSyntacticallyString*/
          true
        );
      }
      result += spanResult.value;
      result += span.literal.text;
      resolvedOtherFiles || (resolvedOtherFiles = spanResult.resolvedOtherFiles);
      hasExternalReferences || (hasExternalReferences = spanResult.hasExternalReferences);
    }
    return evaluatorResult(
      result,
      /*isSyntacticallyString*/
      true,
      resolvedOtherFiles,
      hasExternalReferences
    );
  }
  return evaluate;
}
function isConstAssertion(location) {
  return isAssertionExpression(location) && isConstTypeReference(location.type) || isJSDocTypeTag(location) && isConstTypeReference(location.typeExpression);
}
function findConstructorDeclaration(node) {
  const members = node.members;
  for (const member of members) {
    if (member.kind === 176 /* Constructor */ && nodeIsPresent(member.body)) {
      return member;
    }
  }
}
function createNameResolver({
  compilerOptions,
  requireSymbol,
  argumentsSymbol,
  error: error2,
  getSymbolOfDeclaration,
  globals,
  lookup,
  setRequiresScopeChangeCache = returnUndefined,
  getRequiresScopeChangeCache = returnUndefined,
  onPropertyWithInvalidInitializer = returnFalse,
  onFailedToResolveSymbol = returnUndefined,
  onSuccessfullyResolvedSymbol = returnUndefined
}) {
  var isolatedModulesLikeFlagName = compilerOptions.verbatimModuleSyntax ? "verbatimModuleSyntax" : "isolatedModules";
  var emitStandardClassFields = getEmitStandardClassFields(compilerOptions);
  var emptySymbols = createSymbolTable();
  return resolveNameHelper;
  function resolveNameHelper(location, nameArg, meaning, nameNotFoundMessage, isUse, excludeGlobals) {
    var _a, _b, _c;
    const originalLocation = location;
    let result;
    let lastLocation;
    let lastSelfReferenceLocation;
    let propertyWithInvalidInitializer;
    let associatedDeclarationForContainingInitializerOrBindingName;
    let withinDeferredContext = false;
    let grandparent;
    const name = isString(nameArg) ? nameArg : nameArg.escapedText;
    loop:
      while (location) {
        if (name === "const" && isConstAssertion(location)) {
          return void 0;
        }
        if (isModuleOrEnumDeclaration(location) && lastLocation && location.name === lastLocation) {
          lastLocation = location;
          location = location.parent;
        }
        if (canHaveLocals(location) && location.locals && !isGlobalSourceFile(location)) {
          if (result = lookup(location.locals, name, meaning)) {
            let useResult = true;
            if (isFunctionLike(location) && lastLocation && lastLocation !== location.body) {
              if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 320 /* JSDoc */) {
                useResult = result.flags & 262144 /* TypeParameter */ ? !!(lastLocation.flags & 16 /* Synthesized */) || // Synthetic fake scopes are added for signatures so type parameters are accessible from them
                lastLocation === location.type || lastLocation.kind === 169 /* Parameter */ || lastLocation.kind === 341 /* JSDocParameterTag */ || lastLocation.kind === 342 /* JSDocReturnTag */ || lastLocation.kind === 168 /* TypeParameter */ : false;
              }
              if (meaning & result.flags & 3 /* Variable */) {
                if (useOuterVariableScopeInParameter(result, location, lastLocation)) {
                  useResult = false;
                } else if (result.flags & 1 /* FunctionScopedVariable */) {
                  useResult = lastLocation.kind === 169 /* Parameter */ || !!(lastLocation.flags & 16 /* Synthesized */) || // Synthetic fake scopes are added for signatures so parameters are accessible from them
                  lastLocation === location.type && !!findAncestor(result.valueDeclaration, isParameter);
                }
              }
            } else if (location.kind === 194 /* ConditionalType */) {
              useResult = lastLocation === location.trueType;
            }
            if (useResult) {
              break loop;
            } else {
              result = void 0;
            }
          }
        }
        withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation);
        switch (location.kind) {
          case 307 /* SourceFile */:
            if (!isExternalOrCommonJsModule(location)) break;
          // falls through
          case 267 /* ModuleDeclaration */:
            const moduleExports = ((_a = getSymbolOfDeclaration(location)) == null ? void 0 : _a.exports) || emptySymbols;
            if (location.kind === 307 /* SourceFile */ || isModuleDeclaration(location) && location.flags & 33554432 /* Ambient */ && !isGlobalScopeAugmentation(location)) {
              if (result = moduleExports.get("default" /* Default */)) {
                const localSymbol = getLocalSymbolForExportDefault(result);
                if (localSymbol && result.flags & meaning && localSymbol.escapedName === name) {
                  break loop;
                }
                result = void 0;
              }
              const moduleExport = moduleExports.get(name);
              if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && (getDeclarationOfKind(moduleExport, 281 /* ExportSpecifier */) || getDeclarationOfKind(moduleExport, 280 /* NamespaceExport */))) {
                break;
              }
            }
            if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) {
              if (isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) == null ? void 0 : _b.some(isJSDocTypeAlias))) {
                result = void 0;
              } else {
                break loop;
              }
            }
            break;
          case 266 /* EnumDeclaration */:
            if (result = lookup(((_c = getSymbolOfDeclaration(location)) == null ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) {
              if (nameNotFoundMessage && getIsolatedModules(compilerOptions) && !(location.flags & 33554432 /* Ambient */) && getSourceFileOfNode(location) !== getSourceFileOfNode(result.valueDeclaration)) {
                error2(
                  originalLocation,
                  Diagnostics.Cannot_access_0_from_another_file_without_qualification_when_1_is_enabled_Use_2_instead,
                  unescapeLeadingUnderscores(name),
                  isolatedModulesLikeFlagName,
                  `${unescapeLeadingUnderscores(getSymbolOfDeclaration(location).escapedName)}.${unescapeLeadingUnderscores(name)}`
                );
              }
              break loop;
            }
            break;
          case 172 /* PropertyDeclaration */:
            if (!isStatic(location)) {
              const ctor = findConstructorDeclaration(location.parent);
              if (ctor && ctor.locals) {
                if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) {
                  Debug.assertNode(location, isPropertyDeclaration);
                  propertyWithInvalidInitializer = location;
                }
              }
            }
            break;
          case 263 /* ClassDeclaration */:
          case 231 /* ClassExpression */:
          case 264 /* InterfaceDeclaration */:
            if (result = lookup(getSymbolOfDeclaration(location).members || emptySymbols, name, meaning & 788968 /* Type */)) {
              if (!isTypeParameterSymbolDeclaredInContainer(result, location)) {
                result = void 0;
                break;
              }
              if (lastLocation && isStatic(lastLocation)) {
                if (nameNotFoundMessage) {
                  error2(originalLocation, Diagnostics.Static_members_cannot_reference_class_type_parameters);
                }
                return void 0;
              }
              break loop;
            }
            if (isClassExpression(location) && meaning & 32 /* Class */) {
              const className = location.name;
              if (className && name === className.escapedText) {
                result = location.symbol;
                break loop;
              }
            }
            break;
          case 233 /* ExpressionWithTypeArguments */:
            if (lastLocation === location.expression && location.parent.token === 96 /* ExtendsKeyword */) {
              const container = location.parent.parent;
              if (isClassLike(container) && (result = lookup(getSymbolOfDeclaration(container).members, name, meaning & 788968 /* Type */))) {
                if (nameNotFoundMessage) {
                  error2(originalLocation, Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters);
                }
                return void 0;
              }
            }
            break;
          // It is not legal to reference a class's own type parameters from a computed property name that
          // belongs to the class. For example:
          //
          //   function foo<T>() { return '' }
          //   class C<T> { // <-- Class's own type parameter T
          //       [foo<T>()]() { } // <-- Reference to T from class's own computed property
          //   }
          //
          case 167 /* ComputedPropertyName */:
            grandparent = location.parent.parent;
            if (isClassLike(grandparent) || grandparent.kind === 264 /* InterfaceDeclaration */) {
              if (result = lookup(getSymbolOfDeclaration(grandparent).members, name, meaning & 788968 /* Type */)) {
                if (nameNotFoundMessage) {
                  error2(originalLocation, Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
                }
                return void 0;
              }
            }
            break;
          case 219 /* ArrowFunction */:
            if (getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) {
              break;
            }
          // falls through
          case 174 /* MethodDeclaration */:
          case 176 /* Constructor */:
          case 177 /* GetAccessor */:
          case 178 /* SetAccessor */:
          case 262 /* FunctionDeclaration */:
            if (meaning & 3 /* Variable */ && name === "arguments") {
              result = argumentsSymbol;
              break loop;
            }
            break;
          case 218 /* FunctionExpression */:
            if (meaning & 3 /* Variable */ && name === "arguments") {
              result = argumentsSymbol;
              break loop;
            }
            if (meaning & 16 /* Function */) {
              const functionName = location.name;
              if (functionName && name === functionName.escapedText) {
                result = location.symbol;
                break loop;
              }
            }
            break;
          case 170 /* Decorator */:
            if (location.parent && location.parent.kind === 169 /* Parameter */) {
              location = location.parent;
            }
            if (location.parent && (isClassElement(location.parent) || location.parent.kind === 263 /* ClassDeclaration */)) {
              location = location.parent;
            }
            break;
          case 346 /* JSDocTypedefTag */:
          case 338 /* JSDocCallbackTag */:
          case 340 /* JSDocEnumTag */:
          case 351 /* JSDocImportTag */:
            const root = getJSDocRoot(location);
            if (root) {
              location = root.parent;
            }
            break;
          case 169 /* Parameter */:
            if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && isBindingPattern(lastLocation))) {
              if (!associatedDeclarationForContainingInitializerOrBindingName) {
                associatedDeclarationForContainingInitializerOrBindingName = location;
              }
            }
            break;
          case 208 /* BindingElement */:
            if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && isBindingPattern(lastLocation))) {
              if (isPartOfParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) {
                associatedDeclarationForContainingInitializerOrBindingName = location;
              }
            }
            break;
          case 195 /* InferType */:
            if (meaning & 262144 /* TypeParameter */) {
              const parameterName = location.typeParameter.name;
              if (parameterName && name === parameterName.escapedText) {
                result = location.typeParameter.symbol;
                break loop;
              }
            }
            break;
          case 281 /* ExportSpecifier */:
            if (lastLocation && lastLocation === location.propertyName && location.parent.parent.moduleSpecifier) {
              location = location.parent.parent.parent;
            }
            break;
        }
        if (isSelfReferenceLocation(location, lastLocation)) {
          lastSelfReferenceLocation = location;
        }
        lastLocation = location;
        location = isJSDocTemplateTag(location) ? getEffectiveContainerForJSDocTemplateTag(location) || location.parent : isJSDocParameterTag(location) || isJSDocReturnTag(location) ? getHostSignatureFromJSDoc(location) || location.parent : location.parent;
      }
    if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
      result.isReferenced |= meaning;
    }
    if (!result) {
      if (lastLocation) {
        Debug.assertNode(lastLocation, isSourceFile);
        if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) {
          return lastLocation.symbol;
        }
      }
      if (!excludeGlobals) {
        result = lookup(globals, name, meaning);
      }
    }
    if (!result) {
      if (originalLocation && isInJSFile(originalLocation) && originalLocation.parent) {
        if (isRequireCall(
          originalLocation.parent,
          /*requireStringLiteralLikeArgument*/
          false
        )) {
          return requireSymbol;
        }
      }
    }
    if (nameNotFoundMessage) {
      if (propertyWithInvalidInitializer && onPropertyWithInvalidInitializer(originalLocation, name, propertyWithInvalidInitializer, result)) {
        return void 0;
      }
      if (!result) {
        onFailedToResolveSymbol(originalLocation, nameArg, meaning, nameNotFoundMessage);
      } else {
        onSuccessfullyResolvedSymbol(originalLocation, result, meaning, lastLocation, associatedDeclarationForContainingInitializerOrBindingName, withinDeferredContext);
      }
    }
    return result;
  }
  function useOuterVariableScopeInParameter(result, location, lastLocation) {
    const target = getEmitScriptTarget(compilerOptions);
    const functionLocation = location;
    if (isParameter(lastLocation) && functionLocation.body && result.valueDeclaration && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) {
      if (target >= 2 /* ES2015 */) {
        let declarationRequiresScopeChange = getRequiresScopeChangeCache(functionLocation);
        if (declarationRequiresScopeChange === void 0) {
          declarationRequiresScopeChange = forEach(functionLocation.parameters, requiresScopeChange) || false;
          setRequiresScopeChangeCache(functionLocation, declarationRequiresScopeChange);
        }
        return !declarationRequiresScopeChange;
      }
    }
    return false;
    function requiresScopeChange(node) {
      return requiresScopeChangeWorker(node.name) || !!node.initializer && requiresScopeChangeWorker(node.initializer);
    }
    function requiresScopeChangeWorker(node) {
      switch (node.kind) {
        case 219 /* ArrowFunction */:
        case 218 /* FunctionExpression */:
        case 262 /* FunctionDeclaration */:
        case 176 /* Constructor */:
          return false;
        case 174 /* MethodDeclaration */:
        case 177 /* GetAccessor */:
        case 178 /* SetAccessor */:
        case 303 /* PropertyAssignment */:
          return requiresScopeChangeWorker(node.name);
        case 172 /* PropertyDeclaration */:
          if (hasStaticModifier(node)) {
            return !emitStandardClassFields;
          }
          return requiresScopeChangeWorker(node.name);
        default:
          if (isNullishCoalesce(node) || isOptionalChain(node)) {
            return target < 7 /* ES2020 */;
          }
          if (isBindingElement(node) && node.dotDotDotToken && isObjectBindingPattern(node.parent)) {
            return target < 4 /* ES2017 */;
          }
          if (isTypeNode(node)) return false;
          return forEachChild(node, requiresScopeChangeWorker) || false;
      }
    }
  }
  function getIsDeferredContext(location, lastLocation) {
    if (location.kind !== 219 /* ArrowFunction */ && location.kind !== 218 /* FunctionExpression */) {
      return isTypeQueryNode(location) || (isFunctionLikeDeclaration(location) || location.kind === 172 /* PropertyDeclaration */ && !isStatic(location)) && (!lastLocation || lastLocation !== location.name);
    }
    if (lastLocation && lastLocation === location.name) {
      return false;
    }
    if (location.asteriskToken || hasSyntacticModifier(location, 1024 /* Async */)) {
      return true;
    }
    return !getImmediatelyInvokedFunctionExpression(location);
  }
  function isSelfReferenceLocation(node, lastLocation) {
    switch (node.kind) {
      case 169 /* Parameter */:
        return !!lastLocation && lastLocation === node.name;
      case 262 /* FunctionDeclaration */:
      case 263 /* ClassDeclaration */:
      case 264 /* InterfaceDeclaration */:
      case 266 /* EnumDeclaration */:
      case 265 /* TypeAliasDeclaration */:
      case 267 /* ModuleDeclaration */:
        return true;
      default:
        return false;
    }
  }
  function isTypeParameterSymbolDeclaredInContainer(symbol, container) {
    if (symbol.declarations) {
      for (const decl of symbol.declarations) {
        if (decl.kind === 168 /* TypeParameter */) {
          const parent2 = isJSDocTemplateTag(decl.parent) ? getJSDocHost(decl.parent) : decl.parent;
          if (parent2 === container) {
            return !(isJSDocTemplateTag(decl.parent) && find(decl.parent.parent.tags, isJSDocTypeAlias));
          }
        }
      }
    }
    return false;
  }
}
function isPrimitiveLiteralValue(node, includeBigInt = true) {
  Debug.type(node);
  switch (node.kind) {
    case 112 /* TrueKeyword */:
    case 97 /* FalseKeyword */:
    case 9 /* NumericLiteral */:
    case 11 /* StringLiteral */:
    case 15 /* NoSubstitutionTemplateLiteral */:
      return true;
    case 10 /* BigIntLiteral */:
      return includeBigInt;
    case 224 /* PrefixUnaryExpression */:
      if (node.operator === 41 /* MinusToken */) {
        return isNumericLiteral(node.operand) || includeBigInt && isBigIntLiteral(node.operand);
      }
      if (node.operator === 40 /* PlusToken */) {
        return isNumericLiteral(node.operand);
      }
      return false;
    default:
      assertType(node);
      return false;
  }
}
function unwrapParenthesizedExpression(o) {
  while (o.kind === 217 /* ParenthesizedExpression */) {
    o = o.expression;
  }
  return o;
}
function hasInferredType(node) {
  Debug.type(node);
  switch (node.kind) {
    case 169 /* Parameter */:
    case 171 /* PropertySignature */:
    case 172 /* PropertyDeclaration */:
    case 208 /* BindingElement */:
    case 211 /* PropertyAccessExpression */:
    case 212 /* ElementAccessExpression */:
    case 226 /* BinaryExpression */:
    case 260 /* VariableDeclaration */:
    case 277 /* ExportAssignment */:
    case 303 /* PropertyAssignment */:
    case 304 /* ShorthandPropertyAssignment */:
    case 341 /* JSDocParameterTag */:
    case 348 /* JSDocPropertyTag */:
      return true;
    default:
      assertType(node);
      return false;
  }
}
function isSideEffectImport(node) {
  const ancestor = findAncestor(node, isImportDeclaration);
  return !!ancestor && !ancestor.importClause;
}
var unprefixedNodeCoreModulesList = [
  "assert",
  "assert/strict",
  "async_hooks",
  "buffer",
  "child_process",
  "cluster",
  "console",
  "constants",
  "crypto",
  "dgram",
  "diagnostics_channel",
  "dns",
  "dns/promises",
  "domain",
  "events",
  "fs",
  "fs/promises",
  "http",
  "http2",
  "https",
  "inspector",
  "inspector/promises",
  "module",
  "net",
  "os",
  "path",
  "path/posix",
  "path/win32",
  "perf_hooks",
  "process",
  "punycode",
  "querystring",
  "readline",
  "readline/promises",
  "repl",
  "stream",
  "stream/consumers",
  "stream/promises",
  "stream/web",
  "string_decoder",
  "sys",
  "test/mock_loader",
  "timers",
  "timers/promises",
  "tls",
  "trace_events",
  "tty",
  "url",
  "util",
  "util/types",
  "v8",
  "vm",
  "wasi",
  "worker_threads",
  "zlib"
];
var unprefixedNodeCoreModules = new Set(unprefixedNodeCoreModulesList);
var exclusivelyPrefixedNodeCoreModules = /* @__PURE__ */ new Set([
  "node:sea",
  "node:sqlite",
  "node:test",
  "node:test/reporters"
]);
var nodeCoreModules = /* @__PURE__ */ new Set([
  ...unprefixedNodeCoreModulesList,
  ...unprefixedNodeCoreModulesList.map((name) => `node:${name}`),
  ...exclusivelyPrefixedNodeCoreModules
]);
function forEachDynamicImportOrRequireCall(file, includeTypeSpaceImports, requireStringLiteralLikeArgument, cb) {
  const isJavaScriptFile = isInJSFile(file);
  const r = /import|require/g;
  while (r.exec(file.text) !== null) {
    const node = getNodeAtPosition(
      file,
      r.lastIndex,
      /*includeJSDoc*/
      includeTypeSpaceImports
    );
    if (isJavaScriptFile && isRequireCall(node, requireStringLiteralLikeArgument)) {
      cb(node, node.arguments[0]);
    } else if (isImportCall(node) && node.arguments.length >= 1 && (!requireStringLiteralLikeArgument || isStringLiteralLike(node.arguments[0]))) {
      cb(node, node.arguments[0]);
    } else if (includeTypeSpaceImports && isLiteralImportTypeNode(node)) {
      cb(node, node.argument.literal);
    } else if (includeTypeSpaceImports && isJSDocImportTag(node)) {
      const moduleNameExpr = getExternalModuleName(node);
      if (moduleNameExpr && isStringLiteral(moduleNameExpr) && moduleNameExpr.text) {
        cb(node, moduleNameExpr);
      }
    }
  }
}
function getNodeAtPosition(sourceFile, position, includeJSDoc) {
  const isJavaScriptFile = isInJSFile(sourceFile);
  let current = sourceFile;
  const getContainingChild = (child) => {
    if (child.pos <= position && (position < child.end || position === child.end && child.kind === 1 /* EndOfFileToken */)) {
      return child;
    }
  };
  while (true) {
    const child = isJavaScriptFile && includeJSDoc && hasJSDocNodes(current) && forEach(current.jsDoc, getContainingChild) || forEachChild(current, getContainingChild);
    if (!child) {
      return current;
    }
    current = child;
  }
}
function isNewScopeNode(node) {
  return isFunctionLike(node) || isJSDocSignature(node) || isMappedTypeNode(node);
}

// src/compiler/factory/baseNodeFactory.ts
function createBaseNodeFactory() {
  let NodeConstructor2;
  let TokenConstructor2;
  let IdentifierConstructor2;
  let PrivateIdentifierConstructor2;
  let SourceFileConstructor2;
  return {
    createBaseSourceFileNode,
    createBaseIdentifierNode,
    createBasePrivateIdentifierNode,
    createBaseTokenNode,
    createBaseNode
  };
  function createBaseSourceFileNode(kind) {
    return new (SourceFileConstructor2 || (SourceFileConstructor2 = objectAllocator.getSourceFileConstructor()))(
      kind,
      /*pos*/
      -1,
      /*end*/
      -1
    );
  }
  function createBaseIdentifierNode(kind) {
    return new (IdentifierConstructor2 || (IdentifierConstructor2 = objectAllocator.getIdentifierConstructor()))(
      kind,
      /*pos*/
      -1,
      /*end*/
      -1
    );
  }
  function createBasePrivateIdentifierNode(kind) {
    return new (PrivateIdentifierConstructor2 || (PrivateIdentifierConstructor2 = objectAllocator.getPrivateIdentifierConstructor()))(
      kind,
      /*pos*/
      -1,
      /*end*/
      -1
    );
  }
  function createBaseTokenNode(kind) {
    return new (TokenConstructor2 || (TokenConstructor2 = objectAllocator.getTokenConstructor()))(
      kind,
      /*pos*/
      -1,
      /*end*/
      -1
    );
  }
  function createBaseNode(kind) {
    return new (NodeConstructor2 || (NodeConstructor2 = objectAllocator.getNodeConstructor()))(
      kind,
      /*pos*/
      -1,
      /*end*/
      -1
    );
  }
}

// src/compiler/factory/parenthesizerRules.ts
function createParenthesizerRules(factory2) {
  let binaryLeftOperandParenthesizerCache;
  let binaryRightOperandParenthesizerCache;
  return {
    getParenthesizeLeftSideOfBinaryForOperator,
    getParenthesizeRightSideOfBinaryForOperator,
    parenthesizeLeftSideOfBinary,
    parenthesizeRightSideOfBinary,
    parenthesizeExpressionOfComputedPropertyName,
    parenthesizeConditionOfConditionalExpression,
    parenthesizeBranchOfConditionalExpression,
    parenthesizeExpressionOfExportDefault,
    parenthesizeExpressionOfNew,
    parenthesizeLeftSideOfAccess,
    parenthesizeOperandOfPostfixUnary,
    parenthesizeOperandOfPrefixUnary,
    parenthesizeExpressionsOfCommaDelimitedList,
    parenthesizeExpressionForDisallowedComma,
    parenthesizeExpressionOfExpressionStatement,
    parenthesizeConciseBodyOfArrowFunction,
    parenthesizeCheckTypeOfConditionalType,
    parenthesizeExtendsTypeOfConditionalType,
    parenthesizeConstituentTypesOfUnionType,
    parenthesizeConstituentTypeOfUnionType,
    parenthesizeConstituentTypesOfIntersectionType,
    parenthesizeConstituentTypeOfIntersectionType,
    parenthesizeOperandOfTypeOperator,
    parenthesizeOperandOfReadonlyTypeOperator,
    parenthesizeNonArrayTypeOfPostfixType,
    parenthesizeElementTypesOfTupleType,
    parenthesizeElementTypeOfTupleType,
    parenthesizeTypeOfOptionalType,
    parenthesizeTypeArguments,
    parenthesizeLeadingTypeArgument
  };
  function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) {
    binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = /* @__PURE__ */ new Map());
    let parenthesizerRule = binaryLeftOperandParenthesizerCache.get(operatorKind);
    if (!parenthesizerRule) {
      parenthesizerRule = (node) => parenthesizeLeftSideOfBinary(operatorKind, node);
      binaryLeftOperandParenthesizerCache.set(operatorKind, parenthesizerRule);
    }
    return parenthesizerRule;
  }
  function getParenthesizeRightSideOfBinaryForOperator(operatorKind) {
    binaryRightOperandParenthesizerCache || (binaryRightOperandParenthesizerCache = /* @__PURE__ */ new Map());
    let parenthesizerRule = binaryRightOperandParenthesizerCache.get(operatorKind);
    if (!parenthesizerRule) {
      parenthesizerRule = (node) => parenthesizeRightSideOfBinary(
        operatorKind,
        /*leftSide*/
        void 0,
        node
      );
      binaryRightOperandParenthesizerCache.set(operatorKind, parenthesizerRule);
    }
    return parenthesizerRule;
  }
  function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) {
    const binaryOperatorPrecedence = getOperatorPrecedence(226 /* BinaryExpression */, binaryOperator);
    const binaryOperatorAssociativity = getOperatorAssociativity(226 /* BinaryExpression */, binaryOperator);
    const emittedOperand = skipPartiallyEmittedExpressions(operand);
    if (!isLeftSideOfBinary && operand.kind === 219 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) {
      return true;
    }
    const operandPrecedence = getExpressionPrecedence(emittedOperand);
    switch (compareValues(operandPrecedence, binaryOperatorPrecedence)) {
      case -1 /* LessThan */:
        if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ && operand.kind === 229 /* YieldExpression */) {
          return false;
        }
        return true;
      case 1 /* GreaterThan */:
        return false;
      case 0 /* EqualTo */:
        if (isLeftSideOfBinary) {
          return binaryOperatorAssociativity === 1 /* Right */;
        } else {
          if (isBinaryExpression(emittedOperand) && emittedOperand.operatorToken.kind === binaryOperator) {
            if (operatorHasAssociativeProperty(binaryOperator)) {
              return false;
            }
            if (binaryOperator === 40 /* PlusToken */) {
              const leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */;
              if (isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) {
                return false;
              }
            }
          }
          const operandAssociativity = getExpressionAssociativity(emittedOperand);
          return operandAssociativity === 0 /* Left */;
        }
    }
  }
  function operatorHasAssociativeProperty(binaryOperator) {
    return binaryOperator === 42 /* AsteriskToken */ || binaryOperator === 52 /* BarToken */ || binaryOperator === 51 /* AmpersandToken */ || binaryOperator === 53 /* CaretToken */ || binaryOperator === 28 /* CommaToken */;
  }
  function getLiteralKindOfBinaryPlusOperand(node) {
    node = skipPartiallyEmittedExpressions(node);
    if (isLiteralKind(node.kind)) {
      return node.kind;
    }
    if (node.kind === 226 /* BinaryExpression */ && node.operatorToken.kind === 40 /* PlusToken */) {
      if (node.cachedLiteralKind !== void 0) {
        return node.cachedLiteralKind;
      }
      const leftKind = getLiteralKindOfBinaryPlusOperand(node.left);
      const literalKind = isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : 0 /* Unknown */;
      node.cachedLiteralKind = literalKind;
      return literalKind;
    }
    return 0 /* Unknown */;
  }
  function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) {
    const skipped = skipPartiallyEmittedExpressions(operand);
    if (skipped.kind === 217 /* ParenthesizedExpression */) {
      return operand;
    }
    return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) ? factory2.createParenthesizedExpression(operand) : operand;
  }
  function parenthesizeLeftSideOfBinary(binaryOperator, leftSide) {
    return parenthesizeBinaryOperand(
      binaryOperator,
      leftSide,
      /*isLeftSideOfBinary*/
      true
    );
  }
  function parenthesizeRightSideOfBinary(binaryOperator, leftSide, rightSide) {
    return parenthesizeBinaryOperand(
      binaryOperator,
      rightSide,
      /*isLeftSideOfBinary*/
      false,
      leftSide
    );
  }
  function parenthesizeExpressionOfComputedPropertyName(expression) {
    return isCommaSequence(expression) ? factory2.createParenthesizedExpression(expression) : expression;
  }
  function parenthesizeConditionOfConditionalExpression(condition) {
    const conditionalPrecedence = getOperatorPrecedence(227 /* ConditionalExpression */, 58 /* QuestionToken */);
    const emittedCondition = skipPartiallyEmittedExpressions(condition);
    const conditionPrecedence = getExpressionPrecedence(emittedCondition);
    if (compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) {
      return factory2.createParenthesizedExpression(condition);
    }
    return condition;
  }
  function parenthesizeBranchOfConditionalExpression(branch) {
    const emittedExpression = skipPartiallyEmittedExpressions(branch);
    return isCommaSequence(emittedExpression) ? factory2.createParenthesizedExpression(branch) : branch;
  }
  function parenthesizeExpressionOfExportDefault(expression) {
    const check = skipPartiallyEmittedExpressions(expression);
    let needsParens = isCommaSequence(check);
    if (!needsParens) {
      switch (getLeftmostExpression(
        check,
        /*stopAtCallExpressions*/
        false
      ).kind) {
        case 231 /* ClassExpression */:
        case 218 /* FunctionExpression */:
          needsParens = true;
      }
    }
    return needsParens ? factory2.createParenthesizedExpression(expression) : expression;
  }
  function parenthesizeExpressionOfNew(expression) {
    const leftmostExpr = getLeftmostExpression(
      expression,
      /*stopAtCallExpressions*/
      true
    );
    switch (leftmostExpr.kind) {
      case 213 /* CallExpression */:
        return factory2.createParenthesizedExpression(expression);
      case 214 /* NewExpression */:
        return !leftmostExpr.arguments ? factory2.createParenthesizedExpression(expression) : expression;
    }
    return parenthesizeLeftSideOfAccess(expression);
  }
  function parenthesizeLeftSideOfAccess(expression, optionalChain) {
    const emittedExpression = skipPartiallyEmittedExpressions(expression);
    if (isLeftHandSideExpression(emittedExpression) && (emittedExpression.kind !== 214 /* NewExpression */ || emittedExpression.arguments) && (optionalChain || !isOptionalChain(emittedExpression))) {
      return expression;
    }
    return setTextRange(factory2.createParenthesizedExpression(expression), expression);
  }
  function parenthesizeOperandOfPostfixUnary(operand) {
    return isLeftHandSideExpression(operand) ? operand : setTextRange(factory2.createParenthesizedExpression(operand), operand);
  }
  function parenthesizeOperandOfPrefixUnary(operand) {
    return isUnaryExpression(operand) ? operand : setTextRange(factory2.createParenthesizedExpression(operand), operand);
  }
  function parenthesizeExpressionsOfCommaDelimitedList(elements) {
    const result = sameMap(elements, parenthesizeExpressionForDisallowedComma);
    return setTextRange(factory2.createNodeArray(result, elements.hasTrailingComma), elements);
  }
  function parenthesizeExpressionForDisallowedComma(expression) {
    const emittedExpression = skipPartiallyEmittedExpressions(expression);
    const expressionPrecedence = getExpressionPrecedence(emittedExpression);
    const commaPrecedence = getOperatorPrecedence(226 /* BinaryExpression */, 28 /* CommaToken */);
    return expressionPrecedence > commaPrecedence ? expression : setTextRange(factory2.createParenthesizedExpression(expression), expression);
  }
  function parenthesizeExpressionOfExpressionStatement(expression) {
    const emittedExpression = skipPartiallyEmittedExpressions(expression);
    if (isCallExpression(emittedExpression)) {
      const callee = emittedExpression.expression;
      const kind = skipPartiallyEmittedExpressions(callee).kind;
      if (kind === 218 /* FunctionExpression */ || kind === 219 /* ArrowFunction */) {
        const updated = factory2.updateCallExpression(
          emittedExpression,
          setTextRange(factory2.createParenthesizedExpression(callee), callee),
          emittedExpression.typeArguments,
          emittedExpression.arguments
        );
        return factory2.restoreOuterExpressions(expression, updated, 8 /* PartiallyEmittedExpressions */);
      }
    }
    const leftmostExpressionKind = getLeftmostExpression(
      emittedExpression,
      /*stopAtCallExpressions*/
      false
    ).kind;
    if (leftmostExpressionKind === 210 /* ObjectLiteralExpression */ || leftmostExpressionKind === 218 /* FunctionExpression */) {
      return setTextRange(factory2.createParenthesizedExpression(expression), expression);
    }
    return expression;
  }
  function parenthesizeConciseBodyOfArrowFunction(body) {
    if (!isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(
      body,
      /*stopAtCallExpressions*/
      false
    ).kind === 210 /* ObjectLiteralExpression */)) {
      return setTextRange(factory2.createParenthesizedExpression(body), body);
    }
    return body;
  }
  function parenthesizeCheckTypeOfConditionalType(checkType) {
    switch (checkType.kind) {
      case 184 /* FunctionType */:
      case 185 /* ConstructorType */:
      case 194 /* ConditionalType */:
        return factory2.createParenthesizedType(checkType);
    }
    return checkType;
  }
  function parenthesizeExtendsTypeOfConditionalType(extendsType) {
    switch (extendsType.kind) {
      case 194 /* ConditionalType */:
        return factory2.createParenthesizedType(extendsType);
    }
    return extendsType;
  }
  function parenthesizeConstituentTypeOfUnionType(type) {
    switch (type.kind) {
      case 192 /* UnionType */:
      // Not strictly necessary, but a union containing a union should have been flattened
      case 193 /* IntersectionType */:
        return factory2.createParenthesizedType(type);
    }
    return parenthesizeCheckTypeOfConditionalType(type);
  }
  function parenthesizeConstituentTypesOfUnionType(members) {
    return factory2.createNodeArray(sameMap(members, parenthesizeConstituentTypeOfUnionType));
  }
  function parenthesizeConstituentTypeOfIntersectionType(type) {
    switch (type.kind) {
      case 192 /* UnionType */:
      case 193 /* IntersectionType */:
        return factory2.createParenthesizedType(type);
    }
    return parenthesizeConstituentTypeOfUnionType(type);
  }
  function parenthesizeConstituentTypesOfIntersectionType(members) {
    return factory2.createNodeArray(sameMap(members, parenthesizeConstituentTypeOfIntersectionType));
  }
  function parenthesizeOperandOfTypeOperator(type) {
    switch (type.kind) {
      case 193 /* IntersectionType */:
        return factory2.createParenthesizedType(type);
    }
    return parenthesizeConstituentTypeOfIntersectionType(type);
  }
  function parenthesizeOperandOfReadonlyTypeOperator(type) {
    switch (type.kind) {
      case 198 /* TypeOperator */:
        return factory2.createParenthesizedType(type);
    }
    return parenthesizeOperandOfTypeOperator(type);
  }
  function parenthesizeNonArrayTypeOfPostfixType(type) {
    switch (type.kind) {
      case 195 /* InferType */:
      case 198 /* TypeOperator */:
      case 186 /* TypeQuery */:
        return factory2.createParenthesizedType(type);
    }
    return parenthesizeOperandOfTypeOperator(type);
  }
  function parenthesizeElementTypesOfTupleType(types) {
    return factory2.createNodeArray(sameMap(types, parenthesizeElementTypeOfTupleType));
  }
  function parenthesizeElementTypeOfTupleType(type) {
    if (hasJSDocPostfixQuestion(type)) return factory2.createParenthesizedType(type);
    return type;
  }
  function hasJSDocPostfixQuestion(type) {
    if (isJSDocNullableType(type)) return type.postfix;
    if (isNamedTupleMember(type)) return hasJSDocPostfixQuestion(type.type);
    if (isFunctionTypeNode(type) || isConstructorTypeNode(type) || isTypeOperatorNode(type)) return hasJSDocPostfixQuestion(type.type);
    if (isConditionalTypeNode(type)) return hasJSDocPostfixQuestion(type.falseType);
    if (isUnionTypeNode(type)) return hasJSDocPostfixQuestion(last(type.types));
    if (isIntersectionTypeNode(type)) return hasJSDocPostfixQuestion(last(type.types));
    if (isInferTypeNode(type)) return !!type.typeParameter.constraint && hasJSDocPostfixQuestion(type.typeParameter.constraint);
    return false;
  }
  function parenthesizeTypeOfOptionalType(type) {
    if (hasJSDocPostfixQuestion(type)) return factory2.createParenthesizedType(type);
    return parenthesizeNonArrayTypeOfPostfixType(type);
  }
  function parenthesizeLeadingTypeArgument(node) {
    return isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory2.createParenthesizedType(node) : node;
  }
  function parenthesizeOrdinalTypeArgument(node, i) {
    return i === 0 ? parenthesizeLeadingTypeArgument(node) : node;
  }
  function parenthesizeTypeArguments(typeArguments) {
    if (some(typeArguments)) {
      return factory2.createNodeArray(sameMap(typeArguments, parenthesizeOrdinalTypeArgument));
    }
  }
}
var nullParenthesizerRules = {
  getParenthesizeLeftSideOfBinaryForOperator: (_) => identity,
  getParenthesizeRightSideOfBinaryForOperator: (_) => identity,
  parenthesizeLeftSideOfBinary: (_binaryOperator, leftSide) => leftSide,
  parenthesizeRightSideOfBinary: (_binaryOperator, _leftSide, rightSide) => rightSide,
  parenthesizeExpressionOfComputedPropertyName: identity,
  parenthesizeConditionOfConditionalExpression: identity,
  parenthesizeBranchOfConditionalExpression: identity,
  parenthesizeExpressionOfExportDefault: identity,
  parenthesizeExpressionOfNew: (expression) => cast(expression, isLeftHandSideExpression),
  parenthesizeLeftSideOfAccess: (expression) => cast(expression, isLeftHandSideExpression),
  parenthesizeOperandOfPostfixUnary: (operand) => cast(operand, isLeftHandSideExpression),
  parenthesizeOperandOfPrefixUnary: (operand) => cast(operand, isUnaryExpression),
  parenthesizeExpressionsOfCommaDelimitedList: (nodes) => cast(nodes, isNodeArray),
  parenthesizeExpressionForDisallowedComma: identity,
  parenthesizeExpressionOfExpressionStatement: identity,
  parenthesizeConciseBodyOfArrowFunction: identity,
  parenthesizeCheckTypeOfConditionalType: identity,
  parenthesizeExtendsTypeOfConditionalType: identity,
  parenthesizeConstituentTypesOfUnionType: (nodes) => cast(nodes, isNodeArray),
  parenthesizeConstituentTypeOfUnionType: identity,
  parenthesizeConstituentTypesOfIntersectionType: (nodes) => cast(nodes, isNodeArray),
  parenthesizeConstituentTypeOfIntersectionType: identity,
  parenthesizeOperandOfTypeOperator: identity,
  parenthesizeOperandOfReadonlyTypeOperator: identity,
  parenthesizeNonArrayTypeOfPostfixType: identity,
  parenthesizeElementTypesOfTupleType: (nodes) => cast(nodes, isNodeArray),
  parenthesizeElementTypeOfTupleType: identity,
  parenthesizeTypeOfOptionalType: identity,
  parenthesizeTypeArguments: (nodes) => nodes && cast(nodes, isNodeArray),
  parenthesizeLeadingTypeArgument: identity
};

// src/compiler/factory/nodeConverters.ts
function createNodeConverters(factory2) {
  return {
    convertToFunctionBlock,
    convertToFunctionExpression,
    convertToClassExpression,
    convertToArrayAssignmentElement,
    convertToObjectAssignmentElement,
    convertToAssignmentPattern,
    convertToObjectAssignmentPattern,
    convertToArrayAssignmentPattern,
    convertToAssignmentElementTarget
  };
  function convertToFunctionBlock(node, multiLine) {
    if (isBlock(node)) return node;
    const returnStatement = factory2.createReturnStatement(node);
    setTextRange(returnStatement, node);
    const body = factory2.createBlock([returnStatement], multiLine);
    setTextRange(body, node);
    return body;
  }
  function convertToFunctionExpression(node) {
    var _a;
    if (!node.body) return Debug.fail(`Cannot convert a FunctionDeclaration without a body`);
    const updated = factory2.createFunctionExpression(
      (_a = getModifiers(node)) == null ? void 0 : _a.filter((modifier) => !isExportModifier(modifier) && !isDefaultModifier(modifier)),
      node.asteriskToken,
      node.name,
      node.typeParameters,
      node.parameters,
      node.type,
      node.body
    );
    setOriginalNode(updated, node);
    setTextRange(updated, node);
    if (getStartsOnNewLine(node)) {
      setStartsOnNewLine(
        updated,
        /*newLine*/
        true
      );
    }
    return updated;
  }
  function convertToClassExpression(node) {
    var _a;
    const updated = factory2.createClassExpression(
      (_a = node.modifiers) == null ? void 0 : _a.filter((modifier) => !isExportModifier(modifier) && !isDefaultModifier(modifier)),
      node.name,
      node.typeParameters,
      node.heritageClauses,
      node.members
    );
    setOriginalNode(updated, node);
    setTextRange(updated, node);
    if (getStartsOnNewLine(node)) {
      setStartsOnNewLine(
        updated,
        /*newLine*/
        true
      );
    }
    return updated;
  }
  function convertToArrayAssignmentElement(element) {
    if (isBindingElement(element)) {
      if (element.dotDotDotToken) {
        Debug.assertNode(element.name, isIdentifier);
        return setOriginalNode(setTextRange(factory2.createSpreadElement(element.name), element), element);
      }
      const expression = convertToAssignmentElementTarget(element.name);
      return element.initializer ? setOriginalNode(
        setTextRange(
          factory2.createAssignment(expression, element.initializer),
          element
        ),
        element
      ) : expression;
    }
    return cast(element, isExpression);
  }
  function convertToObjectAssignmentElement(element) {
    if (isBindingElement(element)) {
      if (element.dotDotDotToken) {
        Debug.assertNode(element.name, isIdentifier);
        return setOriginalNode(setTextRange(factory2.createSpreadAssignment(element.name), element), element);
      }
      if (element.propertyName) {
        const expression = convertToAssignmentElementTarget(element.name);
        return setOriginalNode(setTextRange(factory2.createPropertyAssignment(element.propertyName, element.initializer ? factory2.createAssignment(expression, element.initializer) : expression), element), element);
      }
      Debug.assertNode(element.name, isIdentifier);
      return setOriginalNode(setTextRange(factory2.createShorthandPropertyAssignment(element.name, element.initializer), element), element);
    }
    return cast(element, isObjectLiteralElementLike);
  }
  function convertToAssignmentPattern(node) {
    switch (node.kind) {
      case 207 /* ArrayBindingPattern */:
      case 209 /* ArrayLiteralExpression */:
        return convertToArrayAssignmentPattern(node);
      case 206 /* ObjectBindingPattern */:
      case 210 /* ObjectLiteralExpression */:
        return convertToObjectAssignmentPattern(node);
    }
  }
  function convertToObjectAssignmentPattern(node) {
    if (isObjectBindingPattern(node)) {
      return setOriginalNode(
        setTextRange(
          factory2.createObjectLiteralExpression(map(node.elements, convertToObjectAssignmentElement)),
          node
        ),
        node
      );
    }
    return cast(node, isObjectLiteralExpression);
  }
  function convertToArrayAssignmentPattern(node) {
    if (isArrayBindingPattern(node)) {
      return setOriginalNode(
        setTextRange(
          factory2.createArrayLiteralExpression(map(node.elements, convertToArrayAssignmentElement)),
          node
        ),
        node
      );
    }
    return cast(node, isArrayLiteralExpression);
  }
  function convertToAssignmentElementTarget(node) {
    if (isBindingPattern(node)) {
      return convertToAssignmentPattern(node);
    }
    return cast(node, isExpression);
  }
}
var nullNodeConverters = {
  convertToFunctionBlock: notImplemented,
  convertToFunctionExpression: notImplemented,
  convertToClassExpression: notImplemented,
  convertToArrayAssignmentElement: notImplemented,
  convertToObjectAssignmentElement: notImplemented,
  convertToAssignmentPattern: notImplemented,
  convertToObjectAssignmentPattern: notImplemented,
  convertToArrayAssignmentPattern: notImplemented,
  convertToAssignmentElementTarget: notImplemented
};

// src/compiler/factory/nodeFactory.ts
var nextAutoGenerateId = 0;
var NodeFactoryFlags = /* @__PURE__ */ ((NodeFactoryFlags2) => {
  NodeFactoryFlags2[NodeFactoryFlags2["None"] = 0] = "None";
  NodeFactoryFlags2[NodeFactoryFlags2["NoParenthesizerRules"] = 1] = "NoParenthesizerRules";
  NodeFactoryFlags2[NodeFactoryFlags2["NoNodeConverters"] = 2] = "NoNodeConverters";
  NodeFactoryFlags2[NodeFactoryFlags2["NoIndentationOnFreshPropertyAccess"] = 4] = "NoIndentationOnFreshPropertyAccess";
  NodeFactoryFlags2[NodeFactoryFlags2["NoOriginalNode"] = 8] = "NoOriginalNode";
  return NodeFactoryFlags2;
})(NodeFactoryFlags || {});
var nodeFactoryPatchers = [];
function addNodeFactoryPatcher(fn) {
  nodeFactoryPatchers.push(fn);
}
function createNodeFactory(flags, baseFactory2) {
  const setOriginal = flags & 8 /* NoOriginalNode */ ? identity : setOriginalNode;
  const parenthesizerRules = memoize(() => flags & 1 /* NoParenthesizerRules */ ? nullParenthesizerRules : createParenthesizerRules(factory2));
  const converters = memoize(() => flags & 2 /* NoNodeConverters */ ? nullNodeConverters : createNodeConverters(factory2));
  const getBinaryCreateFunction = memoizeOne((operator) => (left, right) => createBinaryExpression(left, operator, right));
  const getPrefixUnaryCreateFunction = memoizeOne((operator) => (operand) => createPrefixUnaryExpression(operator, operand));
  const getPostfixUnaryCreateFunction = memoizeOne((operator) => (operand) => createPostfixUnaryExpression(operand, operator));
  const getJSDocPrimaryTypeCreateFunction = memoizeOne((kind) => () => createJSDocPrimaryTypeWorker(kind));
  const getJSDocUnaryTypeCreateFunction = memoizeOne((kind) => (type) => createJSDocUnaryTypeWorker(kind, type));
  const getJSDocUnaryTypeUpdateFunction = memoizeOne((kind) => (node, type) => updateJSDocUnaryTypeWorker(kind, node, type));
  const getJSDocPrePostfixUnaryTypeCreateFunction = memoizeOne((kind) => (type, postfix) => createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix));
  const getJSDocPrePostfixUnaryTypeUpdateFunction = memoizeOne((kind) => (node, type) => updateJSDocPrePostfixUnaryTypeWorker(kind, node, type));
  const getJSDocSimpleTagCreateFunction = memoizeOne((kind) => (tagName, comment) => createJSDocSimpleTagWorker(kind, tagName, comment));
  const getJSDocSimpleTagUpdateFunction = memoizeOne((kind) => (node, tagName, comment) => updateJSDocSimpleTagWorker(kind, node, tagName, comment));
  const getJSDocTypeLikeTagCreateFunction = memoizeOne((kind) => (tagName, typeExpression, comment) => createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment));
  const getJSDocTypeLikeTagUpdateFunction = memoizeOne((kind) => (node, tagName, typeExpression, comment) => updateJSDocTypeLikeTagWorker(kind, node, tagName, typeExpression, comment));
  const factory2 = {
    get parenthesizer() {
      return parenthesizerRules();
    },
    get converters() {
      return converters();
    },
    baseFactory: baseFactory2,
    flags,
    createNodeArray,
    createNumericLiteral,
    createBigIntLiteral,
    createStringLiteral,
    createStringLiteralFromNode,
    createRegularExpressionLiteral,
    createLiteralLikeNode,
    createIdentifier,
    createTempVariable,
    createLoopVariable,
    createUniqueName,
    getGeneratedNameForNode,
    createPrivateIdentifier,
    createUniquePrivateName,
    getGeneratedPrivateNameForNode,
    createToken,
    createSuper,
    createThis,
    createNull,
    createTrue,
    createFalse,
    createModifier,
    createModifiersFromModifierFlags,
    createQualifiedName,
    updateQualifiedName,
    createComputedPropertyName,
    updateComputedPropertyName,
    createTypeParameterDeclaration,
    updateTypeParameterDeclaration,
    createParameterDeclaration,
    updateParameterDeclaration,
    createDecorator,
    updateDecorator,
    createPropertySignature,
    updatePropertySignature,
    createPropertyDeclaration,
    updatePropertyDeclaration: updatePropertyDeclaration2,
    createMethodSignature,
    updateMethodSignature,
    createMethodDeclaration,
    updateMethodDeclaration,
    createConstructorDeclaration,
    updateConstructorDeclaration,
    createGetAccessorDeclaration,
    updateGetAccessorDeclaration,
    createSetAccessorDeclaration,
    updateSetAccessorDeclaration,
    createCallSignature,
    updateCallSignature,
    createConstructSignature,
    updateConstructSignature,
    createIndexSignature,
    updateIndexSignature,
    createClassStaticBlockDeclaration,
    updateClassStaticBlockDeclaration,
    createTemplateLiteralTypeSpan,
    updateTemplateLiteralTypeSpan,
    createKeywordTypeNode,
    createTypePredicateNode,
    updateTypePredicateNode,
    createTypeReferenceNode,
    updateTypeReferenceNode,
    createFunctionTypeNode,
    updateFunctionTypeNode,
    createConstructorTypeNode,
    updateConstructorTypeNode,
    createTypeQueryNode,
    updateTypeQueryNode,
    createTypeLiteralNode,
    updateTypeLiteralNode,
    createArrayTypeNode,
    updateArrayTypeNode,
    createTupleTypeNode,
    updateTupleTypeNode,
    createNamedTupleMember,
    updateNamedTupleMember,
    createOptionalTypeNode,
    updateOptionalTypeNode,
    createRestTypeNode,
    updateRestTypeNode,
    createUnionTypeNode,
    updateUnionTypeNode,
    createIntersectionTypeNode,
    updateIntersectionTypeNode,
    createConditionalTypeNode,
    updateConditionalTypeNode,
    createInferTypeNode,
    updateInferTypeNode,
    createImportTypeNode,
    updateImportTypeNode,
    createParenthesizedType,
    updateParenthesizedType,
    createThisTypeNode,
    createTypeOperatorNode,
    updateTypeOperatorNode,
    createIndexedAccessTypeNode,
    updateIndexedAccessTypeNode,
    createMappedTypeNode,
    updateMappedTypeNode,
    createLiteralTypeNode,
    updateLiteralTypeNode,
    createTemplateLiteralType,
    updateTemplateLiteralType,
    createObjectBindingPattern,
    updateObjectBindingPattern,
    createArrayBindingPattern,
    updateArrayBindingPattern,
    createBindingElement,
    updateBindingElement,
    createArrayLiteralExpression,
    updateArrayLiteralExpression,
    createObjectLiteralExpression,
    updateObjectLiteralExpression,
    createPropertyAccessExpression: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? (expression, name) => setEmitFlags(createPropertyAccessExpression(expression, name), 262144 /* NoIndentation */) : createPropertyAccessExpression,
    updatePropertyAccessExpression,
    createPropertyAccessChain: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? (expression, questionDotToken, name) => setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 262144 /* NoIndentation */) : createPropertyAccessChain,
    updatePropertyAccessChain,
    createElementAccessExpression,
    updateElementAccessExpression,
    createElementAccessChain,
    updateElementAccessChain,
    createCallExpression,
    updateCallExpression,
    createCallChain,
    updateCallChain,
    createNewExpression,
    updateNewExpression,
    createTaggedTemplateExpression,
    updateTaggedTemplateExpression,
    createTypeAssertion,
    updateTypeAssertion,
    createParenthesizedExpression,
    updateParenthesizedExpression,
    createFunctionExpression,
    updateFunctionExpression,
    createArrowFunction,
    updateArrowFunction,
    createDeleteExpression,
    updateDeleteExpression,
    createTypeOfExpression,
    updateTypeOfExpression,
    createVoidExpression,
    updateVoidExpression,
    createAwaitExpression,
    updateAwaitExpression,
    createPrefixUnaryExpression,
    updatePrefixUnaryExpression,
    createPostfixUnaryExpression,
    updatePostfixUnaryExpression,
    createBinaryExpression,
    updateBinaryExpression,
    createConditionalExpression,
    updateConditionalExpression,
    createTemplateExpression,
    updateTemplateExpression,
    createTemplateHead,
    createTemplateMiddle,
    createTemplateTail,
    createNoSubstitutionTemplateLiteral,
    createTemplateLiteralLikeNode,
    createYieldExpression,
    updateYieldExpression,
    createSpreadElement,
    updateSpreadElement,
    createClassExpression,
    updateClassExpression,
    createOmittedExpression,
    createExpressionWithTypeArguments,
    updateExpressionWithTypeArguments,
    createAsExpression,
    updateAsExpression,
    createNonNullExpression,
    updateNonNullExpression,
    createSatisfiesExpression,
    updateSatisfiesExpression,
    createNonNullChain,
    updateNonNullChain,
    createMetaProperty,
    updateMetaProperty,
    createTemplateSpan,
    updateTemplateSpan,
    createSemicolonClassElement,
    createBlock,
    updateBlock,
    createVariableStatement,
    updateVariableStatement,
    createEmptyStatement,
    createExpressionStatement,
    updateExpressionStatement,
    createIfStatement,
    updateIfStatement,
    createDoStatement,
    updateDoStatement,
    createWhileStatement,
    updateWhileStatement,
    createForStatement,
    updateForStatement,
    createForInStatement,
    updateForInStatement,
    createForOfStatement,
    updateForOfStatement,
    createContinueStatement,
    updateContinueStatement,
    createBreakStatement,
    updateBreakStatement,
    createReturnStatement,
    updateReturnStatement,
    createWithStatement,
    updateWithStatement,
    createSwitchStatement,
    updateSwitchStatement,
    createLabeledStatement,
    updateLabeledStatement,
    createThrowStatement,
    updateThrowStatement,
    createTryStatement,
    updateTryStatement,
    createDebuggerStatement,
    createVariableDeclaration,
    updateVariableDeclaration,
    createVariableDeclarationList,
    updateVariableDeclarationList,
    createFunctionDeclaration,
    updateFunctionDeclaration,
    createClassDeclaration,
    updateClassDeclaration,
    createInterfaceDeclaration,
    updateInterfaceDeclaration,
    createTypeAliasDeclaration,
    updateTypeAliasDeclaration,
    createEnumDeclaration,
    updateEnumDeclaration,
    createModuleDeclaration,
    updateModuleDeclaration,
    createModuleBlock,
    updateModuleBlock,
    createCaseBlock,
    updateCaseBlock,
    createNamespaceExportDeclaration,
    updateNamespaceExportDeclaration,
    createImportEqualsDeclaration,
    updateImportEqualsDeclaration,
    createImportDeclaration,
    updateImportDeclaration,
    createImportClause: createImportClause2,
    updateImportClause,
    createAssertClause,
    updateAssertClause,
    createAssertEntry,
    updateAssertEntry,
    createImportTypeAssertionContainer,
    updateImportTypeAssertionContainer,
    createImportAttributes,
    updateImportAttributes,
    createImportAttribute,
    updateImportAttribute,
    createNamespaceImport,
    updateNamespaceImport,
    createNamespaceExport,
    updateNamespaceExport,
    createNamedImports,
    updateNamedImports,
    createImportSpecifier,
    updateImportSpecifier,
    createExportAssignment: createExportAssignment2,
    updateExportAssignment,
    createExportDeclaration,
    updateExportDeclaration,
    createNamedExports,
    updateNamedExports,
    createExportSpecifier,
    updateExportSpecifier,
    createMissingDeclaration,
    createExternalModuleReference,
    updateExternalModuleReference,
    // lazily load factory members for JSDoc types with similar structure
    get createJSDocAllType() {
      return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */);
    },
    get createJSDocUnknownType() {
      return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */);
    },
    get createJSDocNonNullableType() {
      return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */);
    },
    get updateJSDocNonNullableType() {
      return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */);
    },
    get createJSDocNullableType() {
      return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */);
    },
    get updateJSDocNullableType() {
      return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */);
    },
    get createJSDocOptionalType() {
      return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */);
    },
    get updateJSDocOptionalType() {
      return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */);
    },
    get createJSDocVariadicType() {
      return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */);
    },
    get updateJSDocVariadicType() {
      return getJSDocUnaryTypeUpdateFunction(318 /* JSDocVariadicType */);
    },
    get createJSDocNamepathType() {
      return getJSDocUnaryTypeCreateFunction(319 /* JSDocNamepathType */);
    },
    get updateJSDocNamepathType() {
      return getJSDocUnaryTypeUpdateFunction(319 /* JSDocNamepathType */);
    },
    createJSDocFunctionType,
    updateJSDocFunctionType,
    createJSDocTypeLiteral,
    updateJSDocTypeLiteral,
    createJSDocTypeExpression,
    updateJSDocTypeExpression,
    createJSDocSignature,
    updateJSDocSignature,
    createJSDocTemplateTag,
    updateJSDocTemplateTag,
    createJSDocTypedefTag,
    updateJSDocTypedefTag,
    createJSDocParameterTag,
    updateJSDocParameterTag,
    createJSDocPropertyTag,
    updateJSDocPropertyTag,
    createJSDocCallbackTag,
    updateJSDocCallbackTag,
    createJSDocOverloadTag,
    updateJSDocOverloadTag,
    createJSDocAugmentsTag,
    updateJSDocAugmentsTag,
    createJSDocImplementsTag,
    updateJSDocImplementsTag,
    createJSDocSeeTag,
    updateJSDocSeeTag,
    createJSDocImportTag,
    updateJSDocImportTag,
    createJSDocNameReference,
    updateJSDocNameReference,
    createJSDocMemberName,
    updateJSDocMemberName,
    createJSDocLink,
    updateJSDocLink,
    createJSDocLinkCode,
    updateJSDocLinkCode,
    createJSDocLinkPlain,
    updateJSDocLinkPlain,
    // lazily load factory members for JSDoc tags with similar structure
    get createJSDocTypeTag() {
      return getJSDocTypeLikeTagCreateFunction(344 /* JSDocTypeTag */);
    },
    get updateJSDocTypeTag() {
      return getJSDocTypeLikeTagUpdateFunction(344 /* JSDocTypeTag */);
    },
    get createJSDocReturnTag() {
      return getJSDocTypeLikeTagCreateFunction(342 /* JSDocReturnTag */);
    },
    get updateJSDocReturnTag() {
      return getJSDocTypeLikeTagUpdateFunction(342 /* JSDocReturnTag */);
    },
    get createJSDocThisTag() {
      return getJSDocTypeLikeTagCreateFunction(343 /* JSDocThisTag */);
    },
    get updateJSDocThisTag() {
      return getJSDocTypeLikeTagUpdateFunction(343 /* JSDocThisTag */);
    },
    get createJSDocAuthorTag() {
      return getJSDocSimpleTagCreateFunction(330 /* JSDocAuthorTag */);
    },
    get updateJSDocAuthorTag() {
      return getJSDocSimpleTagUpdateFunction(330 /* JSDocAuthorTag */);
    },
    get createJSDocClassTag() {
      return getJSDocSimpleTagCreateFunction(332 /* JSDocClassTag */);
    },
    get updateJSDocClassTag() {
      return getJSDocSimpleTagUpdateFunction(332 /* JSDocClassTag */);
    },
    get createJSDocPublicTag() {
      return getJSDocSimpleTagCreateFunction(333 /* JSDocPublicTag */);
    },
    get updateJSDocPublicTag() {
      return getJSDocSimpleTagUpdateFunction(333 /* JSDocPublicTag */);
    },
    get createJSDocPrivateTag() {
      return getJSDocSimpleTagCreateFunction(334 /* JSDocPrivateTag */);
    },
    get updateJSDocPrivateTag() {
      return getJSDocSimpleTagUpdateFunction(334 /* JSDocPrivateTag */);
    },
    get createJSDocProtectedTag() {
      return getJSDocSimpleTagCreateFunction(335 /* JSDocProtectedTag */);
    },
    get updateJSDocProtectedTag() {
      return getJSDocSimpleTagUpdateFunction(335 /* JSDocProtectedTag */);
    },
    get createJSDocReadonlyTag() {
      return getJSDocSimpleTagCreateFunction(336 /* JSDocReadonlyTag */);
    },
    get updateJSDocReadonlyTag() {
      return getJSDocSimpleTagUpdateFunction(336 /* JSDocReadonlyTag */);
    },
    get createJSDocOverrideTag() {
      return getJSDocSimpleTagCreateFunction(337 /* JSDocOverrideTag */);
    },
    get updateJSDocOverrideTag() {
      return getJSDocSimpleTagUpdateFunction(337 /* JSDocOverrideTag */);
    },
    get createJSDocDeprecatedTag() {
      return getJSDocSimpleTagCreateFunction(331 /* JSDocDeprecatedTag */);
    },
    get updateJSDocDeprecatedTag() {
      return getJSDocSimpleTagUpdateFunction(331 /* JSDocDeprecatedTag */);
    },
    get createJSDocThrowsTag() {
      return getJSDocTypeLikeTagCreateFunction(349 /* JSDocThrowsTag */);
    },
    get updateJSDocThrowsTag() {
      return getJSDocTypeLikeTagUpdateFunction(349 /* JSDocThrowsTag */);
    },
    get createJSDocSatisfiesTag() {
      return getJSDocTypeLikeTagCreateFunction(350 /* JSDocSatisfiesTag */);
    },
    get updateJSDocSatisfiesTag() {
      return getJSDocTypeLikeTagUpdateFunction(350 /* JSDocSatisfiesTag */);
    },
    createJSDocEnumTag,
    updateJSDocEnumTag,
    createJSDocUnknownTag,
    updateJSDocUnknownTag,
    createJSDocText,
    updateJSDocText,
    createJSDocComment,
    updateJSDocComment,
    createJsxElement,
    updateJsxElement,
    createJsxSelfClosingElement,
    updateJsxSelfClosingElement,
    createJsxOpeningElement,
    updateJsxOpeningElement,
    createJsxClosingElement,
    updateJsxClosingElement,
    createJsxFragment,
    createJsxText,
    updateJsxText,
    createJsxOpeningFragment,
    createJsxJsxClosingFragment,
    updateJsxFragment,
    createJsxAttribute,
    updateJsxAttribute,
    createJsxAttributes,
    updateJsxAttributes,
    createJsxSpreadAttribute,
    updateJsxSpreadAttribute,
    createJsxExpression,
    updateJsxExpression,
    createJsxNamespacedName,
    updateJsxNamespacedName,
    createCaseClause,
    updateCaseClause,
    createDefaultClause,
    updateDefaultClause,
    createHeritageClause,
    updateHeritageClause,
    createCatchClause,
    updateCatchClause,
    createPropertyAssignment,
    updatePropertyAssignment,
    createShorthandPropertyAssignment,
    updateShorthandPropertyAssignment,
    createSpreadAssignment,
    updateSpreadAssignment,
    createEnumMember,
    updateEnumMember,
    createSourceFile: createSourceFile2,
    updateSourceFile: updateSourceFile2,
    createRedirectedSourceFile,
    createBundle,
    updateBundle,
    createSyntheticExpression,
    createSyntaxList: createSyntaxList3,
    createNotEmittedStatement,
    createNotEmittedTypeElement,
    createPartiallyEmittedExpression,
    updatePartiallyEmittedExpression,
    createCommaListExpression,
    updateCommaListExpression,
    createSyntheticReferenceExpression,
    updateSyntheticReferenceExpression,
    cloneNode,
    // Lazily load factory methods for common operator factories and utilities
    get createComma() {
      return getBinaryCreateFunction(28 /* CommaToken */);
    },
    get createAssignment() {
      return getBinaryCreateFunction(64 /* EqualsToken */);
    },
    get createLogicalOr() {
      return getBinaryCreateFunction(57 /* BarBarToken */);
    },
    get createLogicalAnd() {
      return getBinaryCreateFunction(56 /* AmpersandAmpersandToken */);
    },
    get createBitwiseOr() {
      return getBinaryCreateFunction(52 /* BarToken */);
    },
    get createBitwiseXor() {
      return getBinaryCreateFunction(53 /* CaretToken */);
    },
    get createBitwiseAnd() {
      return getBinaryCreateFunction(51 /* AmpersandToken */);
    },
    get createStrictEquality() {
      return getBinaryCreateFunction(37 /* EqualsEqualsEqualsToken */);
    },
    get createStrictInequality() {
      return getBinaryCreateFunction(38 /* ExclamationEqualsEqualsToken */);
    },
    get createEquality() {
      return getBinaryCreateFunction(35 /* EqualsEqualsToken */);
    },
    get createInequality() {
      return getBinaryCreateFunction(36 /* ExclamationEqualsToken */);
    },
    get createLessThan() {
      return getBinaryCreateFunction(30 /* LessThanToken */);
    },
    get createLessThanEquals() {
      return getBinaryCreateFunction(33 /* LessThanEqualsToken */);
    },
    get createGreaterThan() {
      return getBinaryCreateFunction(32 /* GreaterThanToken */);
    },
    get createGreaterThanEquals() {
      return getBinaryCreateFunction(34 /* GreaterThanEqualsToken */);
    },
    get createLeftShift() {
      return getBinaryCreateFunction(48 /* LessThanLessThanToken */);
    },
    get createRightShift() {
      return getBinaryCreateFunction(49 /* GreaterThanGreaterThanToken */);
    },
    get createUnsignedRightShift() {
      return getBinaryCreateFunction(50 /* GreaterThanGreaterThanGreaterThanToken */);
    },
    get createAdd() {
      return getBinaryCreateFunction(40 /* PlusToken */);
    },
    get createSubtract() {
      return getBinaryCreateFunction(41 /* MinusToken */);
    },
    get createMultiply() {
      return getBinaryCreateFunction(42 /* AsteriskToken */);
    },
    get createDivide() {
      return getBinaryCreateFunction(44 /* SlashToken */);
    },
    get createModulo() {
      return getBinaryCreateFunction(45 /* PercentToken */);
    },
    get createExponent() {
      return getBinaryCreateFunction(43 /* AsteriskAsteriskToken */);
    },
    get createPrefixPlus() {
      return getPrefixUnaryCreateFunction(40 /* PlusToken */);
    },
    get createPrefixMinus() {
      return getPrefixUnaryCreateFunction(41 /* MinusToken */);
    },
    get createPrefixIncrement() {
      return getPrefixUnaryCreateFunction(46 /* PlusPlusToken */);
    },
    get createPrefixDecrement() {
      return getPrefixUnaryCreateFunction(47 /* MinusMinusToken */);
    },
    get createBitwiseNot() {
      return getPrefixUnaryCreateFunction(55 /* TildeToken */);
    },
    get createLogicalNot() {
      return getPrefixUnaryCreateFunction(54 /* ExclamationToken */);
    },
    get createPostfixIncrement() {
      return getPostfixUnaryCreateFunction(46 /* PlusPlusToken */);
    },
    get createPostfixDecrement() {
      return getPostfixUnaryCreateFunction(47 /* MinusMinusToken */);
    },
    // Compound nodes
    createImmediatelyInvokedFunctionExpression,
    createImmediatelyInvokedArrowFunction,
    createVoidZero,
    createExportDefault,
    createExternalModuleExport,
    createTypeCheck,
    createIsNotTypeCheck,
    createMethodCall,
    createGlobalMethodCall,
    createFunctionBindCall,
    createFunctionCallCall,
    createFunctionApplyCall,
    createArraySliceCall,
    createArrayConcatCall,
    createObjectDefinePropertyCall,
    createObjectGetOwnPropertyDescriptorCall,
    createReflectGetCall,
    createReflectSetCall,
    createPropertyDescriptor,
    createCallBinding,
    createAssignmentTargetWrapper,
    // Utilities
    inlineExpressions,
    getInternalName,
    getLocalName,
    getExportName,
    getDeclarationName,
    getNamespaceMemberName,
    getExternalModuleOrNamespaceExportName,
    restoreOuterExpressions,
    restoreEnclosingLabel,
    createUseStrictPrologue,
    copyPrologue,
    copyStandardPrologue,
    copyCustomPrologue,
    ensureUseStrict,
    liftToBlock,
    mergeLexicalEnvironment,
    replaceModifiers,
    replaceDecoratorsAndModifiers,
    replacePropertyName
  };
  forEach(nodeFactoryPatchers, (fn) => fn(factory2));
  return factory2;
  function createNodeArray(elements, hasTrailingComma) {
    if (elements === void 0 || elements === emptyArray) {
      elements = [];
    } else if (isNodeArray(elements)) {
      if (hasTrailingComma === void 0 || elements.hasTrailingComma === hasTrailingComma) {
        if (elements.transformFlags === void 0) {
          aggregateChildrenFlags(elements);
        }
        Debug.attachNodeArrayDebugInfo(elements);
        return elements;
      }
      const array2 = elements.slice();
      array2.pos = elements.pos;
      array2.end = elements.end;
      array2.hasTrailingComma = hasTrailingComma;
      array2.transformFlags = elements.transformFlags;
      Debug.attachNodeArrayDebugInfo(array2);
      return array2;
    }
    const length2 = elements.length;
    const array = length2 >= 1 && length2 <= 4 ? elements.slice() : elements;
    array.pos = -1;
    array.end = -1;
    array.hasTrailingComma = !!hasTrailingComma;
    array.transformFlags = 0 /* None */;
    aggregateChildrenFlags(array);
    Debug.attachNodeArrayDebugInfo(array);
    return array;
  }
  function createBaseNode(kind) {
    return baseFactory2.createBaseNode(kind);
  }
  function createBaseDeclaration(kind) {
    const node = createBaseNode(kind);
    node.symbol = void 0;
    node.localSymbol = void 0;
    return node;
  }
  function finishUpdateBaseSignatureDeclaration(updated, original) {
    if (updated !== original) {
      updated.typeArguments = original.typeArguments;
    }
    return update(updated, original);
  }
  function createNumericLiteral(value, numericLiteralFlags = 0 /* None */) {
    const text = typeof value === "number" ? value + "" : value;
    Debug.assert(text.charCodeAt(0) !== 45 /* minus */, "Negative numbers should be created in combination with createPrefixUnaryExpression");
    const node = createBaseDeclaration(9 /* NumericLiteral */);
    node.text = text;
    node.numericLiteralFlags = numericLiteralFlags;
    if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) node.transformFlags |= 1024 /* ContainsES2015 */;
    return node;
  }
  function createBigIntLiteral(value) {
    const node = createBaseToken(10 /* BigIntLiteral */);
    node.text = typeof value === "string" ? value : pseudoBigIntToString(value) + "n";
    node.transformFlags |= 32 /* ContainsES2020 */;
    return node;
  }
  function createBaseStringLiteral(text, isSingleQuote) {
    const node = createBaseDeclaration(11 /* StringLiteral */);
    node.text = text;
    node.singleQuote = isSingleQuote;
    return node;
  }
  function createStringLiteral(text, isSingleQuote, hasExtendedUnicodeEscape) {
    const node = createBaseStringLiteral(text, isSingleQuote);
    node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
    if (hasExtendedUnicodeEscape) node.transformFlags |= 1024 /* ContainsES2015 */;
    return node;
  }
  function createStringLiteralFromNode(sourceNode) {
    const node = createBaseStringLiteral(
      getTextOfIdentifierOrLiteral(sourceNode),
      /*isSingleQuote*/
      void 0
    );
    node.textSourceNode = sourceNode;
    return node;
  }
  function createRegularExpressionLiteral(text) {
    const node = createBaseToken(14 /* RegularExpressionLiteral */);
    node.text = text;
    return node;
  }
  function createLiteralLikeNode(kind, text) {
    switch (kind) {
      case 9 /* NumericLiteral */:
        return createNumericLiteral(
          text,
          /*numericLiteralFlags*/
          0
        );
      case 10 /* BigIntLiteral */:
        return createBigIntLiteral(text);
      case 11 /* StringLiteral */:
        return createStringLiteral(
          text,
          /*isSingleQuote*/
          void 0
        );
      case 12 /* JsxText */:
        return createJsxText(
          text,
          /*containsOnlyTriviaWhiteSpaces*/
          false
        );
      case 13 /* JsxTextAllWhiteSpaces */:
        return createJsxText(
          text,
          /*containsOnlyTriviaWhiteSpaces*/
          true
        );
      case 14 /* RegularExpressionLiteral */:
        return createRegularExpressionLiteral(text);
      case 15 /* NoSubstitutionTemplateLiteral */:
        return createTemplateLiteralLikeNode(
          kind,
          text,
          /*rawText*/
          void 0,
          /*templateFlags*/
          0
        );
    }
  }
  function createBaseIdentifier(escapedText) {
    const node = baseFactory2.createBaseIdentifierNode(80 /* Identifier */);
    node.escapedText = escapedText;
    node.jsDoc = void 0;
    node.flowNode = void 0;
    node.symbol = void 0;
    return node;
  }
  function createBaseGeneratedIdentifier(text, autoGenerateFlags, prefix, suffix) {
    const node = createBaseIdentifier(escapeLeadingUnderscores(text));
    setIdentifierAutoGenerate(node, {
      flags: autoGenerateFlags,
      id: nextAutoGenerateId,
      prefix,
      suffix
    });
    nextAutoGenerateId++;
    return node;
  }
  function createIdentifier(text, originalKeywordKind, hasExtendedUnicodeEscape) {
    if (originalKeywordKind === void 0 && text) {
      originalKeywordKind = stringToToken(text);
    }
    if (originalKeywordKind === 80 /* Identifier */) {
      originalKeywordKind = void 0;
    }
    const node = createBaseIdentifier(escapeLeadingUnderscores(text));
    if (hasExtendedUnicodeEscape) node.flags |= 256 /* IdentifierHasExtendedUnicodeEscape */;
    if (node.escapedText === "await") {
      node.transformFlags |= 67108864 /* ContainsPossibleTopLevelAwait */;
    }
    if (node.flags & 256 /* IdentifierHasExtendedUnicodeEscape */) {
      node.transformFlags |= 1024 /* ContainsES2015 */;
    }
    return node;
  }
  function createTempVariable(recordTempVariable, reservedInNestedScopes, prefix, suffix) {
    let flags2 = 1 /* Auto */;
    if (reservedInNestedScopes) flags2 |= 8 /* ReservedInNestedScopes */;
    const name = createBaseGeneratedIdentifier("", flags2, prefix, suffix);
    if (recordTempVariable) {
      recordTempVariable(name);
    }
    return name;
  }
  function createLoopVariable(reservedInNestedScopes) {
    let flags2 = 2 /* Loop */;
    if (reservedInNestedScopes) flags2 |= 8 /* ReservedInNestedScopes */;
    return createBaseGeneratedIdentifier(
      "",
      flags2,
      /*prefix*/
      void 0,
      /*suffix*/
      void 0
    );
  }
  function createUniqueName(text, flags2 = 0 /* None */, prefix, suffix) {
    Debug.assert(!(flags2 & 7 /* KindMask */), "Argument out of range: flags");
    Debug.assert((flags2 & (16 /* Optimistic */ | 32 /* FileLevel */)) !== 32 /* FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic");
    return createBaseGeneratedIdentifier(text, 3 /* Unique */ | flags2, prefix, suffix);
  }
  function getGeneratedNameForNode(node, flags2 = 0, prefix, suffix) {
    Debug.assert(!(flags2 & 7 /* KindMask */), "Argument out of range: flags");
    const text = !node ? "" : isMemberName(node) ? formatGeneratedName(
      /*privateName*/
      false,
      prefix,
      node,
      suffix,
      idText
    ) : `generated@${getNodeId(node)}`;
    if (prefix || suffix) flags2 |= 16 /* Optimistic */;
    const name = createBaseGeneratedIdentifier(text, 4 /* Node */ | flags2, prefix, suffix);
    name.original = node;
    return name;
  }
  function createBasePrivateIdentifier(escapedText) {
    const node = baseFactory2.createBasePrivateIdentifierNode(81 /* PrivateIdentifier */);
    node.escapedText = escapedText;
    node.transformFlags |= 16777216 /* ContainsClassFields */;
    return node;
  }
  function createPrivateIdentifier(text) {
    if (!startsWith(text, "#")) Debug.fail("First character of private identifier must be #: " + text);
    return createBasePrivateIdentifier(escapeLeadingUnderscores(text));
  }
  function createBaseGeneratedPrivateIdentifier(text, autoGenerateFlags, prefix, suffix) {
    const node = createBasePrivateIdentifier(escapeLeadingUnderscores(text));
    setIdentifierAutoGenerate(node, {
      flags: autoGenerateFlags,
      id: nextAutoGenerateId,
      prefix,
      suffix
    });
    nextAutoGenerateId++;
    return node;
  }
  function createUniquePrivateName(text, prefix, suffix) {
    if (text && !startsWith(text, "#")) Debug.fail("First character of private identifier must be #: " + text);
    const autoGenerateFlags = 8 /* ReservedInNestedScopes */ | (text ? 3 /* Unique */ : 1 /* Auto */);
    return createBaseGeneratedPrivateIdentifier(text ?? "", autoGenerateFlags, prefix, suffix);
  }
  function getGeneratedPrivateNameForNode(node, prefix, suffix) {
    const text = isMemberName(node) ? formatGeneratedName(
      /*privateName*/
      true,
      prefix,
      node,
      suffix,
      idText
    ) : `#generated@${getNodeId(node)}`;
    const flags2 = prefix || suffix ? 16 /* Optimistic */ : 0 /* None */;
    const name = createBaseGeneratedPrivateIdentifier(text, 4 /* Node */ | flags2, prefix, suffix);
    name.original = node;
    return name;
  }
  function createBaseToken(kind) {
    return baseFactory2.createBaseTokenNode(kind);
  }
  function createToken(token) {
    Debug.assert(token >= 0 /* FirstToken */ && token <= 165 /* LastToken */, "Invalid token");
    Debug.assert(token <= 15 /* FirstTemplateToken */ || token >= 18 /* LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals.");
    Debug.assert(token <= 9 /* FirstLiteralToken */ || token >= 15 /* LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals.");
    Debug.assert(token !== 80 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers");
    const node = createBaseToken(token);
    let transformFlags = 0 /* None */;
    switch (token) {
      case 134 /* AsyncKeyword */:
        transformFlags = 256 /* ContainsES2017 */ | 128 /* ContainsES2018 */;
        break;
      case 160 /* UsingKeyword */:
        transformFlags = 4 /* ContainsESNext */;
        break;
      case 125 /* PublicKeyword */:
      case 123 /* PrivateKeyword */:
      case 124 /* ProtectedKeyword */:
      case 148 /* ReadonlyKeyword */:
      case 128 /* AbstractKeyword */:
      case 138 /* DeclareKeyword */:
      case 87 /* ConstKeyword */:
      case 133 /* AnyKeyword */:
      case 150 /* NumberKeyword */:
      case 163 /* BigIntKeyword */:
      case 146 /* NeverKeyword */:
      case 151 /* ObjectKeyword */:
      case 103 /* InKeyword */:
      case 147 /* OutKeyword */:
      case 164 /* OverrideKeyword */:
      case 154 /* StringKeyword */:
      case 136 /* BooleanKeyword */:
      case 155 /* SymbolKeyword */:
      case 116 /* VoidKeyword */:
      case 159 /* UnknownKeyword */:
      case 157 /* UndefinedKeyword */:
        transformFlags = 1 /* ContainsTypeScript */;
        break;
      case 108 /* SuperKeyword */:
        transformFlags = 1024 /* ContainsES2015 */ | 134217728 /* ContainsLexicalSuper */;
        node.flowNode = void 0;
        break;
      case 126 /* StaticKeyword */:
        transformFlags = 1024 /* ContainsES2015 */;
        break;
      case 129 /* AccessorKeyword */:
        transformFlags = 16777216 /* ContainsClassFields */;
        break;
      case 110 /* ThisKeyword */:
        transformFlags = 16384 /* ContainsLexicalThis */;
        node.flowNode = void 0;
        break;
    }
    if (transformFlags) {
      node.transformFlags |= transformFlags;
    }
    return node;
  }
  function createSuper() {
    return createToken(108 /* SuperKeyword */);
  }
  function createThis() {
    return createToken(110 /* ThisKeyword */);
  }
  function createNull() {
    return createToken(106 /* NullKeyword */);
  }
  function createTrue() {
    return createToken(112 /* TrueKeyword */);
  }
  function createFalse() {
    return createToken(97 /* FalseKeyword */);
  }
  function createModifier(kind) {
    return createToken(kind);
  }
  function createModifiersFromModifierFlags(flags2) {
    const result = [];
    if (flags2 & 32 /* Export */) result.push(createModifier(95 /* ExportKeyword */));
    if (flags2 & 128 /* Ambient */) result.push(createModifier(138 /* DeclareKeyword */));
    if (flags2 & 2048 /* Default */) result.push(createModifier(90 /* DefaultKeyword */));
    if (flags2 & 4096 /* Const */) result.push(createModifier(87 /* ConstKeyword */));
    if (flags2 & 1 /* Public */) result.push(createModifier(125 /* PublicKeyword */));
    if (flags2 & 2 /* Private */) result.push(createModifier(123 /* PrivateKeyword */));
    if (flags2 & 4 /* Protected */) result.push(createModifier(124 /* ProtectedKeyword */));
    if (flags2 & 64 /* Abstract */) result.push(createModifier(128 /* AbstractKeyword */));
    if (flags2 & 256 /* Static */) result.push(createModifier(126 /* StaticKeyword */));
    if (flags2 & 16 /* Override */) result.push(createModifier(164 /* OverrideKeyword */));
    if (flags2 & 8 /* Readonly */) result.push(createModifier(148 /* ReadonlyKeyword */));
    if (flags2 & 512 /* Accessor */) result.push(createModifier(129 /* AccessorKeyword */));
    if (flags2 & 1024 /* Async */) result.push(createModifier(134 /* AsyncKeyword */));
    if (flags2 & 8192 /* In */) result.push(createModifier(103 /* InKeyword */));
    if (flags2 & 16384 /* Out */) result.push(createModifier(147 /* OutKeyword */));
    return result.length ? result : void 0;
  }
  function createQualifiedName(left, right) {
    const node = createBaseNode(166 /* QualifiedName */);
    node.left = left;
    node.right = asName(right);
    node.transformFlags |= propagateChildFlags(node.left) | propagateIdentifierNameFlags(node.right);
    node.flowNode = void 0;
    return node;
  }
  function updateQualifiedName(node, left, right) {
    return node.left !== left || node.right !== right ? update(createQualifiedName(left, right), node) : node;
  }
  function createComputedPropertyName(expression) {
    const node = createBaseNode(167 /* ComputedPropertyName */);
    node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression);
    node.transformFlags |= propagateChildFlags(node.expression) | 1024 /* ContainsES2015 */ | 131072 /* ContainsComputedPropertyName */;
    return node;
  }
  function updateComputedPropertyName(node, expression) {
    return node.expression !== expression ? update(createComputedPropertyName(expression), node) : node;
  }
  function createTypeParameterDeclaration(modifiers, name, constraint, defaultType) {
    const node = createBaseDeclaration(168 /* TypeParameter */);
    node.modifiers = asNodeArray(modifiers);
    node.name = asName(name);
    node.constraint = constraint;
    node.default = defaultType;
    node.transformFlags = 1 /* ContainsTypeScript */;
    node.expression = void 0;
    node.jsDoc = void 0;
    return node;
  }
  function updateTypeParameterDeclaration(node, modifiers, name, constraint, defaultType) {
    return node.modifiers !== modifiers || node.name !== name || node.constraint !== constraint || node.default !== defaultType ? update(createTypeParameterDeclaration(modifiers, name, constraint, defaultType), node) : node;
  }
  function createParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, type, initializer) {
    const node = createBaseDeclaration(169 /* Parameter */);
    node.modifiers = asNodeArray(modifiers);
    node.dotDotDotToken = dotDotDotToken;
    node.name = asName(name);
    node.questionToken = questionToken;
    node.type = type;
    node.initializer = asInitializer(initializer);
    if (isThisIdentifier(node.name)) {
      node.transformFlags = 1 /* ContainsTypeScript */;
    } else {
      node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.dotDotDotToken) | propagateNameFlags(node.name) | propagateChildFlags(node.questionToken) | propagateChildFlags(node.initializer) | (node.questionToken ?? node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (node.dotDotDotToken ?? node.initializer ? 1024 /* ContainsES2015 */ : 0 /* None */) | (modifiersToFlags(node.modifiers) & 31 /* ParameterPropertyModifier */ ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */);
    }
    node.jsDoc = void 0;
    return node;
  }
  function updateParameterDeclaration(node, modifiers, dotDotDotToken, name, questionToken, type, initializer) {
    return node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer ? update(createParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, type, initializer), node) : node;
  }
  function createDecorator(expression) {
    const node = createBaseNode(170 /* Decorator */);
    node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(
      expression,
      /*optionalChain*/
      false
    );
    node.transformFlags |= propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */ | 8192 /* ContainsTypeScriptClassSyntax */ | 33554432 /* ContainsDecorators */;
    return node;
  }
  function updateDecorator(node, expression) {
    return node.expression !== expression ? update(createDecorator(expression), node) : node;
  }
  function createPropertySignature(modifiers, name, questionToken, type) {
    const node = createBaseDeclaration(171 /* PropertySignature */);
    node.modifiers = asNodeArray(modifiers);
    node.name = asName(name);
    node.type = type;
    node.questionToken = questionToken;
    node.transformFlags = 1 /* ContainsTypeScript */;
    node.initializer = void 0;
    node.jsDoc = void 0;
    return node;
  }
  function updatePropertySignature(node, modifiers, name, questionToken, type) {
    return node.modifiers !== modifiers || node.name !== name || node.questionToken !== questionToken || node.type !== type ? finishUpdatePropertySignature(createPropertySignature(modifiers, name, questionToken, type), node) : node;
  }
  function finishUpdatePropertySignature(updated, original) {
    if (updated !== original) {
      updated.initializer = original.initializer;
    }
    return update(updated, original);
  }
  function createPropertyDeclaration(modifiers, name, questionOrExclamationToken, type, initializer) {
    const node = createBaseDeclaration(172 /* PropertyDeclaration */);
    node.modifiers = asNodeArray(modifiers);
    node.name = asName(name);
    node.questionToken = questionOrExclamationToken && isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : void 0;
    node.exclamationToken = questionOrExclamationToken && isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : void 0;
    node.type = type;
    node.initializer = asInitializer(initializer);
    const isAmbient = node.flags & 33554432 /* Ambient */ || modifiersToFlags(node.modifiers) & 128 /* Ambient */;
    node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildFlags(node.initializer) | (isAmbient || node.questionToken || node.exclamationToken || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (isComputedPropertyName(node.name) || modifiersToFlags(node.modifiers) & 256 /* Static */ && node.initializer ? 8192 /* ContainsTypeScriptClassSyntax */ : 0 /* None */) | 16777216 /* ContainsClassFields */;
    node.jsDoc = void 0;
    return node;
  }
  function updatePropertyDeclaration2(node, modifiers, name, questionOrExclamationToken, type, initializer) {
    return node.modifiers !== modifiers || node.name !== name || node.questionToken !== (questionOrExclamationToken !== void 0 && isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : void 0) || node.exclamationToken !== (questionOrExclamationToken !== void 0 && isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : void 0) || node.type !== type || node.initializer !== initializer ? update(createPropertyDeclaration(modifiers, name, questionOrExclamationToken, type, initializer), node) : node;
  }
  function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) {
    const node = createBaseDeclaration(173 /* MethodSignature */);
    node.modifiers = asNodeArray(modifiers);
    node.name = asName(name);
    node.questionToken = questionToken;
    node.typeParameters = asNodeArray(typeParameters);
    node.parameters = asNodeArray(parameters);
    node.type = type;
    node.transformFlags = 1 /* ContainsTypeScript */;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.typeArguments = void 0;
    return node;
  }
  function updateMethodSignature(node, modifiers, name, questionToken, typeParameters, parameters, type) {
    return node.modifiers !== modifiers || node.name !== name || node.questionToken !== questionToken || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type ? finishUpdateBaseSignatureDeclaration(createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type), node) : node;
  }
  function createMethodDeclaration(modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) {
    const node = createBaseDeclaration(174 /* MethodDeclaration */);
    node.modifiers = asNodeArray(modifiers);
    node.asteriskToken = asteriskToken;
    node.name = asName(name);
    node.questionToken = questionToken;
    node.exclamationToken = void 0;
    node.typeParameters = asNodeArray(typeParameters);
    node.parameters = createNodeArray(parameters);
    node.type = type;
    node.body = body;
    if (!node.body) {
      node.transformFlags = 1 /* ContainsTypeScript */;
    } else {
      const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */;
      const isGenerator = !!node.asteriskToken;
      const isAsyncGenerator = isAsync && isGenerator;
      node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.asteriskToken) | propagateNameFlags(node.name) | propagateChildFlags(node.questionToken) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (isAsyncGenerator ? 128 /* ContainsES2018 */ : isAsync ? 256 /* ContainsES2017 */ : isGenerator ? 2048 /* ContainsGenerator */ : 0 /* None */) | (node.questionToken || node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | 1024 /* ContainsES2015 */;
    }
    node.typeArguments = void 0;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.flowNode = void 0;
    node.endFlowNode = void 0;
    node.returnFlowNode = void 0;
    return node;
  }
  function updateMethodDeclaration(node, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) {
    return node.modifiers !== modifiers || node.asteriskToken !== asteriskToken || node.name !== name || node.questionToken !== questionToken || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body ? finishUpdateMethodDeclaration(createMethodDeclaration(modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) : node;
  }
  function finishUpdateMethodDeclaration(updated, original) {
    if (updated !== original) {
      updated.exclamationToken = original.exclamationToken;
    }
    return update(updated, original);
  }
  function createClassStaticBlockDeclaration(body) {
    const node = createBaseDeclaration(175 /* ClassStaticBlockDeclaration */);
    node.body = body;
    node.transformFlags = propagateChildFlags(body) | 16777216 /* ContainsClassFields */;
    node.modifiers = void 0;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.endFlowNode = void 0;
    node.returnFlowNode = void 0;
    return node;
  }
  function updateClassStaticBlockDeclaration(node, body) {
    return node.body !== body ? finishUpdateClassStaticBlockDeclaration(createClassStaticBlockDeclaration(body), node) : node;
  }
  function finishUpdateClassStaticBlockDeclaration(updated, original) {
    if (updated !== original) {
      updated.modifiers = original.modifiers;
    }
    return update(updated, original);
  }
  function createConstructorDeclaration(modifiers, parameters, body) {
    const node = createBaseDeclaration(176 /* Constructor */);
    node.modifiers = asNodeArray(modifiers);
    node.parameters = createNodeArray(parameters);
    node.body = body;
    if (!node.body) {
      node.transformFlags = 1 /* ContainsTypeScript */;
    } else {
      node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | 1024 /* ContainsES2015 */;
    }
    node.typeParameters = void 0;
    node.type = void 0;
    node.typeArguments = void 0;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.endFlowNode = void 0;
    node.returnFlowNode = void 0;
    return node;
  }
  function updateConstructorDeclaration(node, modifiers, parameters, body) {
    return node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body ? finishUpdateConstructorDeclaration(createConstructorDeclaration(modifiers, parameters, body), node) : node;
  }
  function finishUpdateConstructorDeclaration(updated, original) {
    if (updated !== original) {
      updated.typeParameters = original.typeParameters;
      updated.type = original.type;
    }
    return finishUpdateBaseSignatureDeclaration(updated, original);
  }
  function createGetAccessorDeclaration(modifiers, name, parameters, type, body) {
    const node = createBaseDeclaration(177 /* GetAccessor */);
    node.modifiers = asNodeArray(modifiers);
    node.name = asName(name);
    node.parameters = createNodeArray(parameters);
    node.type = type;
    node.body = body;
    if (!node.body) {
      node.transformFlags = 1 /* ContainsTypeScript */;
    } else {
      node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (node.type ? 1 /* ContainsTypeScript */ : 0 /* None */);
    }
    node.typeArguments = void 0;
    node.typeParameters = void 0;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.flowNode = void 0;
    node.endFlowNode = void 0;
    node.returnFlowNode = void 0;
    return node;
  }
  function updateGetAccessorDeclaration(node, modifiers, name, parameters, type, body) {
    return node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body ? finishUpdateGetAccessorDeclaration(createGetAccessorDeclaration(modifiers, name, parameters, type, body), node) : node;
  }
  function finishUpdateGetAccessorDeclaration(updated, original) {
    if (updated !== original) {
      updated.typeParameters = original.typeParameters;
    }
    return finishUpdateBaseSignatureDeclaration(updated, original);
  }
  function createSetAccessorDeclaration(modifiers, name, parameters, body) {
    const node = createBaseDeclaration(178 /* SetAccessor */);
    node.modifiers = asNodeArray(modifiers);
    node.name = asName(name);
    node.parameters = createNodeArray(parameters);
    node.body = body;
    if (!node.body) {
      node.transformFlags = 1 /* ContainsTypeScript */;
    } else {
      node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (node.type ? 1 /* ContainsTypeScript */ : 0 /* None */);
    }
    node.typeArguments = void 0;
    node.typeParameters = void 0;
    node.type = void 0;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.flowNode = void 0;
    node.endFlowNode = void 0;
    node.returnFlowNode = void 0;
    return node;
  }
  function updateSetAccessorDeclaration(node, modifiers, name, parameters, body) {
    return node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body ? finishUpdateSetAccessorDeclaration(createSetAccessorDeclaration(modifiers, name, parameters, body), node) : node;
  }
  function finishUpdateSetAccessorDeclaration(updated, original) {
    if (updated !== original) {
      updated.typeParameters = original.typeParameters;
      updated.type = original.type;
    }
    return finishUpdateBaseSignatureDeclaration(updated, original);
  }
  function createCallSignature(typeParameters, parameters, type) {
    const node = createBaseDeclaration(179 /* CallSignature */);
    node.typeParameters = asNodeArray(typeParameters);
    node.parameters = asNodeArray(parameters);
    node.type = type;
    node.transformFlags = 1 /* ContainsTypeScript */;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.typeArguments = void 0;
    return node;
  }
  function updateCallSignature(node, typeParameters, parameters, type) {
    return node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type ? finishUpdateBaseSignatureDeclaration(createCallSignature(typeParameters, parameters, type), node) : node;
  }
  function createConstructSignature(typeParameters, parameters, type) {
    const node = createBaseDeclaration(180 /* ConstructSignature */);
    node.typeParameters = asNodeArray(typeParameters);
    node.parameters = asNodeArray(parameters);
    node.type = type;
    node.transformFlags = 1 /* ContainsTypeScript */;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.typeArguments = void 0;
    return node;
  }
  function updateConstructSignature(node, typeParameters, parameters, type) {
    return node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type ? finishUpdateBaseSignatureDeclaration(createConstructSignature(typeParameters, parameters, type), node) : node;
  }
  function createIndexSignature(modifiers, parameters, type) {
    const node = createBaseDeclaration(181 /* IndexSignature */);
    node.modifiers = asNodeArray(modifiers);
    node.parameters = asNodeArray(parameters);
    node.type = type;
    node.transformFlags = 1 /* ContainsTypeScript */;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.typeArguments = void 0;
    return node;
  }
  function updateIndexSignature(node, modifiers, parameters, type) {
    return node.parameters !== parameters || node.type !== type || node.modifiers !== modifiers ? finishUpdateBaseSignatureDeclaration(createIndexSignature(modifiers, parameters, type), node) : node;
  }
  function createTemplateLiteralTypeSpan(type, literal) {
    const node = createBaseNode(204 /* TemplateLiteralTypeSpan */);
    node.type = type;
    node.literal = literal;
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateTemplateLiteralTypeSpan(node, type, literal) {
    return node.type !== type || node.literal !== literal ? update(createTemplateLiteralTypeSpan(type, literal), node) : node;
  }
  function createKeywordTypeNode(kind) {
    return createToken(kind);
  }
  function createTypePredicateNode(assertsModifier, parameterName, type) {
    const node = createBaseNode(182 /* TypePredicate */);
    node.assertsModifier = assertsModifier;
    node.parameterName = asName(parameterName);
    node.type = type;
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateTypePredicateNode(node, assertsModifier, parameterName, type) {
    return node.assertsModifier !== assertsModifier || node.parameterName !== parameterName || node.type !== type ? update(createTypePredicateNode(assertsModifier, parameterName, type), node) : node;
  }
  function createTypeReferenceNode(typeName, typeArguments) {
    const node = createBaseNode(183 /* TypeReference */);
    node.typeName = asName(typeName);
    node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments));
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateTypeReferenceNode(node, typeName, typeArguments) {
    return node.typeName !== typeName || node.typeArguments !== typeArguments ? update(createTypeReferenceNode(typeName, typeArguments), node) : node;
  }
  function createFunctionTypeNode(typeParameters, parameters, type) {
    const node = createBaseDeclaration(184 /* FunctionType */);
    node.typeParameters = asNodeArray(typeParameters);
    node.parameters = asNodeArray(parameters);
    node.type = type;
    node.transformFlags = 1 /* ContainsTypeScript */;
    node.modifiers = void 0;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.typeArguments = void 0;
    return node;
  }
  function updateFunctionTypeNode(node, typeParameters, parameters, type) {
    return node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type ? finishUpdateFunctionTypeNode(createFunctionTypeNode(typeParameters, parameters, type), node) : node;
  }
  function finishUpdateFunctionTypeNode(updated, original) {
    if (updated !== original) {
      updated.modifiers = original.modifiers;
    }
    return finishUpdateBaseSignatureDeclaration(updated, original);
  }
  function createConstructorTypeNode(...args) {
    return args.length === 4 ? createConstructorTypeNode1(...args) : args.length === 3 ? createConstructorTypeNode2(...args) : Debug.fail("Incorrect number of arguments specified.");
  }
  function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) {
    const node = createBaseDeclaration(185 /* ConstructorType */);
    node.modifiers = asNodeArray(modifiers);
    node.typeParameters = asNodeArray(typeParameters);
    node.parameters = asNodeArray(parameters);
    node.type = type;
    node.transformFlags = 1 /* ContainsTypeScript */;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.typeArguments = void 0;
    return node;
  }
  function createConstructorTypeNode2(typeParameters, parameters, type) {
    return createConstructorTypeNode1(
      /*modifiers*/
      void 0,
      typeParameters,
      parameters,
      type
    );
  }
  function updateConstructorTypeNode(...args) {
    return args.length === 5 ? updateConstructorTypeNode1(...args) : args.length === 4 ? updateConstructorTypeNode2(...args) : Debug.fail("Incorrect number of arguments specified.");
  }
  function updateConstructorTypeNode1(node, modifiers, typeParameters, parameters, type) {
    return node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type ? finishUpdateBaseSignatureDeclaration(createConstructorTypeNode(modifiers, typeParameters, parameters, type), node) : node;
  }
  function updateConstructorTypeNode2(node, typeParameters, parameters, type) {
    return updateConstructorTypeNode1(node, node.modifiers, typeParameters, parameters, type);
  }
  function createTypeQueryNode(exprName, typeArguments) {
    const node = createBaseNode(186 /* TypeQuery */);
    node.exprName = exprName;
    node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateTypeQueryNode(node, exprName, typeArguments) {
    return node.exprName !== exprName || node.typeArguments !== typeArguments ? update(createTypeQueryNode(exprName, typeArguments), node) : node;
  }
  function createTypeLiteralNode(members) {
    const node = createBaseDeclaration(187 /* TypeLiteral */);
    node.members = createNodeArray(members);
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateTypeLiteralNode(node, members) {
    return node.members !== members ? update(createTypeLiteralNode(members), node) : node;
  }
  function createArrayTypeNode(elementType) {
    const node = createBaseNode(188 /* ArrayType */);
    node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType);
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateArrayTypeNode(node, elementType) {
    return node.elementType !== elementType ? update(createArrayTypeNode(elementType), node) : node;
  }
  function createTupleTypeNode(elements) {
    const node = createBaseNode(189 /* TupleType */);
    node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements));
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateTupleTypeNode(node, elements) {
    return node.elements !== elements ? update(createTupleTypeNode(elements), node) : node;
  }
  function createNamedTupleMember(dotDotDotToken, name, questionToken, type) {
    const node = createBaseDeclaration(202 /* NamedTupleMember */);
    node.dotDotDotToken = dotDotDotToken;
    node.name = name;
    node.questionToken = questionToken;
    node.type = type;
    node.transformFlags = 1 /* ContainsTypeScript */;
    node.jsDoc = void 0;
    return node;
  }
  function updateNamedTupleMember(node, dotDotDotToken, name, questionToken, type) {
    return node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.questionToken !== questionToken || node.type !== type ? update(createNamedTupleMember(dotDotDotToken, name, questionToken, type), node) : node;
  }
  function createOptionalTypeNode(type) {
    const node = createBaseNode(190 /* OptionalType */);
    node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type);
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateOptionalTypeNode(node, type) {
    return node.type !== type ? update(createOptionalTypeNode(type), node) : node;
  }
  function createRestTypeNode(type) {
    const node = createBaseNode(191 /* RestType */);
    node.type = type;
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateRestTypeNode(node, type) {
    return node.type !== type ? update(createRestTypeNode(type), node) : node;
  }
  function createUnionOrIntersectionTypeNode(kind, types, parenthesize) {
    const node = createBaseNode(kind);
    node.types = factory2.createNodeArray(parenthesize(types));
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateUnionOrIntersectionTypeNode(node, types, parenthesize) {
    return node.types !== types ? update(createUnionOrIntersectionTypeNode(node.kind, types, parenthesize), node) : node;
  }
  function createUnionTypeNode(types) {
    return createUnionOrIntersectionTypeNode(192 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
  }
  function updateUnionTypeNode(node, types) {
    return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
  }
  function createIntersectionTypeNode(types) {
    return createUnionOrIntersectionTypeNode(193 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
  }
  function updateIntersectionTypeNode(node, types) {
    return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
  }
  function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
    const node = createBaseNode(194 /* ConditionalType */);
    node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType);
    node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType);
    node.trueType = trueType;
    node.falseType = falseType;
    node.transformFlags = 1 /* ContainsTypeScript */;
    node.locals = void 0;
    node.nextContainer = void 0;
    return node;
  }
  function updateConditionalTypeNode(node, checkType, extendsType, trueType, falseType) {
    return node.checkType !== checkType || node.extendsType !== extendsType || node.trueType !== trueType || node.falseType !== falseType ? update(createConditionalTypeNode(checkType, extendsType, trueType, falseType), node) : node;
  }
  function createInferTypeNode(typeParameter) {
    const node = createBaseNode(195 /* InferType */);
    node.typeParameter = typeParameter;
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateInferTypeNode(node, typeParameter) {
    return node.typeParameter !== typeParameter ? update(createInferTypeNode(typeParameter), node) : node;
  }
  function createTemplateLiteralType(head, templateSpans) {
    const node = createBaseNode(203 /* TemplateLiteralType */);
    node.head = head;
    node.templateSpans = createNodeArray(templateSpans);
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateTemplateLiteralType(node, head, templateSpans) {
    return node.head !== head || node.templateSpans !== templateSpans ? update(createTemplateLiteralType(head, templateSpans), node) : node;
  }
  function createImportTypeNode(argument, attributes, qualifier, typeArguments, isTypeOf = false) {
    const node = createBaseNode(205 /* ImportType */);
    node.argument = argument;
    node.attributes = attributes;
    if (node.assertions && node.assertions.assertClause && node.attributes) {
      node.assertions.assertClause = node.attributes;
    }
    node.qualifier = qualifier;
    node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
    node.isTypeOf = isTypeOf;
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateImportTypeNode(node, argument, attributes, qualifier, typeArguments, isTypeOf = node.isTypeOf) {
    return node.argument !== argument || node.attributes !== attributes || node.qualifier !== qualifier || node.typeArguments !== typeArguments || node.isTypeOf !== isTypeOf ? update(createImportTypeNode(argument, attributes, qualifier, typeArguments, isTypeOf), node) : node;
  }
  function createParenthesizedType(type) {
    const node = createBaseNode(196 /* ParenthesizedType */);
    node.type = type;
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateParenthesizedType(node, type) {
    return node.type !== type ? update(createParenthesizedType(type), node) : node;
  }
  function createThisTypeNode() {
    const node = createBaseNode(197 /* ThisType */);
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function createTypeOperatorNode(operator, type) {
    const node = createBaseNode(198 /* TypeOperator */);
    node.operator = operator;
    node.type = operator === 148 /* ReadonlyKeyword */ ? parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) : parenthesizerRules().parenthesizeOperandOfTypeOperator(type);
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateTypeOperatorNode(node, type) {
    return node.type !== type ? update(createTypeOperatorNode(node.operator, type), node) : node;
  }
  function createIndexedAccessTypeNode(objectType, indexType) {
    const node = createBaseNode(199 /* IndexedAccessType */);
    node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType);
    node.indexType = indexType;
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateIndexedAccessTypeNode(node, objectType, indexType) {
    return node.objectType !== objectType || node.indexType !== indexType ? update(createIndexedAccessTypeNode(objectType, indexType), node) : node;
  }
  function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members) {
    const node = createBaseDeclaration(200 /* MappedType */);
    node.readonlyToken = readonlyToken;
    node.typeParameter = typeParameter;
    node.nameType = nameType;
    node.questionToken = questionToken;
    node.type = type;
    node.members = members && createNodeArray(members);
    node.transformFlags = 1 /* ContainsTypeScript */;
    node.locals = void 0;
    node.nextContainer = void 0;
    return node;
  }
  function updateMappedTypeNode(node, readonlyToken, typeParameter, nameType, questionToken, type, members) {
    return node.readonlyToken !== readonlyToken || node.typeParameter !== typeParameter || node.nameType !== nameType || node.questionToken !== questionToken || node.type !== type || node.members !== members ? update(createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), node) : node;
  }
  function createLiteralTypeNode(literal) {
    const node = createBaseNode(201 /* LiteralType */);
    node.literal = literal;
    node.transformFlags = 1 /* ContainsTypeScript */;
    return node;
  }
  function updateLiteralTypeNode(node, literal) {
    return node.literal !== literal ? update(createLiteralTypeNode(literal), node) : node;
  }
  function createObjectBindingPattern(elements) {
    const node = createBaseNode(206 /* ObjectBindingPattern */);
    node.elements = createNodeArray(elements);
    node.transformFlags |= propagateChildrenFlags(node.elements) | 1024 /* ContainsES2015 */ | 524288 /* ContainsBindingPattern */;
    if (node.transformFlags & 32768 /* ContainsRestOrSpread */) {
      node.transformFlags |= 128 /* ContainsES2018 */ | 65536 /* ContainsObjectRestOrSpread */;
    }
    return node;
  }
  function updateObjectBindingPattern(node, elements) {
    return node.elements !== elements ? update(createObjectBindingPattern(elements), node) : node;
  }
  function createArrayBindingPattern(elements) {
    const node = createBaseNode(207 /* ArrayBindingPattern */);
    node.elements = createNodeArray(elements);
    node.transformFlags |= propagateChildrenFlags(node.elements) | 1024 /* ContainsES2015 */ | 524288 /* ContainsBindingPattern */;
    return node;
  }
  function updateArrayBindingPattern(node, elements) {
    return node.elements !== elements ? update(createArrayBindingPattern(elements), node) : node;
  }
  function createBindingElement(dotDotDotToken, propertyName, name, initializer) {
    const node = createBaseDeclaration(208 /* BindingElement */);
    node.dotDotDotToken = dotDotDotToken;
    node.propertyName = asName(propertyName);
    node.name = asName(name);
    node.initializer = asInitializer(initializer);
    node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateNameFlags(node.propertyName) | propagateNameFlags(node.name) | propagateChildFlags(node.initializer) | (node.dotDotDotToken ? 32768 /* ContainsRestOrSpread */ : 0 /* None */) | 1024 /* ContainsES2015 */;
    node.flowNode = void 0;
    return node;
  }
  function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) {
    return node.propertyName !== propertyName || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer ? update(createBindingElement(dotDotDotToken, propertyName, name, initializer), node) : node;
  }
  function createArrayLiteralExpression(elements, multiLine) {
    const node = createBaseNode(209 /* ArrayLiteralExpression */);
    const lastElement = elements && lastOrUndefined(elements);
    const elementsArray = createNodeArray(elements, lastElement && isOmittedExpression(lastElement) ? true : void 0);
    node.elements = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(elementsArray);
    node.multiLine = multiLine;
    node.transformFlags |= propagateChildrenFlags(node.elements);
    return node;
  }
  function updateArrayLiteralExpression(node, elements) {
    return node.elements !== elements ? update(createArrayLiteralExpression(elements, node.multiLine), node) : node;
  }
  function createObjectLiteralExpression(properties, multiLine) {
    const node = createBaseDeclaration(210 /* ObjectLiteralExpression */);
    node.properties = createNodeArray(properties);
    node.multiLine = multiLine;
    node.transformFlags |= propagateChildrenFlags(node.properties);
    node.jsDoc = void 0;
    return node;
  }
  function updateObjectLiteralExpression(node, properties) {
    return node.properties !== properties ? update(createObjectLiteralExpression(properties, node.multiLine), node) : node;
  }
  function createBasePropertyAccessExpression(expression, questionDotToken, name) {
    const node = createBaseDeclaration(211 /* PropertyAccessExpression */);
    node.expression = expression;
    node.questionDotToken = questionDotToken;
    node.name = name;
    node.transformFlags = propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (isIdentifier(node.name) ? propagateIdentifierNameFlags(node.name) : propagateChildFlags(node.name) | 536870912 /* ContainsPrivateIdentifierInExpression */);
    node.jsDoc = void 0;
    node.flowNode = void 0;
    return node;
  }
  function createPropertyAccessExpression(expression, name) {
    const node = createBasePropertyAccessExpression(
      parenthesizerRules().parenthesizeLeftSideOfAccess(
        expression,
        /*optionalChain*/
        false
      ),
      /*questionDotToken*/
      void 0,
      asName(name)
    );
    if (isSuperKeyword(expression)) {
      node.transformFlags |= 256 /* ContainsES2017 */ | 128 /* ContainsES2018 */;
    }
    return node;
  }
  function updatePropertyAccessExpression(node, expression, name) {
    if (isPropertyAccessChain(node)) {
      return updatePropertyAccessChain(node, expression, node.questionDotToken, cast(name, isIdentifier));
    }
    return node.expression !== expression || node.name !== name ? update(createPropertyAccessExpression(expression, name), node) : node;
  }
  function createPropertyAccessChain(expression, questionDotToken, name) {
    const node = createBasePropertyAccessExpression(
      parenthesizerRules().parenthesizeLeftSideOfAccess(
        expression,
        /*optionalChain*/
        true
      ),
      questionDotToken,
      asName(name)
    );
    node.flags |= 64 /* OptionalChain */;
    node.transformFlags |= 32 /* ContainsES2020 */;
    return node;
  }
  function updatePropertyAccessChain(node, expression, questionDotToken, name) {
    Debug.assert(!!(node.flags & 64 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead.");
    return node.expression !== expression || node.questionDotToken !== questionDotToken || node.name !== name ? update(createPropertyAccessChain(expression, questionDotToken, name), node) : node;
  }
  function createBaseElementAccessExpression(expression, questionDotToken, argumentExpression) {
    const node = createBaseDeclaration(212 /* ElementAccessExpression */);
    node.expression = expression;
    node.questionDotToken = questionDotToken;
    node.argumentExpression = argumentExpression;
    node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression);
    node.jsDoc = void 0;
    node.flowNode = void 0;
    return node;
  }
  function createElementAccessExpression(expression, index) {
    const node = createBaseElementAccessExpression(
      parenthesizerRules().parenthesizeLeftSideOfAccess(
        expression,
        /*optionalChain*/
        false
      ),
      /*questionDotToken*/
      void 0,
      asExpression(index)
    );
    if (isSuperKeyword(expression)) {
      node.transformFlags |= 256 /* ContainsES2017 */ | 128 /* ContainsES2018 */;
    }
    return node;
  }
  function updateElementAccessExpression(node, expression, argumentExpression) {
    if (isElementAccessChain(node)) {
      return updateElementAccessChain(node, expression, node.questionDotToken, argumentExpression);
    }
    return node.expression !== expression || node.argumentExpression !== argumentExpression ? update(createElementAccessExpression(expression, argumentExpression), node) : node;
  }
  function createElementAccessChain(expression, questionDotToken, index) {
    const node = createBaseElementAccessExpression(
      parenthesizerRules().parenthesizeLeftSideOfAccess(
        expression,
        /*optionalChain*/
        true
      ),
      questionDotToken,
      asExpression(index)
    );
    node.flags |= 64 /* OptionalChain */;
    node.transformFlags |= 32 /* ContainsES2020 */;
    return node;
  }
  function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) {
    Debug.assert(!!(node.flags & 64 /* OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead.");
    return node.expression !== expression || node.questionDotToken !== questionDotToken || node.argumentExpression !== argumentExpression ? update(createElementAccessChain(expression, questionDotToken, argumentExpression), node) : node;
  }
  function createBaseCallExpression(expression, questionDotToken, typeArguments, argumentsArray) {
    const node = createBaseDeclaration(213 /* CallExpression */);
    node.expression = expression;
    node.questionDotToken = questionDotToken;
    node.typeArguments = typeArguments;
    node.arguments = argumentsArray;
    node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments);
    if (node.typeArguments) {
      node.transformFlags |= 1 /* ContainsTypeScript */;
    }
    if (isSuperProperty(node.expression)) {
      node.transformFlags |= 16384 /* ContainsLexicalThis */;
    }
    return node;
  }
  function createCallExpression(expression, typeArguments, argumentsArray) {
    const node = createBaseCallExpression(
      parenthesizerRules().parenthesizeLeftSideOfAccess(
        expression,
        /*optionalChain*/
        false
      ),
      /*questionDotToken*/
      void 0,
      asNodeArray(typeArguments),
      parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray))
    );
    if (isImportKeyword(node.expression)) {
      node.transformFlags |= 8388608 /* ContainsDynamicImport */;
    }
    return node;
  }
  function updateCallExpression(node, expression, typeArguments, argumentsArray) {
    if (isCallChain(node)) {
      return updateCallChain(node, expression, node.questionDotToken, typeArguments, argumentsArray);
    }
    return node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray ? update(createCallExpression(expression, typeArguments, argumentsArray), node) : node;
  }
  function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
    const node = createBaseCallExpression(
      parenthesizerRules().parenthesizeLeftSideOfAccess(
        expression,
        /*optionalChain*/
        true
      ),
      questionDotToken,
      asNodeArray(typeArguments),
      parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray))
    );
    node.flags |= 64 /* OptionalChain */;
    node.transformFlags |= 32 /* ContainsES2020 */;
    return node;
  }
  function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) {
    Debug.assert(!!(node.flags & 64 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead.");
    return node.expression !== expression || node.questionDotToken !== questionDotToken || node.typeArguments !== typeArguments || node.arguments !== argumentsArray ? update(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node) : node;
  }
  function createNewExpression(expression, typeArguments, argumentsArray) {
    const node = createBaseDeclaration(214 /* NewExpression */);
    node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression);
    node.typeArguments = asNodeArray(typeArguments);
    node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : void 0;
    node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | 32 /* ContainsES2020 */;
    if (node.typeArguments) {
      node.transformFlags |= 1 /* ContainsTypeScript */;
    }
    return node;
  }
  function updateNewExpression(node, expression, typeArguments, argumentsArray) {
    return node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray ? update(createNewExpression(expression, typeArguments, argumentsArray), node) : node;
  }
  function createTaggedTemplateExpression(tag, typeArguments, template) {
    const node = createBaseNode(215 /* TaggedTemplateExpression */);
    node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(
      tag,
      /*optionalChain*/
      false
    );
    node.typeArguments = asNodeArray(typeArguments);
    node.template = template;
    node.transformFlags |= propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | 1024 /* ContainsES2015 */;
    if (node.typeArguments) {
      node.transformFlags |= 1 /* ContainsTypeScript */;
    }
    if (hasInvalidEscape(node.template)) {
      node.transformFlags |= 128 /* ContainsES2018 */;
    }
    return node;
  }
  function updateTaggedTemplateExpression(node, tag, typeArguments, template) {
    return node.tag !== tag || node.typeArguments !== typeArguments || node.template !== template ? update(createTaggedTemplateExpression(tag, typeArguments, template), node) : node;
  }
  function createTypeAssertion(type, expression) {
    const node = createBaseNode(216 /* TypeAssertionExpression */);
    node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
    node.type = type;
    node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | 1 /* ContainsTypeScript */;
    return node;
  }
  function updateTypeAssertion(node, type, expression) {
    return node.type !== type || node.expression !== expression ? update(createTypeAssertion(type, expression), node) : node;
  }
  function createParenthesizedExpression(expression) {
    const node = createBaseNode(217 /* ParenthesizedExpression */);
    node.expression = expression;
    node.transformFlags = propagateChildFlags(node.expression);
    node.jsDoc = void 0;
    return node;
  }
  function updateParenthesizedExpression(node, expression) {
    return node.expression !== expression ? update(createParenthesizedExpression(expression), node) : node;
  }
  function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
    const node = createBaseDeclaration(218 /* FunctionExpression */);
    node.modifiers = asNodeArray(modifiers);
    node.asteriskToken = asteriskToken;
    node.name = asName(name);
    node.typeParameters = asNodeArray(typeParameters);
    node.parameters = createNodeArray(parameters);
    node.type = type;
    node.body = body;
    const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */;
    const isGenerator = !!node.asteriskToken;
    const isAsyncGenerator = isAsync && isGenerator;
    node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.asteriskToken) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (isAsyncGenerator ? 128 /* ContainsES2018 */ : isAsync ? 256 /* ContainsES2017 */ : isGenerator ? 2048 /* ContainsGenerator */ : 0 /* None */) | (node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | 4194304 /* ContainsHoistedDeclarationOrCompletion */;
    node.typeArguments = void 0;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.flowNode = void 0;
    node.endFlowNode = void 0;
    node.returnFlowNode = void 0;
    return node;
  }
  function updateFunctionExpression(node, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
    return node.name !== name || node.modifiers !== modifiers || node.asteriskToken !== asteriskToken || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body ? finishUpdateBaseSignatureDeclaration(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node;
  }
  function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) {
    const node = createBaseDeclaration(219 /* ArrowFunction */);
    node.modifiers = asNodeArray(modifiers);
    node.typeParameters = asNodeArray(typeParameters);
    node.parameters = createNodeArray(parameters);
    node.type = type;
    node.equalsGreaterThanToken = equalsGreaterThanToken ?? createToken(39 /* EqualsGreaterThanToken */);
    node.body = parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body);
    const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */;
    node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.equalsGreaterThanToken) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | (isAsync ? 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */ : 0 /* None */) | 1024 /* ContainsES2015 */;
    node.typeArguments = void 0;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.flowNode = void 0;
    node.endFlowNode = void 0;
    node.returnFlowNode = void 0;
    return node;
  }
  function updateArrowFunction(node, modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) {
    return node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.equalsGreaterThanToken !== equalsGreaterThanToken || node.body !== body ? finishUpdateBaseSignatureDeclaration(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node) : node;
  }
  function createDeleteExpression(expression) {
    const node = createBaseNode(220 /* DeleteExpression */);
    node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
    node.transformFlags |= propagateChildFlags(node.expression);
    return node;
  }
  function updateDeleteExpression(node, expression) {
    return node.expression !== expression ? update(createDeleteExpression(expression), node) : node;
  }
  function createTypeOfExpression(expression) {
    const node = createBaseNode(221 /* TypeOfExpression */);
    node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
    node.transformFlags |= propagateChildFlags(node.expression);
    return node;
  }
  function updateTypeOfExpression(node, expression) {
    return node.expression !== expression ? update(createTypeOfExpression(expression), node) : node;
  }
  function createVoidExpression(expression) {
    const node = createBaseNode(222 /* VoidExpression */);
    node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
    node.transformFlags |= propagateChildFlags(node.expression);
    return node;
  }
  function updateVoidExpression(node, expression) {
    return node.expression !== expression ? update(createVoidExpression(expression), node) : node;
  }
  function createAwaitExpression(expression) {
    const node = createBaseNode(223 /* AwaitExpression */);
    node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
    node.transformFlags |= propagateChildFlags(node.expression) | 256 /* ContainsES2017 */ | 128 /* ContainsES2018 */ | 2097152 /* ContainsAwait */;
    return node;
  }
  function updateAwaitExpression(node, expression) {
    return node.expression !== expression ? update(createAwaitExpression(expression), node) : node;
  }
  function createPrefixUnaryExpression(operator, operand) {
    const node = createBaseNode(224 /* PrefixUnaryExpression */);
    node.operator = operator;
    node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand);
    node.transformFlags |= propagateChildFlags(node.operand);
    if ((operator === 46 /* PlusPlusToken */ || operator === 47 /* MinusMinusToken */) && isIdentifier(node.operand) && !isGeneratedIdentifier(node.operand) && !isLocalName(node.operand)) {
      node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */;
    }
    return node;
  }
  function updatePrefixUnaryExpression(node, operand) {
    return node.operand !== operand ? update(createPrefixUnaryExpression(node.operator, operand), node) : node;
  }
  function createPostfixUnaryExpression(operand, operator) {
    const node = createBaseNode(225 /* PostfixUnaryExpression */);
    node.operator = operator;
    node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand);
    node.transformFlags |= propagateChildFlags(node.operand);
    if (isIdentifier(node.operand) && !isGeneratedIdentifier(node.operand) && !isLocalName(node.operand)) {
      node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */;
    }
    return node;
  }
  function updatePostfixUnaryExpression(node, operand) {
    return node.operand !== operand ? update(createPostfixUnaryExpression(operand, node.operator), node) : node;
  }
  function createBinaryExpression(left, operator, right) {
    const node = createBaseDeclaration(226 /* BinaryExpression */);
    const operatorToken = asToken(operator);
    const operatorKind = operatorToken.kind;
    node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left);
    node.operatorToken = operatorToken;
    node.right = parenthesizerRules().parenthesizeRightSideOfBinary(operatorKind, node.left, right);
    node.transformFlags |= propagateChildFlags(node.left) | propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right);
    if (operatorKind === 61 /* QuestionQuestionToken */) {
      node.transformFlags |= 32 /* ContainsES2020 */;
    } else if (operatorKind === 64 /* EqualsToken */) {
      if (isObjectLiteralExpression(node.left)) {
        node.transformFlags |= 1024 /* ContainsES2015 */ | 128 /* ContainsES2018 */ | 4096 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left);
      } else if (isArrayLiteralExpression(node.left)) {
        node.transformFlags |= 1024 /* ContainsES2015 */ | 4096 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left);
      }
    } else if (operatorKind === 43 /* AsteriskAsteriskToken */ || operatorKind === 68 /* AsteriskAsteriskEqualsToken */) {
      node.transformFlags |= 512 /* ContainsES2016 */;
    } else if (isLogicalOrCoalescingAssignmentOperator(operatorKind)) {
      node.transformFlags |= 16 /* ContainsES2021 */;
    }
    if (operatorKind === 103 /* InKeyword */ && isPrivateIdentifier(node.left)) {
      node.transformFlags |= 536870912 /* ContainsPrivateIdentifierInExpression */;
    }
    node.jsDoc = void 0;
    return node;
  }
  function propagateAssignmentPatternFlags(node) {
    return containsObjectRestOrSpread(node) ? 65536 /* ContainsObjectRestOrSpread */ : 0 /* None */;
  }
  function updateBinaryExpression(node, left, operator, right) {
    return node.left !== left || node.operatorToken !== operator || node.right !== right ? update(createBinaryExpression(left, operator, right), node) : node;
  }
  function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) {
    const node = createBaseNode(227 /* ConditionalExpression */);
    node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition);
    node.questionToken = questionToken ?? createToken(58 /* QuestionToken */);
    node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue);
    node.colonToken = colonToken ?? createToken(59 /* ColonToken */);
    node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse);
    node.transformFlags |= propagateChildFlags(node.condition) | propagateChildFlags(node.questionToken) | propagateChildFlags(node.whenTrue) | propagateChildFlags(node.colonToken) | propagateChildFlags(node.whenFalse);
    return node;
  }
  function updateConditionalExpression(node, condition, questionToken, whenTrue, colonToken, whenFalse) {
    return node.condition !== condition || node.questionToken !== questionToken || node.whenTrue !== whenTrue || node.colonToken !== colonToken || node.whenFalse !== whenFalse ? update(createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse), node) : node;
  }
  function createTemplateExpression(head, templateSpans) {
    const node = createBaseNode(228 /* TemplateExpression */);
    node.head = head;
    node.templateSpans = createNodeArray(templateSpans);
    node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | 1024 /* ContainsES2015 */;
    return node;
  }
  function updateTemplateExpression(node, head, templateSpans) {
    return node.head !== head || node.templateSpans !== templateSpans ? update(createTemplateExpression(head, templateSpans), node) : node;
  }
  function checkTemplateLiteralLikeNode(kind, text, rawText, templateFlags = 0 /* None */) {
    Debug.assert(!(templateFlags & ~7176 /* TemplateLiteralLikeFlags */), "Unsupported template flags.");
    let cooked = void 0;
    if (rawText !== void 0 && rawText !== text) {
      cooked = getCookedText(kind, rawText);
      if (typeof cooked === "object") {
        return Debug.fail("Invalid raw text");
      }
    }
    if (text === void 0) {
      if (cooked === void 0) {
        return Debug.fail("Arguments 'text' and 'rawText' may not both be undefined.");
      }
      text = cooked;
    } else if (cooked !== void 0) {
      Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'.");
    }
    return text;
  }
  function getTransformFlagsOfTemplateLiteralLike(templateFlags) {
    let transformFlags = 1024 /* ContainsES2015 */;
    if (templateFlags) {
      transformFlags |= 128 /* ContainsES2018 */;
    }
    return transformFlags;
  }
  function createTemplateLiteralLikeToken(kind, text, rawText, templateFlags) {
    const node = createBaseToken(kind);
    node.text = text;
    node.rawText = rawText;
    node.templateFlags = templateFlags & 7176 /* TemplateLiteralLikeFlags */;
    node.transformFlags = getTransformFlagsOfTemplateLiteralLike(node.templateFlags);
    return node;
  }
  function createTemplateLiteralLikeDeclaration(kind, text, rawText, templateFlags) {
    const node = createBaseDeclaration(kind);
    node.text = text;
    node.rawText = rawText;
    node.templateFlags = templateFlags & 7176 /* TemplateLiteralLikeFlags */;
    node.transformFlags = getTransformFlagsOfTemplateLiteralLike(node.templateFlags);
    return node;
  }
  function createTemplateLiteralLikeNode(kind, text, rawText, templateFlags) {
    if (kind === 15 /* NoSubstitutionTemplateLiteral */) {
      return createTemplateLiteralLikeDeclaration(kind, text, rawText, templateFlags);
    }
    return createTemplateLiteralLikeToken(kind, text, rawText, templateFlags);
  }
  function createTemplateHead(text, rawText, templateFlags) {
    text = checkTemplateLiteralLikeNode(16 /* TemplateHead */, text, rawText, templateFlags);
    return createTemplateLiteralLikeNode(16 /* TemplateHead */, text, rawText, templateFlags);
  }
  function createTemplateMiddle(text, rawText, templateFlags) {
    text = checkTemplateLiteralLikeNode(16 /* TemplateHead */, text, rawText, templateFlags);
    return createTemplateLiteralLikeNode(17 /* TemplateMiddle */, text, rawText, templateFlags);
  }
  function createTemplateTail(text, rawText, templateFlags) {
    text = checkTemplateLiteralLikeNode(16 /* TemplateHead */, text, rawText, templateFlags);
    return createTemplateLiteralLikeNode(18 /* TemplateTail */, text, rawText, templateFlags);
  }
  function createNoSubstitutionTemplateLiteral(text, rawText, templateFlags) {
    text = checkTemplateLiteralLikeNode(16 /* TemplateHead */, text, rawText, templateFlags);
    return createTemplateLiteralLikeDeclaration(15 /* NoSubstitutionTemplateLiteral */, text, rawText, templateFlags);
  }
  function createYieldExpression(asteriskToken, expression) {
    Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression.");
    const node = createBaseNode(229 /* YieldExpression */);
    node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
    node.asteriskToken = asteriskToken;
    node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | 1024 /* ContainsES2015 */ | 128 /* ContainsES2018 */ | 1048576 /* ContainsYield */;
    return node;
  }
  function updateYieldExpression(node, asteriskToken, expression) {
    return node.expression !== expression || node.asteriskToken !== asteriskToken ? update(createYieldExpression(asteriskToken, expression), node) : node;
  }
  function createSpreadElement(expression) {
    const node = createBaseNode(230 /* SpreadElement */);
    node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
    node.transformFlags |= propagateChildFlags(node.expression) | 1024 /* ContainsES2015 */ | 32768 /* ContainsRestOrSpread */;
    return node;
  }
  function updateSpreadElement(node, expression) {
    return node.expression !== expression ? update(createSpreadElement(expression), node) : node;
  }
  function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) {
    const node = createBaseDeclaration(231 /* ClassExpression */);
    node.modifiers = asNodeArray(modifiers);
    node.name = asName(name);
    node.typeParameters = asNodeArray(typeParameters);
    node.heritageClauses = asNodeArray(heritageClauses);
    node.members = createNodeArray(members);
    node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.heritageClauses) | propagateChildrenFlags(node.members) | (node.typeParameters ? 1 /* ContainsTypeScript */ : 0 /* None */) | 1024 /* ContainsES2015 */;
    node.jsDoc = void 0;
    return node;
  }
  function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) {
    return node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members ? update(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node) : node;
  }
  function createOmittedExpression() {
    return createBaseNode(232 /* OmittedExpression */);
  }
  function createExpressionWithTypeArguments(expression, typeArguments) {
    const node = createBaseNode(233 /* ExpressionWithTypeArguments */);
    node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(
      expression,
      /*optionalChain*/
      false
    );
    node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
    node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | 1024 /* ContainsES2015 */;
    return node;
  }
  function updateExpressionWithTypeArguments(node, expression, typeArguments) {
    return node.expression !== expression || node.typeArguments !== typeArguments ? update(createExpressionWithTypeArguments(expression, typeArguments), node) : node;
  }
  function createAsExpression(expression, type) {
    const node = createBaseNode(234 /* AsExpression */);
    node.expression = expression;
    node.type = type;
    node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | 1 /* ContainsTypeScript */;
    return node;
  }
  function updateAsExpression(node, expression, type) {
    return node.expression !== expression || node.type !== type ? update(createAsExpression(expression, type), node) : node;
  }
  function createNonNullExpression(expression) {
    const node = createBaseNode(235 /* NonNullExpression */);
    node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(
      expression,
      /*optionalChain*/
      false
    );
    node.transformFlags |= propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */;
    return node;
  }
  function updateNonNullExpression(node, expression) {
    if (isNonNullChain(node)) {
      return updateNonNullChain(node, expression);
    }
    return node.expression !== expression ? update(createNonNullExpression(expression), node) : node;
  }
  function createSatisfiesExpression(expression, type) {
    const node = createBaseNode(238 /* SatisfiesExpression */);
    node.expression = expression;
    node.type = type;
    node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | 1 /* ContainsTypeScript */;
    return node;
  }
  function updateSatisfiesExpression(node, expression, type) {
    return node.expression !== expression || node.type !== type ? update(createSatisfiesExpression(expression, type), node) : node;
  }
  function createNonNullChain(expression) {
    const node = createBaseNode(235 /* NonNullExpression */);
    node.flags |= 64 /* OptionalChain */;
    node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(
      expression,
      /*optionalChain*/
      true
    );
    node.transformFlags |= propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */;
    return node;
  }
  function updateNonNullChain(node, expression) {
    Debug.assert(!!(node.flags & 64 /* OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead.");
    return node.expression !== expression ? update(createNonNullChain(expression), node) : node;
  }
  function createMetaProperty(keywordToken, name) {
    const node = createBaseNode(236 /* MetaProperty */);
    node.keywordToken = keywordToken;
    node.name = name;
    node.transformFlags |= propagateChildFlags(node.name);
    switch (keywordToken) {
      case 105 /* NewKeyword */:
        node.transformFlags |= 1024 /* ContainsES2015 */;
        break;
      case 102 /* ImportKeyword */:
        node.transformFlags |= 32 /* ContainsES2020 */;
        break;
      default:
        return Debug.assertNever(keywordToken);
    }
    node.flowNode = void 0;
    return node;
  }
  function updateMetaProperty(node, name) {
    return node.name !== name ? update(createMetaProperty(node.keywordToken, name), node) : node;
  }
  function createTemplateSpan(expression, literal) {
    const node = createBaseNode(239 /* TemplateSpan */);
    node.expression = expression;
    node.literal = literal;
    node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | 1024 /* ContainsES2015 */;
    return node;
  }
  function updateTemplateSpan(node, expression, literal) {
    return node.expression !== expression || node.literal !== literal ? update(createTemplateSpan(expression, literal), node) : node;
  }
  function createSemicolonClassElement() {
    const node = createBaseNode(240 /* SemicolonClassElement */);
    node.transformFlags |= 1024 /* ContainsES2015 */;
    return node;
  }
  function createBlock(statements, multiLine) {
    const node = createBaseNode(241 /* Block */);
    node.statements = createNodeArray(statements);
    node.multiLine = multiLine;
    node.transformFlags |= propagateChildrenFlags(node.statements);
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    return node;
  }
  function updateBlock(node, statements) {
    return node.statements !== statements ? update(createBlock(statements, node.multiLine), node) : node;
  }
  function createVariableStatement(modifiers, declarationList) {
    const node = createBaseNode(243 /* VariableStatement */);
    node.modifiers = asNodeArray(modifiers);
    node.declarationList = isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList;
    node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.declarationList);
    if (modifiersToFlags(node.modifiers) & 128 /* Ambient */) {
      node.transformFlags = 1 /* ContainsTypeScript */;
    }
    node.jsDoc = void 0;
    node.flowNode = void 0;
    return node;
  }
  function updateVariableStatement(node, modifiers, declarationList) {
    return node.modifiers !== modifiers || node.declarationList !== declarationList ? update(createVariableStatement(modifiers, declarationList), node) : node;
  }
  function createEmptyStatement() {
    const node = createBaseNode(242 /* EmptyStatement */);
    node.jsDoc = void 0;
    return node;
  }
  function createExpressionStatement(expression) {
    const node = createBaseNode(244 /* ExpressionStatement */);
    node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression);
    node.transformFlags |= propagateChildFlags(node.expression);
    node.jsDoc = void 0;
    node.flowNode = void 0;
    return node;
  }
  function updateExpressionStatement(node, expression) {
    return node.expression !== expression ? update(createExpressionStatement(expression), node) : node;
  }
  function createIfStatement(expression, thenStatement, elseStatement) {
    const node = createBaseNode(245 /* IfStatement */);
    node.expression = expression;
    node.thenStatement = asEmbeddedStatement(thenStatement);
    node.elseStatement = asEmbeddedStatement(elseStatement);
    node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.thenStatement) | propagateChildFlags(node.elseStatement);
    node.jsDoc = void 0;
    node.flowNode = void 0;
    return node;
  }
  function updateIfStatement(node, expression, thenStatement, elseStatement) {
    return node.expression !== expression || node.thenStatement !== thenStatement || node.elseStatement !== elseStatement ? update(createIfStatement(expression, thenStatement, elseStatement), node) : node;
  }
  function createDoStatement(statement, expression) {
    const node = createBaseNode(246 /* DoStatement */);
    node.statement = asEmbeddedStatement(statement);
    node.expression = expression;
    node.transformFlags |= propagateChildFlags(node.statement) | propagateChildFlags(node.expression);
    node.jsDoc = void 0;
    node.flowNode = void 0;
    return node;
  }
  function updateDoStatement(node, statement, expression) {
    return node.statement !== statement || node.expression !== expression ? update(createDoStatement(statement, expression), node) : node;
  }
  function createWhileStatement(expression, statement) {
    const node = createBaseNode(247 /* WhileStatement */);
    node.expression = expression;
    node.statement = asEmbeddedStatement(statement);
    node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.statement);
    node.jsDoc = void 0;
    node.flowNode = void 0;
    return node;
  }
  function updateWhileStatement(node, expression, statement) {
    return node.expression !== expression || node.statement !== statement ? update(createWhileStatement(expression, statement), node) : node;
  }
  function createForStatement(initializer, condition, incrementor, statement) {
    const node = createBaseNode(248 /* ForStatement */);
    node.initializer = initializer;
    node.condition = condition;
    node.incrementor = incrementor;
    node.statement = asEmbeddedStatement(statement);
    node.transformFlags |= propagateChildFlags(node.initializer) | propagateChildFlags(node.condition) | propagateChildFlags(node.incrementor) | propagateChildFlags(node.statement);
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.flowNode = void 0;
    return node;
  }
  function updateForStatement(node, initializer, condition, incrementor, statement) {
    return node.initializer !== initializer || node.condition !== condition || node.incrementor !== incrementor || node.statement !== statement ? update(createForStatement(initializer, condition, incrementor, statement), node) : node;
  }
  function createForInStatement(initializer, expression, statement) {
    const node = createBaseNode(249 /* ForInStatement */);
    node.initializer = initializer;
    node.expression = expression;
    node.statement = asEmbeddedStatement(statement);
    node.transformFlags |= propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement);
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.flowNode = void 0;
    return node;
  }
  function updateForInStatement(node, initializer, expression, statement) {
    return node.initializer !== initializer || node.expression !== expression || node.statement !== statement ? update(createForInStatement(initializer, expression, statement), node) : node;
  }
  function createForOfStatement(awaitModifier, initializer, expression, statement) {
    const node = createBaseNode(250 /* ForOfStatement */);
    node.awaitModifier = awaitModifier;
    node.initializer = initializer;
    node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
    node.statement = asEmbeddedStatement(statement);
    node.transformFlags |= propagateChildFlags(node.awaitModifier) | propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | 1024 /* ContainsES2015 */;
    if (awaitModifier) node.transformFlags |= 128 /* ContainsES2018 */;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.flowNode = void 0;
    return node;
  }
  function updateForOfStatement(node, awaitModifier, initializer, expression, statement) {
    return node.awaitModifier !== awaitModifier || node.initializer !== initializer || node.expression !== expression || node.statement !== statement ? update(createForOfStatement(awaitModifier, initializer, expression, statement), node) : node;
  }
  function createContinueStatement(label) {
    const node = createBaseNode(251 /* ContinueStatement */);
    node.label = asName(label);
    node.transformFlags |= propagateChildFlags(node.label) | 4194304 /* ContainsHoistedDeclarationOrCompletion */;
    node.jsDoc = void 0;
    node.flowNode = void 0;
    return node;
  }
  function updateContinueStatement(node, label) {
    return node.label !== label ? update(createContinueStatement(label), node) : node;
  }
  function createBreakStatement(label) {
    const node = createBaseNode(252 /* BreakStatement */);
    node.label = asName(label);
    node.transformFlags |= propagateChildFlags(node.label) | 4194304 /* ContainsHoistedDeclarationOrCompletion */;
    node.jsDoc = void 0;
    node.flowNode = void 0;
    return node;
  }
  function updateBreakStatement(node, label) {
    return node.label !== label ? update(createBreakStatement(label), node) : node;
  }
  function createReturnStatement(expression) {
    const node = createBaseNode(253 /* ReturnStatement */);
    node.expression = expression;
    node.transformFlags |= propagateChildFlags(node.expression) | 128 /* ContainsES2018 */ | 4194304 /* ContainsHoistedDeclarationOrCompletion */;
    node.jsDoc = void 0;
    node.flowNode = void 0;
    return node;
  }
  function updateReturnStatement(node, expression) {
    return node.expression !== expression ? update(createReturnStatement(expression), node) : node;
  }
  function createWithStatement(expression, statement) {
    const node = createBaseNode(254 /* WithStatement */);
    node.expression = expression;
    node.statement = asEmbeddedStatement(statement);
    node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.statement);
    node.jsDoc = void 0;
    node.flowNode = void 0;
    return node;
  }
  function updateWithStatement(node, expression, statement) {
    return node.expression !== expression || node.statement !== statement ? update(createWithStatement(expression, statement), node) : node;
  }
  function createSwitchStatement(expression, caseBlock) {
    const node = createBaseNode(255 /* SwitchStatement */);
    node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
    node.caseBlock = caseBlock;
    node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.caseBlock);
    node.jsDoc = void 0;
    node.flowNode = void 0;
    node.possiblyExhaustive = false;
    return node;
  }
  function updateSwitchStatement(node, expression, caseBlock) {
    return node.expression !== expression || node.caseBlock !== caseBlock ? update(createSwitchStatement(expression, caseBlock), node) : node;
  }
  function createLabeledStatement(label, statement) {
    const node = createBaseNode(256 /* LabeledStatement */);
    node.label = asName(label);
    node.statement = asEmbeddedStatement(statement);
    node.transformFlags |= propagateChildFlags(node.label) | propagateChildFlags(node.statement);
    node.jsDoc = void 0;
    node.flowNode = void 0;
    return node;
  }
  function updateLabeledStatement(node, label, statement) {
    return node.label !== label || node.statement !== statement ? update(createLabeledStatement(label, statement), node) : node;
  }
  function createThrowStatement(expression) {
    const node = createBaseNode(257 /* ThrowStatement */);
    node.expression = expression;
    node.transformFlags |= propagateChildFlags(node.expression);
    node.jsDoc = void 0;
    node.flowNode = void 0;
    return node;
  }
  function updateThrowStatement(node, expression) {
    return node.expression !== expression ? update(createThrowStatement(expression), node) : node;
  }
  function createTryStatement(tryBlock, catchClause, finallyBlock) {
    const node = createBaseNode(258 /* TryStatement */);
    node.tryBlock = tryBlock;
    node.catchClause = catchClause;
    node.finallyBlock = finallyBlock;
    node.transformFlags |= propagateChildFlags(node.tryBlock) | propagateChildFlags(node.catchClause) | propagateChildFlags(node.finallyBlock);
    node.jsDoc = void 0;
    node.flowNode = void 0;
    return node;
  }
  function updateTryStatement(node, tryBlock, catchClause, finallyBlock) {
    return node.tryBlock !== tryBlock || node.catchClause !== catchClause || node.finallyBlock !== finallyBlock ? update(createTryStatement(tryBlock, catchClause, finallyBlock), node) : node;
  }
  function createDebuggerStatement() {
    const node = createBaseNode(259 /* DebuggerStatement */);
    node.jsDoc = void 0;
    node.flowNode = void 0;
    return node;
  }
  function createVariableDeclaration(name, exclamationToken, type, initializer) {
    const node = createBaseDeclaration(260 /* VariableDeclaration */);
    node.name = asName(name);
    node.exclamationToken = exclamationToken;
    node.type = type;
    node.initializer = asInitializer(initializer);
    node.transformFlags |= propagateNameFlags(node.name) | propagateChildFlags(node.initializer) | (node.exclamationToken ?? node.type ? 1 /* ContainsTypeScript */ : 0 /* None */);
    node.jsDoc = void 0;
    return node;
  }
  function updateVariableDeclaration(node, name, exclamationToken, type, initializer) {
    return node.name !== name || node.type !== type || node.exclamationToken !== exclamationToken || node.initializer !== initializer ? update(createVariableDeclaration(name, exclamationToken, type, initializer), node) : node;
  }
  function createVariableDeclarationList(declarations, flags2 = 0 /* None */) {
    const node = createBaseNode(261 /* VariableDeclarationList */);
    node.flags |= flags2 & 7 /* BlockScoped */;
    node.declarations = createNodeArray(declarations);
    node.transformFlags |= propagateChildrenFlags(node.declarations) | 4194304 /* ContainsHoistedDeclarationOrCompletion */;
    if (flags2 & 7 /* BlockScoped */) {
      node.transformFlags |= 1024 /* ContainsES2015 */ | 262144 /* ContainsBlockScopedBinding */;
    }
    if (flags2 & 4 /* Using */) {
      node.transformFlags |= 4 /* ContainsESNext */;
    }
    return node;
  }
  function updateVariableDeclarationList(node, declarations) {
    return node.declarations !== declarations ? update(createVariableDeclarationList(declarations, node.flags), node) : node;
  }
  function createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
    const node = createBaseDeclaration(262 /* FunctionDeclaration */);
    node.modifiers = asNodeArray(modifiers);
    node.asteriskToken = asteriskToken;
    node.name = asName(name);
    node.typeParameters = asNodeArray(typeParameters);
    node.parameters = createNodeArray(parameters);
    node.type = type;
    node.body = body;
    if (!node.body || modifiersToFlags(node.modifiers) & 128 /* Ambient */) {
      node.transformFlags = 1 /* ContainsTypeScript */;
    } else {
      const isAsync = modifiersToFlags(node.modifiers) & 1024 /* Async */;
      const isGenerator = !!node.asteriskToken;
      const isAsyncGenerator = isAsync && isGenerator;
      node.transformFlags = propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.asteriskToken) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type) | propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */ | (isAsyncGenerator ? 128 /* ContainsES2018 */ : isAsync ? 256 /* ContainsES2017 */ : isGenerator ? 2048 /* ContainsGenerator */ : 0 /* None */) | (node.typeParameters || node.type ? 1 /* ContainsTypeScript */ : 0 /* None */) | 4194304 /* ContainsHoistedDeclarationOrCompletion */;
    }
    node.typeArguments = void 0;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.endFlowNode = void 0;
    node.returnFlowNode = void 0;
    return node;
  }
  function updateFunctionDeclaration(node, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
    return node.modifiers !== modifiers || node.asteriskToken !== asteriskToken || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body ? finishUpdateFunctionDeclaration(createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node;
  }
  function finishUpdateFunctionDeclaration(updated, original) {
    if (updated !== original) {
      if (updated.modifiers === original.modifiers) {
        updated.modifiers = original.modifiers;
      }
    }
    return finishUpdateBaseSignatureDeclaration(updated, original);
  }
  function createClassDeclaration(modifiers, name, typeParameters, heritageClauses, members) {
    const node = createBaseDeclaration(263 /* ClassDeclaration */);
    node.modifiers = asNodeArray(modifiers);
    node.name = asName(name);
    node.typeParameters = asNodeArray(typeParameters);
    node.heritageClauses = asNodeArray(heritageClauses);
    node.members = createNodeArray(members);
    if (modifiersToFlags(node.modifiers) & 128 /* Ambient */) {
      node.transformFlags = 1 /* ContainsTypeScript */;
    } else {
      node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateNameFlags(node.name) | propagateChildrenFlags(node.typeParameters) | propagateChildrenFlags(node.heritageClauses) | propagateChildrenFlags(node.members) | (node.typeParameters ? 1 /* ContainsTypeScript */ : 0 /* None */) | 1024 /* ContainsES2015 */;
      if (node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */) {
        node.transformFlags |= 1 /* ContainsTypeScript */;
      }
    }
    node.jsDoc = void 0;
    return node;
  }
  function updateClassDeclaration(node, modifiers, name, typeParameters, heritageClauses, members) {
    return node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members ? update(createClassDeclaration(modifiers, name, typeParameters, heritageClauses, members), node) : node;
  }
  function createInterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, members) {
    const node = createBaseDeclaration(264 /* InterfaceDeclaration */);
    node.modifiers = asNodeArray(modifiers);
    node.name = asName(name);
    node.typeParameters = asNodeArray(typeParameters);
    node.heritageClauses = asNodeArray(heritageClauses);
    node.members = createNodeArray(members);
    node.transformFlags = 1 /* ContainsTypeScript */;
    node.jsDoc = void 0;
    return node;
  }
  function updateInterfaceDeclaration(node, modifiers, name, typeParameters, heritageClauses, members) {
    return node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members ? update(createInterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, members), node) : node;
  }
  function createTypeAliasDeclaration(modifiers, name, typeParameters, type) {
    const node = createBaseDeclaration(265 /* TypeAliasDeclaration */);
    node.modifiers = asNodeArray(modifiers);
    node.name = asName(name);
    node.typeParameters = asNodeArray(typeParameters);
    node.type = type;
    node.transformFlags = 1 /* ContainsTypeScript */;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    return node;
  }
  function updateTypeAliasDeclaration(node, modifiers, name, typeParameters, type) {
    return node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.type !== type ? update(createTypeAliasDeclaration(modifiers, name, typeParameters, type), node) : node;
  }
  function createEnumDeclaration(modifiers, name, members) {
    const node = createBaseDeclaration(266 /* EnumDeclaration */);
    node.modifiers = asNodeArray(modifiers);
    node.name = asName(name);
    node.members = createNodeArray(members);
    node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.name) | propagateChildrenFlags(node.members) | 1 /* ContainsTypeScript */;
    node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
    node.jsDoc = void 0;
    return node;
  }
  function updateEnumDeclaration(node, modifiers, name, members) {
    return node.modifiers !== modifiers || node.name !== name || node.members !== members ? update(createEnumDeclaration(modifiers, name, members), node) : node;
  }
  function createModuleDeclaration(modifiers, name, body, flags2 = 0 /* None */) {
    const node = createBaseDeclaration(267 /* ModuleDeclaration */);
    node.modifiers = asNodeArray(modifiers);
    node.flags |= flags2 & (32 /* Namespace */ | 8 /* NestedNamespace */ | 2048 /* GlobalAugmentation */);
    node.name = name;
    node.body = body;
    if (modifiersToFlags(node.modifiers) & 128 /* Ambient */) {
      node.transformFlags = 1 /* ContainsTypeScript */;
    } else {
      node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.name) | propagateChildFlags(node.body) | 1 /* ContainsTypeScript */;
    }
    node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    return node;
  }
  function updateModuleDeclaration(node, modifiers, name, body) {
    return node.modifiers !== modifiers || node.name !== name || node.body !== body ? update(createModuleDeclaration(modifiers, name, body, node.flags), node) : node;
  }
  function createModuleBlock(statements) {
    const node = createBaseNode(268 /* ModuleBlock */);
    node.statements = createNodeArray(statements);
    node.transformFlags |= propagateChildrenFlags(node.statements);
    node.jsDoc = void 0;
    return node;
  }
  function updateModuleBlock(node, statements) {
    return node.statements !== statements ? update(createModuleBlock(statements), node) : node;
  }
  function createCaseBlock(clauses) {
    const node = createBaseNode(269 /* CaseBlock */);
    node.clauses = createNodeArray(clauses);
    node.transformFlags |= propagateChildrenFlags(node.clauses);
    node.locals = void 0;
    node.nextContainer = void 0;
    return node;
  }
  function updateCaseBlock(node, clauses) {
    return node.clauses !== clauses ? update(createCaseBlock(clauses), node) : node;
  }
  function createNamespaceExportDeclaration(name) {
    const node = createBaseDeclaration(270 /* NamespaceExportDeclaration */);
    node.name = asName(name);
    node.transformFlags |= propagateIdentifierNameFlags(node.name) | 1 /* ContainsTypeScript */;
    node.modifiers = void 0;
    node.jsDoc = void 0;
    return node;
  }
  function updateNamespaceExportDeclaration(node, name) {
    return node.name !== name ? finishUpdateNamespaceExportDeclaration(createNamespaceExportDeclaration(name), node) : node;
  }
  function finishUpdateNamespaceExportDeclaration(updated, original) {
    if (updated !== original) {
      updated.modifiers = original.modifiers;
    }
    return update(updated, original);
  }
  function createImportEqualsDeclaration(modifiers, isTypeOnly, name, moduleReference) {
    const node = createBaseDeclaration(271 /* ImportEqualsDeclaration */);
    node.modifiers = asNodeArray(modifiers);
    node.name = asName(name);
    node.isTypeOnly = isTypeOnly;
    node.moduleReference = moduleReference;
    node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateIdentifierNameFlags(node.name) | propagateChildFlags(node.moduleReference);
    if (!isExternalModuleReference(node.moduleReference)) {
      node.transformFlags |= 1 /* ContainsTypeScript */;
    }
    node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
    node.jsDoc = void 0;
    return node;
  }
  function updateImportEqualsDeclaration(node, modifiers, isTypeOnly, name, moduleReference) {
    return node.modifiers !== modifiers || node.isTypeOnly !== isTypeOnly || node.name !== name || node.moduleReference !== moduleReference ? update(createImportEqualsDeclaration(modifiers, isTypeOnly, name, moduleReference), node) : node;
  }
  function createImportDeclaration(modifiers, importClause, moduleSpecifier, attributes) {
    const node = createBaseNode(272 /* ImportDeclaration */);
    node.modifiers = asNodeArray(modifiers);
    node.importClause = importClause;
    node.moduleSpecifier = moduleSpecifier;
    node.attributes = node.assertClause = attributes;
    node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier);
    node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
    node.jsDoc = void 0;
    return node;
  }
  function updateImportDeclaration(node, modifiers, importClause, moduleSpecifier, attributes) {
    return node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier || node.attributes !== attributes ? update(createImportDeclaration(modifiers, importClause, moduleSpecifier, attributes), node) : node;
  }
  function createImportClause2(isTypeOnly, name, namedBindings) {
    const node = createBaseDeclaration(273 /* ImportClause */);
    node.isTypeOnly = isTypeOnly;
    node.name = name;
    node.namedBindings = namedBindings;
    node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.namedBindings);
    if (isTypeOnly) {
      node.transformFlags |= 1 /* ContainsTypeScript */;
    }
    node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
    return node;
  }
  function updateImportClause(node, isTypeOnly, name, namedBindings) {
    return node.isTypeOnly !== isTypeOnly || node.name !== name || node.namedBindings !== namedBindings ? update(createImportClause2(isTypeOnly, name, namedBindings), node) : node;
  }
  function createAssertClause(elements, multiLine) {
    const node = createBaseNode(300 /* AssertClause */);
    node.elements = createNodeArray(elements);
    node.multiLine = multiLine;
    node.token = 132 /* AssertKeyword */;
    node.transformFlags |= 4 /* ContainsESNext */;
    return node;
  }
  function updateAssertClause(node, elements, multiLine) {
    return node.elements !== elements || node.multiLine !== multiLine ? update(createAssertClause(elements, multiLine), node) : node;
  }
  function createAssertEntry(name, value) {
    const node = createBaseNode(301 /* AssertEntry */);
    node.name = name;
    node.value = value;
    node.transformFlags |= 4 /* ContainsESNext */;
    return node;
  }
  function updateAssertEntry(node, name, value) {
    return node.name !== name || node.value !== value ? update(createAssertEntry(name, value), node) : node;
  }
  function createImportTypeAssertionContainer(clause, multiLine) {
    const node = createBaseNode(302 /* ImportTypeAssertionContainer */);
    node.assertClause = clause;
    node.multiLine = multiLine;
    return node;
  }
  function updateImportTypeAssertionContainer(node, clause, multiLine) {
    return node.assertClause !== clause || node.multiLine !== multiLine ? update(createImportTypeAssertionContainer(clause, multiLine), node) : node;
  }
  function createImportAttributes(elements, multiLine, token) {
    const node = createBaseNode(300 /* ImportAttributes */);
    node.token = token ?? 118 /* WithKeyword */;
    node.elements = createNodeArray(elements);
    node.multiLine = multiLine;
    node.transformFlags |= 4 /* ContainsESNext */;
    return node;
  }
  function updateImportAttributes(node, elements, multiLine) {
    return node.elements !== elements || node.multiLine !== multiLine ? update(createImportAttributes(elements, multiLine, node.token), node) : node;
  }
  function createImportAttribute(name, value) {
    const node = createBaseNode(301 /* ImportAttribute */);
    node.name = name;
    node.value = value;
    node.transformFlags |= 4 /* ContainsESNext */;
    return node;
  }
  function updateImportAttribute(node, name, value) {
    return node.name !== name || node.value !== value ? update(createImportAttribute(name, value), node) : node;
  }
  function createNamespaceImport(name) {
    const node = createBaseDeclaration(274 /* NamespaceImport */);
    node.name = name;
    node.transformFlags |= propagateChildFlags(node.name);
    node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
    return node;
  }
  function updateNamespaceImport(node, name) {
    return node.name !== name ? update(createNamespaceImport(name), node) : node;
  }
  function createNamespaceExport(name) {
    const node = createBaseDeclaration(280 /* NamespaceExport */);
    node.name = name;
    node.transformFlags |= propagateChildFlags(node.name) | 32 /* ContainsES2020 */;
    node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
    return node;
  }
  function updateNamespaceExport(node, name) {
    return node.name !== name ? update(createNamespaceExport(name), node) : node;
  }
  function createNamedImports(elements) {
    const node = createBaseNode(275 /* NamedImports */);
    node.elements = createNodeArray(elements);
    node.transformFlags |= propagateChildrenFlags(node.elements);
    node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
    return node;
  }
  function updateNamedImports(node, elements) {
    return node.elements !== elements ? update(createNamedImports(elements), node) : node;
  }
  function createImportSpecifier(isTypeOnly, propertyName, name) {
    const node = createBaseDeclaration(276 /* ImportSpecifier */);
    node.isTypeOnly = isTypeOnly;
    node.propertyName = propertyName;
    node.name = name;
    node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name);
    node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
    return node;
  }
  function updateImportSpecifier(node, isTypeOnly, propertyName, name) {
    return node.isTypeOnly !== isTypeOnly || node.propertyName !== propertyName || node.name !== name ? update(createImportSpecifier(isTypeOnly, propertyName, name), node) : node;
  }
  function createExportAssignment2(modifiers, isExportEquals, expression) {
    const node = createBaseDeclaration(277 /* ExportAssignment */);
    node.modifiers = asNodeArray(modifiers);
    node.isExportEquals = isExportEquals;
    node.expression = isExportEquals ? parenthesizerRules().parenthesizeRightSideOfBinary(
      64 /* EqualsToken */,
      /*leftSide*/
      void 0,
      expression
    ) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression);
    node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.expression);
    node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
    node.jsDoc = void 0;
    return node;
  }
  function updateExportAssignment(node, modifiers, expression) {
    return node.modifiers !== modifiers || node.expression !== expression ? update(createExportAssignment2(modifiers, node.isExportEquals, expression), node) : node;
  }
  function createExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, attributes) {
    const node = createBaseDeclaration(278 /* ExportDeclaration */);
    node.modifiers = asNodeArray(modifiers);
    node.isTypeOnly = isTypeOnly;
    node.exportClause = exportClause;
    node.moduleSpecifier = moduleSpecifier;
    node.attributes = node.assertClause = attributes;
    node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier);
    node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
    node.jsDoc = void 0;
    return node;
  }
  function updateExportDeclaration(node, modifiers, isTypeOnly, exportClause, moduleSpecifier, attributes) {
    return node.modifiers !== modifiers || node.isTypeOnly !== isTypeOnly || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier || node.attributes !== attributes ? finishUpdateExportDeclaration(createExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, attributes), node) : node;
  }
  function finishUpdateExportDeclaration(updated, original) {
    if (updated !== original) {
      if (updated.modifiers === original.modifiers) {
        updated.modifiers = original.modifiers;
      }
    }
    return update(updated, original);
  }
  function createNamedExports(elements) {
    const node = createBaseNode(279 /* NamedExports */);
    node.elements = createNodeArray(elements);
    node.transformFlags |= propagateChildrenFlags(node.elements);
    node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
    return node;
  }
  function updateNamedExports(node, elements) {
    return node.elements !== elements ? update(createNamedExports(elements), node) : node;
  }
  function createExportSpecifier(isTypeOnly, propertyName, name) {
    const node = createBaseNode(281 /* ExportSpecifier */);
    node.isTypeOnly = isTypeOnly;
    node.propertyName = asName(propertyName);
    node.name = asName(name);
    node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name);
    node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
    node.jsDoc = void 0;
    return node;
  }
  function updateExportSpecifier(node, isTypeOnly, propertyName, name) {
    return node.isTypeOnly !== isTypeOnly || node.propertyName !== propertyName || node.name !== name ? update(createExportSpecifier(isTypeOnly, propertyName, name), node) : node;
  }
  function createMissingDeclaration() {
    const node = createBaseDeclaration(282 /* MissingDeclaration */);
    node.jsDoc = void 0;
    return node;
  }
  function createExternalModuleReference(expression) {
    const node = createBaseNode(283 /* ExternalModuleReference */);
    node.expression = expression;
    node.transformFlags |= propagateChildFlags(node.expression);
    node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */;
    return node;
  }
  function updateExternalModuleReference(node, expression) {
    return node.expression !== expression ? update(createExternalModuleReference(expression), node) : node;
  }
  function createJSDocPrimaryTypeWorker(kind) {
    return createBaseNode(kind);
  }
  function createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix = false) {
    const node = createJSDocUnaryTypeWorker(
      kind,
      postfix ? type && parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(type) : type
    );
    node.postfix = postfix;
    return node;
  }
  function createJSDocUnaryTypeWorker(kind, type) {
    const node = createBaseNode(kind);
    node.type = type;
    return node;
  }
  function updateJSDocPrePostfixUnaryTypeWorker(kind, node, type) {
    return node.type !== type ? update(createJSDocPrePostfixUnaryTypeWorker(kind, type, node.postfix), node) : node;
  }
  function updateJSDocUnaryTypeWorker(kind, node, type) {
    return node.type !== type ? update(createJSDocUnaryTypeWorker(kind, type), node) : node;
  }
  function createJSDocFunctionType(parameters, type) {
    const node = createBaseDeclaration(317 /* JSDocFunctionType */);
    node.parameters = asNodeArray(parameters);
    node.type = type;
    node.transformFlags = propagateChildrenFlags(node.parameters) | (node.type ? 1 /* ContainsTypeScript */ : 0 /* None */);
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    node.typeArguments = void 0;
    return node;
  }
  function updateJSDocFunctionType(node, parameters, type) {
    return node.parameters !== parameters || node.type !== type ? update(createJSDocFunctionType(parameters, type), node) : node;
  }
  function createJSDocTypeLiteral(propertyTags, isArrayType = false) {
    const node = createBaseDeclaration(322 /* JSDocTypeLiteral */);
    node.jsDocPropertyTags = asNodeArray(propertyTags);
    node.isArrayType = isArrayType;
    return node;
  }
  function updateJSDocTypeLiteral(node, propertyTags, isArrayType) {
    return node.jsDocPropertyTags !== propertyTags || node.isArrayType !== isArrayType ? update(createJSDocTypeLiteral(propertyTags, isArrayType), node) : node;
  }
  function createJSDocTypeExpression(type) {
    const node = createBaseNode(309 /* JSDocTypeExpression */);
    node.type = type;
    return node;
  }
  function updateJSDocTypeExpression(node, type) {
    return node.type !== type ? update(createJSDocTypeExpression(type), node) : node;
  }
  function createJSDocSignature(typeParameters, parameters, type) {
    const node = createBaseDeclaration(323 /* JSDocSignature */);
    node.typeParameters = asNodeArray(typeParameters);
    node.parameters = createNodeArray(parameters);
    node.type = type;
    node.jsDoc = void 0;
    node.locals = void 0;
    node.nextContainer = void 0;
    return node;
  }
  function updateJSDocSignature(node, typeParameters, parameters, type) {
    return node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type ? update(createJSDocSignature(typeParameters, parameters, type), node) : node;
  }
  function getDefaultTagName(node) {
    const defaultTagName = getDefaultTagNameForKind(node.kind);
    return node.tagName.escapedText === escapeLeadingUnderscores(defaultTagName) ? node.tagName : createIdentifier(defaultTagName);
  }
  function createBaseJSDocTag(kind, tagName, comment) {
    const node = createBaseNode(kind);
    node.tagName = tagName;
    node.comment = comment;
    return node;
  }
  function createBaseJSDocTagDeclaration(kind, tagName, comment) {
    const node = createBaseDeclaration(kind);
    node.tagName = tagName;
    node.comment = comment;
    return node;
  }
  function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) {
    const node = createBaseJSDocTag(345 /* JSDocTemplateTag */, tagName ?? createIdentifier("template"), comment);
    node.constraint = constraint;
    node.typeParameters = createNodeArray(typeParameters);
    return node;
  }
  function updateJSDocTemplateTag(node, tagName = getDefaultTagName(node), constraint, typeParameters, comment) {
    return node.tagName !== tagName || node.constraint !== constraint || node.typeParameters !== typeParameters || node.comment !== comment ? update(createJSDocTemplateTag(tagName, constraint, typeParameters, comment), node) : node;
  }
  function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) {
    const node = createBaseJSDocTagDeclaration(346 /* JSDocTypedefTag */, tagName ?? createIdentifier("typedef"), comment);
    node.typeExpression = typeExpression;
    node.fullName = fullName;
    node.name = getJSDocTypeAliasName(fullName);
    node.locals = void 0;
    node.nextContainer = void 0;
    return node;
  }
  function updateJSDocTypedefTag(node, tagName = getDefaultTagName(node), typeExpression, fullName, comment) {
    return node.tagName !== tagName || node.typeExpression !== typeExpression || node.fullName !== fullName || node.comment !== comment ? update(createJSDocTypedefTag(tagName, typeExpression, fullName, comment), node) : node;
  }
  function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) {
    const node = createBaseJSDocTagDeclaration(341 /* JSDocParameterTag */, tagName ?? createIdentifier("param"), comment);
    node.typeExpression = typeExpression;
    node.name = name;
    node.isNameFirst = !!isNameFirst;
    node.isBracketed = isBracketed;
    return node;
  }
  function updateJSDocParameterTag(node, tagName = getDefaultTagName(node), name, isBracketed, typeExpression, isNameFirst, comment) {
    return node.tagName !== tagName || node.name !== name || node.isBracketed !== isBracketed || node.typeExpression !== typeExpression || node.isNameFirst !== isNameFirst || node.comment !== comment ? update(createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment), node) : node;
  }
  function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) {
    const node = createBaseJSDocTagDeclaration(348 /* JSDocPropertyTag */, tagName ?? createIdentifier("prop"), comment);
    node.typeExpression = typeExpression;
    node.name = name;
    node.isNameFirst = !!isNameFirst;
    node.isBracketed = isBracketed;
    return node;
  }
  function updateJSDocPropertyTag(node, tagName = getDefaultTagName(node), name, isBracketed, typeExpression, isNameFirst, comment) {
    return node.tagName !== tagName || node.name !== name || node.isBracketed !== isBracketed || node.typeExpression !== typeExpression || node.isNameFirst !== isNameFirst || node.comment !== comment ? update(createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment), node) : node;
  }
  function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) {
    const node = createBaseJSDocTagDeclaration(338 /* JSDocCallbackTag */, tagName ?? createIdentifier("callback"), comment);
    node.typeExpression = typeExpression;
    node.fullName = fullName;
    node.name = getJSDocTypeAliasName(fullName);
    node.locals = void 0;
    node.nextContainer = void 0;
    return node;
  }
  function updateJSDocCallbackTag(node, tagName = getDefaultTagName(node), typeExpression, fullName, comment) {
    return node.tagName !== tagName || node.typeExpression !== typeExpression || node.fullName !== fullName || node.comment !== comment ? update(createJSDocCallbackTag(tagName, typeExpression, fullName, comment), node) : node;
  }
  function createJSDocOverloadTag(tagName, typeExpression, comment) {
    const node = createBaseJSDocTag(339 /* JSDocOverloadTag */, tagName ?? createIdentifier("overload"), comment);
    node.typeExpression = typeExpression;
    return node;
  }
  function updateJSDocOverloadTag(node, tagName = getDefaultTagName(node), typeExpression, comment) {
    return node.tagName !== tagName || node.typeExpression !== typeExpression || node.comment !== comment ? update(createJSDocOverloadTag(tagName, typeExpression, comment), node) : node;
  }
  function createJSDocAugmentsTag(tagName, className, comment) {
    const node = createBaseJSDocTag(328 /* JSDocAugmentsTag */, tagName ?? createIdentifier("augments"), comment);
    node.class = className;
    return node;
  }
  function updateJSDocAugmentsTag(node, tagName = getDefaultTagName(node), className, comment) {
    return node.tagName !== tagName || node.class !== className || node.comment !== comment ? update(createJSDocAugmentsTag(tagName, className, comment), node) : node;
  }
  function createJSDocImplementsTag(tagName, className, comment) {
    const node = createBaseJSDocTag(329 /* JSDocImplementsTag */, tagName ?? createIdentifier("implements"), comment);
    node.class = className;
    return node;
  }
  function createJSDocSeeTag(tagName, name, comment) {
    const node = createBaseJSDocTag(347 /* JSDocSeeTag */, tagName ?? createIdentifier("see"), comment);
    node.name = name;
    return node;
  }
  function updateJSDocSeeTag(node, tagName, name, comment) {
    return node.tagName !== tagName || node.name !== name || node.comment !== comment ? update(createJSDocSeeTag(tagName, name, comment), node) : node;
  }
  function createJSDocNameReference(name) {
    const node = createBaseNode(310 /* JSDocNameReference */);
    node.name = name;
    return node;
  }
  function updateJSDocNameReference(node, name) {
    return node.name !== name ? update(createJSDocNameReference(name), node) : node;
  }
  function createJSDocMemberName(left, right) {
    const node = createBaseNode(311 /* JSDocMemberName */);
    node.left = left;
    node.right = right;
    node.transformFlags |= propagateChildFlags(node.left) | propagateChildFlags(node.right);
    return node;
  }
  function updateJSDocMemberName(node, left, right) {
    return node.left !== left || node.right !== right ? update(createJSDocMemberName(left, right), node) : node;
  }
  function createJSDocLink(name, text) {
    const node = createBaseNode(324 /* JSDocLink */);
    node.name = name;
    node.text = text;
    return node;
  }
  function updateJSDocLink(node, name, text) {
    return node.name !== name ? update(createJSDocLink(name, text), node) : node;
  }
  function createJSDocLinkCode(name, text) {
    const node = createBaseNode(325 /* JSDocLinkCode */);
    node.name = name;
    node.text = text;
    return node;
  }
  function updateJSDocLinkCode(node, name, text) {
    return node.name !== name ? update(createJSDocLinkCode(name, text), node) : node;
  }
  function createJSDocLinkPlain(name, text) {
    const node = createBaseNode(326 /* JSDocLinkPlain */);
    node.name = name;
    node.text = text;
    return node;
  }
  function updateJSDocLinkPlain(node, name, text) {
    return node.name !== name ? update(createJSDocLinkPlain(name, text), node) : node;
  }
  function updateJSDocImplementsTag(node, tagName = getDefaultTagName(node), className, comment) {
    return node.tagName !== tagName || node.class !== className || node.comment !== comment ? update(createJSDocImplementsTag(tagName, className, comment), node) : node;
  }
  function createJSDocSimpleTagWorker(kind, tagName, comment) {
    const node = createBaseJSDocTag(kind, tagName ?? createIdentifier(getDefaultTagNameForKind(kind)), comment);
    return node;
  }
  function updateJSDocSimpleTagWorker(kind, node, tagName = getDefaultTagName(node), comment) {
    return node.tagName !== tagName || node.comment !== comment ? update(createJSDocSimpleTagWorker(kind, tagName, comment), node) : node;
  }
  function createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment) {
    const node = createBaseJSDocTag(kind, tagName ?? createIdentifier(getDefaultTagNameForKind(kind)), comment);
    node.typeExpression = typeExpression;
    return node;
  }
  function updateJSDocTypeLikeTagWorker(kind, node, tagName = getDefaultTagName(node), typeExpression, comment) {
    return node.tagName !== tagName || node.typeExpression !== typeExpression || node.comment !== comment ? update(createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment), node) : node;
  }
  function createJSDocUnknownTag(tagName, comment) {
    const node = createBaseJSDocTag(327 /* JSDocTag */, tagName, comment);
    return node;
  }
  function updateJSDocUnknownTag(node, tagName, comment) {
    return node.tagName !== tagName || node.comment !== comment ? update(createJSDocUnknownTag(tagName, comment), node) : node;
  }
  function createJSDocEnumTag(tagName, typeExpression, comment) {
    const node = createBaseJSDocTagDeclaration(340 /* JSDocEnumTag */, tagName ?? createIdentifier(getDefaultTagNameForKind(340 /* JSDocEnumTag */)), comment);
    node.typeExpression = typeExpression;
    node.locals = void 0;
    node.nextContainer = void 0;
    return node;
  }
  function updateJSDocEnumTag(node, tagName = getDefaultTagName(node), typeExpression, comment) {
    return node.tagName !== tagName || node.typeExpression !== typeExpression || node.comment !== comment ? update(createJSDocEnumTag(tagName, typeExpression, comment), node) : node;
  }
  function createJSDocImportTag(tagName, importClause, moduleSpecifier, attributes, comment) {
    const node = createBaseJSDocTag(351 /* JSDocImportTag */, tagName ?? createIdentifier("import"), comment);
    node.importClause = importClause;
    node.moduleSpecifier = moduleSpecifier;
    node.attributes = attributes;
    node.comment = comment;
    return node;
  }
  function updateJSDocImportTag(node, tagName, importClause, moduleSpecifier, attributes, comment) {
    return node.tagName !== tagName || node.comment !== comment || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier || node.attributes !== attributes ? update(createJSDocImportTag(tagName, importClause, moduleSpecifier, attributes, comment), node) : node;
  }
  function createJSDocText(text) {
    const node = createBaseNode(321 /* JSDocText */);
    node.text = text;
    return node;
  }
  function updateJSDocText(node, text) {
    return node.text !== text ? update(createJSDocText(text), node) : node;
  }
  function createJSDocComment(comment, tags) {
    const node = createBaseNode(320 /* JSDoc */);
    node.comment = comment;
    node.tags = asNodeArray(tags);
    return node;
  }
  function updateJSDocComment(node, comment, tags) {
    return node.comment !== comment || node.tags !== tags ? update(createJSDocComment(comment, tags), node) : node;
  }
  function createJsxElement(openingElement, children, closingElement) {
    const node = createBaseNode(284 /* JsxElement */);
    node.openingElement = openingElement;
    node.children = createNodeArray(children);
    node.closingElement = closingElement;
    node.transformFlags |= propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingElement) | 2 /* ContainsJsx */;
    return node;
  }
  function updateJsxElement(node, openingElement, children, closingElement) {
    return node.openingElement !== openingElement || node.children !== children || node.closingElement !== closingElement ? update(createJsxElement(openingElement, children, closingElement), node) : node;
  }
  function createJsxSelfClosingElement(tagName, typeArguments, attributes) {
    const node = createBaseNode(285 /* JsxSelfClosingElement */);
    node.tagName = tagName;
    node.typeArguments = asNodeArray(typeArguments);
    node.attributes = attributes;
    node.transformFlags |= propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | 2 /* ContainsJsx */;
    if (node.typeArguments) {
      node.transformFlags |= 1 /* ContainsTypeScript */;
    }
    return node;
  }
  function updateJsxSelfClosingElement(node, tagName, typeArguments, attributes) {
    return node.tagName !== tagName || node.typeArguments !== typeArguments || node.attributes !== attributes ? update(createJsxSelfClosingElement(tagName, typeArguments, attributes), node) : node;
  }
  function createJsxOpeningElement(tagName, typeArguments, attributes) {
    const node = createBaseNode(286 /* JsxOpeningElement */);
    node.tagName = tagName;
    node.typeArguments = asNodeArray(typeArguments);
    node.attributes = attributes;
    node.transformFlags |= propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | 2 /* ContainsJsx */;
    if (typeArguments) {
      node.transformFlags |= 1 /* ContainsTypeScript */;
    }
    return node;
  }
  function updateJsxOpeningElement(node, tagName, typeArguments, attributes) {
    return node.tagName !== tagName || node.typeArguments !== typeArguments || node.attributes !== attributes ? update(createJsxOpeningElement(tagName, typeArguments, attributes), node) : node;
  }
  function createJsxClosingElement(tagName) {
    const node = createBaseNode(287 /* JsxClosingElement */);
    node.tagName = tagName;
    node.transformFlags |= propagateChildFlags(node.tagName) | 2 /* ContainsJsx */;
    return node;
  }
  function updateJsxClosingElement(node, tagName) {
    return node.tagName !== tagName ? update(createJsxClosingElement(tagName), node) : node;
  }
  function createJsxFragment(openingFragment, children, closingFragment) {
    const node = createBaseNode(288 /* JsxFragment */);
    node.openingFragment = openingFragment;
    node.children = createNodeArray(children);
    node.closingFragment = closingFragment;
    node.transformFlags |= propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingFragment) | 2 /* ContainsJsx */;
    return node;
  }
  function updateJsxFragment(node, openingFragment, children, closingFragment) {
    return node.openingFragment !== openingFragment || node.children !== children || node.closingFragment !== closingFragment ? update(createJsxFragment(openingFragment, children, closingFragment), node) : node;
  }
  function createJsxText(text, containsOnlyTriviaWhiteSpaces) {
    const node = createBaseNode(12 /* JsxText */);
    node.text = text;
    node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces;
    node.transformFlags |= 2 /* ContainsJsx */;
    return node;
  }
  function updateJsxText(node, text, containsOnlyTriviaWhiteSpaces) {
    return node.text !== text || node.containsOnlyTriviaWhiteSpaces !== containsOnlyTriviaWhiteSpaces ? update(createJsxText(text, containsOnlyTriviaWhiteSpaces), node) : node;
  }
  function createJsxOpeningFragment() {
    const node = createBaseNode(289 /* JsxOpeningFragment */);
    node.transformFlags |= 2 /* ContainsJsx */;
    return node;
  }
  function createJsxJsxClosingFragment() {
    const node = createBaseNode(290 /* JsxClosingFragment */);
    node.transformFlags |= 2 /* ContainsJsx */;
    return node;
  }
  function createJsxAttribute(name, initializer) {
    const node = createBaseDeclaration(291 /* JsxAttribute */);
    node.name = name;
    node.initializer = initializer;
    node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | 2 /* ContainsJsx */;
    return node;
  }
  function updateJsxAttribute(node, name, initializer) {
    return node.name !== name || node.initializer !== initializer ? update(createJsxAttribute(name, initializer), node) : node;
  }
  function createJsxAttributes(properties) {
    const node = createBaseDeclaration(292 /* JsxAttributes */);
    node.properties = createNodeArray(properties);
    node.transformFlags |= propagateChildrenFlags(node.properties) | 2 /* ContainsJsx */;
    return node;
  }
  function updateJsxAttributes(node, properties) {
    return node.properties !== properties ? update(createJsxAttributes(properties), node) : node;
  }
  function createJsxSpreadAttribute(expression) {
    const node = createBaseNode(293 /* JsxSpreadAttribute */);
    node.expression = expression;
    node.transformFlags |= propagateChildFlags(node.expression) | 2 /* ContainsJsx */;
    return node;
  }
  function updateJsxSpreadAttribute(node, expression) {
    return node.expression !== expression ? update(createJsxSpreadAttribute(expression), node) : node;
  }
  function createJsxExpression(dotDotDotToken, expression) {
    const node = createBaseNode(294 /* JsxExpression */);
    node.dotDotDotToken = dotDotDotToken;
    node.expression = expression;
    node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.expression) | 2 /* ContainsJsx */;
    return node;
  }
  function updateJsxExpression(node, expression) {
    return node.expression !== expression ? update(createJsxExpression(node.dotDotDotToken, expression), node) : node;
  }
  function createJsxNamespacedName(namespace, name) {
    const node = createBaseNode(295 /* JsxNamespacedName */);
    node.namespace = namespace;
    node.name = name;
    node.transformFlags |= propagateChildFlags(node.namespace) | propagateChildFlags(node.name) | 2 /* ContainsJsx */;
    return node;
  }
  function updateJsxNamespacedName(node, namespace, name) {
    return node.namespace !== namespace || node.name !== name ? update(createJsxNamespacedName(namespace, name), node) : node;
  }
  function createCaseClause(expression, statements) {
    const node = createBaseNode(296 /* CaseClause */);
    node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
    node.statements = createNodeArray(statements);
    node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.statements);
    node.jsDoc = void 0;
    return node;
  }
  function updateCaseClause(node, expression, statements) {
    return node.expression !== expression || node.statements !== statements ? update(createCaseClause(expression, statements), node) : node;
  }
  function createDefaultClause(statements) {
    const node = createBaseNode(297 /* DefaultClause */);
    node.statements = createNodeArray(statements);
    node.transformFlags = propagateChildrenFlags(node.statements);
    return node;
  }
  function updateDefaultClause(node, statements) {
    return node.statements !== statements ? update(createDefaultClause(statements), node) : node;
  }
  function createHeritageClause(token, types) {
    const node = createBaseNode(298 /* HeritageClause */);
    node.token = token;
    node.types = createNodeArray(types);
    node.transformFlags |= propagateChildrenFlags(node.types);
    switch (token) {
      case 96 /* ExtendsKeyword */:
        node.transformFlags |= 1024 /* ContainsES2015 */;
        break;
      case 119 /* ImplementsKeyword */:
        node.transformFlags |= 1 /* ContainsTypeScript */;
        break;
      default:
        return Debug.assertNever(token);
    }
    return node;
  }
  function updateHeritageClause(node, types) {
    return node.types !== types ? update(createHeritageClause(node.token, types), node) : node;
  }
  function createCatchClause(variableDeclaration, block) {
    const node = createBaseNode(299 /* CatchClause */);
    node.variableDeclaration = asVariableDeclaration(variableDeclaration);
    node.block = block;
    node.transformFlags |= propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block) | (!variableDeclaration ? 64 /* ContainsES2019 */ : 0 /* None */);
    node.locals = void 0;
    node.nextContainer = void 0;
    return node;
  }
  function updateCatchClause(node, variableDeclaration, block) {
    return node.variableDeclaration !== variableDeclaration || node.block !== block ? update(createCatchClause(variableDeclaration, block), node) : node;
  }
  function createPropertyAssignment(name, initializer) {
    const node = createBaseDeclaration(303 /* PropertyAssignment */);
    node.name = asName(name);
    node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer);
    node.transformFlags |= propagateNameFlags(node.name) | propagateChildFlags(node.initializer);
    node.modifiers = void 0;
    node.questionToken = void 0;
    node.exclamationToken = void 0;
    node.jsDoc = void 0;
    return node;
  }
  function updatePropertyAssignment(node, name, initializer) {
    return node.name !== name || node.initializer !== initializer ? finishUpdatePropertyAssignment(createPropertyAssignment(name, initializer), node) : node;
  }
  function finishUpdatePropertyAssignment(updated, original) {
    if (updated !== original) {
      updated.modifiers = original.modifiers;
      updated.questionToken = original.questionToken;
      updated.exclamationToken = original.exclamationToken;
    }
    return update(updated, original);
  }
  function createShorthandPropertyAssignment(name, objectAssignmentInitializer) {
    const node = createBaseDeclaration(304 /* ShorthandPropertyAssignment */);
    node.name = asName(name);
    node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer);
    node.transformFlags |= propagateIdentifierNameFlags(node.name) | propagateChildFlags(node.objectAssignmentInitializer) | 1024 /* ContainsES2015 */;
    node.equalsToken = void 0;
    node.modifiers = void 0;
    node.questionToken = void 0;
    node.exclamationToken = void 0;
    node.jsDoc = void 0;
    return node;
  }
  function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) {
    return node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer ? finishUpdateShorthandPropertyAssignment(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node) : node;
  }
  function finishUpdateShorthandPropertyAssignment(updated, original) {
    if (updated !== original) {
      updated.modifiers = original.modifiers;
      updated.questionToken = original.questionToken;
      updated.exclamationToken = original.exclamationToken;
      updated.equalsToken = original.equalsToken;
    }
    return update(updated, original);
  }
  function createSpreadAssignment(expression) {
    const node = createBaseDeclaration(305 /* SpreadAssignment */);
    node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
    node.transformFlags |= propagateChildFlags(node.expression) | 128 /* ContainsES2018 */ | 65536 /* ContainsObjectRestOrSpread */;
    node.jsDoc = void 0;
    return node;
  }
  function updateSpreadAssignment(node, expression) {
    return node.expression !== expression ? update(createSpreadAssignment(expression), node) : node;
  }
  function createEnumMember(name, initializer) {
    const node = createBaseDeclaration(306 /* EnumMember */);
    node.name = asName(name);
    node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer);
    node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | 1 /* ContainsTypeScript */;
    node.jsDoc = void 0;
    return node;
  }
  function updateEnumMember(node, name, initializer) {
    return node.name !== name || node.initializer !== initializer ? update(createEnumMember(name, initializer), node) : node;
  }
  function createSourceFile2(statements, endOfFileToken, flags2) {
    const node = baseFactory2.createBaseSourceFileNode(307 /* SourceFile */);
    node.statements = createNodeArray(statements);
    node.endOfFileToken = endOfFileToken;
    node.flags |= flags2;
    node.text = "";
    node.fileName = "";
    node.path = "";
    node.resolvedPath = "";
    node.originalFileName = "";
    node.languageVersion = 1 /* ES5 */;
    node.languageVariant = 0;
    node.scriptKind = 0;
    node.isDeclarationFile = false;
    node.hasNoDefaultLib = false;
    node.transformFlags |= propagateChildrenFlags(node.statements) | propagateChildFlags(node.endOfFileToken);
    node.locals = void 0;
    node.nextContainer = void 0;
    node.endFlowNode = void 0;
    node.nodeCount = 0;
    node.identifierCount = 0;
    node.symbolCount = 0;
    node.parseDiagnostics = void 0;
    node.bindDiagnostics = void 0;
    node.bindSuggestionDiagnostics = void 0;
    node.lineMap = void 0;
    node.externalModuleIndicator = void 0;
    node.setExternalModuleIndicator = void 0;
    node.pragmas = void 0;
    node.checkJsDirective = void 0;
    node.referencedFiles = void 0;
    node.typeReferenceDirectives = void 0;
    node.libReferenceDirectives = void 0;
    node.amdDependencies = void 0;
    node.commentDirectives = void 0;
    node.identifiers = void 0;
    node.packageJsonLocations = void 0;
    node.packageJsonScope = void 0;
    node.imports = void 0;
    node.moduleAugmentations = void 0;
    node.ambientModuleNames = void 0;
    node.classifiableNames = void 0;
    node.impliedNodeFormat = void 0;
    return node;
  }
  function createRedirectedSourceFile(redirectInfo) {
    const node = Object.create(redirectInfo.redirectTarget);
    Object.defineProperties(node, {
      id: {
        get() {
          return this.redirectInfo.redirectTarget.id;
        },
        set(value) {
          this.redirectInfo.redirectTarget.id = value;
        }
      },
      symbol: {
        get() {
          return this.redirectInfo.redirectTarget.symbol;
        },
        set(value) {
          this.redirectInfo.redirectTarget.symbol = value;
        }
      }
    });
    node.redirectInfo = redirectInfo;
    return node;
  }
  function cloneRedirectedSourceFile(source) {
    const node = createRedirectedSourceFile(source.redirectInfo);
    node.flags |= source.flags & ~16 /* Synthesized */;
    node.fileName = source.fileName;
    node.path = source.path;
    node.resolvedPath = source.resolvedPath;
    node.originalFileName = source.originalFileName;
    node.packageJsonLocations = source.packageJsonLocations;
    node.packageJsonScope = source.packageJsonScope;
    node.emitNode = void 0;
    return node;
  }
  function cloneSourceFileWorker(source) {
    const node = baseFactory2.createBaseSourceFileNode(307 /* SourceFile */);
    node.flags |= source.flags & ~16 /* Synthesized */;
    for (const p in source) {
      if (hasProperty(node, p) || !hasProperty(source, p)) {
        continue;
      }
      if (p === "emitNode") {
        node.emitNode = void 0;
        continue;
      }
      node[p] = source[p];
    }
    return node;
  }
  function cloneSourceFile(source) {
    const node = source.redirectInfo ? cloneRedirectedSourceFile(source) : cloneSourceFileWorker(source);
    setOriginal(node, source);
    return node;
  }
  function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) {
    const node = cloneSourceFile(source);
    node.statements = createNodeArray(statements);
    node.isDeclarationFile = isDeclarationFile;
    node.referencedFiles = referencedFiles;
    node.typeReferenceDirectives = typeReferences;
    node.hasNoDefaultLib = hasNoDefaultLib;
    node.libReferenceDirectives = libReferences;
    node.transformFlags = propagateChildrenFlags(node.statements) | propagateChildFlags(node.endOfFileToken);
    return node;
  }
  function updateSourceFile2(node, statements, isDeclarationFile = node.isDeclarationFile, referencedFiles = node.referencedFiles, typeReferenceDirectives = node.typeReferenceDirectives, hasNoDefaultLib = node.hasNoDefaultLib, libReferenceDirectives = node.libReferenceDirectives) {
    return node.statements !== statements || node.isDeclarationFile !== isDeclarationFile || node.referencedFiles !== referencedFiles || node.typeReferenceDirectives !== typeReferenceDirectives || node.hasNoDefaultLib !== hasNoDefaultLib || node.libReferenceDirectives !== libReferenceDirectives ? update(cloneSourceFileWithChanges(node, statements, isDeclarationFile, referencedFiles, typeReferenceDirectives, hasNoDefaultLib, libReferenceDirectives), node) : node;
  }
  function createBundle(sourceFiles) {
    const node = createBaseNode(308 /* Bundle */);
    node.sourceFiles = sourceFiles;
    node.syntheticFileReferences = void 0;
    node.syntheticTypeReferences = void 0;
    node.syntheticLibReferences = void 0;
    node.hasNoDefaultLib = void 0;
    return node;
  }
  function updateBundle(node, sourceFiles) {
    return node.sourceFiles !== sourceFiles ? update(createBundle(sourceFiles), node) : node;
  }
  function createSyntheticExpression(type, isSpread = false, tupleNameSource) {
    const node = createBaseNode(237 /* SyntheticExpression */);
    node.type = type;
    node.isSpread = isSpread;
    node.tupleNameSource = tupleNameSource;
    return node;
  }
  function createSyntaxList3(children) {
    const node = createBaseNode(352 /* SyntaxList */);
    node._children = children;
    return node;
  }
  function createNotEmittedStatement(original) {
    const node = createBaseNode(353 /* NotEmittedStatement */);
    node.original = original;
    setTextRange(node, original);
    return node;
  }
  function createPartiallyEmittedExpression(expression, original) {
    const node = createBaseNode(355 /* PartiallyEmittedExpression */);
    node.expression = expression;
    node.original = original;
    node.transformFlags |= propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */;
    setTextRange(node, original);
    return node;
  }
  function updatePartiallyEmittedExpression(node, expression) {
    return node.expression !== expression ? update(createPartiallyEmittedExpression(expression, node.original), node) : node;
  }
  function createNotEmittedTypeElement() {
    return createBaseNode(354 /* NotEmittedTypeElement */);
  }
  function flattenCommaElements(node) {
    if (nodeIsSynthesized(node) && !isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) {
      if (isCommaListExpression(node)) {
        return node.elements;
      }
      if (isBinaryExpression(node) && isCommaToken(node.operatorToken)) {
        return [node.left, node.right];
      }
    }
    return node;
  }
  function createCommaListExpression(elements) {
    const node = createBaseNode(356 /* CommaListExpression */);
    node.elements = createNodeArray(sameFlatMap(elements, flattenCommaElements));
    node.transformFlags |= propagateChildrenFlags(node.elements);
    return node;
  }
  function updateCommaListExpression(node, elements) {
    return node.elements !== elements ? update(createCommaListExpression(elements), node) : node;
  }
  function createSyntheticReferenceExpression(expression, thisArg) {
    const node = createBaseNode(357 /* SyntheticReferenceExpression */);
    node.expression = expression;
    node.thisArg = thisArg;
    node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.thisArg);
    return node;
  }
  function updateSyntheticReferenceExpression(node, expression, thisArg) {
    return node.expression !== expression || node.thisArg !== thisArg ? update(createSyntheticReferenceExpression(expression, thisArg), node) : node;
  }
  function cloneGeneratedIdentifier(node) {
    const clone2 = createBaseIdentifier(node.escapedText);
    clone2.flags |= node.flags & ~16 /* Synthesized */;
    clone2.transformFlags = node.transformFlags;
    setOriginal(clone2, node);
    setIdentifierAutoGenerate(clone2, { ...node.emitNode.autoGenerate });
    return clone2;
  }
  function cloneIdentifier(node) {
    const clone2 = createBaseIdentifier(node.escapedText);
    clone2.flags |= node.flags & ~16 /* Synthesized */;
    clone2.jsDoc = node.jsDoc;
    clone2.flowNode = node.flowNode;
    clone2.symbol = node.symbol;
    clone2.transformFlags = node.transformFlags;
    setOriginal(clone2, node);
    const typeArguments = getIdentifierTypeArguments(node);
    if (typeArguments) setIdentifierTypeArguments(clone2, typeArguments);
    return clone2;
  }
  function cloneGeneratedPrivateIdentifier(node) {
    const clone2 = createBasePrivateIdentifier(node.escapedText);
    clone2.flags |= node.flags & ~16 /* Synthesized */;
    clone2.transformFlags = node.transformFlags;
    setOriginal(clone2, node);
    setIdentifierAutoGenerate(clone2, { ...node.emitNode.autoGenerate });
    return clone2;
  }
  function clonePrivateIdentifier(node) {
    const clone2 = createBasePrivateIdentifier(node.escapedText);
    clone2.flags |= node.flags & ~16 /* Synthesized */;
    clone2.transformFlags = node.transformFlags;
    setOriginal(clone2, node);
    return clone2;
  }
  function cloneNode(node) {
    if (node === void 0) {
      return node;
    }
    if (isSourceFile(node)) {
      return cloneSourceFile(node);
    }
    if (isGeneratedIdentifier(node)) {
      return cloneGeneratedIdentifier(node);
    }
    if (isIdentifier(node)) {
      return cloneIdentifier(node);
    }
    if (isGeneratedPrivateIdentifier(node)) {
      return cloneGeneratedPrivateIdentifier(node);
    }
    if (isPrivateIdentifier(node)) {
      return clonePrivateIdentifier(node);
    }
    const clone2 = !isNodeKind(node.kind) ? baseFactory2.createBaseTokenNode(node.kind) : baseFactory2.createBaseNode(node.kind);
    clone2.flags |= node.flags & ~16 /* Synthesized */;
    clone2.transformFlags = node.transformFlags;
    setOriginal(clone2, node);
    for (const key in node) {
      if (hasProperty(clone2, key) || !hasProperty(node, key)) {
        continue;
      }
      clone2[key] = node[key];
    }
    return clone2;
  }
  function createImmediatelyInvokedFunctionExpression(statements, param, paramValue) {
    return createCallExpression(
      createFunctionExpression(
        /*modifiers*/
        void 0,
        /*asteriskToken*/
        void 0,
        /*name*/
        void 0,
        /*typeParameters*/
        void 0,
        /*parameters*/
        param ? [param] : [],
        /*type*/
        void 0,
        createBlock(
          statements,
          /*multiLine*/
          true
        )
      ),
      /*typeArguments*/
      void 0,
      /*argumentsArray*/
      paramValue ? [paramValue] : []
    );
  }
  function createImmediatelyInvokedArrowFunction(statements, param, paramValue) {
    return createCallExpression(
      createArrowFunction(
        /*modifiers*/
        void 0,
        /*typeParameters*/
        void 0,
        /*parameters*/
        param ? [param] : [],
        /*type*/
        void 0,
        /*equalsGreaterThanToken*/
        void 0,
        createBlock(
          statements,
          /*multiLine*/
          true
        )
      ),
      /*typeArguments*/
      void 0,
      /*argumentsArray*/
      paramValue ? [paramValue] : []
    );
  }
  function createVoidZero() {
    return createVoidExpression(createNumericLiteral("0"));
  }
  function createExportDefault(expression) {
    return createExportAssignment2(
      /*modifiers*/
      void 0,
      /*isExportEquals*/
      false,
      expression
    );
  }
  function createExternalModuleExport(exportName) {
    return createExportDeclaration(
      /*modifiers*/
      void 0,
      /*isTypeOnly*/
      false,
      createNamedExports([
        createExportSpecifier(
          /*isTypeOnly*/
          false,
          /*propertyName*/
          void 0,
          exportName
        )
      ])
    );
  }
  function createTypeCheck(value, tag) {
    return tag === "null" ? factory2.createStrictEquality(value, createNull()) : tag === "undefined" ? factory2.createStrictEquality(value, createVoidZero()) : factory2.createStrictEquality(createTypeOfExpression(value), createStringLiteral(tag));
  }
  function createIsNotTypeCheck(value, tag) {
    return tag === "null" ? factory2.createStrictInequality(value, createNull()) : tag === "undefined" ? factory2.createStrictInequality(value, createVoidZero()) : factory2.createStrictInequality(createTypeOfExpression(value), createStringLiteral(tag));
  }
  function createMethodCall(object, methodName, argumentsList) {
    if (isCallChain(object)) {
      return createCallChain(
        createPropertyAccessChain(
          object,
          /*questionDotToken*/
          void 0,
          methodName
        ),
        /*questionDotToken*/
        void 0,
        /*typeArguments*/
        void 0,
        argumentsList
      );
    }
    return createCallExpression(
      createPropertyAccessExpression(object, methodName),
      /*typeArguments*/
      void 0,
      argumentsList
    );
  }
  function createFunctionBindCall(target, thisArg, argumentsList) {
    return createMethodCall(target, "bind", [thisArg, ...argumentsList]);
  }
  function createFunctionCallCall(target, thisArg, argumentsList) {
    return createMethodCall(target, "call", [thisArg, ...argumentsList]);
  }
  function createFunctionApplyCall(target, thisArg, argumentsExpression) {
    return createMethodCall(target, "apply", [thisArg, argumentsExpression]);
  }
  function createGlobalMethodCall(globalObjectName, methodName, argumentsList) {
    return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList);
  }
  function createArraySliceCall(array, start) {
    return createMethodCall(array, "slice", start === void 0 ? [] : [asExpression(start)]);
  }
  function createArrayConcatCall(array, argumentsList) {
    return createMethodCall(array, "concat", argumentsList);
  }
  function createObjectDefinePropertyCall(target, propertyName, attributes) {
    return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]);
  }
  function createObjectGetOwnPropertyDescriptorCall(target, propertyName) {
    return createGlobalMethodCall("Object", "getOwnPropertyDescriptor", [target, asExpression(propertyName)]);
  }
  function createReflectGetCall(target, propertyKey, receiver) {
    return createGlobalMethodCall("Reflect", "get", receiver ? [target, propertyKey, receiver] : [target, propertyKey]);
  }
  function createReflectSetCall(target, propertyKey, value, receiver) {
    return createGlobalMethodCall("Reflect", "set", receiver ? [target, propertyKey, value, receiver] : [target, propertyKey, value]);
  }
  function tryAddPropertyAssignment(properties, propertyName, expression) {
    if (expression) {
      properties.push(createPropertyAssignment(propertyName, expression));
      return true;
    }
    return false;
  }
  function createPropertyDescriptor(attributes, singleLine) {
    const properties = [];
    tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable));
    tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable));
    let isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable));
    isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData;
    let isAccessor2 = tryAddPropertyAssignment(properties, "get", attributes.get);
    isAccessor2 = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor2;
    Debug.assert(!(isData && isAccessor2), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor.");
    return createObjectLiteralExpression(properties, !singleLine);
  }
  function updateOuterExpression(outerExpression, expression) {
    switch (outerExpression.kind) {
      case 217 /* ParenthesizedExpression */:
        return updateParenthesizedExpression(outerExpression, expression);
      case 216 /* TypeAssertionExpression */:
        return updateTypeAssertion(outerExpression, outerExpression.type, expression);
      case 234 /* AsExpression */:
        return updateAsExpression(outerExpression, expression, outerExpression.type);
      case 238 /* SatisfiesExpression */:
        return updateSatisfiesExpression(outerExpression, expression, outerExpression.type);
      case 235 /* NonNullExpression */:
        return updateNonNullExpression(outerExpression, expression);
      case 233 /* ExpressionWithTypeArguments */:
        return updateExpressionWithTypeArguments(outerExpression, expression, outerExpression.typeArguments);
      case 355 /* PartiallyEmittedExpression */:
        return updatePartiallyEmittedExpression(outerExpression, expression);
    }
  }
  function isIgnorableParen(node) {
    return isParenthesizedExpression(node) && nodeIsSynthesized(node) && nodeIsSynthesized(getSourceMapRange(node)) && nodeIsSynthesized(getCommentRange(node)) && !some(getSyntheticLeadingComments(node)) && !some(getSyntheticTrailingComments(node));
  }
  function restoreOuterExpressions(outerExpression, innerExpression, kinds = 31 /* All */) {
    if (outerExpression && isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) {
      return updateOuterExpression(
        outerExpression,
        restoreOuterExpressions(outerExpression.expression, innerExpression)
      );
    }
    return innerExpression;
  }
  function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) {
    if (!outermostLabeledStatement) {
      return node;
    }
    const updated = updateLabeledStatement(
      outermostLabeledStatement,
      outermostLabeledStatement.label,
      isLabeledStatement(outermostLabeledStatement.statement) ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node
    );
    if (afterRestoreLabelCallback) {
      afterRestoreLabelCallback(outermostLabeledStatement);
    }
    return updated;
  }
  function shouldBeCapturedInTempVariable(node, cacheIdentifiers) {
    const target = skipParentheses(node);
    switch (target.kind) {
      case 80 /* Identifier */:
        return cacheIdentifiers;
      case 110 /* ThisKeyword */:
      case 9 /* NumericLiteral */:
      case 10 /* BigIntLiteral */:
      case 11 /* StringLiteral */:
        return false;
      case 209 /* ArrayLiteralExpression */:
        const elements = target.elements;
        if (elements.length === 0) {
          return false;
        }
        return true;
      case 210 /* ObjectLiteralExpression */:
        return target.properties.length > 0;
      default:
        return true;
    }
  }
  function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers = false) {
    const callee = skipOuterExpressions(expression, 31 /* All */);
    let thisArg;
    let target;
    if (isSuperProperty(callee)) {
      thisArg = createThis();
      target = callee;
    } else if (isSuperKeyword(callee)) {
      thisArg = createThis();
      target = languageVersion !== void 0 && languageVersion < 2 /* ES2015 */ ? setTextRange(createIdentifier("_super"), callee) : callee;
    } else if (getEmitFlags(callee) & 8192 /* HelperName */) {
      thisArg = createVoidZero();
      target = parenthesizerRules().parenthesizeLeftSideOfAccess(
        callee,
        /*optionalChain*/
        false
      );
    } else if (isPropertyAccessExpression(callee)) {
      if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
        thisArg = createTempVariable(recordTempVariable);
        target = createPropertyAccessExpression(
          setTextRange(
            factory2.createAssignment(
              thisArg,
              callee.expression
            ),
            callee.expression
          ),
          callee.name
        );
        setTextRange(target, callee);
      } else {
        thisArg = callee.expression;
        target = callee;
      }
    } else if (isElementAccessExpression(callee)) {
      if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
        thisArg = createTempVariable(recordTempVariable);
        target = createElementAccessExpression(
          setTextRange(
            factory2.createAssignment(
              thisArg,
              callee.expression
            ),
            callee.expression
          ),
          callee.argumentExpression
        );
        setTextRange(target, callee);
      } else {
        thisArg = callee.expression;
        target = callee;
      }
    } else {
      thisArg = createVoidZero();
      target = parenthesizerRules().parenthesizeLeftSideOfAccess(
        expression,
        /*optionalChain*/
        false
      );
    }
    return { target, thisArg };
  }
  function createAssignmentTargetWrapper(paramName, expression) {
    return createPropertyAccessExpression(
      // Explicit parens required because of v8 regression (https://bugs.chromium.org/p/v8/issues/detail?id=9560)
      createParenthesizedExpression(
        createObjectLiteralExpression([
          createSetAccessorDeclaration(
            /*modifiers*/
            void 0,
            "value",
            [createParameterDeclaration(
              /*modifiers*/
              void 0,
              /*dotDotDotToken*/
              void 0,
              paramName,
              /*questionToken*/
              void 0,
              /*type*/
              void 0,
              /*initializer*/
              void 0
            )],
            createBlock([
              createExpressionStatement(expression)
            ])
          )
        ])
      ),
      "value"
    );
  }
  function inlineExpressions(expressions) {
    return expressions.length > 10 ? createCommaListExpression(expressions) : reduceLeft(expressions, factory2.createComma);
  }
  function getName(node, allowComments, allowSourceMaps, emitFlags = 0, ignoreAssignedName) {
    const nodeName = ignoreAssignedName ? node && getNonAssignedNameOfDeclaration(node) : getNameOfDeclaration(node);
    if (nodeName && isIdentifier(nodeName) && !isGeneratedIdentifier(nodeName)) {
      const name = setParent(setTextRange(cloneNode(nodeName), nodeName), nodeName.parent);
      emitFlags |= getEmitFlags(nodeName);
      if (!allowSourceMaps) emitFlags |= 96 /* NoSourceMap */;
      if (!allowComments) emitFlags |= 3072 /* NoComments */;
      if (emitFlags) setEmitFlags(name, emitFlags);
      return name;
    }
    return getGeneratedNameForNode(node);
  }
  function getInternalName(node, allowComments, allowSourceMaps) {
    return getName(node, allowComments, allowSourceMaps, 32768 /* LocalName */ | 65536 /* InternalName */);
  }
  function getLocalName(node, allowComments, allowSourceMaps, ignoreAssignedName) {
    return getName(node, allowComments, allowSourceMaps, 32768 /* LocalName */, ignoreAssignedName);
  }
  function getExportName(node, allowComments, allowSourceMaps) {
    return getName(node, allowComments, allowSourceMaps, 16384 /* ExportName */);
  }
  function getDeclarationName(node, allowComments, allowSourceMaps) {
    return getName(node, allowComments, allowSourceMaps);
  }
  function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) {
    const qualifiedName = createPropertyAccessExpression(ns, nodeIsSynthesized(name) ? name : cloneNode(name));
    setTextRange(qualifiedName, name);
    let emitFlags = 0;
    if (!allowSourceMaps) emitFlags |= 96 /* NoSourceMap */;
    if (!allowComments) emitFlags |= 3072 /* NoComments */;
    if (emitFlags) setEmitFlags(qualifiedName, emitFlags);
    return qualifiedName;
  }
  function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) {
    if (ns && hasSyntacticModifier(node, 32 /* Export */)) {
      return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps);
    }
    return getExportName(node, allowComments, allowSourceMaps);
  }
  function copyPrologue(source, target, ensureUseStrict2, visitor) {
    const offset = copyStandardPrologue(source, target, 0, ensureUseStrict2);
    return copyCustomPrologue(source, target, offset, visitor);
  }
  function isUseStrictPrologue2(node) {
    return isStringLiteral(node.expression) && node.expression.text === "use strict";
  }
  function createUseStrictPrologue() {
    return startOnNewLine(createExpressionStatement(createStringLiteral("use strict")));
  }
  function copyStandardPrologue(source, target, statementOffset = 0, ensureUseStrict2) {
    Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
    let foundUseStrict = false;
    const numStatements = source.length;
    while (statementOffset < numStatements) {
      const statement = source[statementOffset];
      if (isPrologueDirective(statement)) {
        if (isUseStrictPrologue2(statement)) {
          foundUseStrict = true;
        }
        target.push(statement);
      } else {
        break;
      }
      statementOffset++;
    }
    if (ensureUseStrict2 && !foundUseStrict) {
      target.push(createUseStrictPrologue());
    }
    return statementOffset;
  }
  function copyCustomPrologue(source, target, statementOffset, visitor, filter2 = returnTrue) {
    const numStatements = source.length;
    while (statementOffset !== void 0 && statementOffset < numStatements) {
      const statement = source[statementOffset];
      if (getEmitFlags(statement) & 2097152 /* CustomPrologue */ && filter2(statement)) {
        append(target, visitor ? visitNode(statement, visitor, isStatement) : statement);
      } else {
        break;
      }
      statementOffset++;
    }
    return statementOffset;
  }
  function ensureUseStrict(statements) {
    const foundUseStrict = findUseStrictPrologue(statements);
    if (!foundUseStrict) {
      return setTextRange(createNodeArray([createUseStrictPrologue(), ...statements]), statements);
    }
    return statements;
  }
  function liftToBlock(nodes) {
    Debug.assert(every(nodes, isStatementOrBlock), "Cannot lift nodes to a Block.");
    return singleOrUndefined(nodes) || createBlock(nodes);
  }
  function findSpanEnd(array, test, start) {
    let i = start;
    while (i < array.length && test(array[i])) {
      i++;
    }
    return i;
  }
  function mergeLexicalEnvironment(statements, declarations) {
    if (!some(declarations)) {
      return statements;
    }
    const leftStandardPrologueEnd = findSpanEnd(statements, isPrologueDirective, 0);
    const leftHoistedFunctionsEnd = findSpanEnd(statements, isHoistedFunction, leftStandardPrologueEnd);
    const leftHoistedVariablesEnd = findSpanEnd(statements, isHoistedVariableStatement, leftHoistedFunctionsEnd);
    const rightStandardPrologueEnd = findSpanEnd(declarations, isPrologueDirective, 0);
    const rightHoistedFunctionsEnd = findSpanEnd(declarations, isHoistedFunction, rightStandardPrologueEnd);
    const rightHoistedVariablesEnd = findSpanEnd(declarations, isHoistedVariableStatement, rightHoistedFunctionsEnd);
    const rightCustomPrologueEnd = findSpanEnd(declarations, isCustomPrologue, rightHoistedVariablesEnd);
    Debug.assert(rightCustomPrologueEnd === declarations.length, "Expected declarations to be valid standard or custom prologues");
    const left = isNodeArray(statements) ? statements.slice() : statements;
    if (rightCustomPrologueEnd > rightHoistedVariablesEnd) {
      left.splice(leftHoistedVariablesEnd, 0, ...declarations.slice(rightHoistedVariablesEnd, rightCustomPrologueEnd));
    }
    if (rightHoistedVariablesEnd > rightHoistedFunctionsEnd) {
      left.splice(leftHoistedFunctionsEnd, 0, ...declarations.slice(rightHoistedFunctionsEnd, rightHoistedVariablesEnd));
    }
    if (rightHoistedFunctionsEnd > rightStandardPrologueEnd) {
      left.splice(leftStandardPrologueEnd, 0, ...declarations.slice(rightStandardPrologueEnd, rightHoistedFunctionsEnd));
    }
    if (rightStandardPrologueEnd > 0) {
      if (leftStandardPrologueEnd === 0) {
        left.splice(0, 0, ...declarations.slice(0, rightStandardPrologueEnd));
      } else {
        const leftPrologues = /* @__PURE__ */ new Map();
        for (let i = 0; i < leftStandardPrologueEnd; i++) {
          const leftPrologue = statements[i];
          leftPrologues.set(leftPrologue.expression.text, true);
        }
        for (let i = rightStandardPrologueEnd - 1; i >= 0; i--) {
          const rightPrologue = declarations[i];
          if (!leftPrologues.has(rightPrologue.expression.text)) {
            left.unshift(rightPrologue);
          }
        }
      }
    }
    if (isNodeArray(statements)) {
      return setTextRange(createNodeArray(left, statements.hasTrailingComma), statements);
    }
    return statements;
  }
  function replaceModifiers(node, modifiers) {
    let modifierArray;
    if (typeof modifiers === "number") {
      modifierArray = createModifiersFromModifierFlags(modifiers);
    } else {
      modifierArray = modifiers;
    }
    return isTypeParameterDeclaration(node) ? updateTypeParameterDeclaration(node, modifierArray, node.name, node.constraint, node.default) : isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isConstructorTypeNode(node) ? updateConstructorTypeNode1(node, modifierArray, node.typeParameters, node.parameters, node.type) : isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) : isPropertyDeclaration(node) ? updatePropertyDeclaration2(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodSignature(node) ? updateMethodSignature(node, modifierArray, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isConstructorDeclaration(node) ? updateConstructorDeclaration(node, modifierArray, node.parameters, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isIndexSignatureDeclaration(node) ? updateIndexSignature(node, modifierArray, node.parameters, node.type) : isFunctionExpression(node) ? updateFunctionExpression(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isArrowFunction(node) ? updateArrowFunction(node, modifierArray, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isVariableStatement(node) ? updateVariableStatement(node, modifierArray, node.declarationList) : isFunctionDeclaration(node) ? updateFunctionDeclaration(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, modifierArray, node.name, node.typeParameters, node.type) : isEnumDeclaration(node) ? updateEnumDeclaration(node, modifierArray, node.name, node.members) : isModuleDeclaration(node) ? updateModuleDeclaration(node, modifierArray, node.name, node.body) : isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, modifierArray, node.isTypeOnly, node.name, node.moduleReference) : isImportDeclaration(node) ? updateImportDeclaration(node, modifierArray, node.importClause, node.moduleSpecifier, node.attributes) : isExportAssignment(node) ? updateExportAssignment(node, modifierArray, node.expression) : isExportDeclaration(node) ? updateExportDeclaration(node, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.attributes) : Debug.assertNever(node);
  }
  function replaceDecoratorsAndModifiers(node, modifierArray) {
    return isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : isPropertyDeclaration(node) ? updatePropertyDeclaration2(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) : isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.body) : isClassExpression(node) ? updateClassExpression(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isClassDeclaration(node) ? updateClassDeclaration(node, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : Debug.assertNever(node);
  }
  function replacePropertyName(node, name) {
    switch (node.kind) {
      case 177 /* GetAccessor */:
        return updateGetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.type, node.body);
      case 178 /* SetAccessor */:
        return updateSetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.body);
      case 174 /* MethodDeclaration */:
        return updateMethodDeclaration(node, node.modifiers, node.asteriskToken, name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body);
      case 173 /* MethodSignature */:
        return updateMethodSignature(node, node.modifiers, name, node.questionToken, node.typeParameters, node.parameters, node.type);
      case 172 /* PropertyDeclaration */:
        return updatePropertyDeclaration2(node, node.modifiers, name, node.questionToken ?? node.exclamationToken, node.type, node.initializer);
      case 171 /* PropertySignature */:
        return updatePropertySignature(node, node.modifiers, name, node.questionToken, node.type);
      case 303 /* PropertyAssignment */:
        return updatePropertyAssignment(node, name, node.initializer);
    }
  }
  function asNodeArray(array) {
    return array ? createNodeArray(array) : void 0;
  }
  function asName(name) {
    return typeof name === "string" ? createIdentifier(name) : name;
  }
  function asExpression(value) {
    return typeof value === "string" ? createStringLiteral(value) : typeof value === "number" ? createNumericLiteral(value) : typeof value === "boolean" ? value ? createTrue() : createFalse() : value;
  }
  function asInitializer(node) {
    return node && parenthesizerRules().parenthesizeExpressionForDisallowedComma(node);
  }
  function asToken(value) {
    return typeof value === "number" ? createToken(value) : value;
  }
  function asEmbeddedStatement(statement) {
    return statement && isNotEmittedStatement(statement) ? setTextRange(setOriginal(createEmptyStatement(), statement), statement) : statement;
  }
  function asVariableDeclaration(variableDeclaration) {
    if (typeof variableDeclaration === "string" || variableDeclaration && !isVariableDeclaration(variableDeclaration)) {
      return createVariableDeclaration(
        variableDeclaration,
        /*exclamationToken*/
        void 0,
        /*type*/
        void 0,
        /*initializer*/
        void 0
      );
    }
    return variableDeclaration;
  }
  function update(updated, original) {
    if (updated !== original) {
      setOriginal(updated, original);
      setTextRange(updated, original);
    }
    return updated;
  }
}
function getDefaultTagNameForKind(kind) {
  switch (kind) {
    case 344 /* JSDocTypeTag */:
      return "type";
    case 342 /* JSDocReturnTag */:
      return "returns";
    case 343 /* JSDocThisTag */:
      return "this";
    case 340 /* JSDocEnumTag */:
      return "enum";
    case 330 /* JSDocAuthorTag */:
      return "author";
    case 332 /* JSDocClassTag */:
      return "class";
    case 333 /* JSDocPublicTag */:
      return "public";
    case 334 /* JSDocPrivateTag */:
      return "private";
    case 335 /* JSDocProtectedTag */:
      return "protected";
    case 336 /* JSDocReadonlyTag */:
      return "readonly";
    case 337 /* JSDocOverrideTag */:
      return "override";
    case 345 /* JSDocTemplateTag */:
      return "template";
    case 346 /* JSDocTypedefTag */:
      return "typedef";
    case 341 /* JSDocParameterTag */:
      return "param";
    case 348 /* JSDocPropertyTag */:
      return "prop";
    case 338 /* JSDocCallbackTag */:
      return "callback";
    case 339 /* JSDocOverloadTag */:
      return "overload";
    case 328 /* JSDocAugmentsTag */:
      return "augments";
    case 329 /* JSDocImplementsTag */:
      return "implements";
    case 351 /* JSDocImportTag */:
      return "import";
    default:
      return Debug.fail(`Unsupported kind: ${Debug.formatSyntaxKind(kind)}`);
  }
}
var rawTextScanner;
var invalidValueSentinel = {};
function getCookedText(kind, rawText) {
  if (!rawTextScanner) {
    rawTextScanner = createScanner(
      99 /* Latest */,
      /*skipTrivia*/
      false,
      0 /* Standard */
    );
  }
  switch (kind) {
    case 15 /* NoSubstitutionTemplateLiteral */:
      rawTextScanner.setText("`" + rawText + "`");
      break;
    case 16 /* TemplateHead */:
      rawTextScanner.setText("`" + rawText + "${");
      break;
    case 17 /* TemplateMiddle */:
      rawTextScanner.setText("}" + rawText + "${");
      break;
    case 18 /* TemplateTail */:
      rawTextScanner.setText("}" + rawText + "`");
      break;
  }
  let token = rawTextScanner.scan();
  if (token === 20 /* CloseBraceToken */) {
    token = rawTextScanner.reScanTemplateToken(
      /*isTaggedTemplate*/
      false
    );
  }
  if (rawTextScanner.isUnterminated()) {
    rawTextScanner.setText(void 0);
    return invalidValueSentinel;
  }
  let tokenValue;
  switch (token) {
    case 15 /* NoSubstitutionTemplateLiteral */:
    case 16 /* TemplateHead */:
    case 17 /* TemplateMiddle */:
    case 18 /* TemplateTail */:
      tokenValue = rawTextScanner.getTokenValue();
      break;
  }
  if (tokenValue === void 0 || rawTextScanner.scan() !== 1 /* EndOfFileToken */) {
    rawTextScanner.setText(void 0);
    return invalidValueSentinel;
  }
  rawTextScanner.setText(void 0);
  return tokenValue;
}
function propagateNameFlags(node) {
  return node && isIdentifier(node) ? propagateIdentifierNameFlags(node) : propagateChildFlags(node);
}
function propagateIdentifierNameFlags(node) {
  return propagateChildFlags(node) & ~67108864 /* ContainsPossibleTopLevelAwait */;
}
function propagatePropertyNameFlagsOfChild(node, transformFlags) {
  return transformFlags | node.transformFlags & 134234112 /* PropertyNamePropagatingFlags */;
}
function propagateChildFlags(child) {
  if (!child) return 0 /* None */;
  const childFlags = child.transformFlags & ~getTransformFlagsSubtreeExclusions(child.kind);
  return isNamedDeclaration(child) && isPropertyName(child.name) ? propagatePropertyNameFlagsOfChild(child.name, childFlags) : childFlags;
}
function propagateChildrenFlags(children) {
  return children ? children.transformFlags : 0 /* None */;
}
function aggregateChildrenFlags(children) {
  let subtreeFlags = 0 /* None */;
  for (const child of children) {
    subtreeFlags |= propagateChildFlags(child);
  }
  children.transformFlags = subtreeFlags;
}
function getTransformFlagsSubtreeExclusions(kind) {
  if (kind >= 182 /* FirstTypeNode */ && kind <= 205 /* LastTypeNode */) {
    return -2 /* TypeExcludes */;
  }
  switch (kind) {
    case 213 /* CallExpression */:
    case 214 /* NewExpression */:
    case 209 /* ArrayLiteralExpression */:
      return -2147450880 /* ArrayLiteralOrCallOrNewExcludes */;
    case 267 /* ModuleDeclaration */:
      return -1941676032 /* ModuleExcludes */;
    case 169 /* Parameter */:
      return -2147483648 /* ParameterExcludes */;
    case 219 /* ArrowFunction */:
      return -2072174592 /* ArrowFunctionExcludes */;
    case 218 /* FunctionExpression */:
    case 262 /* FunctionDeclaration */:
      return -1937940480 /* FunctionExcludes */;
    case 261 /* VariableDeclarationList */:
      return -2146893824 /* VariableDeclarationListExcludes */;
    case 263 /* ClassDeclaration */:
    case 231 /* ClassExpression */:
      return -2147344384 /* ClassExcludes */;
    case 176 /* Constructor */:
      return -1937948672 /* ConstructorExcludes */;
    case 172 /* PropertyDeclaration */:
      return -2013249536 /* PropertyExcludes */;
    case 174 /* MethodDeclaration */:
    case 177 /* GetAccessor */:
    case 178 /* SetAccessor */:
      return -2005057536 /* MethodOrAccessorExcludes */;
    case 133 /* AnyKeyword */:
    case 150 /* NumberKeyword */:
    case 163 /* BigIntKeyword */:
    case 146 /* NeverKeyword */:
    case 154 /* StringKeyword */:
    case 151 /* ObjectKeyword */:
    case 136 /* BooleanKeyword */:
    case 155 /* SymbolKeyword */:
    case 116 /* VoidKeyword */:
    case 168 /* TypeParameter */:
    case 171 /* PropertySignature */:
    case 173 /* MethodSignature */:
    case 179 /* CallSignature */:
    case 180 /* ConstructSignature */:
    case 181 /* IndexSignature */:
    case 264 /* InterfaceDeclaration */:
    case 265 /* TypeAliasDeclaration */:
      return -2 /* TypeExcludes */;
    case 210 /* ObjectLiteralExpression */:
      return -2147278848 /* ObjectLiteralExcludes */;
    case 299 /* CatchClause */:
      return -2147418112 /* CatchClauseExcludes */;
    case 206 /* ObjectBindingPattern */:
    case 207 /* ArrayBindingPattern */:
      return -2147450880 /* BindingPatternExcludes */;
    case 216 /* TypeAssertionExpression */:
    case 238 /* SatisfiesExpression */:
    case 234 /* AsExpression */:
    case 355 /* PartiallyEmittedExpression */:
    case 217 /* ParenthesizedExpression */:
    case 108 /* SuperKeyword */:
      return -2147483648 /* OuterExpressionExcludes */;
    case 211 /* PropertyAccessExpression */:
    case 212 /* ElementAccessExpression */:
      return -2147483648 /* PropertyAccessExcludes */;
    default:
      return -2147483648 /* NodeExcludes */;
  }
}
var baseFactory = createBaseNodeFactory();
function makeSynthetic(node) {
  node.flags |= 16 /* Synthesized */;
  return node;
}
var syntheticFactory = {
  createBaseSourceFileNode: (kind) => makeSynthetic(baseFactory.createBaseSourceFileNode(kind)),
  createBaseIdentifierNode: (kind) => makeSynthetic(baseFactory.createBaseIdentifierNode(kind)),
  createBasePrivateIdentifierNode: (kind) => makeSynthetic(baseFactory.createBasePrivateIdentifierNode(kind)),
  createBaseTokenNode: (kind) => makeSynthetic(baseFactory.createBaseTokenNode(kind)),
  createBaseNode: (kind) => makeSynthetic(baseFactory.createBaseNode(kind))
};
var factory = createNodeFactory(4 /* NoIndentationOnFreshPropertyAccess */, syntheticFactory);
var SourceMapSource2;
function createSourceMapSource(fileName, text, skipTrivia2) {
  return new (SourceMapSource2 || (SourceMapSource2 = objectAllocator.getSourceMapSourceConstructor()))(fileName, text, skipTrivia2);
}
function setOriginalNode(node, original) {
  if (node.original !== original) {
    node.original = original;
    if (original) {
      const emitNode = original.emitNode;
      if (emitNode) node.emitNode = mergeEmitNode(emitNode, node.emitNode);
    }
  }
  return node;
}
function mergeEmitNode(sourceEmitNode, destEmitNode) {
  const {
    flags,
    internalFlags,
    leadingComments,
    trailingComments,
    commentRange,
    sourceMapRange,
    tokenSourceMapRanges,
    constantValue,
    helpers,
    startsOnNewLine,
    snippetElement,
    classThis,
    assignedName
  } = sourceEmitNode;
  if (!destEmitNode) destEmitNode = {};
  if (flags) {
    destEmitNode.flags = flags;
  }
  if (internalFlags) {
    destEmitNode.internalFlags = internalFlags & ~8 /* Immutable */;
  }
  if (leadingComments) {
    destEmitNode.leadingComments = addRange(leadingComments.slice(), destEmitNode.leadingComments);
  }
  if (trailingComments) {
    destEmitNode.trailingComments = addRange(trailingComments.slice(), destEmitNode.trailingComments);
  }
  if (commentRange) {
    destEmitNode.commentRange = commentRange;
  }
  if (sourceMapRange) {
    destEmitNode.sourceMapRange = sourceMapRange;
  }
  if (tokenSourceMapRanges) {
    destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges);
  }
  if (constantValue !== void 0) {
    destEmitNode.constantValue = constantValue;
  }
  if (helpers) {
    for (const helper of helpers) {
      destEmitNode.helpers = appendIfUnique(destEmitNode.helpers, helper);
    }
  }
  if (startsOnNewLine !== void 0) {
    destEmitNode.startsOnNewLine = startsOnNewLine;
  }
  if (snippetElement !== void 0) {
    destEmitNode.snippetElement = snippetElement;
  }
  if (classThis) {
    destEmitNode.classThis = classThis;
  }
  if (assignedName) {
    destEmitNode.assignedName = assignedName;
  }
  return destEmitNode;
}
function mergeTokenSourceMapRanges(sourceRanges, destRanges) {
  if (!destRanges) destRanges = [];
  for (const key in sourceRanges) {
    destRanges[key] = sourceRanges[key];
  }
  return destRanges;
}

// src/compiler/factory/emitNode.ts
function getOrCreateEmitNode(node) {
  if (!node.emitNode) {
    if (isParseTreeNode(node)) {
      if (node.kind === 307 /* SourceFile */) {
        return node.emitNode = { annotatedNodes: [node] };
      }
      const sourceFile = getSourceFileOfNode(getParseTreeNode(getSourceFileOfNode(node))) ?? Debug.fail("Could not determine parsed source file.");
      getOrCreateEmitNode(sourceFile).annotatedNodes.push(node);
    }
    node.emitNode = {};
  } else {
    Debug.assert(!(node.emitNode.internalFlags & 8 /* Immutable */), "Invalid attempt to mutate an immutable node.");
  }
  return node.emitNode;
}
function disposeEmitNodes(sourceFile) {
  var _a, _b;
  const annotatedNodes = (_b = (_a = getSourceFileOfNode(getParseTreeNode(sourceFile))) == null ? void 0 : _a.emitNode) == null ? void 0 : _b.annotatedNodes;
  if (annotatedNodes) {
    for (const node of annotatedNodes) {
      node.emitNode = void 0;
    }
  }
}
function removeAllComments(node) {
  const emitNode = getOrCreateEmitNode(node);
  emitNode.flags |= 3072 /* NoComments */;
  emitNode.leadingComments = void 0;
  emitNode.trailingComments = void 0;
  return node;
}
function setEmitFlags(node, emitFlags) {
  getOrCreateEmitNode(node).flags = emitFlags;
  return node;
}
function addEmitFlags(node, emitFlags) {
  const emitNode = getOrCreateEmitNode(node);
  emitNode.flags = emitNode.flags | emitFlags;
  return node;
}
function setInternalEmitFlags(node, emitFlags) {
  getOrCreateEmitNode(node).internalFlags = emitFlags;
  return node;
}
function addInternalEmitFlags(node, emitFlags) {
  const emitNode = getOrCreateEmitNode(node);
  emitNode.internalFlags = emitNode.internalFlags | emitFlags;
  return node;
}
function getSourceMapRange(node) {
  var _a;
  return ((_a = node.emitNode) == null ? void 0 : _a.sourceMapRange) ?? node;
}
function setSourceMapRange(node, range) {
  getOrCreateEmitNode(node).sourceMapRange = range;
  return node;
}
function getTokenSourceMapRange(node, token) {
  var _a, _b;
  return (_b = (_a = node.emitNode) == null ? void 0 : _a.tokenSourceMapRanges) == null ? void 0 : _b[token];
}
function setTokenSourceMapRange(node, token, range) {
  const emitNode = getOrCreateEmitNode(node);
  const tokenSourceMapRanges = emitNode.tokenSourceMapRanges ?? (emitNode.tokenSourceMapRanges = []);
  tokenSourceMapRanges[token] = range;
  return node;
}
function getStartsOnNewLine(node) {
  var _a;
  return (_a = node.emitNode) == null ? void 0 : _a.startsOnNewLine;
}
function setStartsOnNewLine(node, newLine) {
  getOrCreateEmitNode(node).startsOnNewLine = newLine;
  return node;
}
function getCommentRange(node) {
  var _a;
  return ((_a = node.emitNode) == null ? void 0 : _a.commentRange) ?? node;
}
function setCommentRange(node, range) {
  getOrCreateEmitNode(node).commentRange = range;
  return node;
}
function getSyntheticLeadingComments(node) {
  var _a;
  return (_a = node.emitNode) == null ? void 0 : _a.leadingComments;
}
function setSyntheticLeadingComments(node, comments) {
  getOrCreateEmitNode(node).leadingComments = comments;
  return node;
}
function addSyntheticLeadingComment(node, kind, text, hasTrailingNewLine) {
  return setSyntheticLeadingComments(node, append(getSyntheticLeadingComments(node), { kind, pos: -1, end: -1, hasTrailingNewLine, text }));
}
function getSyntheticTrailingComments(node) {
  var _a;
  return (_a = node.emitNode) == null ? void 0 : _a.trailingComments;
}
function setSyntheticTrailingComments(node, comments) {
  getOrCreateEmitNode(node).trailingComments = comments;
  return node;
}
function addSyntheticTrailingComment(node, kind, text, hasTrailingNewLine) {
  return setSyntheticTrailingComments(node, append(getSyntheticTrailingComments(node), { kind, pos: -1, end: -1, hasTrailingNewLine, text }));
}
function moveSyntheticComments(node, original) {
  setSyntheticLeadingComments(node, getSyntheticLeadingComments(original));
  setSyntheticTrailingComments(node, getSyntheticTrailingComments(original));
  const emit = getOrCreateEmitNode(original);
  emit.leadingComments = void 0;
  emit.trailingComments = void 0;
  return node;
}
function getConstantValue(node) {
  var _a;
  return (_a = node.emitNode) == null ? void 0 : _a.constantValue;
}
function setConstantValue(node, value) {
  const emitNode = getOrCreateEmitNode(node);
  emitNode.constantValue = value;
  return node;
}
function addEmitHelper(node, helper) {
  const emitNode = getOrCreateEmitNode(node);
  emitNode.helpers = append(emitNode.helpers, helper);
  return node;
}
function addEmitHelpers(node, helpers) {
  if (some(helpers)) {
    const emitNode = getOrCreateEmitNode(node);
    for (const helper of helpers) {
      emitNode.helpers = appendIfUnique(emitNode.helpers, helper);
    }
  }
  return node;
}
function removeEmitHelper(node, helper) {
  var _a;
  const helpers = (_a = node.emitNode) == null ? void 0 : _a.helpers;
  if (helpers) {
    return orderedRemoveItem(helpers, helper);
  }
  return false;
}
function getEmitHelpers(node) {
  var _a;
  return (_a = node.emitNode) == null ? void 0 : _a.helpers;
}
function moveEmitHelpers(source, target, predicate) {
  const sourceEmitNode = source.emitNode;
  const sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers;
  if (!some(sourceEmitHelpers)) return;
  const targetEmitNode = getOrCreateEmitNode(target);
  let helpersRemoved = 0;
  for (let i = 0; i < sourceEmitHelpers.length; i++) {
    const helper = sourceEmitHelpers[i];
    if (predicate(helper)) {
      helpersRemoved++;
      targetEmitNode.helpers = appendIfUnique(targetEmitNode.helpers, helper);
    } else if (helpersRemoved > 0) {
      sourceEmitHelpers[i - helpersRemoved] = helper;
    }
  }
  if (helpersRemoved > 0) {
    sourceEmitHelpers.length -= helpersRemoved;
  }
}
function getSnippetElement(node) {
  var _a;
  return (_a = node.emitNode) == null ? void 0 : _a.snippetElement;
}
function setSnippetElement(node, snippet) {
  const emitNode = getOrCreateEmitNode(node);
  emitNode.snippetElement = snippet;
  return node;
}
function ignoreSourceNewlines(node) {
  getOrCreateEmitNode(node).internalFlags |= 4 /* IgnoreSourceNewlines */;
  return node;
}
function setTypeNode(node, type) {
  const emitNode = getOrCreateEmitNode(node);
  emitNode.typeNode = type;
  return node;
}
function getTypeNode(node) {
  var _a;
  return (_a = node.emitNode) == null ? void 0 : _a.typeNode;
}
function setIdentifierTypeArguments(node, typeArguments) {
  getOrCreateEmitNode(node).identifierTypeArguments = typeArguments;
  return node;
}
function getIdentifierTypeArguments(node) {
  var _a;
  return (_a = node.emitNode) == null ? void 0 : _a.identifierTypeArguments;
}
function setIdentifierAutoGenerate(node, autoGenerate) {
  getOrCreateEmitNode(node).autoGenerate = autoGenerate;
  return node;
}
function getIdentifierAutoGenerate(node) {
  var _a;
  return (_a = node.emitNode) == null ? void 0 : _a.autoGenerate;
}
function setIdentifierGeneratedImportReference(node, value) {
  getOrCreateEmitNode(node).generatedImportReference = value;
  return node;
}
function getIdentifierGeneratedImportReference(node) {
  var _a;
  return (_a = node.emitNode) == null ? void 0 : _a.generatedImportReference;
}

// src/compiler/factory/emitHelpers.ts
var PrivateIdentifierKind = /* @__PURE__ */ ((PrivateIdentifierKind2) => {
  PrivateIdentifierKind2["Field"] = "f";
  PrivateIdentifierKind2["Method"] = "m";
  PrivateIdentifierKind2["Accessor"] = "a";
  return PrivateIdentifierKind2;
})(PrivateIdentifierKind || {});
function createEmitHelperFactory(context) {
  const factory2 = context.factory;
  const immutableTrue = memoize(() => setInternalEmitFlags(factory2.createTrue(), 8 /* Immutable */));
  const immutableFalse = memoize(() => setInternalEmitFlags(factory2.createFalse(), 8 /* Immutable */));
  return {
    getUnscopedHelperName,
    // TypeScript Helpers
    createDecorateHelper,
    createMetadataHelper,
    createParamHelper,
    // ES Decorators Helpers
    createESDecorateHelper,
    createRunInitializersHelper,
    // ES2018 Helpers
    createAssignHelper,
    createAwaitHelper,
    createAsyncGeneratorHelper,
    createAsyncDelegatorHelper,
    createAsyncValuesHelper,
    // ES2018 Destructuring Helpers
    createRestHelper,
    // ES2017 Helpers
    createAwaiterHelper,
    // ES2015 Helpers
    createExtendsHelper,
    createTemplateObjectHelper,
    createSpreadArrayHelper,
    createPropKeyHelper,
    createSetFunctionNameHelper,
    // ES2015 Destructuring Helpers
    createValuesHelper,
    createReadHelper,
    // ES2015 Generator Helpers
    createGeneratorHelper,
    // ES Module Helpers
    createImportStarHelper,
    createImportStarCallbackHelper,
    createImportDefaultHelper,
    createExportStarHelper,
    // Class Fields Helpers
    createClassPrivateFieldGetHelper,
    createClassPrivateFieldSetHelper,
    createClassPrivateFieldInHelper,
    // 'using' helpers
    createAddDisposableResourceHelper,
    createDisposeResourcesHelper,
    // --rewriteRelativeImportExtensions helpers
    createRewriteRelativeImportExtensionsHelper
  };
  function getUnscopedHelperName(name) {
    return setEmitFlags(factory2.createIdentifier(name), 8192 /* HelperName */ | 4 /* AdviseOnEmitNode */);
  }
  function createDecorateHelper(decoratorExpressions, target, memberName, descriptor) {
    context.requestEmitHelper(decorateHelper);
    const argumentsArray = [];
    argumentsArray.push(factory2.createArrayLiteralExpression(
      decoratorExpressions,
      /*multiLine*/
      true
    ));
    argumentsArray.push(target);
    if (memberName) {
      argumentsArray.push(memberName);
      if (descriptor) {
        argumentsArray.push(descriptor);
      }
    }
    return factory2.createCallExpression(
      getUnscopedHelperName("__decorate"),
      /*typeArguments*/
      void 0,
      argumentsArray
    );
  }
  function createMetadataHelper(metadataKey, metadataValue) {
    context.requestEmitHelper(metadataHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__metadata"),
      /*typeArguments*/
      void 0,
      [
        factory2.createStringLiteral(metadataKey),
        metadataValue
      ]
    );
  }
  function createParamHelper(expression, parameterOffset, location) {
    context.requestEmitHelper(paramHelper);
    return setTextRange(
      factory2.createCallExpression(
        getUnscopedHelperName("__param"),
        /*typeArguments*/
        void 0,
        [
          factory2.createNumericLiteral(parameterOffset + ""),
          expression
        ]
      ),
      location
    );
  }
  function createESDecorateClassContextObject(contextIn) {
    const properties = [
      factory2.createPropertyAssignment(factory2.createIdentifier("kind"), factory2.createStringLiteral("class")),
      factory2.createPropertyAssignment(factory2.createIdentifier("name"), contextIn.name),
      factory2.createPropertyAssignment(factory2.createIdentifier("metadata"), contextIn.metadata)
    ];
    return factory2.createObjectLiteralExpression(properties);
  }
  function createESDecorateClassElementAccessGetMethod(elementName) {
    const accessor = elementName.computed ? factory2.createElementAccessExpression(factory2.createIdentifier("obj"), elementName.name) : factory2.createPropertyAccessExpression(factory2.createIdentifier("obj"), elementName.name);
    return factory2.createPropertyAssignment(
      "get",
      factory2.createArrowFunction(
        /*modifiers*/
        void 0,
        /*typeParameters*/
        void 0,
        [factory2.createParameterDeclaration(
          /*modifiers*/
          void 0,
          /*dotDotDotToken*/
          void 0,
          factory2.createIdentifier("obj")
        )],
        /*type*/
        void 0,
        /*equalsGreaterThanToken*/
        void 0,
        accessor
      )
    );
  }
  function createESDecorateClassElementAccessSetMethod(elementName) {
    const accessor = elementName.computed ? factory2.createElementAccessExpression(factory2.createIdentifier("obj"), elementName.name) : factory2.createPropertyAccessExpression(factory2.createIdentifier("obj"), elementName.name);
    return factory2.createPropertyAssignment(
      "set",
      factory2.createArrowFunction(
        /*modifiers*/
        void 0,
        /*typeParameters*/
        void 0,
        [
          factory2.createParameterDeclaration(
            /*modifiers*/
            void 0,
            /*dotDotDotToken*/
            void 0,
            factory2.createIdentifier("obj")
          ),
          factory2.createParameterDeclaration(
            /*modifiers*/
            void 0,
            /*dotDotDotToken*/
            void 0,
            factory2.createIdentifier("value")
          )
        ],
        /*type*/
        void 0,
        /*equalsGreaterThanToken*/
        void 0,
        factory2.createBlock([
          factory2.createExpressionStatement(
            factory2.createAssignment(
              accessor,
              factory2.createIdentifier("value")
            )
          )
        ])
      )
    );
  }
  function createESDecorateClassElementAccessHasMethod(elementName) {
    const propertyName = elementName.computed ? elementName.name : isIdentifier(elementName.name) ? factory2.createStringLiteralFromNode(elementName.name) : elementName.name;
    return factory2.createPropertyAssignment(
      "has",
      factory2.createArrowFunction(
        /*modifiers*/
        void 0,
        /*typeParameters*/
        void 0,
        [factory2.createParameterDeclaration(
          /*modifiers*/
          void 0,
          /*dotDotDotToken*/
          void 0,
          factory2.createIdentifier("obj")
        )],
        /*type*/
        void 0,
        /*equalsGreaterThanToken*/
        void 0,
        factory2.createBinaryExpression(
          propertyName,
          103 /* InKeyword */,
          factory2.createIdentifier("obj")
        )
      )
    );
  }
  function createESDecorateClassElementAccessObject(name, access) {
    const properties = [];
    properties.push(createESDecorateClassElementAccessHasMethod(name));
    if (access.get) properties.push(createESDecorateClassElementAccessGetMethod(name));
    if (access.set) properties.push(createESDecorateClassElementAccessSetMethod(name));
    return factory2.createObjectLiteralExpression(properties);
  }
  function createESDecorateClassElementContextObject(contextIn) {
    const properties = [
      factory2.createPropertyAssignment(factory2.createIdentifier("kind"), factory2.createStringLiteral(contextIn.kind)),
      factory2.createPropertyAssignment(factory2.createIdentifier("name"), contextIn.name.computed ? contextIn.name.name : factory2.createStringLiteralFromNode(contextIn.name.name)),
      factory2.createPropertyAssignment(factory2.createIdentifier("static"), contextIn.static ? factory2.createTrue() : factory2.createFalse()),
      factory2.createPropertyAssignment(factory2.createIdentifier("private"), contextIn.private ? factory2.createTrue() : factory2.createFalse()),
      factory2.createPropertyAssignment(factory2.createIdentifier("access"), createESDecorateClassElementAccessObject(contextIn.name, contextIn.access)),
      factory2.createPropertyAssignment(factory2.createIdentifier("metadata"), contextIn.metadata)
    ];
    return factory2.createObjectLiteralExpression(properties);
  }
  function createESDecorateContextObject(contextIn) {
    return contextIn.kind === "class" ? createESDecorateClassContextObject(contextIn) : createESDecorateClassElementContextObject(contextIn);
  }
  function createESDecorateHelper(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
    context.requestEmitHelper(esDecorateHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__esDecorate"),
      /*typeArguments*/
      void 0,
      [
        ctor ?? factory2.createNull(),
        descriptorIn ?? factory2.createNull(),
        decorators,
        createESDecorateContextObject(contextIn),
        initializers,
        extraInitializers
      ]
    );
  }
  function createRunInitializersHelper(thisArg, initializers, value) {
    context.requestEmitHelper(runInitializersHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__runInitializers"),
      /*typeArguments*/
      void 0,
      value ? [thisArg, initializers, value] : [thisArg, initializers]
    );
  }
  function createAssignHelper(attributesSegments) {
    if (getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) {
      return factory2.createCallExpression(
        factory2.createPropertyAccessExpression(factory2.createIdentifier("Object"), "assign"),
        /*typeArguments*/
        void 0,
        attributesSegments
      );
    }
    context.requestEmitHelper(assignHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__assign"),
      /*typeArguments*/
      void 0,
      attributesSegments
    );
  }
  function createAwaitHelper(expression) {
    context.requestEmitHelper(awaitHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__await"),
      /*typeArguments*/
      void 0,
      [expression]
    );
  }
  function createAsyncGeneratorHelper(generatorFunc, hasLexicalThis) {
    context.requestEmitHelper(awaitHelper);
    context.requestEmitHelper(asyncGeneratorHelper);
    (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 524288 /* AsyncFunctionBody */ | 1048576 /* ReuseTempVariableScope */;
    return factory2.createCallExpression(
      getUnscopedHelperName("__asyncGenerator"),
      /*typeArguments*/
      void 0,
      [
        hasLexicalThis ? factory2.createThis() : factory2.createVoidZero(),
        factory2.createIdentifier("arguments"),
        generatorFunc
      ]
    );
  }
  function createAsyncDelegatorHelper(expression) {
    context.requestEmitHelper(awaitHelper);
    context.requestEmitHelper(asyncDelegator);
    return factory2.createCallExpression(
      getUnscopedHelperName("__asyncDelegator"),
      /*typeArguments*/
      void 0,
      [expression]
    );
  }
  function createAsyncValuesHelper(expression) {
    context.requestEmitHelper(asyncValues);
    return factory2.createCallExpression(
      getUnscopedHelperName("__asyncValues"),
      /*typeArguments*/
      void 0,
      [expression]
    );
  }
  function createRestHelper(value, elements, computedTempVariables, location) {
    context.requestEmitHelper(restHelper);
    const propertyNames = [];
    let computedTempVariableOffset = 0;
    for (let i = 0; i < elements.length - 1; i++) {
      const propertyName = getPropertyNameOfBindingOrAssignmentElement(elements[i]);
      if (propertyName) {
        if (isComputedPropertyName(propertyName)) {
          Debug.assertIsDefined(computedTempVariables, "Encountered computed property name but 'computedTempVariables' argument was not provided.");
          const temp = computedTempVariables[computedTempVariableOffset];
          computedTempVariableOffset++;
          propertyNames.push(
            factory2.createConditionalExpression(
              factory2.createTypeCheck(temp, "symbol"),
              /*questionToken*/
              void 0,
              temp,
              /*colonToken*/
              void 0,
              factory2.createAdd(temp, factory2.createStringLiteral(""))
            )
          );
        } else {
          propertyNames.push(factory2.createStringLiteralFromNode(propertyName));
        }
      }
    }
    return factory2.createCallExpression(
      getUnscopedHelperName("__rest"),
      /*typeArguments*/
      void 0,
      [
        value,
        setTextRange(
          factory2.createArrayLiteralExpression(propertyNames),
          location
        )
      ]
    );
  }
  function createAwaiterHelper(hasLexicalThis, argumentsExpression, promiseConstructor, parameters, body) {
    context.requestEmitHelper(awaiterHelper);
    const generatorFunc = factory2.createFunctionExpression(
      /*modifiers*/
      void 0,
      factory2.createToken(42 /* AsteriskToken */),
      /*name*/
      void 0,
      /*typeParameters*/
      void 0,
      parameters ?? [],
      /*type*/
      void 0,
      body
    );
    (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 524288 /* AsyncFunctionBody */ | 1048576 /* ReuseTempVariableScope */;
    return factory2.createCallExpression(
      getUnscopedHelperName("__awaiter"),
      /*typeArguments*/
      void 0,
      [
        hasLexicalThis ? factory2.createThis() : factory2.createVoidZero(),
        argumentsExpression ?? factory2.createVoidZero(),
        promiseConstructor ? createExpressionFromEntityName(factory2, promiseConstructor) : factory2.createVoidZero(),
        generatorFunc
      ]
    );
  }
  function createExtendsHelper(name) {
    context.requestEmitHelper(extendsHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__extends"),
      /*typeArguments*/
      void 0,
      [name, factory2.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */)]
    );
  }
  function createTemplateObjectHelper(cooked, raw) {
    context.requestEmitHelper(templateObjectHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__makeTemplateObject"),
      /*typeArguments*/
      void 0,
      [cooked, raw]
    );
  }
  function createSpreadArrayHelper(to, from, packFrom) {
    context.requestEmitHelper(spreadArrayHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__spreadArray"),
      /*typeArguments*/
      void 0,
      [to, from, packFrom ? immutableTrue() : immutableFalse()]
    );
  }
  function createPropKeyHelper(expr) {
    context.requestEmitHelper(propKeyHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__propKey"),
      /*typeArguments*/
      void 0,
      [expr]
    );
  }
  function createSetFunctionNameHelper(f, name, prefix) {
    context.requestEmitHelper(setFunctionNameHelper);
    return context.factory.createCallExpression(
      getUnscopedHelperName("__setFunctionName"),
      /*typeArguments*/
      void 0,
      prefix ? [f, name, context.factory.createStringLiteral(prefix)] : [f, name]
    );
  }
  function createValuesHelper(expression) {
    context.requestEmitHelper(valuesHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__values"),
      /*typeArguments*/
      void 0,
      [expression]
    );
  }
  function createReadHelper(iteratorRecord, count) {
    context.requestEmitHelper(readHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__read"),
      /*typeArguments*/
      void 0,
      count !== void 0 ? [iteratorRecord, factory2.createNumericLiteral(count + "")] : [iteratorRecord]
    );
  }
  function createGeneratorHelper(body) {
    context.requestEmitHelper(generatorHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__generator"),
      /*typeArguments*/
      void 0,
      [factory2.createThis(), body]
    );
  }
  function createImportStarHelper(expression) {
    context.requestEmitHelper(importStarHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__importStar"),
      /*typeArguments*/
      void 0,
      [expression]
    );
  }
  function createImportStarCallbackHelper() {
    context.requestEmitHelper(importStarHelper);
    return getUnscopedHelperName("__importStar");
  }
  function createImportDefaultHelper(expression) {
    context.requestEmitHelper(importDefaultHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__importDefault"),
      /*typeArguments*/
      void 0,
      [expression]
    );
  }
  function createExportStarHelper(moduleExpression, exportsExpression = factory2.createIdentifier("exports")) {
    context.requestEmitHelper(exportStarHelper);
    context.requestEmitHelper(createBindingHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__exportStar"),
      /*typeArguments*/
      void 0,
      [moduleExpression, exportsExpression]
    );
  }
  function createClassPrivateFieldGetHelper(receiver, state, kind, f) {
    context.requestEmitHelper(classPrivateFieldGetHelper);
    let args;
    if (!f) {
      args = [receiver, state, factory2.createStringLiteral(kind)];
    } else {
      args = [receiver, state, factory2.createStringLiteral(kind), f];
    }
    return factory2.createCallExpression(
      getUnscopedHelperName("__classPrivateFieldGet"),
      /*typeArguments*/
      void 0,
      args
    );
  }
  function createClassPrivateFieldSetHelper(receiver, state, value, kind, f) {
    context.requestEmitHelper(classPrivateFieldSetHelper);
    let args;
    if (!f) {
      args = [receiver, state, value, factory2.createStringLiteral(kind)];
    } else {
      args = [receiver, state, value, factory2.createStringLiteral(kind), f];
    }
    return factory2.createCallExpression(
      getUnscopedHelperName("__classPrivateFieldSet"),
      /*typeArguments*/
      void 0,
      args
    );
  }
  function createClassPrivateFieldInHelper(state, receiver) {
    context.requestEmitHelper(classPrivateFieldInHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__classPrivateFieldIn"),
      /*typeArguments*/
      void 0,
      [state, receiver]
    );
  }
  function createAddDisposableResourceHelper(envBinding, value, async) {
    context.requestEmitHelper(addDisposableResourceHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__addDisposableResource"),
      /*typeArguments*/
      void 0,
      [envBinding, value, async ? factory2.createTrue() : factory2.createFalse()]
    );
  }
  function createDisposeResourcesHelper(envBinding) {
    context.requestEmitHelper(disposeResourcesHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__disposeResources"),
      /*typeArguments*/
      void 0,
      [envBinding]
    );
  }
  function createRewriteRelativeImportExtensionsHelper(expression) {
    context.requestEmitHelper(rewriteRelativeImportExtensionsHelper);
    return factory2.createCallExpression(
      getUnscopedHelperName("__rewriteRelativeImportExtension"),
      /*typeArguments*/
      void 0,
      context.getCompilerOptions().jsx === 1 /* Preserve */ ? [expression, factory2.createTrue()] : [expression]
    );
  }
}
function compareEmitHelpers(x, y) {
  if (x === y) return 0 /* EqualTo */;
  if (x.priority === y.priority) return 0 /* EqualTo */;
  if (x.priority === void 0) return 1 /* GreaterThan */;
  if (y.priority === void 0) return -1 /* LessThan */;
  return compareValues(x.priority, y.priority);
}
function helperString(input, ...args) {
  return (uniqueName) => {
    let result = "";
    for (let i = 0; i < args.length; i++) {
      result += input[i];
      result += uniqueName(args[i]);
    }
    result += input[input.length - 1];
    return result;
  };
}
var decorateHelper = {
  name: "typescript:decorate",
  importName: "__decorate",
  scoped: false,
  priority: 2,
  text: `
            var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
                var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
                if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
                else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
                return c > 3 && r && Object.defineProperty(target, key, r), r;
            };`
};
var metadataHelper = {
  name: "typescript:metadata",
  importName: "__metadata",
  scoped: false,
  priority: 3,
  text: `
            var __metadata = (this && this.__metadata) || function (k, v) {
                if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
            };`
};
var paramHelper = {
  name: "typescript:param",
  importName: "__param",
  scoped: false,
  priority: 4,
  text: `
            var __param = (this && this.__param) || function (paramIndex, decorator) {
                return function (target, key) { decorator(target, key, paramIndex); }
            };`
};
var esDecorateHelper = {
  name: "typescript:esDecorate",
  importName: "__esDecorate",
  scoped: false,
  priority: 2,
  text: `
        var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
            function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
            var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
            var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
            var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
            var _, done = false;
            for (var i = decorators.length - 1; i >= 0; i--) {
                var context = {};
                for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
                for (var p in contextIn.access) context.access[p] = contextIn.access[p];
                context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
                var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
                if (kind === "accessor") {
                    if (result === void 0) continue;
                    if (result === null || typeof result !== "object") throw new TypeError("Object expected");
                    if (_ = accept(result.get)) descriptor.get = _;
                    if (_ = accept(result.set)) descriptor.set = _;
                    if (_ = accept(result.init)) initializers.unshift(_);
                }
                else if (_ = accept(result)) {
                    if (kind === "field") initializers.unshift(_);
                    else descriptor[key] = _;
                }
            }
            if (target) Object.defineProperty(target, contextIn.name, descriptor);
            done = true;
        };`
};
var runInitializersHelper = {
  name: "typescript:runInitializers",
  importName: "__runInitializers",
  scoped: false,
  priority: 2,
  text: `
        var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
            var useValue = arguments.length > 2;
            for (var i = 0; i < initializers.length; i++) {
                value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
            }
            return useValue ? value : void 0;
        };`
};
var assignHelper = {
  name: "typescript:assign",
  importName: "__assign",
  scoped: false,
  priority: 1,
  text: `
            var __assign = (this && this.__assign) || function () {
                __assign = Object.assign || function(t) {
                    for (var s, i = 1, n = arguments.length; i < n; i++) {
                        s = arguments[i];
                        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                            t[p] = s[p];
                    }
                    return t;
                };
                return __assign.apply(this, arguments);
            };`
};
var awaitHelper = {
  name: "typescript:await",
  importName: "__await",
  scoped: false,
  text: `
            var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }`
};
var asyncGeneratorHelper = {
  name: "typescript:asyncGenerator",
  importName: "__asyncGenerator",
  scoped: false,
  dependencies: [awaitHelper],
  text: `
        var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
            if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
            var g = generator.apply(thisArg, _arguments || []), i, q = [];
            return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
            function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
            function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
            function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
            function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
            function fulfill(value) { resume("next", value); }
            function reject(value) { resume("throw", value); }
            function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
        };`
};
var asyncDelegator = {
  name: "typescript:asyncDelegator",
  importName: "__asyncDelegator",
  scoped: false,
  dependencies: [awaitHelper],
  text: `
            var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
                var i, p;
                return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
                function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
            };`
};
var asyncValues = {
  name: "typescript:asyncValues",
  importName: "__asyncValues",
  scoped: false,
  text: `
            var __asyncValues = (this && this.__asyncValues) || function (o) {
                if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
                var m = o[Symbol.asyncIterator], i;
                return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
                function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
                function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
            };`
};
var restHelper = {
  name: "typescript:rest",
  importName: "__rest",
  scoped: false,
  text: `
            var __rest = (this && this.__rest) || function (s, e) {
                var t = {};
                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
                    t[p] = s[p];
                if (s != null && typeof Object.getOwnPropertySymbols === "function")
                    for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
                        if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                            t[p[i]] = s[p[i]];
                    }
                return t;
            };`
};
var awaiterHelper = {
  name: "typescript:awaiter",
  importName: "__awaiter",
  scoped: false,
  priority: 5,
  text: `
            var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
                function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
                return new (P || (P = Promise))(function (resolve, reject) {
                    function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
                    function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
                    function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
                    step((generator = generator.apply(thisArg, _arguments || [])).next());
                });
            };`
};
var extendsHelper = {
  name: "typescript:extends",
  importName: "__extends",
  scoped: false,
  priority: 0,
  text: `
            var __extends = (this && this.__extends) || (function () {
                var extendStatics = function (d, b) {
                    extendStatics = Object.setPrototypeOf ||
                        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                        function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
                    return extendStatics(d, b);
                };

                return function (d, b) {
                    if (typeof b !== "function" && b !== null)
                        throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
                    extendStatics(d, b);
                    function __() { this.constructor = d; }
                    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
                };
            })();`
};
var templateObjectHelper = {
  name: "typescript:makeTemplateObject",
  importName: "__makeTemplateObject",
  scoped: false,
  priority: 0,
  text: `
            var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
                if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
                return cooked;
            };`
};
var readHelper = {
  name: "typescript:read",
  importName: "__read",
  scoped: false,
  text: `
            var __read = (this && this.__read) || function (o, n) {
                var m = typeof Symbol === "function" && o[Symbol.iterator];
                if (!m) return o;
                var i = m.call(o), r, ar = [], e;
                try {
                    while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
                }
                catch (error) { e = { error: error }; }
                finally {
                    try {
                        if (r && !r.done && (m = i["return"])) m.call(i);
                    }
                    finally { if (e) throw e.error; }
                }
                return ar;
            };`
};
var spreadArrayHelper = {
  name: "typescript:spreadArray",
  importName: "__spreadArray",
  scoped: false,
  text: `
            var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
                if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
                    if (ar || !(i in from)) {
                        if (!ar) ar = Array.prototype.slice.call(from, 0, i);
                        ar[i] = from[i];
                    }
                }
                return to.concat(ar || Array.prototype.slice.call(from));
            };`
};
var propKeyHelper = {
  name: "typescript:propKey",
  importName: "__propKey",
  scoped: false,
  text: `
        var __propKey = (this && this.__propKey) || function (x) {
            return typeof x === "symbol" ? x : "".concat(x);
        };`
};
var setFunctionNameHelper = {
  name: "typescript:setFunctionName",
  importName: "__setFunctionName",
  scoped: false,
  text: `
        var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
            if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
            return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
        };`
};
var valuesHelper = {
  name: "typescript:values",
  importName: "__values",
  scoped: false,
  text: `
            var __values = (this && this.__values) || function(o) {
                var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
                if (m) return m.call(o);
                if (o && typeof o.length === "number") return {
                    next: function () {
                        if (o && i >= o.length) o = void 0;
                        return { value: o && o[i++], done: !o };
                    }
                };
                throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
            };`
};
var generatorHelper = {
  name: "typescript:generator",
  importName: "__generator",
  scoped: false,
  priority: 6,
  text: `
            var __generator = (this && this.__generator) || function (thisArg, body) {
                var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
                return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
                function verb(n) { return function (v) { return step([n, v]); }; }
                function step(op) {
                    if (f) throw new TypeError("Generator is already executing.");
                    while (g && (g = 0, op[0] && (_ = 0)), _) try {
                        if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                        if (y = 0, t) op = [op[0] & 2, t.value];
                        switch (op[0]) {
                            case 0: case 1: t = op; break;
                            case 4: _.label++; return { value: op[1], done: false };
                            case 5: _.label++; y = op[1]; op = [0]; continue;
                            case 7: op = _.ops.pop(); _.trys.pop(); continue;
                            default:
                                if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                                if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                                if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                                if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                                if (t[2]) _.ops.pop();
                                _.trys.pop(); continue;
                        }
                        op = body.call(thisArg, _);
                    } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
                    if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
                }
            };`
};
var createBindingHelper = {
  name: "typescript:commonjscreatebinding",
  importName: "__createBinding",
  scoped: false,
  priority: 1,
  text: `
            var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
                if (k2 === undefined) k2 = k;
                var desc = Object.getOwnPropertyDescriptor(m, k);
                if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
                  desc = { enumerable: true, get: function() { return m[k]; } };
                }
                Object.defineProperty(o, k2, desc);
            }) : (function(o, m, k, k2) {
                if (k2 === undefined) k2 = k;
                o[k2] = m[k];
            }));`
};
var setModuleDefaultHelper = {
  name: "typescript:commonjscreatevalue",
  importName: "__setModuleDefault",
  scoped: false,
  priority: 1,
  text: `
            var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
                Object.defineProperty(o, "default", { enumerable: true, value: v });
            }) : function(o, v) {
                o["default"] = v;
            });`
};
var importStarHelper = {
  name: "typescript:commonjsimportstar",
  importName: "__importStar",
  scoped: false,
  dependencies: [createBindingHelper, setModuleDefaultHelper],
  priority: 2,
  text: `
            var __importStar = (this && this.__importStar) || (function () {
                var ownKeys = function(o) {
                    ownKeys = Object.getOwnPropertyNames || function (o) {
                        var ar = [];
                        for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
                        return ar;
                    };
                    return ownKeys(o);
                };
                return function (mod) {
                    if (mod && mod.__esModule) return mod;
                    var result = {};
                    if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
                    __setModuleDefault(result, mod);
                    return result;
                };
            })();`
};
var importDefaultHelper = {
  name: "typescript:commonjsimportdefault",
  importName: "__importDefault",
  scoped: false,
  text: `
            var __importDefault = (this && this.__importDefault) || function (mod) {
                return (mod && mod.__esModule) ? mod : { "default": mod };
            };`
};
var exportStarHelper = {
  name: "typescript:export-star",
  importName: "__exportStar",
  scoped: false,
  dependencies: [createBindingHelper],
  priority: 2,
  text: `
            var __exportStar = (this && this.__exportStar) || function(m, exports) {
                for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
            };`
};
var classPrivateFieldGetHelper = {
  name: "typescript:classPrivateFieldGet",
  importName: "__classPrivateFieldGet",
  scoped: false,
  text: `
            var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
                if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
                if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
                return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
            };`
};
var classPrivateFieldSetHelper = {
  name: "typescript:classPrivateFieldSet",
  importName: "__classPrivateFieldSet",
  scoped: false,
  text: `
            var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
                if (kind === "m") throw new TypeError("Private method is not writable");
                if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
                if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
                return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
            };`
};
var classPrivateFieldInHelper = {
  name: "typescript:classPrivateFieldIn",
  importName: "__classPrivateFieldIn",
  scoped: false,
  text: `
            var __classPrivateFieldIn = (this && this.__classPrivateFieldIn) || function(state, receiver) {
                if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
                return typeof state === "function" ? receiver === state : state.has(receiver);
            };`
};
var addDisposableResourceHelper = {
  name: "typescript:addDisposableResource",
  importName: "__addDisposableResource",
  scoped: false,
  text: `
        var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
            if (value !== null && value !== void 0) {
                if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
                var dispose, inner;
                if (async) {
                    if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
                    dispose = value[Symbol.asyncDispose];
                }
                if (dispose === void 0) {
                    if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
                    dispose = value[Symbol.dispose];
                    if (async) inner = dispose;
                }
                if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
                if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
                env.stack.push({ value: value, dispose: dispose, async: async });
            }
            else if (async) {
                env.stack.push({ async: true });
            }
            return value;
        };`
};
var disposeResourcesHelper = {
  name: "typescript:disposeResources",
  importName: "__disposeResources",
  scoped: false,
  text: `
        var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
            return function (env) {
                function fail(e) {
                    env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
                    env.hasError = true;
                }
                var r, s = 0;
                function next() {
                    while (r = env.stack.pop()) {
                        try {
                            if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
                            if (r.dispose) {
                                var result = r.dispose.call(r.value);
                                if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
                            }
                            else s |= 1;
                        }
                        catch (e) {
                            fail(e);
                        }
                    }
                    if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
                    if (env.hasError) throw env.error;
                }
                return next();
            };
        })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
            var e = new Error(message);
            return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
        });`
};
var rewriteRelativeImportExtensionsHelper = {
  name: "typescript:rewriteRelativeImportExtensions",
  importName: "__rewriteRelativeImportExtension",
  scoped: false,
  text: `
        var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
            if (typeof path === "string" && /^\\.\\.?\\//.test(path)) {
                return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
                    return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
                });
            }
            return path;
        };`
};
var asyncSuperHelper = {
  name: "typescript:async-super",
  scoped: true,
  text: helperString`
            const ${"_superIndex"} = name => super[name];`
};
var advancedAsyncSuperHelper = {
  name: "typescript:advanced-async-super",
  scoped: true,
  text: helperString`
            const ${"_superIndex"} = (function (geti, seti) {
                const cache = Object.create(null);
                return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });
            })(name => super[name], (name, value) => super[name] = value);`
};
function isCallToHelper(firstSegment, helperName) {
  return isCallExpression(firstSegment) && isIdentifier(firstSegment.expression) && (getEmitFlags(firstSegment.expression) & 8192 /* HelperName */) !== 0 && firstSegment.expression.escapedText === helperName;
}

// src/compiler/factory/nodeTests.ts
function isNumericLiteral(node) {
  return node.kind === 9 /* NumericLiteral */;
}
function isBigIntLiteral(node) {
  return node.kind === 10 /* BigIntLiteral */;
}
function isStringLiteral(node) {
  return node.kind === 11 /* StringLiteral */;
}
function isJsxText(node) {
  return node.kind === 12 /* JsxText */;
}
function isRegularExpressionLiteral(node) {
  return node.kind === 14 /* RegularExpressionLiteral */;
}
function isNoSubstitutionTemplateLiteral(node) {
  return node.kind === 15 /* NoSubstitutionTemplateLiteral */;
}
function isTemplateHead(node) {
  return node.kind === 16 /* TemplateHead */;
}
function isTemplateMiddle(node) {
  return node.kind === 17 /* TemplateMiddle */;
}
function isTemplateTail(node) {
  return node.kind === 18 /* TemplateTail */;
}
function isDotDotDotToken(node) {
  return node.kind === 26 /* DotDotDotToken */;
}
function isCommaToken(node) {
  return node.kind === 28 /* CommaToken */;
}
function isPlusToken(node) {
  return node.kind === 40 /* PlusToken */;
}
function isMinusToken(node) {
  return node.kind === 41 /* MinusToken */;
}
function isAsteriskToken(node) {
  return node.kind === 42 /* AsteriskToken */;
}
function isExclamationToken(node) {
  return node.kind === 54 /* ExclamationToken */;
}
function isQuestionToken(node) {
  return node.kind === 58 /* QuestionToken */;
}
function isColonToken(node) {
  return node.kind === 59 /* ColonToken */;
}
function isQuestionDotToken(node) {
  return node.kind === 29 /* QuestionDotToken */;
}
function isEqualsGreaterThanToken(node) {
  return node.kind === 39 /* EqualsGreaterThanToken */;
}
function isIdentifier(node) {
  return node.kind === 80 /* Identifier */;
}
function isPrivateIdentifier(node) {
  return node.kind === 81 /* PrivateIdentifier */;
}
function isExportModifier(node) {
  return node.kind === 95 /* ExportKeyword */;
}
function isDefaultModifier(node) {
  return node.kind === 90 /* DefaultKeyword */;
}
function isAsyncModifier(node) {
  return node.kind === 134 /* AsyncKeyword */;
}
function isAssertsKeyword(node) {
  return node.kind === 131 /* AssertsKeyword */;
}
function isAwaitKeyword(node) {
  return node.kind === 135 /* AwaitKeyword */;
}
function isReadonlyKeyword(node) {
  return node.kind === 148 /* ReadonlyKeyword */;
}
function isStaticModifier(node) {
  return node.kind === 126 /* StaticKeyword */;
}
function isAbstractModifier(node) {
  return node.kind === 128 /* AbstractKeyword */;
}
function isOverrideModifier(node) {
  return node.kind === 164 /* OverrideKeyword */;
}
function isAccessorModifier(node) {
  return node.kind === 129 /* AccessorKeyword */;
}
function isSuperKeyword(node) {
  return node.kind === 108 /* SuperKeyword */;
}
function isImportKeyword(node) {
  return node.kind === 102 /* ImportKeyword */;
}
function isCaseKeyword(node) {
  return node.kind === 84 /* CaseKeyword */;
}
function isQualifiedName(node) {
  return node.kind === 166 /* QualifiedName */;
}
function isComputedPropertyName(node) {
  return node.kind === 167 /* ComputedPropertyName */;
}
function isTypeParameterDeclaration(node) {
  return node.kind === 168 /* TypeParameter */;
}
function isParameter(node) {
  return node.kind === 169 /* Parameter */;
}
function isDecorator(node) {
  return node.kind === 170 /* Decorator */;
}
function isPropertySignature(node) {
  return node.kind === 171 /* PropertySignature */;
}
function isPropertyDeclaration(node) {
  return node.kind === 172 /* PropertyDeclaration */;
}
function isMethodSignature(node) {
  return node.kind === 173 /* MethodSignature */;
}
function isMethodDeclaration(node) {
  return node.kind === 174 /* MethodDeclaration */;
}
function isClassStaticBlockDeclaration(node) {
  return node.kind === 175 /* ClassStaticBlockDeclaration */;
}
function isConstructorDeclaration(node) {
  return node.kind === 176 /* Constructor */;
}
function isGetAccessorDeclaration(node) {
  return node.kind === 177 /* GetAccessor */;
}
function isSetAccessorDeclaration(node) {
  return node.kind === 178 /* SetAccessor */;
}
function isCallSignatureDeclaration(node) {
  return node.kind === 179 /* CallSignature */;
}
function isConstructSignatureDeclaration(node) {
  return node.kind === 180 /* ConstructSignature */;
}
function isIndexSignatureDeclaration(node) {
  return node.kind === 181 /* IndexSignature */;
}
function isTypePredicateNode(node) {
  return node.kind === 182 /* TypePredicate */;
}
function isTypeReferenceNode(node) {
  return node.kind === 183 /* TypeReference */;
}
function isFunctionTypeNode(node) {
  return node.kind === 184 /* FunctionType */;
}
function isConstructorTypeNode(node) {
  return node.kind === 185 /* ConstructorType */;
}
function isTypeQueryNode(node) {
  return node.kind === 186 /* TypeQuery */;
}
function isTypeLiteralNode(node) {
  return node.kind === 187 /* TypeLiteral */;
}
function isArrayTypeNode(node) {
  return node.kind === 188 /* ArrayType */;
}
function isTupleTypeNode(node) {
  return node.kind === 189 /* TupleType */;
}
function isNamedTupleMember(node) {
  return node.kind === 202 /* NamedTupleMember */;
}
function isOptionalTypeNode(node) {
  return node.kind === 190 /* OptionalType */;
}
function isRestTypeNode(node) {
  return node.kind === 191 /* RestType */;
}
function isUnionTypeNode(node) {
  return node.kind === 192 /* UnionType */;
}
function isIntersectionTypeNode(node) {
  return node.kind === 193 /* IntersectionType */;
}
function isConditionalTypeNode(node) {
  return node.kind === 194 /* ConditionalType */;
}
function isInferTypeNode(node) {
  return node.kind === 195 /* InferType */;
}
function isParenthesizedTypeNode(node) {
  return node.kind === 196 /* ParenthesizedType */;
}
function isThisTypeNode(node) {
  return node.kind === 197 /* ThisType */;
}
function isTypeOperatorNode(node) {
  return node.kind === 198 /* TypeOperator */;
}
function isIndexedAccessTypeNode(node) {
  return node.kind === 199 /* IndexedAccessType */;
}
function isMappedTypeNode(node) {
  return node.kind === 200 /* MappedType */;
}
function isLiteralTypeNode(node) {
  return node.kind === 201 /* LiteralType */;
}
function isImportTypeNode(node) {
  return node.kind === 205 /* ImportType */;
}
function isTemplateLiteralTypeSpan(node) {
  return node.kind === 204 /* TemplateLiteralTypeSpan */;
}
function isTemplateLiteralTypeNode(node) {
  return node.kind === 203 /* TemplateLiteralType */;
}
function isObjectBindingPattern(node) {
  return node.kind === 206 /* ObjectBindingPattern */;
}
function isArrayBindingPattern(node) {
  return node.kind === 207 /* ArrayBindingPattern */;
}
function isBindingElement(node) {
  return node.kind === 208 /* BindingElement */;
}
function isArrayLiteralExpression(node) {
  return node.kind === 209 /* ArrayLiteralExpression */;
}
function isObjectLiteralExpression(node) {
  return node.kind === 210 /* ObjectLiteralExpression */;
}
function isPropertyAccessExpression(node) {
  return node.kind === 211 /* PropertyAccessExpression */;
}
function isElementAccessExpression(node) {
  return node.kind === 212 /* ElementAccessExpression */;
}
function isCallExpression(node) {
  return node.kind === 213 /* CallExpression */;
}
function isNewExpression(node) {
  return node.kind === 214 /* NewExpression */;
}
function isTaggedTemplateExpression(node) {
  return node.kind === 215 /* TaggedTemplateExpression */;
}
function isTypeAssertionExpression(node) {
  return node.kind === 216 /* TypeAssertionExpression */;
}
function isParenthesizedExpression(node) {
  return node.kind === 217 /* ParenthesizedExpression */;
}
function isFunctionExpression(node) {
  return node.kind === 218 /* FunctionExpression */;
}
function isArrowFunction(node) {
  return node.kind === 219 /* ArrowFunction */;
}
function isDeleteExpression(node) {
  return node.kind === 220 /* DeleteExpression */;
}
function isTypeOfExpression(node) {
  return node.kind === 221 /* TypeOfExpression */;
}
function isVoidExpression(node) {
  return node.kind === 222 /* VoidExpression */;
}
function isAwaitExpression(node) {
  return node.kind === 223 /* AwaitExpression */;
}
function isPrefixUnaryExpression(node) {
  return node.kind === 224 /* PrefixUnaryExpression */;
}
function isPostfixUnaryExpression(node) {
  return node.kind === 225 /* PostfixUnaryExpression */;
}
function isBinaryExpression(node) {
  return node.kind === 226 /* BinaryExpression */;
}
function isConditionalExpression(node) {
  return node.kind === 227 /* ConditionalExpression */;
}
function isTemplateExpression(node) {
  return node.kind === 228 /* TemplateExpression */;
}
function isYieldExpression(node) {
  return node.kind === 229 /* YieldExpression */;
}
function isSpreadElement(node) {
  return node.kind === 230 /* SpreadElement */;
}
function isClassExpression(node) {
  return node.kind === 231 /* ClassExpression */;
}
function isOmittedExpression(node) {
  return node.kind === 232 /* OmittedExpression */;
}
function isExpressionWithTypeArguments(node) {
  return node.kind === 233 /* ExpressionWithTypeArguments */;
}
function isAsExpression(node) {
  return node.kind === 234 /* AsExpression */;
}
function isSatisfiesExpression(node) {
  return node.kind === 238 /* SatisfiesExpression */;
}
function isNonNullExpression(node) {
  return node.kind === 235 /* NonNullExpression */;
}
function isMetaProperty(node) {
  return node.kind === 236 /* MetaProperty */;
}
function isSyntheticExpression(node) {
  return node.kind === 237 /* SyntheticExpression */;
}
function isPartiallyEmittedExpression(node) {
  return node.kind === 355 /* PartiallyEmittedExpression */;
}
function isCommaListExpression(node) {
  return node.kind === 356 /* CommaListExpression */;
}
function isTemplateSpan(node) {
  return node.kind === 239 /* TemplateSpan */;
}
function isSemicolonClassElement(node) {
  return node.kind === 240 /* SemicolonClassElement */;
}
function isBlock(node) {
  return node.kind === 241 /* Block */;
}
function isVariableStatement(node) {
  return node.kind === 243 /* VariableStatement */;
}
function isEmptyStatement(node) {
  return node.kind === 242 /* EmptyStatement */;
}
function isExpressionStatement(node) {
  return node.kind === 244 /* ExpressionStatement */;
}
function isIfStatement(node) {
  return node.kind === 245 /* IfStatement */;
}
function isDoStatement(node) {
  return node.kind === 246 /* DoStatement */;
}
function isWhileStatement(node) {
  return node.kind === 247 /* WhileStatement */;
}
function isForStatement(node) {
  return node.kind === 248 /* ForStatement */;
}
function isForInStatement(node) {
  return node.kind === 249 /* ForInStatement */;
}
function isForOfStatement(node) {
  return node.kind === 250 /* ForOfStatement */;
}
function isContinueStatement(node) {
  return node.kind === 251 /* ContinueStatement */;
}
function isBreakStatement(node) {
  return node.kind === 252 /* BreakStatement */;
}
function isReturnStatement(node) {
  return node.kind === 253 /* ReturnStatement */;
}
function isWithStatement(node) {
  return node.kind === 254 /* WithStatement */;
}
function isSwitchStatement(node) {
  return node.kind === 255 /* SwitchStatement */;
}
function isLabeledStatement(node) {
  return node.kind === 256 /* LabeledStatement */;
}
function isThrowStatement(node) {
  return node.kind === 257 /* ThrowStatement */;
}
function isTryStatement(node) {
  return node.kind === 258 /* TryStatement */;
}
function isDebuggerStatement(node) {
  return node.kind === 259 /* DebuggerStatement */;
}
function isVariableDeclaration(node) {
  return node.kind === 260 /* VariableDeclaration */;
}
function isVariableDeclarationList(node) {
  return node.kind === 261 /* VariableDeclarationList */;
}
function isFunctionDeclaration(node) {
  return node.kind === 262 /* FunctionDeclaration */;
}
function isClassDeclaration(node) {
  return node.kind === 263 /* ClassDeclaration */;
}
function isInterfaceDeclaration(node) {
  return node.kind === 264 /* InterfaceDeclaration */;
}
function isTypeAliasDeclaration(node) {
  return node.kind === 265 /* TypeAliasDeclaration */;
}
function isEnumDeclaration(node) {
  return node.kind === 266 /* EnumDeclaration */;
}
function isModuleDeclaration(node) {
  return node.kind === 267 /* ModuleDeclaration */;
}
function isModuleBlock(node) {
  return node.kind === 268 /* ModuleBlock */;
}
function isCaseBlock(node) {
  return node.kind === 269 /* CaseBlock */;
}
function isNamespaceExportDeclaration(node) {
  return node.kind === 270 /* NamespaceExportDeclaration */;
}
function isImportEqualsDeclaration(node) {
  return node.kind === 271 /* ImportEqualsDeclaration */;
}
function isImportDeclaration(node) {
  return node.kind === 272 /* ImportDeclaration */;
}
function isImportClause(node) {
  return node.kind === 273 /* ImportClause */;
}
function isImportTypeAssertionContainer(node) {
  return node.kind === 302 /* ImportTypeAssertionContainer */;
}
function isAssertClause(node) {
  return node.kind === 300 /* AssertClause */;
}
function isAssertEntry(node) {
  return node.kind === 301 /* AssertEntry */;
}
function isImportAttributes(node) {
  return node.kind === 300 /* ImportAttributes */;
}
function isImportAttribute(node) {
  return node.kind === 301 /* ImportAttribute */;
}
function isNamespaceImport(node) {
  return node.kind === 274 /* NamespaceImport */;
}
function isNamespaceExport(node) {
  return node.kind === 280 /* NamespaceExport */;
}
function isNamedImports(node) {
  return node.kind === 275 /* NamedImports */;
}
function isImportSpecifier(node) {
  return node.kind === 276 /* ImportSpecifier */;
}
function isExportAssignment(node) {
  return node.kind === 277 /* ExportAssignment */;
}
function isExportDeclaration(node) {
  return node.kind === 278 /* ExportDeclaration */;
}
function isNamedExports(node) {
  return node.kind === 279 /* NamedExports */;
}
function isExportSpecifier(node) {
  return node.kind === 281 /* ExportSpecifier */;
}
function isModuleExportName(node) {
  return node.kind === 80 /* Identifier */ || node.kind === 11 /* StringLiteral */;
}
function isMissingDeclaration(node) {
  return node.kind === 282 /* MissingDeclaration */;
}
function isNotEmittedStatement(node) {
  return node.kind === 353 /* NotEmittedStatement */;
}
function isSyntheticReference(node) {
  return node.kind === 357 /* SyntheticReferenceExpression */;
}
function isExternalModuleReference(node) {
  return node.kind === 283 /* ExternalModuleReference */;
}
function isJsxElement(node) {
  return node.kind === 284 /* JsxElement */;
}
function isJsxSelfClosingElement(node) {
  return node.kind === 285 /* JsxSelfClosingElement */;
}
function isJsxOpeningElement(node) {
  return node.kind === 286 /* JsxOpeningElement */;
}
function isJsxClosingElement(node) {
  return node.kind === 287 /* JsxClosingElement */;
}
function isJsxFragment(node) {
  return node.kind === 288 /* JsxFragment */;
}
function isJsxOpeningFragment(node) {
  return node.kind === 289 /* JsxOpeningFragment */;
}
function isJsxClosingFragment(node) {
  return node.kind === 290 /* JsxClosingFragment */;
}
function isJsxAttribute(node) {
  return node.kind === 291 /* JsxAttribute */;
}
function isJsxAttributes(node) {
  return node.kind === 292 /* JsxAttributes */;
}
function isJsxSpreadAttribute(node) {
  return node.kind === 293 /* JsxSpreadAttribute */;
}
function isJsxExpression(node) {
  return node.kind === 294 /* JsxExpression */;
}
function isJsxNamespacedName(node) {
  return node.kind === 295 /* JsxNamespacedName */;
}
function isCaseClause(node) {
  return node.kind === 296 /* CaseClause */;
}
function isDefaultClause(node) {
  return node.kind === 297 /* DefaultClause */;
}
function isHeritageClause(node) {
  return node.kind === 298 /* HeritageClause */;
}
function isCatchClause(node) {
  return node.kind === 299 /* CatchClause */;
}
function isPropertyAssignment(node) {
  return node.kind === 303 /* PropertyAssignment */;
}
function isShorthandPropertyAssignment(node) {
  return node.kind === 304 /* ShorthandPropertyAssignment */;
}
function isSpreadAssignment(node) {
  return node.kind === 305 /* SpreadAssignment */;
}
function isEnumMember(node) {
  return node.kind === 306 /* EnumMember */;
}
function isSourceFile(node) {
  return node.kind === 307 /* SourceFile */;
}
function isBundle(node) {
  return node.kind === 308 /* Bundle */;
}
function isJSDocTypeExpression(node) {
  return node.kind === 309 /* JSDocTypeExpression */;
}
function isJSDocNameReference(node) {
  return node.kind === 310 /* JSDocNameReference */;
}
function isJSDocMemberName(node) {
  return node.kind === 311 /* JSDocMemberName */;
}
function isJSDocLink(node) {
  return node.kind === 324 /* JSDocLink */;
}
function isJSDocLinkCode(node) {
  return node.kind === 325 /* JSDocLinkCode */;
}
function isJSDocLinkPlain(node) {
  return node.kind === 326 /* JSDocLinkPlain */;
}
function isJSDocAllType(node) {
  return node.kind === 312 /* JSDocAllType */;
}
function isJSDocUnknownType(node) {
  return node.kind === 313 /* JSDocUnknownType */;
}
function isJSDocNullableType(node) {
  return node.kind === 314 /* JSDocNullableType */;
}
function isJSDocNonNullableType(node) {
  return node.kind === 315 /* JSDocNonNullableType */;
}
function isJSDocOptionalType(node) {
  return node.kind === 316 /* JSDocOptionalType */;
}
function isJSDocFunctionType(node) {
  return node.kind === 317 /* JSDocFunctionType */;
}
function isJSDocVariadicType(node) {
  return node.kind === 318 /* JSDocVariadicType */;
}
function isJSDocNamepathType(node) {
  return node.kind === 319 /* JSDocNamepathType */;
}
function isJSDoc(node) {
  return node.kind === 320 /* JSDoc */;
}
function isJSDocTypeLiteral(node) {
  return node.kind === 322 /* JSDocTypeLiteral */;
}
function isJSDocSignature(node) {
  return node.kind === 323 /* JSDocSignature */;
}
function isJSDocAugmentsTag(node) {
  return node.kind === 328 /* JSDocAugmentsTag */;
}
function isJSDocAuthorTag(node) {
  return node.kind === 330 /* JSDocAuthorTag */;
}
function isJSDocClassTag(node) {
  return node.kind === 332 /* JSDocClassTag */;
}
function isJSDocCallbackTag(node) {
  return node.kind === 338 /* JSDocCallbackTag */;
}
function isJSDocPublicTag(node) {
  return node.kind === 333 /* JSDocPublicTag */;
}
function isJSDocPrivateTag(node) {
  return node.kind === 334 /* JSDocPrivateTag */;
}
function isJSDocProtectedTag(node) {
  return node.kind === 335 /* JSDocProtectedTag */;
}
function isJSDocReadonlyTag(node) {
  return node.kind === 336 /* JSDocReadonlyTag */;
}
function isJSDocOverrideTag(node) {
  return node.kind === 337 /* JSDocOverrideTag */;
}
function isJSDocOverloadTag(node) {
  return node.kind === 339 /* JSDocOverloadTag */;
}
function isJSDocDeprecatedTag(node) {
  return node.kind === 331 /* JSDocDeprecatedTag */;
}
function isJSDocSeeTag(node) {
  return node.kind === 347 /* JSDocSeeTag */;
}
function isJSDocEnumTag(node) {
  return node.kind === 340 /* JSDocEnumTag */;
}
function isJSDocParameterTag(node) {
  return node.kind === 341 /* JSDocParameterTag */;
}
function isJSDocReturnTag(node) {
  return node.kind === 342 /* JSDocReturnTag */;
}
function isJSDocThisTag(node) {
  return node.kind === 343 /* JSDocThisTag */;
}
function isJSDocTypeTag(node) {
  return node.kind === 344 /* JSDocTypeTag */;
}
function isJSDocTemplateTag(node) {
  return node.kind === 345 /* JSDocTemplateTag */;
}
function isJSDocTypedefTag(node) {
  return node.kind === 346 /* JSDocTypedefTag */;
}
function isJSDocUnknownTag(node) {
  return node.kind === 327 /* JSDocTag */;
}
function isJSDocPropertyTag(node) {
  return node.kind === 348 /* JSDocPropertyTag */;
}
function isJSDocImplementsTag(node) {
  return node.kind === 329 /* JSDocImplementsTag */;
}
function isJSDocSatisfiesTag(node) {
  return node.kind === 350 /* JSDocSatisfiesTag */;
}
function isJSDocThrowsTag(node) {
  return node.kind === 349 /* JSDocThrowsTag */;
}
function isJSDocImportTag(node) {
  return node.kind === 351 /* JSDocImportTag */;
}
function isSyntaxList(n) {
  return n.kind === 352 /* SyntaxList */;
}

// src/compiler/factory/nodeChildren.ts
var sourceFileToNodeChildren = /* @__PURE__ */ new WeakMap();
function getNodeChildren(node, sourceFile) {
  var _a;
  const kind = node.kind;
  if (!isNodeKind(kind)) {
    return emptyArray;
  }
  if (kind === 352 /* SyntaxList */) {
    return node._children;
  }
  return (_a = sourceFileToNodeChildren.get(sourceFile)) == null ? void 0 : _a.get(node);
}
function setNodeChildren(node, sourceFile, children) {
  if (node.kind === 352 /* SyntaxList */) {
    Debug.fail("Should not need to re-set the children of a SyntaxList.");
  }
  let map2 = sourceFileToNodeChildren.get(sourceFile);
  if (map2 === void 0) {
    map2 = /* @__PURE__ */ new WeakMap();
    sourceFileToNodeChildren.set(sourceFile, map2);
  }
  map2.set(node, children);
  return children;
}
function unsetNodeChildren(node, origSourceFile) {
  var _a;
  if (node.kind === 352 /* SyntaxList */) {
    Debug.fail("Did not expect to unset the children of a SyntaxList.");
  }
  (_a = sourceFileToNodeChildren.get(origSourceFile)) == null ? void 0 : _a.delete(node);
}
function transferSourceFileChildren(sourceFile, targetSourceFile) {
  const map2 = sourceFileToNodeChildren.get(sourceFile);
  if (map2 !== void 0) {
    sourceFileToNodeChildren.delete(sourceFile);
    sourceFileToNodeChildren.set(targetSourceFile, map2);
  }
}

// src/compiler/factory/utilities.ts
function createEmptyExports(factory2) {
  return factory2.createExportDeclaration(
    /*modifiers*/
    void 0,
    /*isTypeOnly*/
    false,
    factory2.createNamedExports([]),
    /*moduleSpecifier*/
    void 0
  );
}
function createMemberAccessForPropertyName(factory2, target, memberName, location) {
  if (isComputedPropertyName(memberName)) {
    return setTextRange(factory2.createElementAccessExpression(target, memberName.expression), location);
  } else {
    const expression = setTextRange(
      isMemberName(memberName) ? factory2.createPropertyAccessExpression(target, memberName) : factory2.createElementAccessExpression(target, memberName),
      memberName
    );
    addEmitFlags(expression, 128 /* NoNestedSourceMaps */);
    return expression;
  }
}
function createReactNamespace(reactNamespace, parent2) {
  const react = parseNodeFactory.createIdentifier(reactNamespace || "React");
  setParent(react, getParseTreeNode(parent2));
  return react;
}
function createJsxFactoryExpressionFromEntityName(factory2, jsxFactory, parent2) {
  if (isQualifiedName(jsxFactory)) {
    const left = createJsxFactoryExpressionFromEntityName(factory2, jsxFactory.left, parent2);
    const right = factory2.createIdentifier(idText(jsxFactory.right));
    right.escapedText = jsxFactory.right.escapedText;
    return factory2.createPropertyAccessExpression(left, right);
  } else {
    return createReactNamespace(idText(jsxFactory), parent2);
  }
}
function createJsxFactoryExpression(factory2, jsxFactoryEntity, reactNamespace, parent2) {
  return jsxFactoryEntity ? createJsxFactoryExpressionFromEntityName(factory2, jsxFactoryEntity, parent2) : factory2.createPropertyAccessExpression(
    createReactNamespace(reactNamespace, parent2),
    "createElement"
  );
}
function createJsxFragmentFactoryExpression(factory2, jsxFragmentFactoryEntity, reactNamespace, parent2) {
  return jsxFragmentFactoryEntity ? createJsxFactoryExpressionFromEntityName(factory2, jsxFragmentFactoryEntity, parent2) : factory2.createPropertyAccessExpression(
    createReactNamespace(reactNamespace, parent2),
    "Fragment"
  );
}
function createExpressionForJsxElement(factory2, callee, tagName, props, children, location) {
  const argumentsList = [tagName];
  if (props) {
    argumentsList.push(props);
  }
  if (children && children.length > 0) {
    if (!props) {
      argumentsList.push(factory2.createNull());
    }
    if (children.length > 1) {
      for (const child of children) {
        startOnNewLine(child);
        argumentsList.push(child);
      }
    } else {
      argumentsList.push(children[0]);
    }
  }
  return setTextRange(
    factory2.createCallExpression(
      callee,
      /*typeArguments*/
      void 0,
      argumentsList
    ),
    location
  );
}
function createExpressionForJsxFragment(factory2, jsxFactoryEntity, jsxFragmentFactoryEntity, reactNamespace, children, parentElement, location) {
  const tagName = createJsxFragmentFactoryExpression(factory2, jsxFragmentFactoryEntity, reactNamespace, parentElement);
  const argumentsList = [tagName, factory2.createNull()];
  if (children && children.length > 0) {
    if (children.length > 1) {
      for (const child of children) {
        startOnNewLine(child);
        argumentsList.push(child);
      }
    } else {
      argumentsList.push(children[0]);
    }
  }
  return setTextRange(
    factory2.createCallExpression(
      createJsxFactoryExpression(factory2, jsxFactoryEntity, reactNamespace, parentElement),
      /*typeArguments*/
      void 0,
      argumentsList
    ),
    location
  );
}
function createForOfBindingStatement(factory2, node, boundValue) {
  if (isVariableDeclarationList(node)) {
    const firstDeclaration = first(node.declarations);
    const updatedDeclaration = factory2.updateVariableDeclaration(
      firstDeclaration,
      firstDeclaration.name,
      /*exclamationToken*/
      void 0,
      /*type*/
      void 0,
      boundValue
    );
    return setTextRange(
      factory2.createVariableStatement(
        /*modifiers*/
        void 0,
        factory2.updateVariableDeclarationList(node, [updatedDeclaration])
      ),
      /*location*/
      node
    );
  } else {
    const updatedExpression = setTextRange(
      factory2.createAssignment(node, boundValue),
      /*location*/
      node
    );
    return setTextRange(
      factory2.createExpressionStatement(updatedExpression),
      /*location*/
      node
    );
  }
}
function createExpressionFromEntityName(factory2, node) {
  if (isQualifiedName(node)) {
    const left = createExpressionFromEntityName(factory2, node.left);
    const right = setParent(setTextRange(factory2.cloneNode(node.right), node.right), node.right.parent);
    return setTextRange(factory2.createPropertyAccessExpression(left, right), node);
  } else {
    return setParent(setTextRange(factory2.cloneNode(node), node), node.parent);
  }
}
function createExpressionForPropertyName(factory2, memberName) {
  if (isIdentifier(memberName)) {
    return factory2.createStringLiteralFromNode(memberName);
  } else if (isComputedPropertyName(memberName)) {
    return setParent(setTextRange(factory2.cloneNode(memberName.expression), memberName.expression), memberName.expression.parent);
  } else {
    return setParent(setTextRange(factory2.cloneNode(memberName), memberName), memberName.parent);
  }
}
function createExpressionForAccessorDeclaration(factory2, properties, property, receiver, multiLine) {
  const { firstAccessor, getAccessor, setAccessor } = getAllAccessorDeclarations(properties, property);
  if (property === firstAccessor) {
    return setTextRange(
      factory2.createObjectDefinePropertyCall(
        receiver,
        createExpressionForPropertyName(factory2, property.name),
        factory2.createPropertyDescriptor({
          enumerable: factory2.createFalse(),
          configurable: true,
          get: getAccessor && setTextRange(
            setOriginalNode(
              factory2.createFunctionExpression(
                getModifiers(getAccessor),
                /*asteriskToken*/
                void 0,
                /*name*/
                void 0,
                /*typeParameters*/
                void 0,
                getAccessor.parameters,
                /*type*/
                void 0,
                getAccessor.body
                // TODO: GH#18217
              ),
              getAccessor
            ),
            getAccessor
          ),
          set: setAccessor && setTextRange(
            setOriginalNode(
              factory2.createFunctionExpression(
                getModifiers(setAccessor),
                /*asteriskToken*/
                void 0,
                /*name*/
                void 0,
                /*typeParameters*/
                void 0,
                setAccessor.parameters,
                /*type*/
                void 0,
                setAccessor.body
                // TODO: GH#18217
              ),
              setAccessor
            ),
            setAccessor
          )
        }, !multiLine)
      ),
      firstAccessor
    );
  }
  return void 0;
}
function createExpressionForPropertyAssignment(factory2, property, receiver) {
  return setOriginalNode(
    setTextRange(
      factory2.createAssignment(
        createMemberAccessForPropertyName(
          factory2,
          receiver,
          property.name,
          /*location*/
          property.name
        ),
        property.initializer
      ),
      property
    ),
    property
  );
}
function createExpressionForShorthandPropertyAssignment(factory2, property, receiver) {
  return setOriginalNode(
    setTextRange(
      factory2.createAssignment(
        createMemberAccessForPropertyName(
          factory2,
          receiver,
          property.name,
          /*location*/
          property.name
        ),
        factory2.cloneNode(property.name)
      ),
      /*location*/
      property
    ),
    /*original*/
    property
  );
}
function createExpressionForMethodDeclaration(factory2, method, receiver) {
  return setOriginalNode(
    setTextRange(
      factory2.createAssignment(
        createMemberAccessForPropertyName(
          factory2,
          receiver,
          method.name,
          /*location*/
          method.name
        ),
        setOriginalNode(
          setTextRange(
            factory2.createFunctionExpression(
              getModifiers(method),
              method.asteriskToken,
              /*name*/
              void 0,
              /*typeParameters*/
              void 0,
              method.parameters,
              /*type*/
              void 0,
              method.body
              // TODO: GH#18217
            ),
            /*location*/
            method
          ),
          /*original*/
          method
        )
      ),
      /*location*/
      method
    ),
    /*original*/
    method
  );
}
function createExpressionForObjectLiteralElementLike(factory2, node, property, receiver) {
  if (property.name && isPrivateIdentifier(property.name)) {
    Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals.");
  }
  switch (property.kind) {
    case 177 /* GetAccessor */:
    case 178 /* SetAccessor */:
      return createExpressionForAccessorDeclaration(factory2, node.properties, property, receiver, !!node.multiLine);
    case 303 /* PropertyAssignment */:
      return createExpressionForPropertyAssignment(factory2, property, receiver);
    case 304 /* ShorthandPropertyAssignment */:
      return createExpressionForShorthandPropertyAssignment(factory2, property, receiver);
    case 174 /* MethodDeclaration */:
      return createExpressionForMethodDeclaration(factory2, property, receiver);
  }
}
function expandPreOrPostfixIncrementOrDecrementExpression(factory2, node, expression, recordTempVariable, resultVariable) {
  const operator = node.operator;
  Debug.assert(operator === 46 /* PlusPlusToken */ || operator === 47 /* MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression");
  const temp = factory2.createTempVariable(recordTempVariable);
  expression = factory2.createAssignment(temp, expression);
  setTextRange(expression, node.operand);
  let operation = isPrefixUnaryExpression(node) ? factory2.createPrefixUnaryExpression(operator, temp) : factory2.createPostfixUnaryExpression(temp, operator);
  setTextRange(operation, node);
  if (resultVariable) {
    operation = factory2.createAssignment(resultVariable, operation);
    setTextRange(operation, node);
  }
  expression = factory2.createComma(expression, operation);
  setTextRange(expression, node);
  if (isPostfixUnaryExpression(node)) {
    expression = factory2.createComma(expression, temp);
    setTextRange(expression, node);
  }
  return expression;
}
function isInternalName(node) {
  return (getEmitFlags(node) & 65536 /* InternalName */) !== 0;
}
function isLocalName(node) {
  return (getEmitFlags(node) & 32768 /* LocalName */) !== 0;
}
function isExportName(node) {
  return (getEmitFlags(node) & 16384 /* ExportName */) !== 0;
}
function isUseStrictPrologue(node) {
  return isStringLiteral(node.expression) && node.expression.text === "use strict";
}
function findUseStrictPrologue(statements) {
  for (const statement of statements) {
    if (isPrologueDirective(statement)) {
      if (isUseStrictPrologue(statement)) {
        return statement;
      }
    } else {
      break;
    }
  }
  return void 0;
}
function startsWithUseStrict(statements) {
  const firstStatement = firstOrUndefined(statements);
  return firstStatement !== void 0 && isPrologueDirective(firstStatement) && isUseStrictPrologue(firstStatement);
}
function isCommaExpression(node) {
  return node.kind === 226 /* BinaryExpression */ && node.operatorToken.kind === 28 /* CommaToken */;
}
function isCommaSequence(node) {
  return isCommaExpression(node) || isCommaListExpression(node);
}
function isJSDocTypeAssertion(node) {
  return isParenthesizedExpression(node) && isInJSFile(node) && !!getJSDocTypeTag(node);
}
function getJSDocTypeAssertionType(node) {
  const type = getJSDocType(node);
  Debug.assertIsDefined(type);
  return type;
}
function isOuterExpression(node, kinds = 31 /* All */) {
  switch (node.kind) {
    case 217 /* ParenthesizedExpression */:
      if (kinds & -2147483648 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) {
        return false;
      }
      return (kinds & 1 /* Parentheses */) !== 0;
    case 216 /* TypeAssertionExpression */:
    case 234 /* AsExpression */:
    case 238 /* SatisfiesExpression */:
      return (kinds & 2 /* TypeAssertions */) !== 0;
    case 233 /* ExpressionWithTypeArguments */:
      return (kinds & 16 /* ExpressionsWithTypeArguments */) !== 0;
    case 235 /* NonNullExpression */:
      return (kinds & 4 /* NonNullAssertions */) !== 0;
    case 355 /* PartiallyEmittedExpression */:
      return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0;
  }
  return false;
}
function skipOuterExpressions(node, kinds = 31 /* All */) {
  while (isOuterExpression(node, kinds)) {
    node = node.expression;
  }
  return node;
}
function walkUpOuterExpressions(node, kinds = 31 /* All */) {
  let parent2 = node.parent;
  while (isOuterExpression(parent2, kinds)) {
    parent2 = parent2.parent;
    Debug.assert(parent2);
  }
  return parent2;
}
function startOnNewLine(node) {
  return setStartsOnNewLine(
    node,
    /*newLine*/
    true
  );
}
function getExternalHelpersModuleName(node) {
  const parseNode = getOriginalNode(node, isSourceFile);
  const emitNode = parseNode && parseNode.emitNode;
  return emitNode && emitNode.externalHelpersModuleName;
}
function hasRecordedExternalHelpers(sourceFile) {
  const parseNode = getOriginalNode(sourceFile, isSourceFile);
  const emitNode = parseNode && parseNode.emitNode;
  return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers);
}
function createExternalHelpersImportDeclarationIfNeeded(nodeFactory, helperFactory, sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) {
  if (compilerOptions.importHelpers && isEffectiveExternalModule(sourceFile, compilerOptions)) {
    const moduleKind = getEmitModuleKind(compilerOptions);
    const impliedModuleKind = getImpliedNodeFormatForEmitWorker(sourceFile, compilerOptions);
    const helpers = getImportedHelpers(sourceFile);
    if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || impliedModuleKind === 99 /* ESNext */ || impliedModuleKind === void 0 && moduleKind === 200 /* Preserve */) {
      if (helpers) {
        const helperNames = [];
        for (const helper of helpers) {
          const importName = helper.importName;
          if (importName) {
            pushIfUnique(helperNames, importName);
          }
        }
        if (some(helperNames)) {
          helperNames.sort(compareStringsCaseSensitive);
          const namedBindings = nodeFactory.createNamedImports(
            map(helperNames, (name) => isFileLevelUniqueName(sourceFile, name) ? nodeFactory.createImportSpecifier(
              /*isTypeOnly*/
              false,
              /*propertyName*/
              void 0,
              nodeFactory.createIdentifier(name)
            ) : nodeFactory.createImportSpecifier(
              /*isTypeOnly*/
              false,
              nodeFactory.createIdentifier(name),
              helperFactory.getUnscopedHelperName(name)
            ))
          );
          const parseNode = getOriginalNode(sourceFile, isSourceFile);
          const emitNode = getOrCreateEmitNode(parseNode);
          emitNode.externalHelpers = true;
          const externalHelpersImportDeclaration = nodeFactory.createImportDeclaration(
            /*modifiers*/
            void 0,
            nodeFactory.createImportClause(
              /*isTypeOnly*/
              false,
              /*name*/
              void 0,
              namedBindings
            ),
            nodeFactory.createStringLiteral(externalHelpersModuleNameText),
            /*attributes*/
            void 0
          );
          addInternalEmitFlags(externalHelpersImportDeclaration, 2 /* NeverApplyImportHelper */);
          return externalHelpersImportDeclaration;
        }
      }
    } else {
      const externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(nodeFactory, sourceFile, compilerOptions, helpers, hasExportStarsToExportValues, hasImportStar || hasImportDefault);
      if (externalHelpersModuleName) {
        const externalHelpersImportDeclaration = nodeFactory.createImportEqualsDeclaration(
          /*modifiers*/
          void 0,
          /*isTypeOnly*/
          false,
          externalHelpersModuleName,
          nodeFactory.createExternalModuleReference(nodeFactory.createStringLiteral(externalHelpersModuleNameText))
        );
        addInternalEmitFlags(externalHelpersImportDeclaration, 2 /* NeverApplyImportHelper */);
        return externalHelpersImportDeclaration;
      }
    }
  }
}
function getImportedHelpers(sourceFile) {
  return filter(getEmitHelpers(sourceFile), (helper) => !helper.scoped);
}
function getOrCreateExternalHelpersModuleNameIfNeeded(factory2, node, compilerOptions, helpers, hasExportStarsToExportValues, hasImportStarOrImportDefault) {
  const externalHelpersModuleName = getExternalHelpersModuleName(node);
  if (externalHelpersModuleName) {
    return externalHelpersModuleName;
  }
  const create = some(helpers) || (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && getEmitModuleFormatOfFileWorker(node, compilerOptions) < 4 /* System */;
  if (create) {
    const parseNode = getOriginalNode(node, isSourceFile);
    const emitNode = getOrCreateEmitNode(parseNode);
    return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = factory2.createUniqueName(externalHelpersModuleNameText));
  }
}
function getLocalNameForExternalImport(factory2, node, sourceFile) {
  const namespaceDeclaration = getNamespaceDeclarationNode(node);
  if (namespaceDeclaration && !isDefaultImport(node) && !isExportNamespaceAsDefaultDeclaration(node)) {
    const name = namespaceDeclaration.name;
    if (name.kind === 11 /* StringLiteral */) {
      return factory2.getGeneratedNameForNode(node);
    }
    return isGeneratedIdentifier(name) ? name : factory2.createIdentifier(getSourceTextOfNodeFromSourceFile(sourceFile, name) || idText(name));
  }
  if (node.kind === 272 /* ImportDeclaration */ && node.importClause) {
    return factory2.getGeneratedNameForNode(node);
  }
  if (node.kind === 278 /* ExportDeclaration */ && node.moduleSpecifier) {
    return factory2.getGeneratedNameForNode(node);
  }
  return void 0;
}
function getExternalModuleNameLiteral(factory2, importNode, sourceFile, host, resolver, compilerOptions) {
  const moduleName = getExternalModuleName(importNode);
  if (moduleName && isStringLiteral(moduleName)) {
    return tryGetModuleNameFromDeclaration(importNode, host, factory2, resolver, compilerOptions) || tryRenameExternalModule(factory2, moduleName, sourceFile) || factory2.cloneNode(moduleName);
  }
  return void 0;
}
function tryRenameExternalModule(factory2, moduleName, sourceFile) {
  const rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text);
  return rename ? factory2.createStringLiteral(rename) : void 0;
}
function tryGetModuleNameFromFile(factory2, file, host, options) {
  if (!file) {
    return void 0;
  }
  if (file.moduleName) {
    return factory2.createStringLiteral(file.moduleName);
  }
  if (!file.isDeclarationFile && options.outFile) {
    return factory2.createStringLiteral(getExternalModuleNameFromPath(host, file.fileName));
  }
  return void 0;
}
function tryGetModuleNameFromDeclaration(declaration, host, factory2, resolver, compilerOptions) {
  return tryGetModuleNameFromFile(factory2, resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions);
}
function getInitializerOfBindingOrAssignmentElement(bindingElement) {
  if (isDeclarationBindingElement(bindingElement)) {
    return bindingElement.initializer;
  }
  if (isPropertyAssignment(bindingElement)) {
    const initializer = bindingElement.initializer;
    return isAssignmentExpression(
      initializer,
      /*excludeCompoundAssignment*/
      true
    ) ? initializer.right : void 0;
  }
  if (isShorthandPropertyAssignment(bindingElement)) {
    return bindingElement.objectAssignmentInitializer;
  }
  if (isAssignmentExpression(
    bindingElement,
    /*excludeCompoundAssignment*/
    true
  )) {
    return bindingElement.right;
  }
  if (isSpreadElement(bindingElement)) {
    return getInitializerOfBindingOrAssignmentElement(bindingElement.expression);
  }
}
function getTargetOfBindingOrAssignmentElement(bindingElement) {
  if (isDeclarationBindingElement(bindingElement)) {
    return bindingElement.name;
  }
  if (isObjectLiteralElementLike(bindingElement)) {
    switch (bindingElement.kind) {
      case 303 /* PropertyAssignment */:
        return getTargetOfBindingOrAssignmentElement(bindingElement.initializer);
      case 304 /* ShorthandPropertyAssignment */:
        return bindingElement.name;
      case 305 /* SpreadAssignment */:
        return getTargetOfBindingOrAssignmentElement(bindingElement.expression);
    }
    return void 0;
  }
  if (isAssignmentExpression(
    bindingElement,
    /*excludeCompoundAssignment*/
    true
  )) {
    return getTargetOfBindingOrAssignmentElement(bindingElement.left);
  }
  if (isSpreadElement(bindingElement)) {
    return getTargetOfBindingOrAssignmentElement(bindingElement.expression);
  }
  return bindingElement;
}
function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) {
  switch (bindingElement.kind) {
    case 169 /* Parameter */:
    case 208 /* BindingElement */:
      return bindingElement.dotDotDotToken;
    case 230 /* SpreadElement */:
    case 305 /* SpreadAssignment */:
      return bindingElement;
  }
  return void 0;
}
function getPropertyNameOfBindingOrAssignmentElement(bindingElement) {
  const propertyName = tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement);
  Debug.assert(!!propertyName || isSpreadAssignment(bindingElement), "Invalid property name for binding element.");
  return propertyName;
}
function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) {
  switch (bindingElement.kind) {
    case 208 /* BindingElement */:
      if (bindingElement.propertyName) {
        const propertyName = bindingElement.propertyName;
        if (isPrivateIdentifier(propertyName)) {
          return Debug.failBadSyntaxKind(propertyName);
        }
        return isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression) ? propertyName.expression : propertyName;
      }
      break;
    case 303 /* PropertyAssignment */:
      if (bindingElement.name) {
        const propertyName = bindingElement.name;
        if (isPrivateIdentifier(propertyName)) {
          return Debug.failBadSyntaxKind(propertyName);
        }
        return isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression) ? propertyName.expression : propertyName;
      }
      break;
    case 305 /* SpreadAssignment */:
      if (bindingElement.name && isPrivateIdentifier(bindingElement.name)) {
        return Debug.failBadSyntaxKind(bindingElement.name);
      }
      return bindingElement.name;
  }
  const target = getTargetOfBindingOrAssignmentElement(bindingElement);
  if (target && isPropertyName(target)) {
    return target;
  }
}
function isStringOrNumericLiteral(node) {
  const kind = node.kind;
  return kind === 11 /* StringLiteral */ || kind === 9 /* NumericLiteral */;
}
function getElementsOfBindingOrAssignmentPattern(name) {
  switch (name.kind) {
    case 206 /* ObjectBindingPattern */:
    case 207 /* ArrayBindingPattern */:
    case 209 /* ArrayLiteralExpression */:
      return name.elements;
    case 210 /* ObjectLiteralExpression */:
      return name.properties;
  }
}
function getJSDocTypeAliasName(fullName) {
  if (fullName) {
    let rightNode = fullName;
    while (true) {
      if (isIdentifier(rightNode) || !rightNode.body) {
        return isIdentifier(rightNode) ? rightNode : rightNode.name;
      }
      rightNode = rightNode.body;
    }
  }
}
function canHaveIllegalType(node) {
  const kind = node.kind;
  return kind === 176 /* Constructor */ || kind === 178 /* SetAccessor */;
}
function canHaveIllegalTypeParameters(node) {
  const kind = node.kind;
  return kind === 176 /* Constructor */ || kind === 177 /* GetAccessor */ || kind === 178 /* SetAccessor */;
}
function canHaveIllegalDecorators(node) {
  const kind = node.kind;
  return kind === 303 /* PropertyAssignment */ || kind === 304 /* ShorthandPropertyAssignment */ || kind === 262 /* FunctionDeclaration */ || kind === 176 /* Constructor */ || kind === 181 /* IndexSignature */ || kind === 175 /* ClassStaticBlockDeclaration */ || kind === 282 /* MissingDeclaration */ || kind === 243 /* VariableStatement */ || kind === 264 /* InterfaceDeclaration */ || kind === 265 /* TypeAliasDeclaration */ || kind === 266 /* EnumDeclaration */ || kind === 267 /* ModuleDeclaration */ || kind === 271 /* ImportEqualsDeclaration */ || kind === 272 /* ImportDeclaration */ || kind === 270 /* NamespaceExportDeclaration */ || kind === 278 /* ExportDeclaration */ || kind === 277 /* ExportAssignment */;
}
function canHaveIllegalModifiers(node) {
  const kind = node.kind;
  return kind === 175 /* ClassStaticBlockDeclaration */ || kind === 303 /* PropertyAssignment */ || kind === 304 /* ShorthandPropertyAssignment */ || kind === 282 /* MissingDeclaration */ || kind === 270 /* NamespaceExportDeclaration */;
}
function isQuestionOrExclamationToken(node) {
  return isQuestionToken(node) || isExclamationToken(node);
}
function isIdentifierOrThisTypeNode(node) {
  return isIdentifier(node) || isThisTypeNode(node);
}
function isReadonlyKeywordOrPlusOrMinusToken(node) {
  return isReadonlyKeyword(node) || isPlusToken(node) || isMinusToken(node);
}
function isQuestionOrPlusOrMinusToken(node) {
  return isQuestionToken(node) || isPlusToken(node) || isMinusToken(node);
}
function isModuleName(node) {
  return isIdentifier(node) || isStringLiteral(node);
}
function isExponentiationOperator(kind) {
  return kind === 43 /* AsteriskAsteriskToken */;
}
function isMultiplicativeOperator(kind) {
  return kind === 42 /* AsteriskToken */ || kind === 44 /* SlashToken */ || kind === 45 /* PercentToken */;
}
function isMultiplicativeOperatorOrHigher(kind) {
  return isExponentiationOperator(kind) || isMultiplicativeOperator(kind);
}
function isAdditiveOperator(kind) {
  return kind === 40 /* PlusToken */ || kind === 41 /* MinusToken */;
}
function isAdditiveOperatorOrHigher(kind) {
  return isAdditiveOperator(kind) || isMultiplicativeOperatorOrHigher(kind);
}
function isShiftOperator(kind) {
  return kind === 48 /* LessThanLessThanToken */ || kind === 49 /* GreaterThanGreaterThanToken */ || kind === 50 /* GreaterThanGreaterThanGreaterThanToken */;
}
function isShiftOperatorOrHigher(kind) {
  return isShiftOperator(kind) || isAdditiveOperatorOrHigher(kind);
}
function isRelationalOperator(kind) {
  return kind === 30 /* LessThanToken */ || kind === 33 /* LessThanEqualsToken */ || kind === 32 /* GreaterThanToken */ || kind === 34 /* GreaterThanEqualsToken */ || kind === 104 /* InstanceOfKeyword */ || kind === 103 /* InKeyword */;
}
function isRelationalOperatorOrHigher(kind) {
  return isRelationalOperator(kind) || isShiftOperatorOrHigher(kind);
}
function isEqualityOperator(kind) {
  return kind === 35 /* EqualsEqualsToken */ || kind === 37 /* EqualsEqualsEqualsToken */ || kind === 36 /* ExclamationEqualsToken */ || kind === 38 /* ExclamationEqualsEqualsToken */;
}
function isEqualityOperatorOrHigher(kind) {
  return isEqualityOperator(kind) || isRelationalOperatorOrHigher(kind);
}
function isBitwiseOperator(kind) {
  return kind === 51 /* AmpersandToken */ || kind === 52 /* BarToken */ || kind === 53 /* CaretToken */;
}
function isBitwiseOperatorOrHigher(kind) {
  return isBitwiseOperator(kind) || isEqualityOperatorOrHigher(kind);
}
function isLogicalOperator2(kind) {
  return kind === 56 /* AmpersandAmpersandToken */ || kind === 57 /* BarBarToken */;
}
function isLogicalOperatorOrHigher(kind) {
  return isLogicalOperator2(kind) || isBitwiseOperatorOrHigher(kind);
}
function isAssignmentOperatorOrHigher(kind) {
  return kind === 61 /* QuestionQuestionToken */ || isLogicalOperatorOrHigher(kind) || isAssignmentOperator(kind);
}
function isBinaryOperator(kind) {
  return isAssignmentOperatorOrHigher(kind) || kind === 28 /* CommaToken */;
}
function isBinaryOperatorToken(node) {
  return isBinaryOperator(node.kind);
}
var BinaryExpressionState;
((BinaryExpressionState2) => {
  function enter(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, outerState) {
    const prevUserState = stackIndex > 0 ? userStateStack[stackIndex - 1] : void 0;
    Debug.assertEqual(stateStack[stackIndex], enter);
    userStateStack[stackIndex] = machine.onEnter(nodeStack[stackIndex], prevUserState, outerState);
    stateStack[stackIndex] = nextState(machine, enter);
    return stackIndex;
  }
  BinaryExpressionState2.enter = enter;
  function left(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) {
    Debug.assertEqual(stateStack[stackIndex], left);
    Debug.assertIsDefined(machine.onLeft);
    stateStack[stackIndex] = nextState(machine, left);
    const nextNode = machine.onLeft(nodeStack[stackIndex].left, userStateStack[stackIndex], nodeStack[stackIndex]);
    if (nextNode) {
      checkCircularity(stackIndex, nodeStack, nextNode);
      return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode);
    }
    return stackIndex;
  }
  BinaryExpressionState2.left = left;
  function operator(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) {
    Debug.assertEqual(stateStack[stackIndex], operator);
    Debug.assertIsDefined(machine.onOperator);
    stateStack[stackIndex] = nextState(machine, operator);
    machine.onOperator(nodeStack[stackIndex].operatorToken, userStateStack[stackIndex], nodeStack[stackIndex]);
    return stackIndex;
  }
  BinaryExpressionState2.operator = operator;
  function right(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) {
    Debug.assertEqual(stateStack[stackIndex], right);
    Debug.assertIsDefined(machine.onRight);
    stateStack[stackIndex] = nextState(machine, right);
    const nextNode = machine.onRight(nodeStack[stackIndex].right, userStateStack[stackIndex], nodeStack[stackIndex]);
    if (nextNode) {
      checkCircularity(stackIndex, nodeStack, nextNode);
      return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode);
    }
    return stackIndex;
  }
  BinaryExpressionState2.right = right;
  function exit(machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, _outerState) {
    Debug.assertEqual(stateStack[stackIndex], exit);
    stateStack[stackIndex] = nextState(machine, exit);
    const result = machine.onExit(nodeStack[stackIndex], userStateStack[stackIndex]);
    if (stackIndex > 0) {
      stackIndex--;
      if (machine.foldState) {
        const side = stateStack[stackIndex] === exit ? "right" : "left";
        userStateStack[stackIndex] = machine.foldState(userStateStack[stackIndex], result, side);
      }
    } else {
      resultHolder.value = result;
    }
    return stackIndex;
  }
  BinaryExpressionState2.exit = exit;
  function done(_machine, stackIndex, stateStack, _nodeStack, _userStateStack, _resultHolder, _outerState) {
    Debug.assertEqual(stateStack[stackIndex], done);
    return stackIndex;
  }
  BinaryExpressionState2.done = done;
  function nextState(machine, currentState) {
    switch (currentState) {
      case enter:
        if (machine.onLeft) return left;
      // falls through
      case left:
        if (machine.onOperator) return operator;
      // falls through
      case operator:
        if (machine.onRight) return right;
      // falls through
      case right:
        return exit;
      case exit:
        return done;
      case done:
        return done;
      default:
        Debug.fail("Invalid state");
    }
  }
  BinaryExpressionState2.nextState = nextState;
  function pushStack(stackIndex, stateStack, nodeStack, userStateStack, node) {
    stackIndex++;
    stateStack[stackIndex] = enter;
    nodeStack[stackIndex] = node;
    userStateStack[stackIndex] = void 0;
    return stackIndex;
  }
  function checkCircularity(stackIndex, nodeStack, node) {
    if (Debug.shouldAssert(2 /* Aggressive */)) {
      while (stackIndex >= 0) {
        Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected.");
        stackIndex--;
      }
    }
  }
})(BinaryExpressionState || (BinaryExpressionState = {}));
var BinaryExpressionStateMachine = class {
  constructor(onEnter, onLeft, onOperator, onRight, onExit, foldState) {
    this.onEnter = onEnter;
    this.onLeft = onLeft;
    this.onOperator = onOperator;
    this.onRight = onRight;
    this.onExit = onExit;
    this.foldState = foldState;
  }
};
function createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState) {
  const machine = new BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState);
  return trampoline;
  function trampoline(node, outerState) {
    const resultHolder = { value: void 0 };
    const stateStack = [BinaryExpressionState.enter];
    const nodeStack = [node];
    const userStateStack = [void 0];
    let stackIndex = 0;
    while (stateStack[stackIndex] !== BinaryExpressionState.done) {
      stackIndex = stateStack[stackIndex](machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, outerState);
    }
    Debug.assertEqual(stackIndex, 0);
    return resultHolder.value;
  }
}
function isExportOrDefaultKeywordKind(kind) {
  return kind === 95 /* ExportKeyword */ || kind === 90 /* DefaultKeyword */;
}
function isExportOrDefaultModifier(node) {
  const kind = node.kind;
  return isExportOrDefaultKeywordKind(kind);
}
function elideNodes(factory2, nodes) {
  if (nodes === void 0) return void 0;
  if (nodes.length === 0) return nodes;
  return setTextRange(factory2.createNodeArray([], nodes.hasTrailingComma), nodes);
}
function getNodeForGeneratedName(name) {
  var _a;
  const autoGenerate = name.emitNode.autoGenerate;
  if (autoGenerate.flags & 4 /* Node */) {
    const autoGenerateId = autoGenerate.id;
    let node = name;
    let original = node.original;
    while (original) {
      node = original;
      const autoGenerate2 = (_a = node.emitNode) == null ? void 0 : _a.autoGenerate;
      if (isMemberName(node) && (autoGenerate2 === void 0 || !!(autoGenerate2.flags & 4 /* Node */) && autoGenerate2.id !== autoGenerateId)) {
        break;
      }
      original = node.original;
    }
    return node;
  }
  return name;
}
function formatGeneratedNamePart(part, generateName) {
  return typeof part === "object" ? formatGeneratedName(
    /*privateName*/
    false,
    part.prefix,
    part.node,
    part.suffix,
    generateName
  ) : typeof part === "string" ? part.length > 0 && part.charCodeAt(0) === 35 /* hash */ ? part.slice(1) : part : "";
}
function formatIdentifier(name, generateName) {
  return typeof name === "string" ? name : formatIdentifierWorker(name, Debug.checkDefined(generateName));
}
function formatIdentifierWorker(node, generateName) {
  return isGeneratedPrivateIdentifier(node) ? generateName(node).slice(1) : isGeneratedIdentifier(node) ? generateName(node) : isPrivateIdentifier(node) ? node.escapedText.slice(1) : idText(node);
}
function formatGeneratedName(privateName, prefix, baseName, suffix, generateName) {
  prefix = formatGeneratedNamePart(prefix, generateName);
  suffix = formatGeneratedNamePart(suffix, generateName);
  baseName = formatIdentifier(baseName, generateName);
  return `${privateName ? "#" : ""}${prefix}${baseName}${suffix}`;
}
function createAccessorPropertyBackingField(factory2, node, modifiers, initializer) {
  return factory2.updatePropertyDeclaration(
    node,
    modifiers,
    factory2.getGeneratedPrivateNameForNode(
      node.name,
      /*prefix*/
      void 0,
      "_accessor_storage"
    ),
    /*questionOrExclamationToken*/
    void 0,
    /*type*/
    void 0,
    initializer
  );
}
function createAccessorPropertyGetRedirector(factory2, node, modifiers, name, receiver = factory2.createThis()) {
  return factory2.createGetAccessorDeclaration(
    modifiers,
    name,
    [],
    /*type*/
    void 0,
    factory2.createBlock([
      factory2.createReturnStatement(
        factory2.createPropertyAccessExpression(
          receiver,
          factory2.getGeneratedPrivateNameForNode(
            node.name,
            /*prefix*/
            void 0,
            "_accessor_storage"
          )
        )
      )
    ])
  );
}
function createAccessorPropertySetRedirector(factory2, node, modifiers, name, receiver = factory2.createThis()) {
  return factory2.createSetAccessorDeclaration(
    modifiers,
    name,
    [factory2.createParameterDeclaration(
      /*modifiers*/
      void 0,
      /*dotDotDotToken*/
      void 0,
      "value"
    )],
    factory2.createBlock([
      factory2.createExpressionStatement(
        factory2.createAssignment(
          factory2.createPropertyAccessExpression(
            receiver,
            factory2.getGeneratedPrivateNameForNode(
              node.name,
              /*prefix*/
              void 0,
              "_accessor_storage"
            )
          ),
          factory2.createIdentifier("value")
        )
      )
    ])
  );
}
function findComputedPropertyNameCacheAssignment(name) {
  let node = name.expression;
  while (true) {
    node = skipOuterExpressions(node);
    if (isCommaListExpression(node)) {
      node = last(node.elements);
      continue;
    }
    if (isCommaExpression(node)) {
      node = node.right;
      continue;
    }
    if (isAssignmentExpression(
      node,
      /*excludeCompoundAssignment*/
      true
    ) && isGeneratedIdentifier(node.left)) {
      return node;
    }
    break;
  }
}
function isSyntheticParenthesizedExpression(node) {
  return isParenthesizedExpression(node) && nodeIsSynthesized(node) && !node.emitNode;
}
function flattenCommaListWorker(node, expressions) {
  if (isSyntheticParenthesizedExpression(node)) {
    flattenCommaListWorker(node.expression, expressions);
  } else if (isCommaExpression(node)) {
    flattenCommaListWorker(node.left, expressions);
    flattenCommaListWorker(node.right, expressions);
  } else if (isCommaListExpression(node)) {
    for (const child of node.elements) {
      flattenCommaListWorker(child, expressions);
    }
  } else {
    expressions.push(node);
  }
}
function flattenCommaList(node) {
  const expressions = [];
  flattenCommaListWorker(node, expressions);
  return expressions;
}
function containsObjectRestOrSpread(node) {
  if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) return true;
  if (node.transformFlags & 128 /* ContainsES2018 */) {
    for (const element of getElementsOfBindingOrAssignmentPattern(node)) {
      const target = getTargetOfBindingOrAssignmentElement(element);
      if (target && isAssignmentPattern(target)) {
        if (target.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
          return true;
        }
        if (target.transformFlags & 128 /* ContainsES2018 */) {
          if (containsObjectRestOrSpread(target)) return true;
        }
      }
    }
  }
  return false;
}

// src/compiler/factory/utilitiesPublic.ts
function setTextRange(range, location) {
  return location ? setTextRangePosEnd(range, location.pos, location.end) : range;
}
function canHaveModifiers(node) {
  const kind = node.kind;
  return kind === 168 /* TypeParameter */ || kind === 169 /* Parameter */ || kind === 171 /* PropertySignature */ || kind === 172 /* PropertyDeclaration */ || kind === 173 /* MethodSignature */ || kind === 174 /* MethodDeclaration */ || kind === 176 /* Constructor */ || kind === 177 /* GetAccessor */ || kind === 178 /* SetAccessor */ || kind === 181 /* IndexSignature */ || kind === 185 /* ConstructorType */ || kind === 218 /* FunctionExpression */ || kind === 219 /* ArrowFunction */ || kind === 231 /* ClassExpression */ || kind === 243 /* VariableStatement */ || kind === 262 /* FunctionDeclaration */ || kind === 263 /* ClassDeclaration */ || kind === 264 /* InterfaceDeclaration */ || kind === 265 /* TypeAliasDeclaration */ || kind === 266 /* EnumDeclaration */ || kind === 267 /* ModuleDeclaration */ || kind === 271 /* ImportEqualsDeclaration */ || kind === 272 /* ImportDeclaration */ || kind === 277 /* ExportAssignment */ || kind === 278 /* ExportDeclaration */;
}
function canHaveDecorators(node) {
  const kind = node.kind;
  return kind === 169 /* Parameter */ || kind === 172 /* PropertyDeclaration */ || kind === 174 /* MethodDeclaration */ || kind === 177 /* GetAccessor */ || kind === 178 /* SetAccessor */ || kind === 231 /* ClassExpression */ || kind === 263 /* ClassDeclaration */;
}

// src/compiler/parser.ts
var NodeConstructor;
var TokenConstructor;
var IdentifierConstructor;
var PrivateIdentifierConstructor;
var SourceFileConstructor;
var parseBaseNodeFactory = {
  createBaseSourceFileNode: (kind) => new (SourceFileConstructor || (SourceFileConstructor = objectAllocator.getSourceFileConstructor()))(kind, -1, -1),
  createBaseIdentifierNode: (kind) => new (IdentifierConstructor || (IdentifierConstructor = objectAllocator.getIdentifierConstructor()))(kind, -1, -1),
  createBasePrivateIdentifierNode: (kind) => new (PrivateIdentifierConstructor || (PrivateIdentifierConstructor = objectAllocator.getPrivateIdentifierConstructor()))(kind, -1, -1),
  createBaseTokenNode: (kind) => new (TokenConstructor || (TokenConstructor = objectAllocator.getTokenConstructor()))(kind, -1, -1),
  createBaseNode: (kind) => new (NodeConstructor || (NodeConstructor = objectAllocator.getNodeConstructor()))(kind, -1, -1)
};
var parseNodeFactory = createNodeFactory(1 /* NoParenthesizerRules */, parseBaseNodeFactory);
function visitNode2(cbNode, node) {
  return node && cbNode(node);
}
function visitNodes(cbNode, cbNodes, nodes) {
  if (nodes) {
    if (cbNodes) {
      return cbNodes(nodes);
    }
    for (const node of nodes) {
      const result = cbNode(node);
      if (result) {
        return result;
      }
    }
  }
}
function isJSDocLikeText(text, start) {
  return text.charCodeAt(start + 1) === 42 /* asterisk */ && text.charCodeAt(start + 2) === 42 /* asterisk */ && text.charCodeAt(start + 3) !== 47 /* slash */;
}
function isFileProbablyExternalModule(sourceFile) {
  return forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) || getImportMetaIfNecessary(sourceFile);
}
function isAnExternalModuleIndicatorNode(node) {
  return canHaveModifiers(node) && hasModifierOfKind(node, 95 /* ExportKeyword */) || isImportEqualsDeclaration(node) && isExternalModuleReference(node.moduleReference) || isImportDeclaration(node) || isExportAssignment(node) || isExportDeclaration(node) ? node : void 0;
}
function getImportMetaIfNecessary(sourceFile) {
  return sourceFile.flags & 8388608 /* PossiblyContainsImportMeta */ ? walkTreeForImportMeta(sourceFile) : void 0;
}
function walkTreeForImportMeta(node) {
  return isImportMeta2(node) ? node : forEachChild(node, walkTreeForImportMeta);
}
function hasModifierOfKind(node, kind) {
  return some(node.modifiers, (m) => m.kind === kind);
}
function isImportMeta2(node) {
  return isMetaProperty(node) && node.keywordToken === 102 /* ImportKeyword */ && node.name.escapedText === "meta";
}
var forEachChildTable = {
  [166 /* QualifiedName */]: function forEachChildInQualifiedName(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.left) || visitNode2(cbNode, node.right);
  },
  [168 /* TypeParameter */]: function forEachChildInTypeParameter(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name) || visitNode2(cbNode, node.constraint) || visitNode2(cbNode, node.default) || visitNode2(cbNode, node.expression);
  },
  [304 /* ShorthandPropertyAssignment */]: function forEachChildInShorthandPropertyAssignment(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name) || visitNode2(cbNode, node.questionToken) || visitNode2(cbNode, node.exclamationToken) || visitNode2(cbNode, node.equalsToken) || visitNode2(cbNode, node.objectAssignmentInitializer);
  },
  [305 /* SpreadAssignment */]: function forEachChildInSpreadAssignment(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression);
  },
  [169 /* Parameter */]: function forEachChildInParameter(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.dotDotDotToken) || visitNode2(cbNode, node.name) || visitNode2(cbNode, node.questionToken) || visitNode2(cbNode, node.type) || visitNode2(cbNode, node.initializer);
  },
  [172 /* PropertyDeclaration */]: function forEachChildInPropertyDeclaration(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name) || visitNode2(cbNode, node.questionToken) || visitNode2(cbNode, node.exclamationToken) || visitNode2(cbNode, node.type) || visitNode2(cbNode, node.initializer);
  },
  [171 /* PropertySignature */]: function forEachChildInPropertySignature(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name) || visitNode2(cbNode, node.questionToken) || visitNode2(cbNode, node.type) || visitNode2(cbNode, node.initializer);
  },
  [303 /* PropertyAssignment */]: function forEachChildInPropertyAssignment(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name) || visitNode2(cbNode, node.questionToken) || visitNode2(cbNode, node.exclamationToken) || visitNode2(cbNode, node.initializer);
  },
  [260 /* VariableDeclaration */]: function forEachChildInVariableDeclaration(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.name) || visitNode2(cbNode, node.exclamationToken) || visitNode2(cbNode, node.type) || visitNode2(cbNode, node.initializer);
  },
  [208 /* BindingElement */]: function forEachChildInBindingElement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.dotDotDotToken) || visitNode2(cbNode, node.propertyName) || visitNode2(cbNode, node.name) || visitNode2(cbNode, node.initializer);
  },
  [181 /* IndexSignature */]: function forEachChildInIndexSignature(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode2(cbNode, node.type);
  },
  [185 /* ConstructorType */]: function forEachChildInConstructorType(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode2(cbNode, node.type);
  },
  [184 /* FunctionType */]: function forEachChildInFunctionType(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode2(cbNode, node.type);
  },
  [179 /* CallSignature */]: forEachChildInCallOrConstructSignature,
  [180 /* ConstructSignature */]: forEachChildInCallOrConstructSignature,
  [174 /* MethodDeclaration */]: function forEachChildInMethodDeclaration(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.asteriskToken) || visitNode2(cbNode, node.name) || visitNode2(cbNode, node.questionToken) || visitNode2(cbNode, node.exclamationToken) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode2(cbNode, node.type) || visitNode2(cbNode, node.body);
  },
  [173 /* MethodSignature */]: function forEachChildInMethodSignature(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name) || visitNode2(cbNode, node.questionToken) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode2(cbNode, node.type);
  },
  [176 /* Constructor */]: function forEachChildInConstructor(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode2(cbNode, node.type) || visitNode2(cbNode, node.body);
  },
  [177 /* GetAccessor */]: function forEachChildInGetAccessor(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode2(cbNode, node.type) || visitNode2(cbNode, node.body);
  },
  [178 /* SetAccessor */]: function forEachChildInSetAccessor(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode2(cbNode, node.type) || visitNode2(cbNode, node.body);
  },
  [262 /* FunctionDeclaration */]: function forEachChildInFunctionDeclaration(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.asteriskToken) || visitNode2(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode2(cbNode, node.type) || visitNode2(cbNode, node.body);
  },
  [218 /* FunctionExpression */]: function forEachChildInFunctionExpression(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.asteriskToken) || visitNode2(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode2(cbNode, node.type) || visitNode2(cbNode, node.body);
  },
  [219 /* ArrowFunction */]: function forEachChildInArrowFunction(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode2(cbNode, node.type) || visitNode2(cbNode, node.equalsGreaterThanToken) || visitNode2(cbNode, node.body);
  },
  [175 /* ClassStaticBlockDeclaration */]: function forEachChildInClassStaticBlockDeclaration(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.body);
  },
  [183 /* TypeReference */]: function forEachChildInTypeReference(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments);
  },
  [182 /* TypePredicate */]: function forEachChildInTypePredicate(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.assertsModifier) || visitNode2(cbNode, node.parameterName) || visitNode2(cbNode, node.type);
  },
  [186 /* TypeQuery */]: function forEachChildInTypeQuery(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.exprName) || visitNodes(cbNode, cbNodes, node.typeArguments);
  },
  [187 /* TypeLiteral */]: function forEachChildInTypeLiteral(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.members);
  },
  [188 /* ArrayType */]: function forEachChildInArrayType(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.elementType);
  },
  [189 /* TupleType */]: function forEachChildInTupleType(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.elements);
  },
  [192 /* UnionType */]: forEachChildInUnionOrIntersectionType,
  [193 /* IntersectionType */]: forEachChildInUnionOrIntersectionType,
  [194 /* ConditionalType */]: function forEachChildInConditionalType(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.checkType) || visitNode2(cbNode, node.extendsType) || visitNode2(cbNode, node.trueType) || visitNode2(cbNode, node.falseType);
  },
  [195 /* InferType */]: function forEachChildInInferType(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.typeParameter);
  },
  [205 /* ImportType */]: function forEachChildInImportType(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.argument) || visitNode2(cbNode, node.attributes) || visitNode2(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments);
  },
  [302 /* ImportTypeAssertionContainer */]: function forEachChildInImportTypeAssertionContainer(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.assertClause);
  },
  [196 /* ParenthesizedType */]: forEachChildInParenthesizedTypeOrTypeOperator,
  [198 /* TypeOperator */]: forEachChildInParenthesizedTypeOrTypeOperator,
  [199 /* IndexedAccessType */]: function forEachChildInIndexedAccessType(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.objectType) || visitNode2(cbNode, node.indexType);
  },
  [200 /* MappedType */]: function forEachChildInMappedType(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.readonlyToken) || visitNode2(cbNode, node.typeParameter) || visitNode2(cbNode, node.nameType) || visitNode2(cbNode, node.questionToken) || visitNode2(cbNode, node.type) || visitNodes(cbNode, cbNodes, node.members);
  },
  [201 /* LiteralType */]: function forEachChildInLiteralType(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.literal);
  },
  [202 /* NamedTupleMember */]: function forEachChildInNamedTupleMember(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.dotDotDotToken) || visitNode2(cbNode, node.name) || visitNode2(cbNode, node.questionToken) || visitNode2(cbNode, node.type);
  },
  [206 /* ObjectBindingPattern */]: forEachChildInObjectOrArrayBindingPattern,
  [207 /* ArrayBindingPattern */]: forEachChildInObjectOrArrayBindingPattern,
  [209 /* ArrayLiteralExpression */]: function forEachChildInArrayLiteralExpression(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.elements);
  },
  [210 /* ObjectLiteralExpression */]: function forEachChildInObjectLiteralExpression(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.properties);
  },
  [211 /* PropertyAccessExpression */]: function forEachChildInPropertyAccessExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression) || visitNode2(cbNode, node.questionDotToken) || visitNode2(cbNode, node.name);
  },
  [212 /* ElementAccessExpression */]: function forEachChildInElementAccessExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression) || visitNode2(cbNode, node.questionDotToken) || visitNode2(cbNode, node.argumentExpression);
  },
  [213 /* CallExpression */]: forEachChildInCallOrNewExpression,
  [214 /* NewExpression */]: forEachChildInCallOrNewExpression,
  [215 /* TaggedTemplateExpression */]: function forEachChildInTaggedTemplateExpression(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.tag) || visitNode2(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode2(cbNode, node.template);
  },
  [216 /* TypeAssertionExpression */]: function forEachChildInTypeAssertionExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.type) || visitNode2(cbNode, node.expression);
  },
  [217 /* ParenthesizedExpression */]: function forEachChildInParenthesizedExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression);
  },
  [220 /* DeleteExpression */]: function forEachChildInDeleteExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression);
  },
  [221 /* TypeOfExpression */]: function forEachChildInTypeOfExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression);
  },
  [222 /* VoidExpression */]: function forEachChildInVoidExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression);
  },
  [224 /* PrefixUnaryExpression */]: function forEachChildInPrefixUnaryExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.operand);
  },
  [229 /* YieldExpression */]: function forEachChildInYieldExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.asteriskToken) || visitNode2(cbNode, node.expression);
  },
  [223 /* AwaitExpression */]: function forEachChildInAwaitExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression);
  },
  [225 /* PostfixUnaryExpression */]: function forEachChildInPostfixUnaryExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.operand);
  },
  [226 /* BinaryExpression */]: function forEachChildInBinaryExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.left) || visitNode2(cbNode, node.operatorToken) || visitNode2(cbNode, node.right);
  },
  [234 /* AsExpression */]: function forEachChildInAsExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression) || visitNode2(cbNode, node.type);
  },
  [235 /* NonNullExpression */]: function forEachChildInNonNullExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression);
  },
  [238 /* SatisfiesExpression */]: function forEachChildInSatisfiesExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression) || visitNode2(cbNode, node.type);
  },
  [236 /* MetaProperty */]: function forEachChildInMetaProperty(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.name);
  },
  [227 /* ConditionalExpression */]: function forEachChildInConditionalExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.condition) || visitNode2(cbNode, node.questionToken) || visitNode2(cbNode, node.whenTrue) || visitNode2(cbNode, node.colonToken) || visitNode2(cbNode, node.whenFalse);
  },
  [230 /* SpreadElement */]: function forEachChildInSpreadElement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression);
  },
  [241 /* Block */]: forEachChildInBlock,
  [268 /* ModuleBlock */]: forEachChildInBlock,
  [307 /* SourceFile */]: function forEachChildInSourceFile(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.statements) || visitNode2(cbNode, node.endOfFileToken);
  },
  [243 /* VariableStatement */]: function forEachChildInVariableStatement(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.declarationList);
  },
  [261 /* VariableDeclarationList */]: function forEachChildInVariableDeclarationList(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.declarations);
  },
  [244 /* ExpressionStatement */]: function forEachChildInExpressionStatement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression);
  },
  [245 /* IfStatement */]: function forEachChildInIfStatement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression) || visitNode2(cbNode, node.thenStatement) || visitNode2(cbNode, node.elseStatement);
  },
  [246 /* DoStatement */]: function forEachChildInDoStatement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.statement) || visitNode2(cbNode, node.expression);
  },
  [247 /* WhileStatement */]: function forEachChildInWhileStatement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression) || visitNode2(cbNode, node.statement);
  },
  [248 /* ForStatement */]: function forEachChildInForStatement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.initializer) || visitNode2(cbNode, node.condition) || visitNode2(cbNode, node.incrementor) || visitNode2(cbNode, node.statement);
  },
  [249 /* ForInStatement */]: function forEachChildInForInStatement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.initializer) || visitNode2(cbNode, node.expression) || visitNode2(cbNode, node.statement);
  },
  [250 /* ForOfStatement */]: function forEachChildInForOfStatement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.awaitModifier) || visitNode2(cbNode, node.initializer) || visitNode2(cbNode, node.expression) || visitNode2(cbNode, node.statement);
  },
  [251 /* ContinueStatement */]: forEachChildInContinueOrBreakStatement,
  [252 /* BreakStatement */]: forEachChildInContinueOrBreakStatement,
  [253 /* ReturnStatement */]: function forEachChildInReturnStatement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression);
  },
  [254 /* WithStatement */]: function forEachChildInWithStatement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression) || visitNode2(cbNode, node.statement);
  },
  [255 /* SwitchStatement */]: function forEachChildInSwitchStatement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression) || visitNode2(cbNode, node.caseBlock);
  },
  [269 /* CaseBlock */]: function forEachChildInCaseBlock(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.clauses);
  },
  [296 /* CaseClause */]: function forEachChildInCaseClause(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements);
  },
  [297 /* DefaultClause */]: function forEachChildInDefaultClause(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.statements);
  },
  [256 /* LabeledStatement */]: function forEachChildInLabeledStatement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.label) || visitNode2(cbNode, node.statement);
  },
  [257 /* ThrowStatement */]: function forEachChildInThrowStatement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression);
  },
  [258 /* TryStatement */]: function forEachChildInTryStatement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.tryBlock) || visitNode2(cbNode, node.catchClause) || visitNode2(cbNode, node.finallyBlock);
  },
  [299 /* CatchClause */]: function forEachChildInCatchClause(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.variableDeclaration) || visitNode2(cbNode, node.block);
  },
  [170 /* Decorator */]: function forEachChildInDecorator(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression);
  },
  [263 /* ClassDeclaration */]: forEachChildInClassDeclarationOrExpression,
  [231 /* ClassExpression */]: forEachChildInClassDeclarationOrExpression,
  [264 /* InterfaceDeclaration */]: function forEachChildInInterfaceDeclaration(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members);
  },
  [265 /* TypeAliasDeclaration */]: function forEachChildInTypeAliasDeclaration(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode2(cbNode, node.type);
  },
  [266 /* EnumDeclaration */]: function forEachChildInEnumDeclaration(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members);
  },
  [306 /* EnumMember */]: function forEachChildInEnumMember(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.name) || visitNode2(cbNode, node.initializer);
  },
  [267 /* ModuleDeclaration */]: function forEachChildInModuleDeclaration(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name) || visitNode2(cbNode, node.body);
  },
  [271 /* ImportEqualsDeclaration */]: function forEachChildInImportEqualsDeclaration(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name) || visitNode2(cbNode, node.moduleReference);
  },
  [272 /* ImportDeclaration */]: function forEachChildInImportDeclaration(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.importClause) || visitNode2(cbNode, node.moduleSpecifier) || visitNode2(cbNode, node.attributes);
  },
  [273 /* ImportClause */]: function forEachChildInImportClause(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.name) || visitNode2(cbNode, node.namedBindings);
  },
  [300 /* ImportAttributes */]: function forEachChildInImportAttributes(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.elements);
  },
  [301 /* ImportAttribute */]: function forEachChildInImportAttribute(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.name) || visitNode2(cbNode, node.value);
  },
  [270 /* NamespaceExportDeclaration */]: function forEachChildInNamespaceExportDeclaration(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name);
  },
  [274 /* NamespaceImport */]: function forEachChildInNamespaceImport(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.name);
  },
  [280 /* NamespaceExport */]: function forEachChildInNamespaceExport(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.name);
  },
  [275 /* NamedImports */]: forEachChildInNamedImportsOrExports,
  [279 /* NamedExports */]: forEachChildInNamedImportsOrExports,
  [278 /* ExportDeclaration */]: function forEachChildInExportDeclaration(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.exportClause) || visitNode2(cbNode, node.moduleSpecifier) || visitNode2(cbNode, node.attributes);
  },
  [276 /* ImportSpecifier */]: forEachChildInImportOrExportSpecifier,
  [281 /* ExportSpecifier */]: forEachChildInImportOrExportSpecifier,
  [277 /* ExportAssignment */]: function forEachChildInExportAssignment(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.expression);
  },
  [228 /* TemplateExpression */]: function forEachChildInTemplateExpression(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans);
  },
  [239 /* TemplateSpan */]: function forEachChildInTemplateSpan(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression) || visitNode2(cbNode, node.literal);
  },
  [203 /* TemplateLiteralType */]: function forEachChildInTemplateLiteralType(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans);
  },
  [204 /* TemplateLiteralTypeSpan */]: function forEachChildInTemplateLiteralTypeSpan(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.type) || visitNode2(cbNode, node.literal);
  },
  [167 /* ComputedPropertyName */]: function forEachChildInComputedPropertyName(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression);
  },
  [298 /* HeritageClause */]: function forEachChildInHeritageClause(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.types);
  },
  [233 /* ExpressionWithTypeArguments */]: function forEachChildInExpressionWithTypeArguments(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments);
  },
  [283 /* ExternalModuleReference */]: function forEachChildInExternalModuleReference(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression);
  },
  [282 /* MissingDeclaration */]: function forEachChildInMissingDeclaration(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.modifiers);
  },
  [356 /* CommaListExpression */]: function forEachChildInCommaListExpression(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.elements);
  },
  [284 /* JsxElement */]: function forEachChildInJsxElement(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode2(cbNode, node.closingElement);
  },
  [288 /* JsxFragment */]: function forEachChildInJsxFragment(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode2(cbNode, node.closingFragment);
  },
  [285 /* JsxSelfClosingElement */]: forEachChildInJsxOpeningOrSelfClosingElement,
  [286 /* JsxOpeningElement */]: forEachChildInJsxOpeningOrSelfClosingElement,
  [292 /* JsxAttributes */]: function forEachChildInJsxAttributes(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.properties);
  },
  [291 /* JsxAttribute */]: function forEachChildInJsxAttribute(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.name) || visitNode2(cbNode, node.initializer);
  },
  [293 /* JsxSpreadAttribute */]: function forEachChildInJsxSpreadAttribute(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.expression);
  },
  [294 /* JsxExpression */]: function forEachChildInJsxExpression(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.dotDotDotToken) || visitNode2(cbNode, node.expression);
  },
  [287 /* JsxClosingElement */]: function forEachChildInJsxClosingElement(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.tagName);
  },
  [295 /* JsxNamespacedName */]: function forEachChildInJsxNamespacedName(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.namespace) || visitNode2(cbNode, node.name);
  },
  [190 /* OptionalType */]: forEachChildInOptionalRestOrJSDocParameterModifier,
  [191 /* RestType */]: forEachChildInOptionalRestOrJSDocParameterModifier,
  [309 /* JSDocTypeExpression */]: forEachChildInOptionalRestOrJSDocParameterModifier,
  [315 /* JSDocNonNullableType */]: forEachChildInOptionalRestOrJSDocParameterModifier,
  [314 /* JSDocNullableType */]: forEachChildInOptionalRestOrJSDocParameterModifier,
  [316 /* JSDocOptionalType */]: forEachChildInOptionalRestOrJSDocParameterModifier,
  [318 /* JSDocVariadicType */]: forEachChildInOptionalRestOrJSDocParameterModifier,
  [317 /* JSDocFunctionType */]: function forEachChildInJSDocFunctionType(node, cbNode, cbNodes) {
    return visitNodes(cbNode, cbNodes, node.parameters) || visitNode2(cbNode, node.type);
  },
  [320 /* JSDoc */]: function forEachChildInJSDoc(node, cbNode, cbNodes) {
    return (typeof node.comment === "string" ? void 0 : visitNodes(cbNode, cbNodes, node.comment)) || visitNodes(cbNode, cbNodes, node.tags);
  },
  [347 /* JSDocSeeTag */]: function forEachChildInJSDocSeeTag(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.tagName) || visitNode2(cbNode, node.name) || (typeof node.comment === "string" ? void 0 : visitNodes(cbNode, cbNodes, node.comment));
  },
  [310 /* JSDocNameReference */]: function forEachChildInJSDocNameReference(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.name);
  },
  [311 /* JSDocMemberName */]: function forEachChildInJSDocMemberName(node, cbNode, _cbNodes) {
    return visitNode2(cbNode, node.left) || visitNode2(cbNode, node.right);
  },
  [341 /* JSDocParameterTag */]: forEachChildInJSDocParameterOrPropertyTag,
  [348 /* JSDocPropertyTag */]: forEachChildInJSDocParameterOrPropertyTag,
  [330 /* JSDocAuthorTag */]: function forEachChildInJSDocAuthorTag(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.tagName) || (typeof node.comment === "string" ? void 0 : visitNodes(cbNode, cbNodes, node.comment));
  },
  [329 /* JSDocImplementsTag */]: function forEachChildInJSDocImplementsTag(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.tagName) || visitNode2(cbNode, node.class) || (typeof node.comment === "string" ? void 0 : visitNodes(cbNode, cbNodes, node.comment));
  },
  [328 /* JSDocAugmentsTag */]: function forEachChildInJSDocAugmentsTag(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.tagName) || visitNode2(cbNode, node.class) || (typeof node.comment === "string" ? void 0 : visitNodes(cbNode, cbNodes, node.comment));
  },
  [345 /* JSDocTemplateTag */]: function forEachChildInJSDocTemplateTag(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.tagName) || visitNode2(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters) || (typeof node.comment === "string" ? void 0 : visitNodes(cbNode, cbNodes, node.comment));
  },
  [346 /* JSDocTypedefTag */]: function forEachChildInJSDocTypedefTag(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.tagName) || (node.typeExpression && node.typeExpression.kind === 309 /* JSDocTypeExpression */ ? visitNode2(cbNode, node.typeExpression) || visitNode2(cbNode, node.fullName) || (typeof node.comment === "string" ? void 0 : visitNodes(cbNode, cbNodes, node.comment)) : visitNode2(cbNode, node.fullName) || visitNode2(cbNode, node.typeExpression) || (typeof node.comment === "string" ? void 0 : visitNodes(cbNode, cbNodes, node.comment)));
  },
  [338 /* JSDocCallbackTag */]: function forEachChildInJSDocCallbackTag(node, cbNode, cbNodes) {
    return visitNode2(cbNode, node.tagName) || visitNode2(cbNode, node.fullName) || visitNode2(cbNode, node.typeExpression) || (typeof node.comment === "string" ? void 0 : visitNodes(cbNode, cbNodes, node.comment));
  },
  [342 /* JSDocReturnTag */]: forEachChildInJSDocTypeLikeTag,
  [344 /* JSDocTypeTag */]: forEachChildInJSDocTypeLikeTag,
  [343 /* JSDocThisTag */]: forEachChildInJSDocTypeLikeTag,
  [340 /* JSDocEnumTag */]: forEachChildInJSDocTypeLikeTag,
  [350 /* JSDocSatisfiesTag */]: forEachChildInJSDocTypeLikeTag,
  [349 /* JSDocThrowsTag */]: forEachChildInJSDocTypeLikeTag,
  [339 /* JSDocOverloadTag */]: forEachChildInJSDocTypeLikeTag,
  [323 /* JSDocSignature */]: function forEachChildInJSDocSignature(node, cbNode, _cbNodes) {
    return forEach(node.typeParameters, cbNode) || forEach(node.parameters, cbNode) || visitNode2(cbNode, node.type);
  },
  [324 /* JSDocLink */]: forEachChildInJSDocLinkCodeOrPlain,
  [325 /* JSDocLinkCode */]: forEachChildInJSDocLinkCodeOrPlain,
  [326 /* JSDocLinkPlain */]: forEachChildInJSDocLinkCodeOrPlain,
  [322 /* JSDocTypeLiteral */]: function forEachChildInJSDocTypeLiteral(node, cbNode, _cbNodes) {
    return forEach(node.jsDocPropertyTags, cbNode);
  },
  [327 /* JSDocTag */]: forEachChildInJSDocTag,
  [332 /* JSDocClassTag */]: forEachChildInJSDocTag,
  [333 /* JSDocPublicTag */]: forEachChildInJSDocTag,
  [334 /* JSDocPrivateTag */]: forEachChildInJSDocTag,
  [335 /* JSDocProtectedTag */]: forEachChildInJSDocTag,
  [336 /* JSDocReadonlyTag */]: forEachChildInJSDocTag,
  [331 /* JSDocDeprecatedTag */]: forEachChildInJSDocTag,
  [337 /* JSDocOverrideTag */]: forEachChildInJSDocTag,
  [351 /* JSDocImportTag */]: forEachChildInJSDocImportTag,
  [355 /* PartiallyEmittedExpression */]: forEachChildInPartiallyEmittedExpression
};
function forEachChildInCallOrConstructSignature(node, cbNode, cbNodes) {
  return visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode2(cbNode, node.type);
}
function forEachChildInUnionOrIntersectionType(node, cbNode, cbNodes) {
  return visitNodes(cbNode, cbNodes, node.types);
}
function forEachChildInParenthesizedTypeOrTypeOperator(node, cbNode, _cbNodes) {
  return visitNode2(cbNode, node.type);
}
function forEachChildInObjectOrArrayBindingPattern(node, cbNode, cbNodes) {
  return visitNodes(cbNode, cbNodes, node.elements);
}
function forEachChildInCallOrNewExpression(node, cbNode, cbNodes) {
  return visitNode2(cbNode, node.expression) || // TODO: should we separate these branches out?
  visitNode2(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments);
}
function forEachChildInBlock(node, cbNode, cbNodes) {
  return visitNodes(cbNode, cbNodes, node.statements);
}
function forEachChildInContinueOrBreakStatement(node, cbNode, _cbNodes) {
  return visitNode2(cbNode, node.label);
}
function forEachChildInClassDeclarationOrExpression(node, cbNode, cbNodes) {
  return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode2(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members);
}
function forEachChildInNamedImportsOrExports(node, cbNode, cbNodes) {
  return visitNodes(cbNode, cbNodes, node.elements);
}
function forEachChildInImportOrExportSpecifier(node, cbNode, _cbNodes) {
  return visitNode2(cbNode, node.propertyName) || visitNode2(cbNode, node.name);
}
function forEachChildInJsxOpeningOrSelfClosingElement(node, cbNode, cbNodes) {
  return visitNode2(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode2(cbNode, node.attributes);
}
function forEachChildInOptionalRestOrJSDocParameterModifier(node, cbNode, _cbNodes) {
  return visitNode2(cbNode, node.type);
}
function forEachChildInJSDocParameterOrPropertyTag(node, cbNode, cbNodes) {
  return visitNode2(cbNode, node.tagName) || (node.isNameFirst ? visitNode2(cbNode, node.name) || visitNode2(cbNode, node.typeExpression) : visitNode2(cbNode, node.typeExpression) || visitNode2(cbNode, node.name)) || (typeof node.comment === "string" ? void 0 : visitNodes(cbNode, cbNodes, node.comment));
}
function forEachChildInJSDocTypeLikeTag(node, cbNode, cbNodes) {
  return visitNode2(cbNode, node.tagName) || visitNode2(cbNode, node.typeExpression) || (typeof node.comment === "string" ? void 0 : visitNodes(cbNode, cbNodes, node.comment));
}
function forEachChildInJSDocLinkCodeOrPlain(node, cbNode, _cbNodes) {
  return visitNode2(cbNode, node.name);
}
function forEachChildInJSDocTag(node, cbNode, cbNodes) {
  return visitNode2(cbNode, node.tagName) || (typeof node.comment === "string" ? void 0 : visitNodes(cbNode, cbNodes, node.comment));
}
function forEachChildInJSDocImportTag(node, cbNode, cbNodes) {
  return visitNode2(cbNode, node.tagName) || visitNode2(cbNode, node.importClause) || visitNode2(cbNode, node.moduleSpecifier) || visitNode2(cbNode, node.attributes) || (typeof node.comment === "string" ? void 0 : visitNodes(cbNode, cbNodes, node.comment));
}
function forEachChildInPartiallyEmittedExpression(node, cbNode, _cbNodes) {
  return visitNode2(cbNode, node.expression);
}
function forEachChild(node, cbNode, cbNodes) {
  if (node === void 0 || node.kind <= 165 /* LastToken */) {
    return;
  }
  const fn = forEachChildTable[node.kind];
  return fn === void 0 ? void 0 : fn(node, cbNode, cbNodes);
}
function forEachChildRecursively(rootNode, cbNode, cbNodes) {
  const queue = gatherPossibleChildren(rootNode);
  const parents = [];
  while (parents.length < queue.length) {
    parents.push(rootNode);
  }
  while (queue.length !== 0) {
    const current = queue.pop();
    const parent2 = parents.pop();
    if (isArray(current)) {
      if (cbNodes) {
        const res = cbNodes(current, parent2);
        if (res) {
          if (res === "skip") continue;
          return res;
        }
      }
      for (let i = current.length - 1; i >= 0; --i) {
        queue.push(current[i]);
        parents.push(parent2);
      }
    } else {
      const res = cbNode(current, parent2);
      if (res) {
        if (res === "skip") continue;
        return res;
      }
      if (current.kind >= 166 /* FirstNode */) {
        for (const child of gatherPossibleChildren(current)) {
          queue.push(child);
          parents.push(current);
        }
      }
    }
  }
}
function gatherPossibleChildren(node) {
  const children = [];
  forEachChild(node, addWorkItem, addWorkItem);
  return children;
  function addWorkItem(n) {
    children.unshift(n);
  }
}
function setExternalModuleIndicator(sourceFile) {
  sourceFile.externalModuleIndicator = isFileProbablyExternalModule(sourceFile);
}
function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes = false, scriptKind) {
  var _a, _b;
  (_a = tracing) == null ? void 0 : _a.push(
    tracing.Phase.Parse,
    "createSourceFile",
    { path: fileName },
    /*separateBeginAndEnd*/
    true
  );
  mark("beforeParse");
  let result;
  const {
    languageVersion,
    setExternalModuleIndicator: overrideSetExternalModuleIndicator,
    impliedNodeFormat: format,
    jsDocParsingMode
  } = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions };
  if (languageVersion === 100 /* JSON */) {
    result = Parser.parseSourceFile(
      fileName,
      sourceText,
      languageVersion,
      /*syntaxCursor*/
      void 0,
      setParentNodes,
      6 /* JSON */,
      noop,
      jsDocParsingMode
    );
  } else {
    const setIndicator = format === void 0 ? overrideSetExternalModuleIndicator : (file) => {
      file.impliedNodeFormat = format;
      return (overrideSetExternalModuleIndicator || setExternalModuleIndicator)(file);
    };
    result = Parser.parseSourceFile(
      fileName,
      sourceText,
      languageVersion,
      /*syntaxCursor*/
      void 0,
      setParentNodes,
      scriptKind,
      setIndicator,
      jsDocParsingMode
    );
  }
  mark("afterParse");
  measure("Parse", "beforeParse", "afterParse");
  (_b = tracing) == null ? void 0 : _b.pop();
  return result;
}
function parseIsolatedEntityName(text, languageVersion) {
  return Parser.parseIsolatedEntityName(text, languageVersion);
}
function parseJsonText(fileName, sourceText) {
  return Parser.parseJsonText(fileName, sourceText);
}
function isExternalModule(file) {
  return file.externalModuleIndicator !== void 0;
}
function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks = false) {
  const newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
  newSourceFile.flags |= sourceFile.flags & 12582912 /* PermanentlySetIncrementalFlags */;
  return newSourceFile;
}
function parseIsolatedJSDocComment(content, start, length2) {
  const result = Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length2);
  if (result && result.jsDoc) {
    Parser.fixupParentReferences(result.jsDoc);
  }
  return result;
}
function parseJSDocTypeExpressionForTests(content, start, length2) {
  return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length2);
}
var Parser;
((Parser2) => {
  var scanner2 = createScanner(
    99 /* Latest */,
    /*skipTrivia*/
    true
  );
  var disallowInAndDecoratorContext = 8192 /* DisallowInContext */ | 32768 /* DecoratorContext */;
  var NodeConstructor2;
  var TokenConstructor2;
  var IdentifierConstructor2;
  var PrivateIdentifierConstructor2;
  var SourceFileConstructor2;
  function countNode(node) {
    nodeCount++;
    return node;
  }
  var baseNodeFactory = {
    createBaseSourceFileNode: (kind) => countNode(new SourceFileConstructor2(
      kind,
      /*pos*/
      0,
      /*end*/
      0
    )),
    createBaseIdentifierNode: (kind) => countNode(new IdentifierConstructor2(
      kind,
      /*pos*/
      0,
      /*end*/
      0
    )),
    createBasePrivateIdentifierNode: (kind) => countNode(new PrivateIdentifierConstructor2(
      kind,
      /*pos*/
      0,
      /*end*/
      0
    )),
    createBaseTokenNode: (kind) => countNode(new TokenConstructor2(
      kind,
      /*pos*/
      0,
      /*end*/
      0
    )),
    createBaseNode: (kind) => countNode(new NodeConstructor2(
      kind,
      /*pos*/
      0,
      /*end*/
      0
    ))
  };
  var factory2 = createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory);
  var {
    createNodeArray: factoryCreateNodeArray,
    createNumericLiteral: factoryCreateNumericLiteral,
    createStringLiteral: factoryCreateStringLiteral,
    createLiteralLikeNode: factoryCreateLiteralLikeNode,
    createIdentifier: factoryCreateIdentifier,
    createPrivateIdentifier: factoryCreatePrivateIdentifier,
    createToken: factoryCreateToken,
    createArrayLiteralExpression: factoryCreateArrayLiteralExpression,
    createObjectLiteralExpression: factoryCreateObjectLiteralExpression,
    createPropertyAccessExpression: factoryCreatePropertyAccessExpression,
    createPropertyAccessChain: factoryCreatePropertyAccessChain,
    createElementAccessExpression: factoryCreateElementAccessExpression,
    createElementAccessChain: factoryCreateElementAccessChain,
    createCallExpression: factoryCreateCallExpression,
    createCallChain: factoryCreateCallChain,
    createNewExpression: factoryCreateNewExpression,
    createParenthesizedExpression: factoryCreateParenthesizedExpression,
    createBlock: factoryCreateBlock,
    createVariableStatement: factoryCreateVariableStatement,
    createExpressionStatement: factoryCreateExpressionStatement,
    createIfStatement: factoryCreateIfStatement,
    createWhileStatement: factoryCreateWhileStatement,
    createForStatement: factoryCreateForStatement,
    createForOfStatement: factoryCreateForOfStatement,
    createVariableDeclaration: factoryCreateVariableDeclaration,
    createVariableDeclarationList: factoryCreateVariableDeclarationList
  } = factory2;
  var fileName;
  var sourceFlags;
  var sourceText;
  var languageVersion;
  var scriptKind;
  var languageVariant;
  var parseDiagnostics;
  var jsDocDiagnostics;
  var syntaxCursor;
  var currentToken;
  var nodeCount;
  var identifiers;
  var identifierCount;
  var parsingContext;
  var notParenthesizedArrow;
  var contextFlags;
  var topLevel = true;
  var parseErrorBeforeNextFinishedNode = false;
  function parseSourceFile(fileName2, sourceText2, languageVersion2, syntaxCursor2, setParentNodes = false, scriptKind2, setExternalModuleIndicatorOverride, jsDocParsingMode = 0 /* ParseAll */) {
    var _a;
    scriptKind2 = ensureScriptKind(fileName2, scriptKind2);
    if (scriptKind2 === 6 /* JSON */) {
      const result2 = parseJsonText2(fileName2, sourceText2, languageVersion2, syntaxCursor2, setParentNodes);
      convertToJson(
        result2,
        (_a = result2.statements[0]) == null ? void 0 : _a.expression,
        result2.parseDiagnostics,
        /*returnValue*/
        false,
        /*jsonConversionNotifier*/
        void 0
      );
      result2.referencedFiles = emptyArray;
      result2.typeReferenceDirectives = emptyArray;
      result2.libReferenceDirectives = emptyArray;
      result2.amdDependencies = emptyArray;
      result2.hasNoDefaultLib = false;
      result2.pragmas = emptyMap;
      return result2;
    }
    initializeState(fileName2, sourceText2, languageVersion2, syntaxCursor2, scriptKind2, jsDocParsingMode);
    const result = parseSourceFileWorker(languageVersion2, setParentNodes, scriptKind2, setExternalModuleIndicatorOverride || setExternalModuleIndicator, jsDocParsingMode);
    clearState();
    return result;
  }
  Parser2.parseSourceFile = parseSourceFile;
  function parseIsolatedEntityName2(content, languageVersion2) {
    initializeState(
      "",
      content,
      languageVersion2,
      /*syntaxCursor*/
      void 0,
      1 /* JS */,
      0 /* ParseAll */
    );
    nextToken();
    const entityName = parseEntityName(
      /*allowReservedWords*/
      true
    );
    const isValid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length;
    clearState();
    return isValid ? entityName : void 0;
  }
  Parser2.parseIsolatedEntityName = parseIsolatedEntityName2;
  function parseJsonText2(fileName2, sourceText2, languageVersion2 = 2 /* ES2015 */, syntaxCursor2, setParentNodes = false) {
    initializeState(fileName2, sourceText2, languageVersion2, syntaxCursor2, 6 /* JSON */, 0 /* ParseAll */);
    sourceFlags = contextFlags;
    nextToken();
    const pos = getNodePos();
    let statements, endOfFileToken;
    if (token() === 1 /* EndOfFileToken */) {
      statements = createNodeArray([], pos, pos);
      endOfFileToken = parseTokenNode();
    } else {
      let expressions;
      while (token() !== 1 /* EndOfFileToken */) {
        let expression2;
        switch (token()) {
          case 23 /* OpenBracketToken */:
            expression2 = parseArrayLiteralExpression();
            break;
          case 112 /* TrueKeyword */:
          case 97 /* FalseKeyword */:
          case 106 /* NullKeyword */:
            expression2 = parseTokenNode();
            break;
          case 41 /* MinusToken */:
            if (lookAhead(() => nextToken() === 9 /* NumericLiteral */ && nextToken() !== 59 /* ColonToken */)) {
              expression2 = parsePrefixUnaryExpression();
            } else {
              expression2 = parseObjectLiteralExpression();
            }
            break;
          case 9 /* NumericLiteral */:
          case 11 /* StringLiteral */:
            if (lookAhead(() => nextToken() !== 59 /* ColonToken */)) {
              expression2 = parseLiteralNode();
              break;
            }
          // falls through
          default:
            expression2 = parseObjectLiteralExpression();
            break;
        }
        if (expressions && isArray(expressions)) {
          expressions.push(expression2);
        } else if (expressions) {
          expressions = [expressions, expression2];
        } else {
          expressions = expression2;
          if (token() !== 1 /* EndOfFileToken */) {
            parseErrorAtCurrentToken(Diagnostics.Unexpected_token);
          }
        }
      }
      const expression = isArray(expressions) ? finishNode(factoryCreateArrayLiteralExpression(expressions), pos) : Debug.checkDefined(expressions);
      const statement = factoryCreateExpressionStatement(expression);
      finishNode(statement, pos);
      statements = createNodeArray([statement], pos);
      endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, Diagnostics.Unexpected_token);
    }
    const sourceFile = createSourceFile2(
      fileName2,
      2 /* ES2015 */,
      6 /* JSON */,
      /*isDeclarationFile*/
      false,
      statements,
      endOfFileToken,
      sourceFlags,
      noop
    );
    if (setParentNodes) {
      fixupParentReferences(sourceFile);
    }
    sourceFile.nodeCount = nodeCount;
    sourceFile.identifierCount = identifierCount;
    sourceFile.identifiers = identifiers;
    sourceFile.parseDiagnostics = attachFileToDiagnostics(parseDiagnostics, sourceFile);
    if (jsDocDiagnostics) {
      sourceFile.jsDocDiagnostics = attachFileToDiagnostics(jsDocDiagnostics, sourceFile);
    }
    const result = sourceFile;
    clearState();
    return result;
  }
  Parser2.parseJsonText = parseJsonText2;
  function initializeState(_fileName, _sourceText, _languageVersion, _syntaxCursor, _scriptKind, _jsDocParsingMode) {
    NodeConstructor2 = objectAllocator.getNodeConstructor();
    TokenConstructor2 = objectAllocator.getTokenConstructor();
    IdentifierConstructor2 = objectAllocator.getIdentifierConstructor();
    PrivateIdentifierConstructor2 = objectAllocator.getPrivateIdentifierConstructor();
    SourceFileConstructor2 = objectAllocator.getSourceFileConstructor();
    fileName = normalizePath(_fileName);
    sourceText = _sourceText;
    languageVersion = _languageVersion;
    syntaxCursor = _syntaxCursor;
    scriptKind = _scriptKind;
    languageVariant = getLanguageVariant(_scriptKind);
    parseDiagnostics = [];
    parsingContext = 0;
    identifiers = /* @__PURE__ */ new Map();
    identifierCount = 0;
    nodeCount = 0;
    sourceFlags = 0;
    topLevel = true;
    switch (scriptKind) {
      case 1 /* JS */:
      case 2 /* JSX */:
        contextFlags = 524288 /* JavaScriptFile */;
        break;
      case 6 /* JSON */:
        contextFlags = 524288 /* JavaScriptFile */ | 134217728 /* JsonFile */;
        break;
      default:
        contextFlags = 0 /* None */;
        break;
    }
    parseErrorBeforeNextFinishedNode = false;
    scanner2.setText(sourceText);
    scanner2.setOnError(scanError);
    scanner2.setScriptTarget(languageVersion);
    scanner2.setLanguageVariant(languageVariant);
    scanner2.setScriptKind(scriptKind);
    scanner2.setJSDocParsingMode(_jsDocParsingMode);
  }
  function clearState() {
    scanner2.clearCommentDirectives();
    scanner2.setText("");
    scanner2.setOnError(void 0);
    scanner2.setScriptKind(0 /* Unknown */);
    scanner2.setJSDocParsingMode(0 /* ParseAll */);
    sourceText = void 0;
    languageVersion = void 0;
    syntaxCursor = void 0;
    scriptKind = void 0;
    languageVariant = void 0;
    sourceFlags = 0;
    parseDiagnostics = void 0;
    jsDocDiagnostics = void 0;
    parsingContext = 0;
    identifiers = void 0;
    notParenthesizedArrow = void 0;
    topLevel = true;
  }
  function parseSourceFileWorker(languageVersion2, setParentNodes, scriptKind2, setExternalModuleIndicator2, jsDocParsingMode) {
    const isDeclarationFile = isDeclarationFileName(fileName);
    if (isDeclarationFile) {
      contextFlags |= 33554432 /* Ambient */;
    }
    sourceFlags = contextFlags;
    nextToken();
    const statements = parseList(0 /* SourceElements */, parseStatement);
    Debug.assert(token() === 1 /* EndOfFileToken */);
    const endHasJSDoc = hasPrecedingJSDocComment();
    const endOfFileToken = withJSDoc(parseTokenNode(), endHasJSDoc);
    const sourceFile = createSourceFile2(fileName, languageVersion2, scriptKind2, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator2);
    processCommentPragmas(sourceFile, sourceText);
    processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
    sourceFile.commentDirectives = scanner2.getCommentDirectives();
    sourceFile.nodeCount = nodeCount;
    sourceFile.identifierCount = identifierCount;
    sourceFile.identifiers = identifiers;
    sourceFile.parseDiagnostics = attachFileToDiagnostics(parseDiagnostics, sourceFile);
    sourceFile.jsDocParsingMode = jsDocParsingMode;
    if (jsDocDiagnostics) {
      sourceFile.jsDocDiagnostics = attachFileToDiagnostics(jsDocDiagnostics, sourceFile);
    }
    if (setParentNodes) {
      fixupParentReferences(sourceFile);
    }
    return sourceFile;
    function reportPragmaDiagnostic(pos, end, diagnostic) {
      parseDiagnostics.push(createDetachedDiagnostic(fileName, sourceText, pos, end, diagnostic));
    }
  }
  let hasDeprecatedTag = false;
  function withJSDoc(node, hasJSDoc) {
    if (!hasJSDoc) {
      return node;
    }
    Debug.assert(!node.jsDoc);
    const jsDoc = mapDefined(getJSDocCommentRanges(node, sourceText), (comment) => JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos));
    if (jsDoc.length) node.jsDoc = jsDoc;
    if (hasDeprecatedTag) {
      hasDeprecatedTag = false;
      node.flags |= 536870912 /* Deprecated */;
    }
    return node;
  }
  function reparseTopLevelAwait(sourceFile) {
    const savedSyntaxCursor = syntaxCursor;
    const baseSyntaxCursor = IncrementalParser.createSyntaxCursor(sourceFile);
    syntaxCursor = { currentNode: currentNode2 };
    const statements = [];
    const savedParseDiagnostics = parseDiagnostics;
    parseDiagnostics = [];
    let pos = 0;
    let start = findNextStatementWithAwait(sourceFile.statements, 0);
    while (start !== -1) {
      const prevStatement = sourceFile.statements[pos];
      const nextStatement = sourceFile.statements[start];
      addRange(statements, sourceFile.statements, pos, start);
      pos = findNextStatementWithoutAwait(sourceFile.statements, start);
      const diagnosticStart = findIndex(savedParseDiagnostics, (diagnostic) => diagnostic.start >= prevStatement.pos);
      const diagnosticEnd = diagnosticStart >= 0 ? findIndex(savedParseDiagnostics, (diagnostic) => diagnostic.start >= nextStatement.pos, diagnosticStart) : -1;
      if (diagnosticStart >= 0) {
        addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart, diagnosticEnd >= 0 ? diagnosticEnd : void 0);
      }
      speculationHelper(() => {
        const savedContextFlags = contextFlags;
        contextFlags |= 65536 /* AwaitContext */;
        scanner2.resetTokenState(nextStatement.pos);
        nextToken();
        while (token() !== 1 /* EndOfFileToken */) {
          const startPos = scanner2.getTokenFullStart();
          const statement = parseListElement(0 /* SourceElements */, parseStatement);
          statements.push(statement);
          if (startPos === scanner2.getTokenFullStart()) {
            nextToken();
          }
          if (pos >= 0) {
            const nonAwaitStatement = sourceFile.statements[pos];
            if (statement.end === nonAwaitStatement.pos) {
              break;
            }
            if (statement.end > nonAwaitStatement.pos) {
              pos = findNextStatementWithoutAwait(sourceFile.statements, pos + 1);
            }
          }
        }
        contextFlags = savedContextFlags;
      }, 2 /* Reparse */);
      start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1;
    }
    if (pos >= 0) {
      const prevStatement = sourceFile.statements[pos];
      addRange(statements, sourceFile.statements, pos);
      const diagnosticStart = findIndex(savedParseDiagnostics, (diagnostic) => diagnostic.start >= prevStatement.pos);
      if (diagnosticStart >= 0) {
        addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart);
      }
    }
    syntaxCursor = savedSyntaxCursor;
    return factory2.updateSourceFile(sourceFile, setTextRange(factoryCreateNodeArray(statements), sourceFile.statements));
    function containsPossibleTopLevelAwait(node) {
      return !(node.flags & 65536 /* AwaitContext */) && !!(node.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */);
    }
    function findNextStatementWithAwait(statements2, start2) {
      for (let i = start2; i < statements2.length; i++) {
        if (containsPossibleTopLevelAwait(statements2[i])) {
          return i;
        }
      }
      return -1;
    }
    function findNextStatementWithoutAwait(statements2, start2) {
      for (let i = start2; i < statements2.length; i++) {
        if (!containsPossibleTopLevelAwait(statements2[i])) {
          return i;
        }
      }
      return -1;
    }
    function currentNode2(position) {
      const node = baseSyntaxCursor.currentNode(position);
      if (topLevel && node && containsPossibleTopLevelAwait(node)) {
        markAsIntersectingIncrementalChange(node);
      }
      return node;
    }
  }
  function fixupParentReferences(rootNode) {
    setParentRecursive(
      rootNode,
      /*incremental*/
      true
    );
  }
  Parser2.fixupParentReferences = fixupParentReferences;
  function createSourceFile2(fileName2, languageVersion2, scriptKind2, isDeclarationFile, statements, endOfFileToken, flags, setExternalModuleIndicator2) {
    let sourceFile = factory2.createSourceFile(statements, endOfFileToken, flags);
    setTextRangePosWidth(sourceFile, 0, sourceText.length);
    setFields(sourceFile);
    if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */) {
      const oldSourceFile = sourceFile;
      sourceFile = reparseTopLevelAwait(sourceFile);
      if (oldSourceFile !== sourceFile) setFields(sourceFile);
    }
    return sourceFile;
    function setFields(sourceFile2) {
      sourceFile2.text = sourceText;
      sourceFile2.bindDiagnostics = [];
      sourceFile2.bindSuggestionDiagnostics = void 0;
      sourceFile2.languageVersion = languageVersion2;
      sourceFile2.fileName = fileName2;
      sourceFile2.languageVariant = getLanguageVariant(scriptKind2);
      sourceFile2.isDeclarationFile = isDeclarationFile;
      sourceFile2.scriptKind = scriptKind2;
      setExternalModuleIndicator2(sourceFile2);
      sourceFile2.setExternalModuleIndicator = setExternalModuleIndicator2;
    }
  }
  function setContextFlag(val, flag) {
    if (val) {
      contextFlags |= flag;
    } else {
      contextFlags &= ~flag;
    }
  }
  function setDisallowInContext(val) {
    setContextFlag(val, 8192 /* DisallowInContext */);
  }
  function setYieldContext(val) {
    setContextFlag(val, 16384 /* YieldContext */);
  }
  function setDecoratorContext(val) {
    setContextFlag(val, 32768 /* DecoratorContext */);
  }
  function setAwaitContext(val) {
    setContextFlag(val, 65536 /* AwaitContext */);
  }
  function doOutsideOfContext(context, func) {
    const contextFlagsToClear = context & contextFlags;
    if (contextFlagsToClear) {
      setContextFlag(
        /*val*/
        false,
        contextFlagsToClear
      );
      const result = func();
      setContextFlag(
        /*val*/
        true,
        contextFlagsToClear
      );
      return result;
    }
    return func();
  }
  function doInsideOfContext(context, func) {
    const contextFlagsToSet = context & ~contextFlags;
    if (contextFlagsToSet) {
      setContextFlag(
        /*val*/
        true,
        contextFlagsToSet
      );
      const result = func();
      setContextFlag(
        /*val*/
        false,
        contextFlagsToSet
      );
      return result;
    }
    return func();
  }
  function allowInAnd(func) {
    return doOutsideOfContext(8192 /* DisallowInContext */, func);
  }
  function disallowInAnd(func) {
    return doInsideOfContext(8192 /* DisallowInContext */, func);
  }
  function allowConditionalTypesAnd(func) {
    return doOutsideOfContext(131072 /* DisallowConditionalTypesContext */, func);
  }
  function disallowConditionalTypesAnd(func) {
    return doInsideOfContext(131072 /* DisallowConditionalTypesContext */, func);
  }
  function doInYieldContext(func) {
    return doInsideOfContext(16384 /* YieldContext */, func);
  }
  function doInDecoratorContext(func) {
    return doInsideOfContext(32768 /* DecoratorContext */, func);
  }
  function doInAwaitContext(func) {
    return doInsideOfContext(65536 /* AwaitContext */, func);
  }
  function doOutsideOfAwaitContext(func) {
    return doOutsideOfContext(65536 /* AwaitContext */, func);
  }
  function doInYieldAndAwaitContext(func) {
    return doInsideOfContext(16384 /* YieldContext */ | 65536 /* AwaitContext */, func);
  }
  function doOutsideOfYieldAndAwaitContext(func) {
    return doOutsideOfContext(16384 /* YieldContext */ | 65536 /* AwaitContext */, func);
  }
  function inContext(flags) {
    return (contextFlags & flags) !== 0;
  }
  function inYieldContext() {
    return inContext(16384 /* YieldContext */);
  }
  function inDisallowInContext() {
    return inContext(8192 /* DisallowInContext */);
  }
  function inDisallowConditionalTypesContext() {
    return inContext(131072 /* DisallowConditionalTypesContext */);
  }
  function inDecoratorContext() {
    return inContext(32768 /* DecoratorContext */);
  }
  function inAwaitContext() {
    return inContext(65536 /* AwaitContext */);
  }
  function parseErrorAtCurrentToken(message, ...args) {
    return parseErrorAt(scanner2.getTokenStart(), scanner2.getTokenEnd(), message, ...args);
  }
  function parseErrorAtPosition(start, length2, message, ...args) {
    const lastError = lastOrUndefined(parseDiagnostics);
    let result;
    if (!lastError || start !== lastError.start) {
      result = createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args);
      parseDiagnostics.push(result);
    }
    parseErrorBeforeNextFinishedNode = true;
    return result;
  }
  function parseErrorAt(start, end, message, ...args) {
    return parseErrorAtPosition(start, end - start, message, ...args);
  }
  function parseErrorAtRange(range, message, ...args) {
    parseErrorAt(range.pos, range.end, message, ...args);
  }
  function scanError(message, length2, arg0) {
    parseErrorAtPosition(scanner2.getTokenEnd(), length2, message, arg0);
  }
  function getNodePos() {
    return scanner2.getTokenFullStart();
  }
  function hasPrecedingJSDocComment() {
    return scanner2.hasPrecedingJSDocComment();
  }
  function token() {
    return currentToken;
  }
  function nextTokenWithoutCheck() {
    return currentToken = scanner2.scan();
  }
  function nextTokenAnd(func) {
    nextToken();
    return func();
  }
  function nextToken() {
    if (isKeyword(currentToken) && (scanner2.hasUnicodeEscape() || scanner2.hasExtendedUnicodeEscape())) {
      parseErrorAt(scanner2.getTokenStart(), scanner2.getTokenEnd(), Diagnostics.Keywords_cannot_contain_escape_characters);
    }
    return nextTokenWithoutCheck();
  }
  function nextTokenJSDoc() {
    return currentToken = scanner2.scanJsDocToken();
  }
  function nextJSDocCommentTextToken(inBackticks) {
    return currentToken = scanner2.scanJSDocCommentTextToken(inBackticks);
  }
  function reScanGreaterToken() {
    return currentToken = scanner2.reScanGreaterToken();
  }
  function reScanSlashToken() {
    return currentToken = scanner2.reScanSlashToken();
  }
  function reScanTemplateToken(isTaggedTemplate) {
    return currentToken = scanner2.reScanTemplateToken(isTaggedTemplate);
  }
  function reScanLessThanToken() {
    return currentToken = scanner2.reScanLessThanToken();
  }
  function reScanHashToken() {
    return currentToken = scanner2.reScanHashToken();
  }
  function scanJsxIdentifier() {
    return currentToken = scanner2.scanJsxIdentifier();
  }
  function scanJsxText() {
    return currentToken = scanner2.scanJsxToken();
  }
  function scanJsxAttributeValue() {
    return currentToken = scanner2.scanJsxAttributeValue();
  }
  function speculationHelper(callback, speculationKind) {
    const saveToken = currentToken;
    const saveParseDiagnosticsLength = parseDiagnostics.length;
    const saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
    const saveContextFlags = contextFlags;
    const result = speculationKind !== 0 /* TryParse */ ? scanner2.lookAhead(callback) : scanner2.tryScan(callback);
    Debug.assert(saveContextFlags === contextFlags);
    if (!result || speculationKind !== 0 /* TryParse */) {
      currentToken = saveToken;
      if (speculationKind !== 2 /* Reparse */) {
        parseDiagnostics.length = saveParseDiagnosticsLength;
      }
      parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
    }
    return result;
  }
  function lookAhead(callback) {
    return speculationHelper(callback, 1 /* Lookahead */);
  }
  function tryParse(callback) {
    return speculationHelper(callback, 0 /* TryParse */);
  }
  function isBindingIdentifier() {
    if (token() === 80 /* Identifier */) {
      return true;
    }
    return token() > 118 /* LastReservedWord */;
  }
  function isIdentifier2() {
    if (token() === 80 /* Identifier */) {
      return true;
    }
    if (token() === 127 /* YieldKeyword */ && inYieldContext()) {
      return false;
    }
    if (token() === 135 /* AwaitKeyword */ && inAwaitContext()) {
      return false;
    }
    return token() > 118 /* LastReservedWord */;
  }
  function parseExpected(kind, diagnosticMessage, shouldAdvance = true) {
    if (token() === kind) {
      if (shouldAdvance) {
        nextToken();
      }
      return true;
    }
    if (diagnosticMessage) {
      parseErrorAtCurrentToken(diagnosticMessage);
    } else {
      parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(kind));
    }
    return false;
  }
  const viableKeywordSuggestions = Object.keys(textToKeywordObj).filter((keyword) => keyword.length > 2);
  function parseErrorForMissingSemicolonAfter(node) {
    if (isTaggedTemplateExpression(node)) {
      parseErrorAt(skipTrivia(sourceText, node.template.pos), node.template.end, Diagnostics.Module_declaration_names_may_only_use_or_quoted_strings);
      return;
    }
    const expressionText = isIdentifier(node) ? idText(node) : void 0;
    if (!expressionText || !isIdentifierText(expressionText, languageVersion)) {
      parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(27 /* SemicolonToken */));
      return;
    }
    const pos = skipTrivia(sourceText, node.pos);
    switch (expressionText) {
      case "const":
      case "let":
      case "var":
        parseErrorAt(pos, node.end, Diagnostics.Variable_declaration_not_allowed_at_this_location);
        return;
      case "declare":
        return;
      case "interface":
        parseErrorForInvalidName(Diagnostics.Interface_name_cannot_be_0, Diagnostics.Interface_must_be_given_a_name, 19 /* OpenBraceToken */);
        return;
      case "is":
        parseErrorAt(pos, scanner2.getTokenStart(), Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods);
        return;
      case "module":
      case "namespace":
        parseErrorForInvalidName(Diagnostics.Namespace_name_cannot_be_0, Diagnostics.Namespace_must_be_given_a_name, 19 /* OpenBraceToken */);
        return;
      case "type":
        parseErrorForInvalidName(Diagnostics.Type_alias_name_cannot_be_0, Diagnostics.Type_alias_must_be_given_a_name, 64 /* EqualsToken */);
        return;
    }
    const suggestion = getSpellingSuggestion(expressionText, viableKeywordSuggestions, identity) ?? getSpaceSuggestion(expressionText);
    if (suggestion) {
      parseErrorAt(pos, node.end, Diagnostics.Unknown_keyword_or_identifier_Did_you_mean_0, suggestion);
      return;
    }
    if (token() === 0 /* Unknown */) {
      return;
    }
    parseErrorAt(pos, node.end, Diagnostics.Unexpected_keyword_or_identifier);
  }
  function parseErrorForInvalidName(nameDiagnostic, blankDiagnostic, tokenIfBlankName) {
    if (token() === tokenIfBlankName) {
      parseErrorAtCurrentToken(blankDiagnostic);
    } else {
      parseErrorAtCurrentToken(nameDiagnostic, scanner2.getTokenValue());
    }
  }
  function getSpaceSuggestion(expressionText) {
    for (const keyword of viableKeywordSuggestions) {
      if (expressionText.length > keyword.length + 2 && startsWith(expressionText, keyword)) {
        return `${keyword} ${expressionText.slice(keyword.length)}`;
      }
    }
    return void 0;
  }
  function parseSemicolonAfterPropertyName(name, type, initializer) {
    if (token() === 60 /* AtToken */ && !scanner2.hasPrecedingLineBreak()) {
      parseErrorAtCurrentToken(Diagnostics.Decorators_must_precede_the_name_and_all_keywords_of_property_declarations);
      return;
    }
    if (token() === 21 /* OpenParenToken */) {
      parseErrorAtCurrentToken(Diagnostics.Cannot_start_a_function_call_in_a_type_annotation);
      nextToken();
      return;
    }
    if (type && !canParseSemicolon()) {
      if (initializer) {
        parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(27 /* SemicolonToken */));
      } else {
        parseErrorAtCurrentToken(Diagnostics.Expected_for_property_initializer);
      }
      return;
    }
    if (tryParseSemicolon()) {
      return;
    }
    if (initializer) {
      parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(27 /* SemicolonToken */));
      return;
    }
    parseErrorForMissingSemicolonAfter(name);
  }
  function parseExpectedJSDoc(kind) {
    if (token() === kind) {
      nextTokenJSDoc();
      return true;
    }
    Debug.assert(isKeywordOrPunctuation(kind));
    parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(kind));
    return false;
  }
  function parseExpectedMatchingBrackets(openKind, closeKind, openParsed, openPosition) {
    if (token() === closeKind) {
      nextToken();
      return;
    }
    const lastError = parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(closeKind));
    if (!openParsed) {
      return;
    }
    if (lastError) {
      addRelatedInfo(
        lastError,
        createDetachedDiagnostic(fileName, sourceText, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind))
      );
    }
  }
  function parseOptional(t) {
    if (token() === t) {
      nextToken();
      return true;
    }
    return false;
  }
  function parseOptionalToken(t) {
    if (token() === t) {
      return parseTokenNode();
    }
    return void 0;
  }
  function parseOptionalTokenJSDoc(t) {
    if (token() === t) {
      return parseTokenNodeJSDoc();
    }
    return void 0;
  }
  function parseExpectedToken(t, diagnosticMessage, arg0) {
    return parseOptionalToken(t) || createMissingNode(
      t,
      /*reportAtCurrentPosition*/
      false,
      diagnosticMessage || Diagnostics._0_expected,
      arg0 || tokenToString(t)
    );
  }
  function parseExpectedTokenJSDoc(t) {
    const optional = parseOptionalTokenJSDoc(t);
    if (optional) return optional;
    Debug.assert(isKeywordOrPunctuation(t));
    return createMissingNode(
      t,
      /*reportAtCurrentPosition*/
      false,
      Diagnostics._0_expected,
      tokenToString(t)
    );
  }
  function parseTokenNode() {
    const pos = getNodePos();
    const kind = token();
    nextToken();
    return finishNode(factoryCreateToken(kind), pos);
  }
  function parseTokenNodeJSDoc() {
    const pos = getNodePos();
    const kind = token();
    nextTokenJSDoc();
    return finishNode(factoryCreateToken(kind), pos);
  }
  function canParseSemicolon() {
    if (token() === 27 /* SemicolonToken */) {
      return true;
    }
    return token() === 20 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner2.hasPrecedingLineBreak();
  }
  function tryParseSemicolon() {
    if (!canParseSemicolon()) {
      return false;
    }
    if (token() === 27 /* SemicolonToken */) {
      nextToken();
    }
    return true;
  }
  function parseSemicolon() {
    return tryParseSemicolon() || parseExpected(27 /* SemicolonToken */);
  }
  function createNodeArray(elements, pos, end, hasTrailingComma) {
    const array = factoryCreateNodeArray(elements, hasTrailingComma);
    setTextRangePosEnd(array, pos, end ?? scanner2.getTokenFullStart());
    return array;
  }
  function finishNode(node, pos, end) {
    setTextRangePosEnd(node, pos, end ?? scanner2.getTokenFullStart());
    if (contextFlags) {
      node.flags |= contextFlags;
    }
    if (parseErrorBeforeNextFinishedNode) {
      parseErrorBeforeNextFinishedNode = false;
      node.flags |= 262144 /* ThisNodeHasError */;
    }
    return node;
  }
  function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, ...args) {
    if (reportAtCurrentPosition) {
      parseErrorAtPosition(scanner2.getTokenFullStart(), 0, diagnosticMessage, ...args);
    } else if (diagnosticMessage) {
      parseErrorAtCurrentToken(diagnosticMessage, ...args);
    }
    const pos = getNodePos();
    const result = kind === 80 /* Identifier */ ? factoryCreateIdentifier(
      "",
      /*originalKeywordKind*/
      void 0
    ) : isTemplateLiteralKind(kind) ? factory2.createTemplateLiteralLikeNode(
      kind,
      "",
      "",
      /*templateFlags*/
      void 0
    ) : kind === 9 /* NumericLiteral */ ? factoryCreateNumericLiteral(
      "",
      /*numericLiteralFlags*/
      void 0
    ) : kind === 11 /* StringLiteral */ ? factoryCreateStringLiteral(
      "",
      /*isSingleQuote*/
      void 0
    ) : kind === 282 /* MissingDeclaration */ ? factory2.createMissingDeclaration() : factoryCreateToken(kind);
    return finishNode(result, pos);
  }
  function internIdentifier(text) {
    let identifier = identifiers.get(text);
    if (identifier === void 0) {
      identifiers.set(text, identifier = text);
    }
    return identifier;
  }
  function createIdentifier(isIdentifier3, diagnosticMessage, privateIdentifierDiagnosticMessage) {
    if (isIdentifier3) {
      identifierCount++;
      const pos = scanner2.hasPrecedingJSDocLeadingAsterisks() ? scanner2.getTokenStart() : getNodePos();
      const originalKeywordKind = token();
      const text = internIdentifier(scanner2.getTokenValue());
      const hasExtendedUnicodeEscape = scanner2.hasExtendedUnicodeEscape();
      nextTokenWithoutCheck();
      return finishNode(factoryCreateIdentifier(text, originalKeywordKind, hasExtendedUnicodeEscape), pos);
    }
    if (token() === 81 /* PrivateIdentifier */) {
      parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
      return createIdentifier(
        /*isIdentifier*/
        true
      );
    }
    if (token() === 0 /* Unknown */ && scanner2.tryScan(() => scanner2.reScanInvalidIdentifier() === 80 /* Identifier */)) {
      return createIdentifier(
        /*isIdentifier*/
        true
      );
    }
    identifierCount++;
    const reportAtCurrentPosition = token() === 1 /* EndOfFileToken */;
    const isReservedWord = scanner2.isReservedWord();
    const msgArg = scanner2.getTokenText();
    const defaultMessage = isReservedWord ? Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : Diagnostics.Identifier_expected;
    return createMissingNode(80 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg);
  }
  function parseBindingIdentifier(privateIdentifierDiagnosticMessage) {
    return createIdentifier(
      isBindingIdentifier(),
      /*diagnosticMessage*/
      void 0,
      privateIdentifierDiagnosticMessage
    );
  }
  function parseIdentifier(diagnosticMessage, privateIdentifierDiagnosticMessage) {
    return createIdentifier(isIdentifier2(), diagnosticMessage, privateIdentifierDiagnosticMessage);
  }
  function parseIdentifierName(diagnosticMessage) {
    return createIdentifier(tokenIsIdentifierOrKeyword(token()), diagnosticMessage);
  }
  function parseIdentifierNameErrorOnUnicodeEscapeSequence() {
    if (scanner2.hasUnicodeEscape() || scanner2.hasExtendedUnicodeEscape()) {
      parseErrorAtCurrentToken(Diagnostics.Unicode_escape_sequence_cannot_appear_here);
    }
    return createIdentifier(tokenIsIdentifierOrKeyword(token()));
  }
  function isLiteralPropertyName() {
    return tokenIsIdentifierOrKeyword(token()) || token() === 11 /* StringLiteral */ || token() === 9 /* NumericLiteral */ || token() === 10 /* BigIntLiteral */;
  }
  function isImportAttributeName2() {
    return tokenIsIdentifierOrKeyword(token()) || token() === 11 /* StringLiteral */;
  }
  function parsePropertyNameWorker(allowComputedPropertyNames) {
    if (token() === 11 /* StringLiteral */ || token() === 9 /* NumericLiteral */ || token() === 10 /* BigIntLiteral */) {
      const node = parseLiteralNode();
      node.text = internIdentifier(node.text);
      return node;
    }
    if (allowComputedPropertyNames && token() === 23 /* OpenBracketToken */) {
      return parseComputedPropertyName();
    }
    if (token() === 81 /* PrivateIdentifier */) {
      return parsePrivateIdentifier();
    }
    return parseIdentifierName();
  }
  function parsePropertyName() {
    return parsePropertyNameWorker(
      /*allowComputedPropertyNames*/
      true
    );
  }
  function parseComputedPropertyName() {
    const pos = getNodePos();
    parseExpected(23 /* OpenBracketToken */);
    const expression = allowInAnd(parseExpression);
    parseExpected(24 /* CloseBracketToken */);
    return finishNode(factory2.createComputedPropertyName(expression), pos);
  }
  function parsePrivateIdentifier() {
    const pos = getNodePos();
    const node = factoryCreatePrivateIdentifier(internIdentifier(scanner2.getTokenValue()));
    nextToken();
    return finishNode(node, pos);
  }
  function parseContextualModifier(t) {
    return token() === t && tryParse(nextTokenCanFollowModifier);
  }
  function nextTokenIsOnSameLineAndCanFollowModifier() {
    nextToken();
    if (scanner2.hasPrecedingLineBreak()) {
      return false;
    }
    return canFollowModifier();
  }
  function nextTokenCanFollowModifier() {
    switch (token()) {
      case 87 /* ConstKeyword */:
        return nextToken() === 94 /* EnumKeyword */;
      case 95 /* ExportKeyword */:
        nextToken();
        if (token() === 90 /* DefaultKeyword */) {
          return lookAhead(nextTokenCanFollowDefaultKeyword);
        }
        if (token() === 156 /* TypeKeyword */) {
          return lookAhead(nextTokenCanFollowExportModifier);
        }
        return canFollowExportModifier();
      case 90 /* DefaultKeyword */:
        return nextTokenCanFollowDefaultKeyword();
      case 126 /* StaticKeyword */:
        nextToken();
        return canFollowModifier();
      case 139 /* GetKeyword */:
      case 153 /* SetKeyword */:
        nextToken();
        return canFollowGetOrSetKeyword();
      default:
        return nextTokenIsOnSameLineAndCanFollowModifier();
    }
  }
  function canFollowExportModifier() {
    return token() === 60 /* AtToken */ || token() !== 42 /* AsteriskToken */ && token() !== 130 /* AsKeyword */ && token() !== 19 /* OpenBraceToken */ && canFollowModifier();
  }
  function nextTokenCanFollowExportModifier() {
    nextToken();
    return canFollowExportModifier();
  }
  function parseAnyContextualModifier() {
    return isModifierKind(token()) && tryParse(nextTokenCanFollowModifier);
  }
  function canFollowModifier() {
    return token() === 23 /* OpenBracketToken */ || token() === 19 /* OpenBraceToken */ || token() === 42 /* AsteriskToken */ || token() === 26 /* DotDotDotToken */ || isLiteralPropertyName();
  }
  function canFollowGetOrSetKeyword() {
    return token() === 23 /* OpenBracketToken */ || isLiteralPropertyName();
  }
  function nextTokenCanFollowDefaultKeyword() {
    nextToken();
    return token() === 86 /* ClassKeyword */ || token() === 100 /* FunctionKeyword */ || token() === 120 /* InterfaceKeyword */ || token() === 60 /* AtToken */ || token() === 128 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine) || token() === 134 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine);
  }
  function isListElement2(parsingContext2, inErrorRecovery) {
    const node = currentNode(parsingContext2);
    if (node) {
      return true;
    }
    switch (parsingContext2) {
      case 0 /* SourceElements */:
      case 1 /* BlockStatements */:
      case 3 /* SwitchClauseStatements */:
        return !(token() === 27 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement();
      case 2 /* SwitchClauses */:
        return token() === 84 /* CaseKeyword */ || token() === 90 /* DefaultKeyword */;
      case 4 /* TypeMembers */:
        return lookAhead(isTypeMemberStart);
      case 5 /* ClassMembers */:
        return lookAhead(isClassMemberStart) || token() === 27 /* SemicolonToken */ && !inErrorRecovery;
      case 6 /* EnumMembers */:
        return token() === 23 /* OpenBracketToken */ || isLiteralPropertyName();
      case 12 /* ObjectLiteralMembers */:
        switch (token()) {
          case 23 /* OpenBracketToken */:
          case 42 /* AsteriskToken */:
          case 26 /* DotDotDotToken */:
          case 25 /* DotToken */:
            return true;
          default:
            return isLiteralPropertyName();
        }
      case 18 /* RestProperties */:
        return isLiteralPropertyName();
      case 9 /* ObjectBindingElements */:
        return token() === 23 /* OpenBracketToken */ || token() === 26 /* DotDotDotToken */ || isLiteralPropertyName();
      case 24 /* ImportAttributes */:
        return isImportAttributeName2();
      case 7 /* HeritageClauseElement */:
        if (token() === 19 /* OpenBraceToken */) {
          return lookAhead(isValidHeritageClauseObjectLiteral);
        }
        if (!inErrorRecovery) {
          return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword();
        } else {
          return isIdentifier2() && !isHeritageClauseExtendsOrImplementsKeyword();
        }
      case 8 /* VariableDeclarations */:
        return isBindingIdentifierOrPrivateIdentifierOrPattern();
      case 10 /* ArrayBindingElements */:
        return token() === 28 /* CommaToken */ || token() === 26 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern();
      case 19 /* TypeParameters */:
        return token() === 103 /* InKeyword */ || token() === 87 /* ConstKeyword */ || isIdentifier2();
      case 15 /* ArrayLiteralMembers */:
        switch (token()) {
          case 28 /* CommaToken */:
          case 25 /* DotToken */:
            return true;
        }
      // falls through
      case 11 /* ArgumentExpressions */:
        return token() === 26 /* DotDotDotToken */ || isStartOfExpression();
      case 16 /* Parameters */:
        return isStartOfParameter(
          /*isJSDocParameter*/
          false
        );
      case 17 /* JSDocParameters */:
        return isStartOfParameter(
          /*isJSDocParameter*/
          true
        );
      case 20 /* TypeArguments */:
      case 21 /* TupleElementTypes */:
        return token() === 28 /* CommaToken */ || isStartOfType();
      case 22 /* HeritageClauses */:
        return isHeritageClause2();
      case 23 /* ImportOrExportSpecifiers */:
        if (token() === 161 /* FromKeyword */ && lookAhead(nextTokenIsStringLiteral)) {
          return false;
        }
        if (token() === 11 /* StringLiteral */) {
          return true;
        }
        return tokenIsIdentifierOrKeyword(token());
      case 13 /* JsxAttributes */:
        return tokenIsIdentifierOrKeyword(token()) || token() === 19 /* OpenBraceToken */;
      case 14 /* JsxChildren */:
        return true;
      case 25 /* JSDocComment */:
        return true;
      case 26 /* Count */:
        return Debug.fail("ParsingContext.Count used as a context");
      // Not a real context, only a marker.
      default:
        Debug.assertNever(parsingContext2, "Non-exhaustive case in 'isListElement'.");
    }
  }
  function isValidHeritageClauseObjectLiteral() {
    Debug.assert(token() === 19 /* OpenBraceToken */);
    if (nextToken() === 20 /* CloseBraceToken */) {
      const next = nextToken();
      return next === 28 /* CommaToken */ || next === 19 /* OpenBraceToken */ || next === 96 /* ExtendsKeyword */ || next === 119 /* ImplementsKeyword */;
    }
    return true;
  }
  function nextTokenIsIdentifier() {
    nextToken();
    return isIdentifier2();
  }
  function nextTokenIsIdentifierOrKeyword() {
    nextToken();
    return tokenIsIdentifierOrKeyword(token());
  }
  function nextTokenIsIdentifierOrKeywordOrGreaterThan() {
    nextToken();
    return tokenIsIdentifierOrKeywordOrGreaterThan(token());
  }
  function isHeritageClauseExtendsOrImplementsKeyword() {
    if (token() === 119 /* ImplementsKeyword */ || token() === 96 /* ExtendsKeyword */) {
      return lookAhead(nextTokenIsStartOfExpression);
    }
    return false;
  }
  function nextTokenIsStartOfExpression() {
    nextToken();
    return isStartOfExpression();
  }
  function nextTokenIsStartOfType() {
    nextToken();
    return isStartOfType();
  }
  function isListTerminator(kind) {
    if (token() === 1 /* EndOfFileToken */) {
      return true;
    }
    switch (kind) {
      case 1 /* BlockStatements */:
      case 2 /* SwitchClauses */:
      case 4 /* TypeMembers */:
      case 5 /* ClassMembers */:
      case 6 /* EnumMembers */:
      case 12 /* ObjectLiteralMembers */:
      case 9 /* ObjectBindingElements */:
      case 23 /* ImportOrExportSpecifiers */:
      case 24 /* ImportAttributes */:
        return token() === 20 /* CloseBraceToken */;
      case 3 /* SwitchClauseStatements */:
        return token() === 20 /* CloseBraceToken */ || token() === 84 /* CaseKeyword */ || token() === 90 /* DefaultKeyword */;
      case 7 /* HeritageClauseElement */:
        return token() === 19 /* OpenBraceToken */ || token() === 96 /* ExtendsKeyword */ || token() === 119 /* ImplementsKeyword */;
      case 8 /* VariableDeclarations */:
        return isVariableDeclaratorListTerminator();
      case 19 /* TypeParameters */:
        return token() === 32 /* GreaterThanToken */ || token() === 21 /* OpenParenToken */ || token() === 19 /* OpenBraceToken */ || token() === 96 /* ExtendsKeyword */ || token() === 119 /* ImplementsKeyword */;
      case 11 /* ArgumentExpressions */:
        return token() === 22 /* CloseParenToken */ || token() === 27 /* SemicolonToken */;
      case 15 /* ArrayLiteralMembers */:
      case 21 /* TupleElementTypes */:
      case 10 /* ArrayBindingElements */:
        return token() === 24 /* CloseBracketToken */;
      case 17 /* JSDocParameters */:
      case 16 /* Parameters */:
      case 18 /* RestProperties */:
        return token() === 22 /* CloseParenToken */ || token() === 24 /* CloseBracketToken */;
      case 20 /* TypeArguments */:
        return token() !== 28 /* CommaToken */;
      case 22 /* HeritageClauses */:
        return token() === 19 /* OpenBraceToken */ || token() === 20 /* CloseBraceToken */;
      case 13 /* JsxAttributes */:
        return token() === 32 /* GreaterThanToken */ || token() === 44 /* SlashToken */;
      case 14 /* JsxChildren */:
        return token() === 30 /* LessThanToken */ && lookAhead(nextTokenIsSlash);
      default:
        return false;
    }
  }
  function isVariableDeclaratorListTerminator() {
    if (canParseSemicolon()) {
      return true;
    }
    if (isInOrOfKeyword(token())) {
      return true;
    }
    if (token() === 39 /* EqualsGreaterThanToken */) {
      return true;
    }
    return false;
  }
  function isInSomeParsingContext() {
    Debug.assert(parsingContext, "Missing parsing context");
    for (let kind = 0; kind < 26 /* Count */; kind++) {
      if (parsingContext & 1 << kind) {
        if (isListElement2(
          kind,
          /*inErrorRecovery*/
          true
        ) || isListTerminator(kind)) {
          return true;
        }
      }
    }
    return false;
  }
  function parseList(kind, parseElement) {
    const saveParsingContext = parsingContext;
    parsingContext |= 1 << kind;
    const list = [];
    const listPos = getNodePos();
    while (!isListTerminator(kind)) {
      if (isListElement2(
        kind,
        /*inErrorRecovery*/
        false
      )) {
        list.push(parseListElement(kind, parseElement));
        continue;
      }
      if (abortParsingListOrMoveToNextToken(kind)) {
        break;
      }
    }
    parsingContext = saveParsingContext;
    return createNodeArray(list, listPos);
  }
  function parseListElement(parsingContext2, parseElement) {
    const node = currentNode(parsingContext2);
    if (node) {
      return consumeNode(node);
    }
    return parseElement();
  }
  function currentNode(parsingContext2, pos) {
    var _a;
    if (!syntaxCursor || !isReusableParsingContext(parsingContext2) || parseErrorBeforeNextFinishedNode) {
      return void 0;
    }
    const node = syntaxCursor.currentNode(pos ?? scanner2.getTokenFullStart());
    if (nodeIsMissing(node) || intersectsIncrementalChange(node) || containsParseError(node)) {
      return void 0;
    }
    const nodeContextFlags = node.flags & 101441536 /* ContextFlags */;
    if (nodeContextFlags !== contextFlags) {
      return void 0;
    }
    if (!canReuseNode(node, parsingContext2)) {
      return void 0;
    }
    if (canHaveJSDoc(node) && ((_a = node.jsDoc) == null ? void 0 : _a.jsDocCache)) {
      node.jsDoc.jsDocCache = void 0;
    }
    return node;
  }
  function consumeNode(node) {
    scanner2.resetTokenState(node.end);
    nextToken();
    return node;
  }
  function isReusableParsingContext(parsingContext2) {
    switch (parsingContext2) {
      case 5 /* ClassMembers */:
      case 2 /* SwitchClauses */:
      case 0 /* SourceElements */:
      case 1 /* BlockStatements */:
      case 3 /* SwitchClauseStatements */:
      case 6 /* EnumMembers */:
      case 4 /* TypeMembers */:
      case 8 /* VariableDeclarations */:
      case 17 /* JSDocParameters */:
      case 16 /* Parameters */:
        return true;
    }
    return false;
  }
  function canReuseNode(node, parsingContext2) {
    switch (parsingContext2) {
      case 5 /* ClassMembers */:
        return isReusableClassMember(node);
      case 2 /* SwitchClauses */:
        return isReusableSwitchClause(node);
      case 0 /* SourceElements */:
      case 1 /* BlockStatements */:
      case 3 /* SwitchClauseStatements */:
        return isReusableStatement(node);
      case 6 /* EnumMembers */:
        return isReusableEnumMember(node);
      case 4 /* TypeMembers */:
        return isReusableTypeMember(node);
      case 8 /* VariableDeclarations */:
        return isReusableVariableDeclaration(node);
      case 17 /* JSDocParameters */:
      case 16 /* Parameters */:
        return isReusableParameter(node);
    }
    return false;
  }
  function isReusableClassMember(node) {
    if (node) {
      switch (node.kind) {
        case 176 /* Constructor */:
        case 181 /* IndexSignature */:
        case 177 /* GetAccessor */:
        case 178 /* SetAccessor */:
        case 172 /* PropertyDeclaration */:
        case 240 /* SemicolonClassElement */:
          return true;
        case 174 /* MethodDeclaration */:
          const methodDeclaration = node;
          const nameIsConstructor = methodDeclaration.name.kind === 80 /* Identifier */ && methodDeclaration.name.escapedText === "constructor";
          return !nameIsConstructor;
      }
    }
    return false;
  }
  function isReusableSwitchClause(node) {
    if (node) {
      switch (node.kind) {
        case 296 /* CaseClause */:
        case 297 /* DefaultClause */:
          return true;
      }
    }
    return false;
  }
  function isReusableStatement(node) {
    if (node) {
      switch (node.kind) {
        case 262 /* FunctionDeclaration */:
        case 243 /* VariableStatement */:
        case 241 /* Block */:
        case 245 /* IfStatement */:
        case 244 /* ExpressionStatement */:
        case 257 /* ThrowStatement */:
        case 253 /* ReturnStatement */:
        case 255 /* SwitchStatement */:
        case 252 /* BreakStatement */:
        case 251 /* ContinueStatement */:
        case 249 /* ForInStatement */:
        case 250 /* ForOfStatement */:
        case 248 /* ForStatement */:
        case 247 /* WhileStatement */:
        case 254 /* WithStatement */:
        case 242 /* EmptyStatement */:
        case 258 /* TryStatement */:
        case 256 /* LabeledStatement */:
        case 246 /* DoStatement */:
        case 259 /* DebuggerStatement */:
        case 272 /* ImportDeclaration */:
        case 271 /* ImportEqualsDeclaration */:
        case 278 /* ExportDeclaration */:
        case 277 /* ExportAssignment */:
        case 267 /* ModuleDeclaration */:
        case 263 /* ClassDeclaration */:
        case 264 /* InterfaceDeclaration */:
        case 266 /* EnumDeclaration */:
        case 265 /* TypeAliasDeclaration */:
          return true;
      }
    }
    return false;
  }
  function isReusableEnumMember(node) {
    return node.kind === 306 /* EnumMember */;
  }
  function isReusableTypeMember(node) {
    if (node) {
      switch (node.kind) {
        case 180 /* ConstructSignature */:
        case 173 /* MethodSignature */:
        case 181 /* IndexSignature */:
        case 171 /* PropertySignature */:
        case 179 /* CallSignature */:
          return true;
      }
    }
    return false;
  }
  function isReusableVariableDeclaration(node) {
    if (node.kind !== 260 /* VariableDeclaration */) {
      return false;
    }
    const variableDeclarator = node;
    return variableDeclarator.initializer === void 0;
  }
  function isReusableParameter(node) {
    if (node.kind !== 169 /* Parameter */) {
      return false;
    }
    const parameter = node;
    return parameter.initializer === void 0;
  }
  function abortParsingListOrMoveToNextToken(kind) {
    parsingContextErrors(kind);
    if (isInSomeParsingContext()) {
      return true;
    }
    nextToken();
    return false;
  }
  function parsingContextErrors(context) {
    switch (context) {
      case 0 /* SourceElements */:
        return token() === 90 /* DefaultKeyword */ ? parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(95 /* ExportKeyword */)) : parseErrorAtCurrentToken(Diagnostics.Declaration_or_statement_expected);
      case 1 /* BlockStatements */:
        return parseErrorAtCurrentToken(Diagnostics.Declaration_or_statement_expected);
      case 2 /* SwitchClauses */:
        return parseErrorAtCurrentToken(Diagnostics.case_or_default_expected);
      case 3 /* SwitchClauseStatements */:
        return parseErrorAtCurrentToken(Diagnostics.Statement_expected);
      case 18 /* RestProperties */:
      // fallthrough
      case 4 /* TypeMembers */:
        return parseErrorAtCurrentToken(Diagnostics.Property_or_signature_expected);
      case 5 /* ClassMembers */:
        return parseErrorAtCurrentToken(Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected);
      case 6 /* EnumMembers */:
        return parseErrorAtCurrentToken(Diagnostics.Enum_member_expected);
      case 7 /* HeritageClauseElement */:
        return parseErrorAtCurrentToken(Diagnostics.Expression_expected);
      case 8 /* VariableDeclarations */:
        return isKeyword(token()) ? parseErrorAtCurrentToken(Diagnostics._0_is_not_allowed_as_a_variable_declaration_name, tokenToString(token())) : parseErrorAtCurrentToken(Diagnostics.Variable_declaration_expected);
      case 9 /* ObjectBindingElements */:
        return parseErrorAtCurrentToken(Diagnostics.Property_destructuring_pattern_expected);
      case 10 /* ArrayBindingElements */:
        return parseErrorAtCurrentToken(Diagnostics.Array_element_destructuring_pattern_expected);
      case 11 /* ArgumentExpressions */:
        return parseErrorAtCurrentToken(Diagnostics.Argument_expression_expected);
      case 12 /* ObjectLiteralMembers */:
        return parseErrorAtCurrentToken(Diagnostics.Property_assignment_expected);
      case 15 /* ArrayLiteralMembers */:
        return parseErrorAtCurrentToken(Diagnostics.Expression_or_comma_expected);
      case 17 /* JSDocParameters */:
        return parseErrorAtCurrentToken(Diagnostics.Parameter_declaration_expected);
      case 16 /* Parameters */:
        return isKeyword(token()) ? parseErrorAtCurrentToken(Diagnostics._0_is_not_allowed_as_a_parameter_name, tokenToString(token())) : parseErrorAtCurrentToken(Diagnostics.Parameter_declaration_expected);
      case 19 /* TypeParameters */:
        return parseErrorAtCurrentToken(Diagnostics.Type_parameter_declaration_expected);
      case 20 /* TypeArguments */:
        return parseErrorAtCurrentToken(Diagnostics.Type_argument_expected);
      case 21 /* TupleElementTypes */:
        return parseErrorAtCurrentToken(Diagnostics.Type_expected);
      case 22 /* HeritageClauses */:
        return parseErrorAtCurrentToken(Diagnostics.Unexpected_token_expected);
      case 23 /* ImportOrExportSpecifiers */:
        if (token() === 161 /* FromKeyword */) {
          return parseErrorAtCurrentToken(Diagnostics._0_expected, "}");
        }
        return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
      case 13 /* JsxAttributes */:
        return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
      case 14 /* JsxChildren */:
        return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
      case 24 /* ImportAttributes */:
        return parseErrorAtCurrentToken(Diagnostics.Identifier_or_string_literal_expected);
      case 25 /* JSDocComment */:
        return parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
      case 26 /* Count */:
        return Debug.fail("ParsingContext.Count used as a context");
      // Not a real context, only a marker.
      default:
        Debug.assertNever(context);
    }
  }
  function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
    const saveParsingContext = parsingContext;
    parsingContext |= 1 << kind;
    const list = [];
    const listPos = getNodePos();
    let commaStart = -1;
    while (true) {
      if (isListElement2(
        kind,
        /*inErrorRecovery*/
        false
      )) {
        const startPos = scanner2.getTokenFullStart();
        const result = parseListElement(kind, parseElement);
        if (!result) {
          parsingContext = saveParsingContext;
          return void 0;
        }
        list.push(result);
        commaStart = scanner2.getTokenStart();
        if (parseOptional(28 /* CommaToken */)) {
          continue;
        }
        commaStart = -1;
        if (isListTerminator(kind)) {
          break;
        }
        parseExpected(28 /* CommaToken */, getExpectedCommaDiagnostic(kind));
        if (considerSemicolonAsDelimiter && token() === 27 /* SemicolonToken */ && !scanner2.hasPrecedingLineBreak()) {
          nextToken();
        }
        if (startPos === scanner2.getTokenFullStart()) {
          nextToken();
        }
        continue;
      }
      if (isListTerminator(kind)) {
        break;
      }
      if (abortParsingListOrMoveToNextToken(kind)) {
        break;
      }
    }
    parsingContext = saveParsingContext;
    return createNodeArray(
      list,
      listPos,
      /*end*/
      void 0,
      commaStart >= 0
    );
  }
  function getExpectedCommaDiagnostic(kind) {
    return kind === 6 /* EnumMembers */ ? Diagnostics.An_enum_member_name_must_be_followed_by_a_or : void 0;
  }
  function createMissingList() {
    const list = createNodeArray([], getNodePos());
    list.isMissingList = true;
    return list;
  }
  function isMissingList(arr) {
    return !!arr.isMissingList;
  }
  function parseBracketedList(kind, parseElement, open, close) {
    if (parseExpected(open)) {
      const result = parseDelimitedList(kind, parseElement);
      parseExpected(close);
      return result;
    }
    return createMissingList();
  }
  function parseEntityName(allowReservedWords, diagnosticMessage) {
    const pos = getNodePos();
    let entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
    while (parseOptional(25 /* DotToken */)) {
      if (token() === 30 /* LessThanToken */) {
        break;
      }
      entity = finishNode(
        factory2.createQualifiedName(
          entity,
          parseRightSideOfDot(
            allowReservedWords,
            /*allowPrivateIdentifiers*/
            false,
            /*allowUnicodeEscapeSequenceInIdentifierName*/
            true
          )
        ),
        pos
      );
    }
    return entity;
  }
  function createQualifiedName(entity, name) {
    return finishNode(factory2.createQualifiedName(entity, name), entity.pos);
  }
  function parseRightSideOfDot(allowIdentifierNames, allowPrivateIdentifiers, allowUnicodeEscapeSequenceInIdentifierName) {
    if (scanner2.hasPrecedingLineBreak() && tokenIsIdentifierOrKeyword(token())) {
      const matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
      if (matchesPattern) {
        return createMissingNode(
          80 /* Identifier */,
          /*reportAtCurrentPosition*/
          true,
          Diagnostics.Identifier_expected
        );
      }
    }
    if (token() === 81 /* PrivateIdentifier */) {
      const node = parsePrivateIdentifier();
      return allowPrivateIdentifiers ? node : createMissingNode(
        80 /* Identifier */,
        /*reportAtCurrentPosition*/
        true,
        Diagnostics.Identifier_expected
      );
    }
    if (allowIdentifierNames) {
      return allowUnicodeEscapeSequenceInIdentifierName ? parseIdentifierName() : parseIdentifierNameErrorOnUnicodeEscapeSequence();
    }
    return parseIdentifier();
  }
  function parseTemplateSpans(isTaggedTemplate) {
    const pos = getNodePos();
    const list = [];
    let node;
    do {
      node = parseTemplateSpan(isTaggedTemplate);
      list.push(node);
    } while (node.literal.kind === 17 /* TemplateMiddle */);
    return createNodeArray(list, pos);
  }
  function parseTemplateExpression(isTaggedTemplate) {
    const pos = getNodePos();
    return finishNode(
      factory2.createTemplateExpression(
        parseTemplateHead(isTaggedTemplate),
        parseTemplateSpans(isTaggedTemplate)
      ),
      pos
    );
  }
  function parseTemplateType() {
    const pos = getNodePos();
    return finishNode(
      factory2.createTemplateLiteralType(
        parseTemplateHead(
          /*isTaggedTemplate*/
          false
        ),
        parseTemplateTypeSpans()
      ),
      pos
    );
  }
  function parseTemplateTypeSpans() {
    const pos = getNodePos();
    const list = [];
    let node;
    do {
      node = parseTemplateTypeSpan();
      list.push(node);
    } while (node.literal.kind === 17 /* TemplateMiddle */);
    return createNodeArray(list, pos);
  }
  function parseTemplateTypeSpan() {
    const pos = getNodePos();
    return finishNode(
      factory2.createTemplateLiteralTypeSpan(
        parseType(),
        parseLiteralOfTemplateSpan(
          /*isTaggedTemplate*/
          false
        )
      ),
      pos
    );
  }
  function parseLiteralOfTemplateSpan(isTaggedTemplate) {
    if (token() === 20 /* CloseBraceToken */) {
      reScanTemplateToken(isTaggedTemplate);
      return parseTemplateMiddleOrTemplateTail();
    } else {
      return parseExpectedToken(18 /* TemplateTail */, Diagnostics._0_expected, tokenToString(20 /* CloseBraceToken */));
    }
  }
  function parseTemplateSpan(isTaggedTemplate) {
    const pos = getNodePos();
    return finishNode(
      factory2.createTemplateSpan(
        allowInAnd(parseExpression),
        parseLiteralOfTemplateSpan(isTaggedTemplate)
      ),
      pos
    );
  }
  function parseLiteralNode() {
    return parseLiteralLikeNode(token());
  }
  function parseTemplateHead(isTaggedTemplate) {
    if (!isTaggedTemplate && scanner2.getTokenFlags() & 26656 /* IsInvalid */) {
      reScanTemplateToken(
        /*isTaggedTemplate*/
        false
      );
    }
    const fragment = parseLiteralLikeNode(token());
    Debug.assert(fragment.kind === 16 /* TemplateHead */, "Template head has wrong token kind");
    return fragment;
  }
  function parseTemplateMiddleOrTemplateTail() {
    const fragment = parseLiteralLikeNode(token());
    Debug.assert(fragment.kind === 17 /* TemplateMiddle */ || fragment.kind === 18 /* TemplateTail */, "Template fragment has wrong token kind");
    return fragment;
  }
  function getTemplateLiteralRawText(kind) {
    const isLast = kind === 15 /* NoSubstitutionTemplateLiteral */ || kind === 18 /* TemplateTail */;
    const tokenText = scanner2.getTokenText();
    return tokenText.substring(1, tokenText.length - (scanner2.isUnterminated() ? 0 : isLast ? 1 : 2));
  }
  function parseLiteralLikeNode(kind) {
    const pos = getNodePos();
    const node = isTemplateLiteralKind(kind) ? factory2.createTemplateLiteralLikeNode(kind, scanner2.getTokenValue(), getTemplateLiteralRawText(kind), scanner2.getTokenFlags() & 7176 /* TemplateLiteralLikeFlags */) : (
      // Note that theoretically the following condition would hold true literals like 009,
      // which is not octal. But because of how the scanner separates the tokens, we would
      // never get a token like this. Instead, we would get 00 and 9 as two separate tokens.
      // We also do not need to check for negatives because any prefix operator would be part of a
      // parent unary expression.
      kind === 9 /* NumericLiteral */ ? factoryCreateNumericLiteral(scanner2.getTokenValue(), scanner2.getNumericLiteralFlags()) : kind === 11 /* StringLiteral */ ? factoryCreateStringLiteral(
        scanner2.getTokenValue(),
        /*isSingleQuote*/
        void 0,
        scanner2.hasExtendedUnicodeEscape()
      ) : isLiteralKind(kind) ? factoryCreateLiteralLikeNode(kind, scanner2.getTokenValue()) : Debug.fail()
    );
    if (scanner2.hasExtendedUnicodeEscape()) {
      node.hasExtendedUnicodeEscape = true;
    }
    if (scanner2.isUnterminated()) {
      node.isUnterminated = true;
    }
    nextToken();
    return finishNode(node, pos);
  }
  function parseEntityNameOfTypeReference() {
    return parseEntityName(
      /*allowReservedWords*/
      true,
      Diagnostics.Type_expected
    );
  }
  function parseTypeArgumentsOfTypeReference() {
    if (!scanner2.hasPrecedingLineBreak() && reScanLessThanToken() === 30 /* LessThanToken */) {
      return parseBracketedList(20 /* TypeArguments */, parseType, 30 /* LessThanToken */, 32 /* GreaterThanToken */);
    }
  }
  function parseTypeReference() {
    const pos = getNodePos();
    return finishNode(
      factory2.createTypeReferenceNode(
        parseEntityNameOfTypeReference(),
        parseTypeArgumentsOfTypeReference()
      ),
      pos
    );
  }
  function typeHasArrowFunctionBlockingParseError(node) {
    switch (node.kind) {
      case 183 /* TypeReference */:
        return nodeIsMissing(node.typeName);
      case 184 /* FunctionType */:
      case 185 /* ConstructorType */: {
        const { parameters, type } = node;
        return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type);
      }
      case 196 /* ParenthesizedType */:
        return typeHasArrowFunctionBlockingParseError(node.type);
      default:
        return false;
    }
  }
  function parseThisTypePredicate(lhs) {
    nextToken();
    return finishNode(factory2.createTypePredicateNode(
      /*assertsModifier*/
      void 0,
      lhs,
      parseType()
    ), lhs.pos);
  }
  function parseThisTypeNode() {
    const pos = getNodePos();
    nextToken();
    return finishNode(factory2.createThisTypeNode(), pos);
  }
  function parseJSDocAllType() {
    const pos = getNodePos();
    nextToken();
    return finishNode(factory2.createJSDocAllType(), pos);
  }
  function parseJSDocNonNullableType() {
    const pos = getNodePos();
    nextToken();
    return finishNode(factory2.createJSDocNonNullableType(
      parseNonArrayType(),
      /*postfix*/
      false
    ), pos);
  }
  function parseJSDocUnknownOrNullableType() {
    const pos = getNodePos();
    nextToken();
    if (token() === 28 /* CommaToken */ || token() === 20 /* CloseBraceToken */ || token() === 22 /* CloseParenToken */ || token() === 32 /* GreaterThanToken */ || token() === 64 /* EqualsToken */ || token() === 52 /* BarToken */) {
      return finishNode(factory2.createJSDocUnknownType(), pos);
    } else {
      return finishNode(factory2.createJSDocNullableType(
        parseType(),
        /*postfix*/
        false
      ), pos);
    }
  }
  function parseJSDocFunctionType() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    if (tryParse(nextTokenIsOpenParen)) {
      const parameters = parseParameters(4 /* Type */ | 32 /* JSDoc */);
      const type = parseReturnType(
        59 /* ColonToken */,
        /*isType*/
        false
      );
      return withJSDoc(finishNode(factory2.createJSDocFunctionType(parameters, type), pos), hasJSDoc);
    }
    return finishNode(factory2.createTypeReferenceNode(
      parseIdentifierName(),
      /*typeArguments*/
      void 0
    ), pos);
  }
  function parseJSDocParameter() {
    const pos = getNodePos();
    let name;
    if (token() === 110 /* ThisKeyword */ || token() === 105 /* NewKeyword */) {
      name = parseIdentifierName();
      parseExpected(59 /* ColonToken */);
    }
    return finishNode(
      factory2.createParameterDeclaration(
        /*modifiers*/
        void 0,
        /*dotDotDotToken*/
        void 0,
        // TODO(rbuckton): JSDoc parameters don't have names (except `this`/`new`), should we manufacture an empty identifier?
        name,
        /*questionToken*/
        void 0,
        parseJSDocType(),
        /*initializer*/
        void 0
      ),
      pos
    );
  }
  function parseJSDocType() {
    scanner2.setSkipJsDocLeadingAsterisks(true);
    const pos = getNodePos();
    if (parseOptional(144 /* ModuleKeyword */)) {
      const moduleTag = factory2.createJSDocNamepathType(
        /*type*/
        void 0
      );
      terminate:
        while (true) {
          switch (token()) {
            case 20 /* CloseBraceToken */:
            case 1 /* EndOfFileToken */:
            case 28 /* CommaToken */:
            case 5 /* WhitespaceTrivia */:
              break terminate;
            default:
              nextTokenJSDoc();
          }
        }
      scanner2.setSkipJsDocLeadingAsterisks(false);
      return finishNode(moduleTag, pos);
    }
    const hasDotDotDot = parseOptional(26 /* DotDotDotToken */);
    let type = parseTypeOrTypePredicate();
    scanner2.setSkipJsDocLeadingAsterisks(false);
    if (hasDotDotDot) {
      type = finishNode(factory2.createJSDocVariadicType(type), pos);
    }
    if (token() === 64 /* EqualsToken */) {
      nextToken();
      return finishNode(factory2.createJSDocOptionalType(type), pos);
    }
    return type;
  }
  function parseTypeQuery() {
    const pos = getNodePos();
    parseExpected(114 /* TypeOfKeyword */);
    const entityName = parseEntityName(
      /*allowReservedWords*/
      true
    );
    const typeArguments = !scanner2.hasPrecedingLineBreak() ? tryParseTypeArguments() : void 0;
    return finishNode(factory2.createTypeQueryNode(entityName, typeArguments), pos);
  }
  function parseTypeParameter() {
    const pos = getNodePos();
    const modifiers = parseModifiers(
      /*allowDecorators*/
      false,
      /*permitConstAsModifier*/
      true
    );
    const name = parseIdentifier();
    let constraint;
    let expression;
    if (parseOptional(96 /* ExtendsKeyword */)) {
      if (isStartOfType() || !isStartOfExpression()) {
        constraint = parseType();
      } else {
        expression = parseUnaryExpressionOrHigher();
      }
    }
    const defaultType = parseOptional(64 /* EqualsToken */) ? parseType() : void 0;
    const node = factory2.createTypeParameterDeclaration(modifiers, name, constraint, defaultType);
    node.expression = expression;
    return finishNode(node, pos);
  }
  function parseTypeParameters() {
    if (token() === 30 /* LessThanToken */) {
      return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 30 /* LessThanToken */, 32 /* GreaterThanToken */);
    }
  }
  function isStartOfParameter(isJSDocParameter) {
    return token() === 26 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern() || isModifierKind(token()) || token() === 60 /* AtToken */ || isStartOfType(
      /*inStartOfParameter*/
      !isJSDocParameter
    );
  }
  function parseNameOfParameter(modifiers) {
    const name = parseIdentifierOrPattern(Diagnostics.Private_identifiers_cannot_be_used_as_parameters);
    if (getFullWidth(name) === 0 && !some(modifiers) && isModifierKind(token())) {
      nextToken();
    }
    return name;
  }
  function isParameterNameStart() {
    return isBindingIdentifier() || token() === 23 /* OpenBracketToken */ || token() === 19 /* OpenBraceToken */;
  }
  function parseParameter(inOuterAwaitContext) {
    return parseParameterWorker(inOuterAwaitContext);
  }
  function parseParameterForSpeculation(inOuterAwaitContext) {
    return parseParameterWorker(
      inOuterAwaitContext,
      /*allowAmbiguity*/
      false
    );
  }
  function parseParameterWorker(inOuterAwaitContext, allowAmbiguity = true) {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    const modifiers = inOuterAwaitContext ? doInAwaitContext(() => parseModifiers(
      /*allowDecorators*/
      true
    )) : doOutsideOfAwaitContext(() => parseModifiers(
      /*allowDecorators*/
      true
    ));
    if (token() === 110 /* ThisKeyword */) {
      const node2 = factory2.createParameterDeclaration(
        modifiers,
        /*dotDotDotToken*/
        void 0,
        createIdentifier(
          /*isIdentifier*/
          true
        ),
        /*questionToken*/
        void 0,
        parseTypeAnnotation(),
        /*initializer*/
        void 0
      );
      const modifier = firstOrUndefined(modifiers);
      if (modifier) {
        parseErrorAtRange(modifier, Diagnostics.Neither_decorators_nor_modifiers_may_be_applied_to_this_parameters);
      }
      return withJSDoc(finishNode(node2, pos), hasJSDoc);
    }
    const savedTopLevel = topLevel;
    topLevel = false;
    const dotDotDotToken = parseOptionalToken(26 /* DotDotDotToken */);
    if (!allowAmbiguity && !isParameterNameStart()) {
      return void 0;
    }
    const node = withJSDoc(
      finishNode(
        factory2.createParameterDeclaration(
          modifiers,
          dotDotDotToken,
          parseNameOfParameter(modifiers),
          parseOptionalToken(58 /* QuestionToken */),
          parseTypeAnnotation(),
          parseInitializer()
        ),
        pos
      ),
      hasJSDoc
    );
    topLevel = savedTopLevel;
    return node;
  }
  function parseReturnType(returnToken, isType) {
    if (shouldParseReturnType(returnToken, isType)) {
      return allowConditionalTypesAnd(parseTypeOrTypePredicate);
    }
  }
  function shouldParseReturnType(returnToken, isType) {
    if (returnToken === 39 /* EqualsGreaterThanToken */) {
      parseExpected(returnToken);
      return true;
    } else if (parseOptional(59 /* ColonToken */)) {
      return true;
    } else if (isType && token() === 39 /* EqualsGreaterThanToken */) {
      parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(59 /* ColonToken */));
      nextToken();
      return true;
    }
    return false;
  }
  function parseParametersWorker(flags, allowAmbiguity) {
    const savedYieldContext = inYieldContext();
    const savedAwaitContext = inAwaitContext();
    setYieldContext(!!(flags & 1 /* Yield */));
    setAwaitContext(!!(flags & 2 /* Await */));
    const parameters = flags & 32 /* JSDoc */ ? parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) : parseDelimitedList(16 /* Parameters */, () => allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext));
    setYieldContext(savedYieldContext);
    setAwaitContext(savedAwaitContext);
    return parameters;
  }
  function parseParameters(flags) {
    if (!parseExpected(21 /* OpenParenToken */)) {
      return createMissingList();
    }
    const parameters = parseParametersWorker(
      flags,
      /*allowAmbiguity*/
      true
    );
    parseExpected(22 /* CloseParenToken */);
    return parameters;
  }
  function parseTypeMemberSemicolon() {
    if (parseOptional(28 /* CommaToken */)) {
      return;
    }
    parseSemicolon();
  }
  function parseSignatureMember(kind) {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    if (kind === 180 /* ConstructSignature */) {
      parseExpected(105 /* NewKeyword */);
    }
    const typeParameters = parseTypeParameters();
    const parameters = parseParameters(4 /* Type */);
    const type = parseReturnType(
      59 /* ColonToken */,
      /*isType*/
      true
    );
    parseTypeMemberSemicolon();
    const node = kind === 179 /* CallSignature */ ? factory2.createCallSignature(typeParameters, parameters, type) : factory2.createConstructSignature(typeParameters, parameters, type);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function isIndexSignature() {
    return token() === 23 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature);
  }
  function isUnambiguouslyIndexSignature() {
    nextToken();
    if (token() === 26 /* DotDotDotToken */ || token() === 24 /* CloseBracketToken */) {
      return true;
    }
    if (isModifierKind(token())) {
      nextToken();
      if (isIdentifier2()) {
        return true;
      }
    } else if (!isIdentifier2()) {
      return false;
    } else {
      nextToken();
    }
    if (token() === 59 /* ColonToken */ || token() === 28 /* CommaToken */) {
      return true;
    }
    if (token() !== 58 /* QuestionToken */) {
      return false;
    }
    nextToken();
    return token() === 59 /* ColonToken */ || token() === 28 /* CommaToken */ || token() === 24 /* CloseBracketToken */;
  }
  function parseIndexSignatureDeclaration(pos, hasJSDoc, modifiers) {
    const parameters = parseBracketedList(16 /* Parameters */, () => parseParameter(
      /*inOuterAwaitContext*/
      false
    ), 23 /* OpenBracketToken */, 24 /* CloseBracketToken */);
    const type = parseTypeAnnotation();
    parseTypeMemberSemicolon();
    const node = factory2.createIndexSignature(modifiers, parameters, type);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers) {
    const name = parsePropertyName();
    const questionToken = parseOptionalToken(58 /* QuestionToken */);
    let node;
    if (token() === 21 /* OpenParenToken */ || token() === 30 /* LessThanToken */) {
      const typeParameters = parseTypeParameters();
      const parameters = parseParameters(4 /* Type */);
      const type = parseReturnType(
        59 /* ColonToken */,
        /*isType*/
        true
      );
      node = factory2.createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type);
    } else {
      const type = parseTypeAnnotation();
      node = factory2.createPropertySignature(modifiers, name, questionToken, type);
      if (token() === 64 /* EqualsToken */) node.initializer = parseInitializer();
    }
    parseTypeMemberSemicolon();
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function isTypeMemberStart() {
    if (token() === 21 /* OpenParenToken */ || token() === 30 /* LessThanToken */ || token() === 139 /* GetKeyword */ || token() === 153 /* SetKeyword */) {
      return true;
    }
    let idToken = false;
    while (isModifierKind(token())) {
      idToken = true;
      nextToken();
    }
    if (token() === 23 /* OpenBracketToken */) {
      return true;
    }
    if (isLiteralPropertyName()) {
      idToken = true;
      nextToken();
    }
    if (idToken) {
      return token() === 21 /* OpenParenToken */ || token() === 30 /* LessThanToken */ || token() === 58 /* QuestionToken */ || token() === 59 /* ColonToken */ || token() === 28 /* CommaToken */ || canParseSemicolon();
    }
    return false;
  }
  function parseTypeMember() {
    if (token() === 21 /* OpenParenToken */ || token() === 30 /* LessThanToken */) {
      return parseSignatureMember(179 /* CallSignature */);
    }
    if (token() === 105 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) {
      return parseSignatureMember(180 /* ConstructSignature */);
    }
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    const modifiers = parseModifiers(
      /*allowDecorators*/
      false
    );
    if (parseContextualModifier(139 /* GetKeyword */)) {
      return parseAccessorDeclaration(pos, hasJSDoc, modifiers, 177 /* GetAccessor */, 4 /* Type */);
    }
    if (parseContextualModifier(153 /* SetKeyword */)) {
      return parseAccessorDeclaration(pos, hasJSDoc, modifiers, 178 /* SetAccessor */, 4 /* Type */);
    }
    if (isIndexSignature()) {
      return parseIndexSignatureDeclaration(pos, hasJSDoc, modifiers);
    }
    return parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers);
  }
  function nextTokenIsOpenParenOrLessThan() {
    nextToken();
    return token() === 21 /* OpenParenToken */ || token() === 30 /* LessThanToken */;
  }
  function nextTokenIsDot() {
    return nextToken() === 25 /* DotToken */;
  }
  function nextTokenIsOpenParenOrLessThanOrDot() {
    switch (nextToken()) {
      case 21 /* OpenParenToken */:
      case 30 /* LessThanToken */:
      case 25 /* DotToken */:
        return true;
    }
    return false;
  }
  function parseTypeLiteral() {
    const pos = getNodePos();
    return finishNode(factory2.createTypeLiteralNode(parseObjectTypeMembers()), pos);
  }
  function parseObjectTypeMembers() {
    let members;
    if (parseExpected(19 /* OpenBraceToken */)) {
      members = parseList(4 /* TypeMembers */, parseTypeMember);
      parseExpected(20 /* CloseBraceToken */);
    } else {
      members = createMissingList();
    }
    return members;
  }
  function isStartOfMappedType() {
    nextToken();
    if (token() === 40 /* PlusToken */ || token() === 41 /* MinusToken */) {
      return nextToken() === 148 /* ReadonlyKeyword */;
    }
    if (token() === 148 /* ReadonlyKeyword */) {
      nextToken();
    }
    return token() === 23 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 103 /* InKeyword */;
  }
  function parseMappedTypeParameter() {
    const pos = getNodePos();
    const name = parseIdentifierName();
    parseExpected(103 /* InKeyword */);
    const type = parseType();
    return finishNode(factory2.createTypeParameterDeclaration(
      /*modifiers*/
      void 0,
      name,
      type,
      /*defaultType*/
      void 0
    ), pos);
  }
  function parseMappedType() {
    const pos = getNodePos();
    parseExpected(19 /* OpenBraceToken */);
    let readonlyToken;
    if (token() === 148 /* ReadonlyKeyword */ || token() === 40 /* PlusToken */ || token() === 41 /* MinusToken */) {
      readonlyToken = parseTokenNode();
      if (readonlyToken.kind !== 148 /* ReadonlyKeyword */) {
        parseExpected(148 /* ReadonlyKeyword */);
      }
    }
    parseExpected(23 /* OpenBracketToken */);
    const typeParameter = parseMappedTypeParameter();
    const nameType = parseOptional(130 /* AsKeyword */) ? parseType() : void 0;
    parseExpected(24 /* CloseBracketToken */);
    let questionToken;
    if (token() === 58 /* QuestionToken */ || token() === 40 /* PlusToken */ || token() === 41 /* MinusToken */) {
      questionToken = parseTokenNode();
      if (questionToken.kind !== 58 /* QuestionToken */) {
        parseExpected(58 /* QuestionToken */);
      }
    }
    const type = parseTypeAnnotation();
    parseSemicolon();
    const members = parseList(4 /* TypeMembers */, parseTypeMember);
    parseExpected(20 /* CloseBraceToken */);
    return finishNode(factory2.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos);
  }
  function parseTupleElementType() {
    const pos = getNodePos();
    if (parseOptional(26 /* DotDotDotToken */)) {
      return finishNode(factory2.createRestTypeNode(parseType()), pos);
    }
    const type = parseType();
    if (isJSDocNullableType(type) && type.pos === type.type.pos) {
      const node = factory2.createOptionalTypeNode(type.type);
      setTextRange(node, type);
      node.flags = type.flags;
      return node;
    }
    return type;
  }
  function isNextTokenColonOrQuestionColon() {
    return nextToken() === 59 /* ColonToken */ || token() === 58 /* QuestionToken */ && nextToken() === 59 /* ColonToken */;
  }
  function isTupleElementName() {
    if (token() === 26 /* DotDotDotToken */) {
      return tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon();
    }
    return tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon();
  }
  function parseTupleElementNameOrTupleElementType() {
    if (lookAhead(isTupleElementName)) {
      const pos = getNodePos();
      const hasJSDoc = hasPrecedingJSDocComment();
      const dotDotDotToken = parseOptionalToken(26 /* DotDotDotToken */);
      const name = parseIdentifierName();
      const questionToken = parseOptionalToken(58 /* QuestionToken */);
      parseExpected(59 /* ColonToken */);
      const type = parseTupleElementType();
      const node = factory2.createNamedTupleMember(dotDotDotToken, name, questionToken, type);
      return withJSDoc(finishNode(node, pos), hasJSDoc);
    }
    return parseTupleElementType();
  }
  function parseTupleType() {
    const pos = getNodePos();
    return finishNode(
      factory2.createTupleTypeNode(
        parseBracketedList(21 /* TupleElementTypes */, parseTupleElementNameOrTupleElementType, 23 /* OpenBracketToken */, 24 /* CloseBracketToken */)
      ),
      pos
    );
  }
  function parseParenthesizedType() {
    const pos = getNodePos();
    parseExpected(21 /* OpenParenToken */);
    const type = parseType();
    parseExpected(22 /* CloseParenToken */);
    return finishNode(factory2.createParenthesizedType(type), pos);
  }
  function parseModifiersForConstructorType() {
    let modifiers;
    if (token() === 128 /* AbstractKeyword */) {
      const pos = getNodePos();
      nextToken();
      const modifier = finishNode(factoryCreateToken(128 /* AbstractKeyword */), pos);
      modifiers = createNodeArray([modifier], pos);
    }
    return modifiers;
  }
  function parseFunctionOrConstructorType() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    const modifiers = parseModifiersForConstructorType();
    const isConstructorType = parseOptional(105 /* NewKeyword */);
    Debug.assert(!modifiers || isConstructorType, "Per isStartOfFunctionOrConstructorType, a function type cannot have modifiers.");
    const typeParameters = parseTypeParameters();
    const parameters = parseParameters(4 /* Type */);
    const type = parseReturnType(
      39 /* EqualsGreaterThanToken */,
      /*isType*/
      false
    );
    const node = isConstructorType ? factory2.createConstructorTypeNode(modifiers, typeParameters, parameters, type) : factory2.createFunctionTypeNode(typeParameters, parameters, type);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseKeywordAndNoDot() {
    const node = parseTokenNode();
    return token() === 25 /* DotToken */ ? void 0 : node;
  }
  function parseLiteralTypeNode(negative) {
    const pos = getNodePos();
    if (negative) {
      nextToken();
    }
    let expression = token() === 112 /* TrueKeyword */ || token() === 97 /* FalseKeyword */ || token() === 106 /* NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token());
    if (negative) {
      expression = finishNode(factory2.createPrefixUnaryExpression(41 /* MinusToken */, expression), pos);
    }
    return finishNode(factory2.createLiteralTypeNode(expression), pos);
  }
  function isStartOfTypeOfImportType() {
    nextToken();
    return token() === 102 /* ImportKeyword */;
  }
  function parseImportType() {
    sourceFlags |= 4194304 /* PossiblyContainsDynamicImport */;
    const pos = getNodePos();
    const isTypeOf = parseOptional(114 /* TypeOfKeyword */);
    parseExpected(102 /* ImportKeyword */);
    parseExpected(21 /* OpenParenToken */);
    const type = parseType();
    let attributes;
    if (parseOptional(28 /* CommaToken */)) {
      const openBracePosition = scanner2.getTokenStart();
      parseExpected(19 /* OpenBraceToken */);
      const currentToken2 = token();
      if (currentToken2 === 118 /* WithKeyword */ || currentToken2 === 132 /* AssertKeyword */) {
        nextToken();
      } else {
        parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(118 /* WithKeyword */));
      }
      parseExpected(59 /* ColonToken */);
      attributes = parseImportAttributes(
        currentToken2,
        /*skipKeyword*/
        true
      );
      if (!parseExpected(20 /* CloseBraceToken */)) {
        const lastError = lastOrUndefined(parseDiagnostics);
        if (lastError && lastError.code === Diagnostics._0_expected.code) {
          addRelatedInfo(
            lastError,
            createDetachedDiagnostic(fileName, sourceText, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
          );
        }
      }
    }
    parseExpected(22 /* CloseParenToken */);
    const qualifier = parseOptional(25 /* DotToken */) ? parseEntityNameOfTypeReference() : void 0;
    const typeArguments = parseTypeArgumentsOfTypeReference();
    return finishNode(factory2.createImportTypeNode(type, attributes, qualifier, typeArguments, isTypeOf), pos);
  }
  function nextTokenIsNumericOrBigIntLiteral() {
    nextToken();
    return token() === 9 /* NumericLiteral */ || token() === 10 /* BigIntLiteral */;
  }
  function parseNonArrayType() {
    switch (token()) {
      case 133 /* AnyKeyword */:
      case 159 /* UnknownKeyword */:
      case 154 /* StringKeyword */:
      case 150 /* NumberKeyword */:
      case 163 /* BigIntKeyword */:
      case 155 /* SymbolKeyword */:
      case 136 /* BooleanKeyword */:
      case 157 /* UndefinedKeyword */:
      case 146 /* NeverKeyword */:
      case 151 /* ObjectKeyword */:
        return tryParse(parseKeywordAndNoDot) || parseTypeReference();
      case 67 /* AsteriskEqualsToken */:
        scanner2.reScanAsteriskEqualsToken();
      // falls through
      case 42 /* AsteriskToken */:
        return parseJSDocAllType();
      case 61 /* QuestionQuestionToken */:
        scanner2.reScanQuestionToken();
      // falls through
      case 58 /* QuestionToken */:
        return parseJSDocUnknownOrNullableType();
      case 100 /* FunctionKeyword */:
        return parseJSDocFunctionType();
      case 54 /* ExclamationToken */:
        return parseJSDocNonNullableType();
      case 15 /* NoSubstitutionTemplateLiteral */:
      case 11 /* StringLiteral */:
      case 9 /* NumericLiteral */:
      case 10 /* BigIntLiteral */:
      case 112 /* TrueKeyword */:
      case 97 /* FalseKeyword */:
      case 106 /* NullKeyword */:
        return parseLiteralTypeNode();
      case 41 /* MinusToken */:
        return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(
          /*negative*/
          true
        ) : parseTypeReference();
      case 116 /* VoidKeyword */:
        return parseTokenNode();
      case 110 /* ThisKeyword */: {
        const thisKeyword = parseThisTypeNode();
        if (token() === 142 /* IsKeyword */ && !scanner2.hasPrecedingLineBreak()) {
          return parseThisTypePredicate(thisKeyword);
        } else {
          return thisKeyword;
        }
      }
      case 114 /* TypeOfKeyword */:
        return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery();
      case 19 /* OpenBraceToken */:
        return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral();
      case 23 /* OpenBracketToken */:
        return parseTupleType();
      case 21 /* OpenParenToken */:
        return parseParenthesizedType();
      case 102 /* ImportKeyword */:
        return parseImportType();
      case 131 /* AssertsKeyword */:
        return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference();
      case 16 /* TemplateHead */:
        return parseTemplateType();
      default:
        return parseTypeReference();
    }
  }
  function isStartOfType(inStartOfParameter) {
    switch (token()) {
      case 133 /* AnyKeyword */:
      case 159 /* UnknownKeyword */:
      case 154 /* StringKeyword */:
      case 150 /* NumberKeyword */:
      case 163 /* BigIntKeyword */:
      case 136 /* BooleanKeyword */:
      case 148 /* ReadonlyKeyword */:
      case 155 /* SymbolKeyword */:
      case 158 /* UniqueKeyword */:
      case 116 /* VoidKeyword */:
      case 157 /* UndefinedKeyword */:
      case 106 /* NullKeyword */:
      case 110 /* ThisKeyword */:
      case 114 /* TypeOfKeyword */:
      case 146 /* NeverKeyword */:
      case 19 /* OpenBraceToken */:
      case 23 /* OpenBracketToken */:
      case 30 /* LessThanToken */:
      case 52 /* BarToken */:
      case 51 /* AmpersandToken */:
      case 105 /* NewKeyword */:
      case 11 /* StringLiteral */:
      case 9 /* NumericLiteral */:
      case 10 /* BigIntLiteral */:
      case 112 /* TrueKeyword */:
      case 97 /* FalseKeyword */:
      case 151 /* ObjectKeyword */:
      case 42 /* AsteriskToken */:
      case 58 /* QuestionToken */:
      case 54 /* ExclamationToken */:
      case 26 /* DotDotDotToken */:
      case 140 /* InferKeyword */:
      case 102 /* ImportKeyword */:
      case 131 /* AssertsKeyword */:
      case 15 /* NoSubstitutionTemplateLiteral */:
      case 16 /* TemplateHead */:
        return true;
      case 100 /* FunctionKeyword */:
        return !inStartOfParameter;
      case 41 /* MinusToken */:
        return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral);
      case 21 /* OpenParenToken */:
        return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType);
      default:
        return isIdentifier2();
    }
  }
  function isStartOfParenthesizedOrFunctionType() {
    nextToken();
    return token() === 22 /* CloseParenToken */ || isStartOfParameter(
      /*isJSDocParameter*/
      false
    ) || isStartOfType();
  }
  function parsePostfixTypeOrHigher() {
    const pos = getNodePos();
    let type = parseNonArrayType();
    while (!scanner2.hasPrecedingLineBreak()) {
      switch (token()) {
        case 54 /* ExclamationToken */:
          nextToken();
          type = finishNode(factory2.createJSDocNonNullableType(
            type,
            /*postfix*/
            true
          ), pos);
          break;
        case 58 /* QuestionToken */:
          if (lookAhead(nextTokenIsStartOfType)) {
            return type;
          }
          nextToken();
          type = finishNode(factory2.createJSDocNullableType(
            type,
            /*postfix*/
            true
          ), pos);
          break;
        case 23 /* OpenBracketToken */:
          parseExpected(23 /* OpenBracketToken */);
          if (isStartOfType()) {
            const indexType = parseType();
            parseExpected(24 /* CloseBracketToken */);
            type = finishNode(factory2.createIndexedAccessTypeNode(type, indexType), pos);
          } else {
            parseExpected(24 /* CloseBracketToken */);
            type = finishNode(factory2.createArrayTypeNode(type), pos);
          }
          break;
        default:
          return type;
      }
    }
    return type;
  }
  function parseTypeOperator(operator) {
    const pos = getNodePos();
    parseExpected(operator);
    return finishNode(factory2.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos);
  }
  function tryParseConstraintOfInferType() {
    if (parseOptional(96 /* ExtendsKeyword */)) {
      const constraint = disallowConditionalTypesAnd(parseType);
      if (inDisallowConditionalTypesContext() || token() !== 58 /* QuestionToken */) {
        return constraint;
      }
    }
  }
  function parseTypeParameterOfInferType() {
    const pos = getNodePos();
    const name = parseIdentifier();
    const constraint = tryParse(tryParseConstraintOfInferType);
    const node = factory2.createTypeParameterDeclaration(
      /*modifiers*/
      void 0,
      name,
      constraint
    );
    return finishNode(node, pos);
  }
  function parseInferType() {
    const pos = getNodePos();
    parseExpected(140 /* InferKeyword */);
    return finishNode(factory2.createInferTypeNode(parseTypeParameterOfInferType()), pos);
  }
  function parseTypeOperatorOrHigher() {
    const operator = token();
    switch (operator) {
      case 143 /* KeyOfKeyword */:
      case 158 /* UniqueKeyword */:
      case 148 /* ReadonlyKeyword */:
        return parseTypeOperator(operator);
      case 140 /* InferKeyword */:
        return parseInferType();
    }
    return allowConditionalTypesAnd(parsePostfixTypeOrHigher);
  }
  function parseFunctionOrConstructorTypeToError(isInUnionType) {
    if (isStartOfFunctionTypeOrConstructorType()) {
      const type = parseFunctionOrConstructorType();
      let diagnostic;
      if (isFunctionTypeNode(type)) {
        diagnostic = isInUnionType ? Diagnostics.Function_type_notation_must_be_parenthesized_when_used_in_a_union_type : Diagnostics.Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type;
      } else {
        diagnostic = isInUnionType ? Diagnostics.Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type : Diagnostics.Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type;
      }
      parseErrorAtRange(type, diagnostic);
      return type;
    }
    return void 0;
  }
  function parseUnionOrIntersectionType(operator, parseConstituentType, createTypeNode) {
    const pos = getNodePos();
    const isUnionType = operator === 52 /* BarToken */;
    const hasLeadingOperator = parseOptional(operator);
    let type = hasLeadingOperator && parseFunctionOrConstructorTypeToError(isUnionType) || parseConstituentType();
    if (token() === operator || hasLeadingOperator) {
      const types = [type];
      while (parseOptional(operator)) {
        types.push(parseFunctionOrConstructorTypeToError(isUnionType) || parseConstituentType());
      }
      type = finishNode(createTypeNode(createNodeArray(types, pos)), pos);
    }
    return type;
  }
  function parseIntersectionTypeOrHigher() {
    return parseUnionOrIntersectionType(51 /* AmpersandToken */, parseTypeOperatorOrHigher, factory2.createIntersectionTypeNode);
  }
  function parseUnionTypeOrHigher() {
    return parseUnionOrIntersectionType(52 /* BarToken */, parseIntersectionTypeOrHigher, factory2.createUnionTypeNode);
  }
  function nextTokenIsNewKeyword() {
    nextToken();
    return token() === 105 /* NewKeyword */;
  }
  function isStartOfFunctionTypeOrConstructorType() {
    if (token() === 30 /* LessThanToken */) {
      return true;
    }
    if (token() === 21 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) {
      return true;
    }
    return token() === 105 /* NewKeyword */ || token() === 128 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword);
  }
  function skipParameterStart() {
    if (isModifierKind(token())) {
      parseModifiers(
        /*allowDecorators*/
        false
      );
    }
    if (isIdentifier2() || token() === 110 /* ThisKeyword */) {
      nextToken();
      return true;
    }
    if (token() === 23 /* OpenBracketToken */ || token() === 19 /* OpenBraceToken */) {
      const previousErrorCount = parseDiagnostics.length;
      parseIdentifierOrPattern();
      return previousErrorCount === parseDiagnostics.length;
    }
    return false;
  }
  function isUnambiguouslyStartOfFunctionType() {
    nextToken();
    if (token() === 22 /* CloseParenToken */ || token() === 26 /* DotDotDotToken */) {
      return true;
    }
    if (skipParameterStart()) {
      if (token() === 59 /* ColonToken */ || token() === 28 /* CommaToken */ || token() === 58 /* QuestionToken */ || token() === 64 /* EqualsToken */) {
        return true;
      }
      if (token() === 22 /* CloseParenToken */) {
        nextToken();
        if (token() === 39 /* EqualsGreaterThanToken */) {
          return true;
        }
      }
    }
    return false;
  }
  function parseTypeOrTypePredicate() {
    const pos = getNodePos();
    const typePredicateVariable = isIdentifier2() && tryParse(parseTypePredicatePrefix);
    const type = parseType();
    if (typePredicateVariable) {
      return finishNode(factory2.createTypePredicateNode(
        /*assertsModifier*/
        void 0,
        typePredicateVariable,
        type
      ), pos);
    } else {
      return type;
    }
  }
  function parseTypePredicatePrefix() {
    const id = parseIdentifier();
    if (token() === 142 /* IsKeyword */ && !scanner2.hasPrecedingLineBreak()) {
      nextToken();
      return id;
    }
  }
  function parseAssertsTypePredicate() {
    const pos = getNodePos();
    const assertsModifier = parseExpectedToken(131 /* AssertsKeyword */);
    const parameterName = token() === 110 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier();
    const type = parseOptional(142 /* IsKeyword */) ? parseType() : void 0;
    return finishNode(factory2.createTypePredicateNode(assertsModifier, parameterName, type), pos);
  }
  function parseType() {
    if (contextFlags & 81920 /* TypeExcludesFlags */) {
      return doOutsideOfContext(81920 /* TypeExcludesFlags */, parseType);
    }
    if (isStartOfFunctionTypeOrConstructorType()) {
      return parseFunctionOrConstructorType();
    }
    const pos = getNodePos();
    const type = parseUnionTypeOrHigher();
    if (!inDisallowConditionalTypesContext() && !scanner2.hasPrecedingLineBreak() && parseOptional(96 /* ExtendsKeyword */)) {
      const extendsType = disallowConditionalTypesAnd(parseType);
      parseExpected(58 /* QuestionToken */);
      const trueType = allowConditionalTypesAnd(parseType);
      parseExpected(59 /* ColonToken */);
      const falseType = allowConditionalTypesAnd(parseType);
      return finishNode(factory2.createConditionalTypeNode(type, extendsType, trueType, falseType), pos);
    }
    return type;
  }
  function parseTypeAnnotation() {
    return parseOptional(59 /* ColonToken */) ? parseType() : void 0;
  }
  function isStartOfLeftHandSideExpression() {
    switch (token()) {
      case 110 /* ThisKeyword */:
      case 108 /* SuperKeyword */:
      case 106 /* NullKeyword */:
      case 112 /* TrueKeyword */:
      case 97 /* FalseKeyword */:
      case 9 /* NumericLiteral */:
      case 10 /* BigIntLiteral */:
      case 11 /* StringLiteral */:
      case 15 /* NoSubstitutionTemplateLiteral */:
      case 16 /* TemplateHead */:
      case 21 /* OpenParenToken */:
      case 23 /* OpenBracketToken */:
      case 19 /* OpenBraceToken */:
      case 100 /* FunctionKeyword */:
      case 86 /* ClassKeyword */:
      case 105 /* NewKeyword */:
      case 44 /* SlashToken */:
      case 69 /* SlashEqualsToken */:
      case 80 /* Identifier */:
        return true;
      case 102 /* ImportKeyword */:
        return lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
      default:
        return isIdentifier2();
    }
  }
  function isStartOfExpression() {
    if (isStartOfLeftHandSideExpression()) {
      return true;
    }
    switch (token()) {
      case 40 /* PlusToken */:
      case 41 /* MinusToken */:
      case 55 /* TildeToken */:
      case 54 /* ExclamationToken */:
      case 91 /* DeleteKeyword */:
      case 114 /* TypeOfKeyword */:
      case 116 /* VoidKeyword */:
      case 46 /* PlusPlusToken */:
      case 47 /* MinusMinusToken */:
      case 30 /* LessThanToken */:
      case 135 /* AwaitKeyword */:
      case 127 /* YieldKeyword */:
      case 81 /* PrivateIdentifier */:
      case 60 /* AtToken */:
        return true;
      default:
        if (isBinaryOperator2()) {
          return true;
        }
        return isIdentifier2();
    }
  }
  function isStartOfExpressionStatement() {
    return token() !== 19 /* OpenBraceToken */ && token() !== 100 /* FunctionKeyword */ && token() !== 86 /* ClassKeyword */ && token() !== 60 /* AtToken */ && isStartOfExpression();
  }
  function parseExpression() {
    const saveDecoratorContext = inDecoratorContext();
    if (saveDecoratorContext) {
      setDecoratorContext(
        /*val*/
        false
      );
    }
    const pos = getNodePos();
    let expr = parseAssignmentExpressionOrHigher(
      /*allowReturnTypeInArrowFunction*/
      true
    );
    let operatorToken;
    while (operatorToken = parseOptionalToken(28 /* CommaToken */)) {
      expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(
        /*allowReturnTypeInArrowFunction*/
        true
      ), pos);
    }
    if (saveDecoratorContext) {
      setDecoratorContext(
        /*val*/
        true
      );
    }
    return expr;
  }
  function parseInitializer() {
    return parseOptional(64 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(
      /*allowReturnTypeInArrowFunction*/
      true
    ) : void 0;
  }
  function parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) {
    if (isYieldExpression2()) {
      return parseYieldExpression();
    }
    const arrowExpression = tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction);
    if (arrowExpression) {
      return arrowExpression;
    }
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    const expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
    if (expr.kind === 80 /* Identifier */ && token() === 39 /* EqualsGreaterThanToken */) {
      return parseSimpleArrowFunctionExpression(
        pos,
        expr,
        allowReturnTypeInArrowFunction,
        hasJSDoc,
        /*asyncModifier*/
        void 0
      );
    }
    if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) {
      return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction), pos);
    }
    return parseConditionalExpressionRest(expr, pos, allowReturnTypeInArrowFunction);
  }
  function isYieldExpression2() {
    if (token() === 127 /* YieldKeyword */) {
      if (inYieldContext()) {
        return true;
      }
      return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
    }
    return false;
  }
  function nextTokenIsIdentifierOnSameLine() {
    nextToken();
    return !scanner2.hasPrecedingLineBreak() && isIdentifier2();
  }
  function parseYieldExpression() {
    const pos = getNodePos();
    nextToken();
    if (!scanner2.hasPrecedingLineBreak() && (token() === 42 /* AsteriskToken */ || isStartOfExpression())) {
      return finishNode(
        factory2.createYieldExpression(
          parseOptionalToken(42 /* AsteriskToken */),
          parseAssignmentExpressionOrHigher(
            /*allowReturnTypeInArrowFunction*/
            true
          )
        ),
        pos
      );
    } else {
      return finishNode(factory2.createYieldExpression(
        /*asteriskToken*/
        void 0,
        /*expression*/
        void 0
      ), pos);
    }
  }
  function parseSimpleArrowFunctionExpression(pos, identifier, allowReturnTypeInArrowFunction, hasJSDoc, asyncModifier) {
    Debug.assert(token() === 39 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
    const parameter = factory2.createParameterDeclaration(
      /*modifiers*/
      void 0,
      /*dotDotDotToken*/
      void 0,
      identifier,
      /*questionToken*/
      void 0,
      /*type*/
      void 0,
      /*initializer*/
      void 0
    );
    finishNode(parameter, identifier.pos);
    const parameters = createNodeArray([parameter], parameter.pos, parameter.end);
    const equalsGreaterThanToken = parseExpectedToken(39 /* EqualsGreaterThanToken */);
    const body = parseArrowFunctionExpressionBody(
      /*isAsync*/
      !!asyncModifier,
      allowReturnTypeInArrowFunction
    );
    const node = factory2.createArrowFunction(
      asyncModifier,
      /*typeParameters*/
      void 0,
      parameters,
      /*type*/
      void 0,
      equalsGreaterThanToken,
      body
    );
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
    const triState = isParenthesizedArrowFunctionExpression();
    if (triState === 0 /* False */) {
      return void 0;
    }
    return triState === 1 /* True */ ? parseParenthesizedArrowFunctionExpression(
      /*allowAmbiguity*/
      true,
      /*allowReturnTypeInArrowFunction*/
      true
    ) : tryParse(() => parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction));
  }
  function isParenthesizedArrowFunctionExpression() {
    if (token() === 21 /* OpenParenToken */ || token() === 30 /* LessThanToken */ || token() === 134 /* AsyncKeyword */) {
      return lookAhead(isParenthesizedArrowFunctionExpressionWorker);
    }
    if (token() === 39 /* EqualsGreaterThanToken */) {
      return 1 /* True */;
    }
    return 0 /* False */;
  }
  function isParenthesizedArrowFunctionExpressionWorker() {
    if (token() === 134 /* AsyncKeyword */) {
      nextToken();
      if (scanner2.hasPrecedingLineBreak()) {
        return 0 /* False */;
      }
      if (token() !== 21 /* OpenParenToken */ && token() !== 30 /* LessThanToken */) {
        return 0 /* False */;
      }
    }
    const first2 = token();
    const second = nextToken();
    if (first2 === 21 /* OpenParenToken */) {
      if (second === 22 /* CloseParenToken */) {
        const third = nextToken();
        switch (third) {
          case 39 /* EqualsGreaterThanToken */:
          case 59 /* ColonToken */:
          case 19 /* OpenBraceToken */:
            return 1 /* True */;
          default:
            return 0 /* False */;
        }
      }
      if (second === 23 /* OpenBracketToken */ || second === 19 /* OpenBraceToken */) {
        return 2 /* Unknown */;
      }
      if (second === 26 /* DotDotDotToken */) {
        return 1 /* True */;
      }
      if (isModifierKind(second) && second !== 134 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) {
        if (nextToken() === 130 /* AsKeyword */) {
          return 0 /* False */;
        }
        return 1 /* True */;
      }
      if (!isIdentifier2() && second !== 110 /* ThisKeyword */) {
        return 0 /* False */;
      }
      switch (nextToken()) {
        case 59 /* ColonToken */:
          return 1 /* True */;
        case 58 /* QuestionToken */:
          nextToken();
          if (token() === 59 /* ColonToken */ || token() === 28 /* CommaToken */ || token() === 64 /* EqualsToken */ || token() === 22 /* CloseParenToken */) {
            return 1 /* True */;
          }
          return 0 /* False */;
        case 28 /* CommaToken */:
        case 64 /* EqualsToken */:
        case 22 /* CloseParenToken */:
          return 2 /* Unknown */;
      }
      return 0 /* False */;
    } else {
      Debug.assert(first2 === 30 /* LessThanToken */);
      if (!isIdentifier2() && token() !== 87 /* ConstKeyword */) {
        return 0 /* False */;
      }
      if (languageVariant === 1 /* JSX */) {
        const isArrowFunctionInJsx = lookAhead(() => {
          parseOptional(87 /* ConstKeyword */);
          const third = nextToken();
          if (third === 96 /* ExtendsKeyword */) {
            const fourth = nextToken();
            switch (fourth) {
              case 64 /* EqualsToken */:
              case 32 /* GreaterThanToken */:
              case 44 /* SlashToken */:
                return false;
              default:
                return true;
            }
          } else if (third === 28 /* CommaToken */ || third === 64 /* EqualsToken */) {
            return true;
          }
          return false;
        });
        if (isArrowFunctionInJsx) {
          return 1 /* True */;
        }
        return 0 /* False */;
      }
      return 2 /* Unknown */;
    }
  }
  function parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
    const tokenPos = scanner2.getTokenStart();
    if (notParenthesizedArrow == null ? void 0 : notParenthesizedArrow.has(tokenPos)) {
      return void 0;
    }
    const result = parseParenthesizedArrowFunctionExpression(
      /*allowAmbiguity*/
      false,
      allowReturnTypeInArrowFunction
    );
    if (!result) {
      (notParenthesizedArrow || (notParenthesizedArrow = /* @__PURE__ */ new Set())).add(tokenPos);
    }
    return result;
  }
  function tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction) {
    if (token() === 134 /* AsyncKeyword */) {
      if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
        const pos = getNodePos();
        const hasJSDoc = hasPrecedingJSDocComment();
        const asyncModifier = parseModifiersForArrowFunction();
        const expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
        return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, hasJSDoc, asyncModifier);
      }
    }
    return void 0;
  }
  function isUnParenthesizedAsyncArrowFunctionWorker() {
    if (token() === 134 /* AsyncKeyword */) {
      nextToken();
      if (scanner2.hasPrecedingLineBreak() || token() === 39 /* EqualsGreaterThanToken */) {
        return 0 /* False */;
      }
      const expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
      if (!scanner2.hasPrecedingLineBreak() && expr.kind === 80 /* Identifier */ && token() === 39 /* EqualsGreaterThanToken */) {
        return 1 /* True */;
      }
    }
    return 0 /* False */;
  }
  function parseParenthesizedArrowFunctionExpression(allowAmbiguity, allowReturnTypeInArrowFunction) {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    const modifiers = parseModifiersForArrowFunction();
    const isAsync = some(modifiers, isAsyncModifier) ? 2 /* Await */ : 0 /* None */;
    const typeParameters = parseTypeParameters();
    let parameters;
    if (!parseExpected(21 /* OpenParenToken */)) {
      if (!allowAmbiguity) {
        return void 0;
      }
      parameters = createMissingList();
    } else {
      if (!allowAmbiguity) {
        const maybeParameters = parseParametersWorker(isAsync, allowAmbiguity);
        if (!maybeParameters) {
          return void 0;
        }
        parameters = maybeParameters;
      } else {
        parameters = parseParametersWorker(isAsync, allowAmbiguity);
      }
      if (!parseExpected(22 /* CloseParenToken */) && !allowAmbiguity) {
        return void 0;
      }
    }
    const hasReturnColon = token() === 59 /* ColonToken */;
    const type = parseReturnType(
      59 /* ColonToken */,
      /*isType*/
      false
    );
    if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
      return void 0;
    }
    let unwrappedType = type;
    while ((unwrappedType == null ? void 0 : unwrappedType.kind) === 196 /* ParenthesizedType */) {
      unwrappedType = unwrappedType.type;
    }
    const hasJSDocFunctionType = unwrappedType && isJSDocFunctionType(unwrappedType);
    if (!allowAmbiguity && token() !== 39 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 19 /* OpenBraceToken */)) {
      return void 0;
    }
    const lastToken = token();
    const equalsGreaterThanToken = parseExpectedToken(39 /* EqualsGreaterThanToken */);
    const body = lastToken === 39 /* EqualsGreaterThanToken */ || lastToken === 19 /* OpenBraceToken */ ? parseArrowFunctionExpressionBody(some(modifiers, isAsyncModifier), allowReturnTypeInArrowFunction) : parseIdentifier();
    if (!allowReturnTypeInArrowFunction && hasReturnColon) {
      if (token() !== 59 /* ColonToken */) {
        return void 0;
      }
    }
    const node = factory2.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseArrowFunctionExpressionBody(isAsync, allowReturnTypeInArrowFunction) {
    if (token() === 19 /* OpenBraceToken */) {
      return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
    }
    if (token() !== 27 /* SemicolonToken */ && token() !== 100 /* FunctionKeyword */ && token() !== 86 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) {
      return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */));
    }
    const savedTopLevel = topLevel;
    topLevel = false;
    const node = isAsync ? doInAwaitContext(() => parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction)) : doOutsideOfAwaitContext(() => parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction));
    topLevel = savedTopLevel;
    return node;
  }
  function parseConditionalExpressionRest(leftOperand, pos, allowReturnTypeInArrowFunction) {
    const questionToken = parseOptionalToken(58 /* QuestionToken */);
    if (!questionToken) {
      return leftOperand;
    }
    let colonToken;
    return finishNode(
      factory2.createConditionalExpression(
        leftOperand,
        questionToken,
        doOutsideOfContext(disallowInAndDecoratorContext, () => parseAssignmentExpressionOrHigher(
          /*allowReturnTypeInArrowFunction*/
          false
        )),
        colonToken = parseExpectedToken(59 /* ColonToken */),
        nodeIsPresent(colonToken) ? parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) : createMissingNode(
          80 /* Identifier */,
          /*reportAtCurrentPosition*/
          false,
          Diagnostics._0_expected,
          tokenToString(59 /* ColonToken */)
        )
      ),
      pos
    );
  }
  function parseBinaryExpressionOrHigher(precedence) {
    const pos = getNodePos();
    const leftOperand = parseUnaryExpressionOrHigher();
    return parseBinaryExpressionRest(precedence, leftOperand, pos);
  }
  function isInOrOfKeyword(t) {
    return t === 103 /* InKeyword */ || t === 165 /* OfKeyword */;
  }
  function parseBinaryExpressionRest(precedence, leftOperand, pos) {
    while (true) {
      reScanGreaterToken();
      const newPrecedence = getBinaryOperatorPrecedence(token());
      const consumeCurrentOperator = token() === 43 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence;
      if (!consumeCurrentOperator) {
        break;
      }
      if (token() === 103 /* InKeyword */ && inDisallowInContext()) {
        break;
      }
      if (token() === 130 /* AsKeyword */ || token() === 152 /* SatisfiesKeyword */) {
        if (scanner2.hasPrecedingLineBreak()) {
          break;
        } else {
          const keywordKind = token();
          nextToken();
          leftOperand = keywordKind === 152 /* SatisfiesKeyword */ ? makeSatisfiesExpression(leftOperand, parseType()) : makeAsExpression(leftOperand, parseType());
        }
      } else {
        leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence), pos);
      }
    }
    return leftOperand;
  }
  function isBinaryOperator2() {
    if (inDisallowInContext() && token() === 103 /* InKeyword */) {
      return false;
    }
    return getBinaryOperatorPrecedence(token()) > 0;
  }
  function makeSatisfiesExpression(left, right) {
    return finishNode(factory2.createSatisfiesExpression(left, right), left.pos);
  }
  function makeBinaryExpression(left, operatorToken, right, pos) {
    return finishNode(factory2.createBinaryExpression(left, operatorToken, right), pos);
  }
  function makeAsExpression(left, right) {
    return finishNode(factory2.createAsExpression(left, right), left.pos);
  }
  function parsePrefixUnaryExpression() {
    const pos = getNodePos();
    return finishNode(factory2.createPrefixUnaryExpression(token(), nextTokenAnd(parseSimpleUnaryExpression)), pos);
  }
  function parseDeleteExpression() {
    const pos = getNodePos();
    return finishNode(factory2.createDeleteExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos);
  }
  function parseTypeOfExpression() {
    const pos = getNodePos();
    return finishNode(factory2.createTypeOfExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos);
  }
  function parseVoidExpression() {
    const pos = getNodePos();
    return finishNode(factory2.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos);
  }
  function isAwaitExpression2() {
    if (token() === 135 /* AwaitKeyword */) {
      if (inAwaitContext()) {
        return true;
      }
      return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
    }
    return false;
  }
  function parseAwaitExpression() {
    const pos = getNodePos();
    return finishNode(factory2.createAwaitExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos);
  }
  function parseUnaryExpressionOrHigher() {
    if (isUpdateExpression()) {
      const pos = getNodePos();
      const updateExpression = parseUpdateExpression();
      return token() === 43 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(token()), updateExpression, pos) : updateExpression;
    }
    const unaryOperator = token();
    const simpleUnaryExpression = parseSimpleUnaryExpression();
    if (token() === 43 /* AsteriskAsteriskToken */) {
      const pos = skipTrivia(sourceText, simpleUnaryExpression.pos);
      const { end } = simpleUnaryExpression;
      if (simpleUnaryExpression.kind === 216 /* TypeAssertionExpression */) {
        parseErrorAt(pos, end, Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses);
      } else {
        Debug.assert(isKeywordOrPunctuation(unaryOperator));
        parseErrorAt(pos, end, Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, tokenToString(unaryOperator));
      }
    }
    return simpleUnaryExpression;
  }
  function parseSimpleUnaryExpression() {
    switch (token()) {
      case 40 /* PlusToken */:
      case 41 /* MinusToken */:
      case 55 /* TildeToken */:
      case 54 /* ExclamationToken */:
        return parsePrefixUnaryExpression();
      case 91 /* DeleteKeyword */:
        return parseDeleteExpression();
      case 114 /* TypeOfKeyword */:
        return parseTypeOfExpression();
      case 116 /* VoidKeyword */:
        return parseVoidExpression();
      case 30 /* LessThanToken */:
        if (languageVariant === 1 /* JSX */) {
          return parseJsxElementOrSelfClosingElementOrFragment(
            /*inExpressionContext*/
            true,
            /*topInvalidNodePosition*/
            void 0,
            /*openingTag*/
            void 0,
            /*mustBeUnary*/
            true
          );
        }
        return parseTypeAssertion();
      case 135 /* AwaitKeyword */:
        if (isAwaitExpression2()) {
          return parseAwaitExpression();
        }
      // falls through
      default:
        return parseUpdateExpression();
    }
  }
  function isUpdateExpression() {
    switch (token()) {
      case 40 /* PlusToken */:
      case 41 /* MinusToken */:
      case 55 /* TildeToken */:
      case 54 /* ExclamationToken */:
      case 91 /* DeleteKeyword */:
      case 114 /* TypeOfKeyword */:
      case 116 /* VoidKeyword */:
      case 135 /* AwaitKeyword */:
        return false;
      case 30 /* LessThanToken */:
        if (languageVariant !== 1 /* JSX */) {
          return false;
        }
      // We are in JSX context and the token is part of JSXElement.
      // falls through
      default:
        return true;
    }
  }
  function parseUpdateExpression() {
    if (token() === 46 /* PlusPlusToken */ || token() === 47 /* MinusMinusToken */) {
      const pos = getNodePos();
      return finishNode(factory2.createPrefixUnaryExpression(token(), nextTokenAnd(parseLeftHandSideExpressionOrHigher)), pos);
    } else if (languageVariant === 1 /* JSX */ && token() === 30 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) {
      return parseJsxElementOrSelfClosingElementOrFragment(
        /*inExpressionContext*/
        true
      );
    }
    const expression = parseLeftHandSideExpressionOrHigher();
    Debug.assert(isLeftHandSideExpression(expression));
    if ((token() === 46 /* PlusPlusToken */ || token() === 47 /* MinusMinusToken */) && !scanner2.hasPrecedingLineBreak()) {
      const operator = token();
      nextToken();
      return finishNode(factory2.createPostfixUnaryExpression(expression, operator), expression.pos);
    }
    return expression;
  }
  function parseLeftHandSideExpressionOrHigher() {
    const pos = getNodePos();
    let expression;
    if (token() === 102 /* ImportKeyword */) {
      if (lookAhead(nextTokenIsOpenParenOrLessThan)) {
        sourceFlags |= 4194304 /* PossiblyContainsDynamicImport */;
        expression = parseTokenNode();
      } else if (lookAhead(nextTokenIsDot)) {
        nextToken();
        nextToken();
        expression = finishNode(factory2.createMetaProperty(102 /* ImportKeyword */, parseIdentifierName()), pos);
        sourceFlags |= 8388608 /* PossiblyContainsImportMeta */;
      } else {
        expression = parseMemberExpressionOrHigher();
      }
    } else {
      expression = token() === 108 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher();
    }
    return parseCallExpressionRest(pos, expression);
  }
  function parseMemberExpressionOrHigher() {
    const pos = getNodePos();
    const expression = parsePrimaryExpression();
    return parseMemberExpressionRest(
      pos,
      expression,
      /*allowOptionalChain*/
      true
    );
  }
  function parseSuperExpression() {
    const pos = getNodePos();
    let expression = parseTokenNode();
    if (token() === 30 /* LessThanToken */) {
      const startPos = getNodePos();
      const typeArguments = tryParse(parseTypeArgumentsInExpression);
      if (typeArguments !== void 0) {
        parseErrorAt(startPos, getNodePos(), Diagnostics.super_may_not_use_type_arguments);
        if (!isTemplateStartOfTaggedTemplate()) {
          expression = factory2.createExpressionWithTypeArguments(expression, typeArguments);
        }
      }
    }
    if (token() === 21 /* OpenParenToken */ || token() === 25 /* DotToken */ || token() === 23 /* OpenBracketToken */) {
      return expression;
    }
    parseExpectedToken(25 /* DotToken */, Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
    return finishNode(factoryCreatePropertyAccessExpression(expression, parseRightSideOfDot(
      /*allowIdentifierNames*/
      true,
      /*allowPrivateIdentifiers*/
      true,
      /*allowUnicodeEscapeSequenceInIdentifierName*/
      true
    )), pos);
  }
  function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag, mustBeUnary = false) {
    const pos = getNodePos();
    const opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
    let result;
    if (opening.kind === 286 /* JsxOpeningElement */) {
      let children = parseJsxChildren(opening);
      let closingElement;
      const lastChild = children[children.length - 1];
      if ((lastChild == null ? void 0 : lastChild.kind) === 284 /* JsxElement */ && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) {
        const end = lastChild.children.end;
        const newLast = finishNode(
          factory2.createJsxElement(
            lastChild.openingElement,
            lastChild.children,
            finishNode(factory2.createJsxClosingElement(finishNode(factoryCreateIdentifier(""), end, end)), end, end)
          ),
          lastChild.openingElement.pos,
          end
        );
        children = createNodeArray([...children.slice(0, children.length - 1), newLast], children.pos, end);
        closingElement = lastChild.closingElement;
      } else {
        closingElement = parseJsxClosingElement(opening, inExpressionContext);
        if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) {
          if (openingTag && isJsxOpeningElement(openingTag) && tagNamesAreEquivalent(closingElement.tagName, openingTag.tagName)) {
            parseErrorAtRange(opening.tagName, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, opening.tagName));
          } else {
            parseErrorAtRange(closingElement.tagName, Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, getTextOfNodeFromSourceText(sourceText, opening.tagName));
          }
        }
      }
      result = finishNode(factory2.createJsxElement(opening, children, closingElement), pos);
    } else if (opening.kind === 289 /* JsxOpeningFragment */) {
      result = finishNode(factory2.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos);
    } else {
      Debug.assert(opening.kind === 285 /* JsxSelfClosingElement */);
      result = opening;
    }
    if (!mustBeUnary && inExpressionContext && token() === 30 /* LessThanToken */) {
      const topBadPos = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition;
      const invalidElement = tryParse(() => parseJsxElementOrSelfClosingElementOrFragment(
        /*inExpressionContext*/
        true,
        topBadPos
      ));
      if (invalidElement) {
        const operatorToken = createMissingNode(
          28 /* CommaToken */,
          /*reportAtCurrentPosition*/
          false
        );
        setTextRangePosWidth(operatorToken, invalidElement.pos, 0);
        parseErrorAt(skipTrivia(sourceText, topBadPos), invalidElement.end, Diagnostics.JSX_expressions_must_have_one_parent_element);
        return finishNode(factory2.createBinaryExpression(result, operatorToken, invalidElement), pos);
      }
    }
    return result;
  }
  function parseJsxText() {
    const pos = getNodePos();
    const node = factory2.createJsxText(scanner2.getTokenValue(), currentToken === 13 /* JsxTextAllWhiteSpaces */);
    currentToken = scanner2.scanJsxToken();
    return finishNode(node, pos);
  }
  function parseJsxChild(openingTag, token2) {
    switch (token2) {
      case 1 /* EndOfFileToken */:
        if (isJsxOpeningFragment(openingTag)) {
          parseErrorAtRange(openingTag, Diagnostics.JSX_fragment_has_no_corresponding_closing_tag);
        } else {
          const tag = openingTag.tagName;
          const start = Math.min(skipTrivia(sourceText, tag.pos), tag.end);
          parseErrorAt(start, tag.end, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTag.tagName));
        }
        return void 0;
      case 31 /* LessThanSlashToken */:
      case 7 /* ConflictMarkerTrivia */:
        return void 0;
      case 12 /* JsxText */:
      case 13 /* JsxTextAllWhiteSpaces */:
        return parseJsxText();
      case 19 /* OpenBraceToken */:
        return parseJsxExpression(
          /*inExpressionContext*/
          false
        );
      case 30 /* LessThanToken */:
        return parseJsxElementOrSelfClosingElementOrFragment(
          /*inExpressionContext*/
          false,
          /*topInvalidNodePosition*/
          void 0,
          openingTag
        );
      default:
        return Debug.assertNever(token2);
    }
  }
  function parseJsxChildren(openingTag) {
    const list = [];
    const listPos = getNodePos();
    const saveParsingContext = parsingContext;
    parsingContext |= 1 << 14 /* JsxChildren */;
    while (true) {
      const child = parseJsxChild(openingTag, currentToken = scanner2.reScanJsxToken());
      if (!child) break;
      list.push(child);
      if (isJsxOpeningElement(openingTag) && (child == null ? void 0 : child.kind) === 284 /* JsxElement */ && !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName) && tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) {
        break;
      }
    }
    parsingContext = saveParsingContext;
    return createNodeArray(list, listPos);
  }
  function parseJsxAttributes() {
    const pos = getNodePos();
    return finishNode(factory2.createJsxAttributes(parseList(13 /* JsxAttributes */, parseJsxAttribute)), pos);
  }
  function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) {
    const pos = getNodePos();
    parseExpected(30 /* LessThanToken */);
    if (token() === 32 /* GreaterThanToken */) {
      scanJsxText();
      return finishNode(factory2.createJsxOpeningFragment(), pos);
    }
    const tagName = parseJsxElementName();
    const typeArguments = (contextFlags & 524288 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : void 0;
    const attributes = parseJsxAttributes();
    let node;
    if (token() === 32 /* GreaterThanToken */) {
      scanJsxText();
      node = factory2.createJsxOpeningElement(tagName, typeArguments, attributes);
    } else {
      parseExpected(44 /* SlashToken */);
      if (parseExpected(
        32 /* GreaterThanToken */,
        /*diagnosticMessage*/
        void 0,
        /*shouldAdvance*/
        false
      )) {
        if (inExpressionContext) {
          nextToken();
        } else {
          scanJsxText();
        }
      }
      node = factory2.createJsxSelfClosingElement(tagName, typeArguments, attributes);
    }
    return finishNode(node, pos);
  }
  function parseJsxElementName() {
    const pos = getNodePos();
    const initialExpression = parseJsxTagName();
    if (isJsxNamespacedName(initialExpression)) {
      return initialExpression;
    }
    let expression = initialExpression;
    while (parseOptional(25 /* DotToken */)) {
      expression = finishNode(factoryCreatePropertyAccessExpression(expression, parseRightSideOfDot(
        /*allowIdentifierNames*/
        true,
        /*allowPrivateIdentifiers*/
        false,
        /*allowUnicodeEscapeSequenceInIdentifierName*/
        false
      )), pos);
    }
    return expression;
  }
  function parseJsxTagName() {
    const pos = getNodePos();
    scanJsxIdentifier();
    const isThis2 = token() === 110 /* ThisKeyword */;
    const tagName = parseIdentifierNameErrorOnUnicodeEscapeSequence();
    if (parseOptional(59 /* ColonToken */)) {
      scanJsxIdentifier();
      return finishNode(factory2.createJsxNamespacedName(tagName, parseIdentifierNameErrorOnUnicodeEscapeSequence()), pos);
    }
    return isThis2 ? finishNode(factory2.createToken(110 /* ThisKeyword */), pos) : tagName;
  }
  function parseJsxExpression(inExpressionContext) {
    const pos = getNodePos();
    if (!parseExpected(19 /* OpenBraceToken */)) {
      return void 0;
    }
    let dotDotDotToken;
    let expression;
    if (token() !== 20 /* CloseBraceToken */) {
      if (!inExpressionContext) {
        dotDotDotToken = parseOptionalToken(26 /* DotDotDotToken */);
      }
      expression = parseExpression();
    }
    if (inExpressionContext) {
      parseExpected(20 /* CloseBraceToken */);
    } else {
      if (parseExpected(
        20 /* CloseBraceToken */,
        /*diagnosticMessage*/
        void 0,
        /*shouldAdvance*/
        false
      )) {
        scanJsxText();
      }
    }
    return finishNode(factory2.createJsxExpression(dotDotDotToken, expression), pos);
  }
  function parseJsxAttribute() {
    if (token() === 19 /* OpenBraceToken */) {
      return parseJsxSpreadAttribute();
    }
    const pos = getNodePos();
    return finishNode(factory2.createJsxAttribute(parseJsxAttributeName(), parseJsxAttributeValue()), pos);
  }
  function parseJsxAttributeValue() {
    if (token() === 64 /* EqualsToken */) {
      if (scanJsxAttributeValue() === 11 /* StringLiteral */) {
        return parseLiteralNode();
      }
      if (token() === 19 /* OpenBraceToken */) {
        return parseJsxExpression(
          /*inExpressionContext*/
          true
        );
      }
      if (token() === 30 /* LessThanToken */) {
        return parseJsxElementOrSelfClosingElementOrFragment(
          /*inExpressionContext*/
          true
        );
      }
      parseErrorAtCurrentToken(Diagnostics.or_JSX_element_expected);
    }
    return void 0;
  }
  function parseJsxAttributeName() {
    const pos = getNodePos();
    scanJsxIdentifier();
    const attrName = parseIdentifierNameErrorOnUnicodeEscapeSequence();
    if (parseOptional(59 /* ColonToken */)) {
      scanJsxIdentifier();
      return finishNode(factory2.createJsxNamespacedName(attrName, parseIdentifierNameErrorOnUnicodeEscapeSequence()), pos);
    }
    return attrName;
  }
  function parseJsxSpreadAttribute() {
    const pos = getNodePos();
    parseExpected(19 /* OpenBraceToken */);
    parseExpected(26 /* DotDotDotToken */);
    const expression = parseExpression();
    parseExpected(20 /* CloseBraceToken */);
    return finishNode(factory2.createJsxSpreadAttribute(expression), pos);
  }
  function parseJsxClosingElement(open, inExpressionContext) {
    const pos = getNodePos();
    parseExpected(31 /* LessThanSlashToken */);
    const tagName = parseJsxElementName();
    if (parseExpected(
      32 /* GreaterThanToken */,
      /*diagnosticMessage*/
      void 0,
      /*shouldAdvance*/
      false
    )) {
      if (inExpressionContext || !tagNamesAreEquivalent(open.tagName, tagName)) {
        nextToken();
      } else {
        scanJsxText();
      }
    }
    return finishNode(factory2.createJsxClosingElement(tagName), pos);
  }
  function parseJsxClosingFragment(inExpressionContext) {
    const pos = getNodePos();
    parseExpected(31 /* LessThanSlashToken */);
    if (parseExpected(
      32 /* GreaterThanToken */,
      Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment,
      /*shouldAdvance*/
      false
    )) {
      if (inExpressionContext) {
        nextToken();
      } else {
        scanJsxText();
      }
    }
    return finishNode(factory2.createJsxJsxClosingFragment(), pos);
  }
  function parseTypeAssertion() {
    Debug.assert(languageVariant !== 1 /* JSX */, "Type assertions should never be parsed in JSX; they should be parsed as comparisons or JSX elements/fragments.");
    const pos = getNodePos();
    parseExpected(30 /* LessThanToken */);
    const type = parseType();
    parseExpected(32 /* GreaterThanToken */);
    const expression = parseSimpleUnaryExpression();
    return finishNode(factory2.createTypeAssertion(type, expression), pos);
  }
  function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() {
    nextToken();
    return tokenIsIdentifierOrKeyword(token()) || token() === 23 /* OpenBracketToken */ || isTemplateStartOfTaggedTemplate();
  }
  function isStartOfOptionalPropertyOrElementAccessChain() {
    return token() === 29 /* QuestionDotToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate);
  }
  function tryReparseOptionalChain(node) {
    if (node.flags & 64 /* OptionalChain */) {
      return true;
    }
    if (isNonNullExpression(node)) {
      let expr = node.expression;
      while (isNonNullExpression(expr) && !(expr.flags & 64 /* OptionalChain */)) {
        expr = expr.expression;
      }
      if (expr.flags & 64 /* OptionalChain */) {
        while (isNonNullExpression(node)) {
          node.flags |= 64 /* OptionalChain */;
          node = node.expression;
        }
        return true;
      }
    }
    return false;
  }
  function parsePropertyAccessExpressionRest(pos, expression, questionDotToken) {
    const name = parseRightSideOfDot(
      /*allowIdentifierNames*/
      true,
      /*allowPrivateIdentifiers*/
      true,
      /*allowUnicodeEscapeSequenceInIdentifierName*/
      true
    );
    const isOptionalChain2 = questionDotToken || tryReparseOptionalChain(expression);
    const propertyAccess = isOptionalChain2 ? factoryCreatePropertyAccessChain(expression, questionDotToken, name) : factoryCreatePropertyAccessExpression(expression, name);
    if (isOptionalChain2 && isPrivateIdentifier(propertyAccess.name)) {
      parseErrorAtRange(propertyAccess.name, Diagnostics.An_optional_chain_cannot_contain_private_identifiers);
    }
    if (isExpressionWithTypeArguments(expression) && expression.typeArguments) {
      const pos2 = expression.typeArguments.pos - 1;
      const end = skipTrivia(sourceText, expression.typeArguments.end) + 1;
      parseErrorAt(pos2, end, Diagnostics.An_instantiation_expression_cannot_be_followed_by_a_property_access);
    }
    return finishNode(propertyAccess, pos);
  }
  function parseElementAccessExpressionRest(pos, expression, questionDotToken) {
    let argumentExpression;
    if (token() === 24 /* CloseBracketToken */) {
      argumentExpression = createMissingNode(
        80 /* Identifier */,
        /*reportAtCurrentPosition*/
        true,
        Diagnostics.An_element_access_expression_should_take_an_argument
      );
    } else {
      const argument = allowInAnd(parseExpression);
      if (isStringOrNumericLiteralLike(argument)) {
        argument.text = internIdentifier(argument.text);
      }
      argumentExpression = argument;
    }
    parseExpected(24 /* CloseBracketToken */);
    const indexedAccess = questionDotToken || tryReparseOptionalChain(expression) ? factoryCreateElementAccessChain(expression, questionDotToken, argumentExpression) : factoryCreateElementAccessExpression(expression, argumentExpression);
    return finishNode(indexedAccess, pos);
  }
  function parseMemberExpressionRest(pos, expression, allowOptionalChain) {
    while (true) {
      let questionDotToken;
      let isPropertyAccess = false;
      if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) {
        questionDotToken = parseExpectedToken(29 /* QuestionDotToken */);
        isPropertyAccess = tokenIsIdentifierOrKeyword(token());
      } else {
        isPropertyAccess = parseOptional(25 /* DotToken */);
      }
      if (isPropertyAccess) {
        expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken);
        continue;
      }
      if ((questionDotToken || !inDecoratorContext()) && parseOptional(23 /* OpenBracketToken */)) {
        expression = parseElementAccessExpressionRest(pos, expression, questionDotToken);
        continue;
      }
      if (isTemplateStartOfTaggedTemplate()) {
        expression = !questionDotToken && expression.kind === 233 /* ExpressionWithTypeArguments */ ? parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) : parseTaggedTemplateRest(
          pos,
          expression,
          questionDotToken,
          /*typeArguments*/
          void 0
        );
        continue;
      }
      if (!questionDotToken) {
        if (token() === 54 /* ExclamationToken */ && !scanner2.hasPrecedingLineBreak()) {
          nextToken();
          expression = finishNode(factory2.createNonNullExpression(expression), pos);
          continue;
        }
        const typeArguments = tryParse(parseTypeArgumentsInExpression);
        if (typeArguments) {
          expression = finishNode(factory2.createExpressionWithTypeArguments(expression, typeArguments), pos);
          continue;
        }
      }
      return expression;
    }
  }
  function isTemplateStartOfTaggedTemplate() {
    return token() === 15 /* NoSubstitutionTemplateLiteral */ || token() === 16 /* TemplateHead */;
  }
  function parseTaggedTemplateRest(pos, tag, questionDotToken, typeArguments) {
    const tagExpression = factory2.createTaggedTemplateExpression(
      tag,
      typeArguments,
      token() === 15 /* NoSubstitutionTemplateLiteral */ ? (reScanTemplateToken(
        /*isTaggedTemplate*/
        true
      ), parseLiteralNode()) : parseTemplateExpression(
        /*isTaggedTemplate*/
        true
      )
    );
    if (questionDotToken || tag.flags & 64 /* OptionalChain */) {
      tagExpression.flags |= 64 /* OptionalChain */;
    }
    tagExpression.questionDotToken = questionDotToken;
    return finishNode(tagExpression, pos);
  }
  function parseCallExpressionRest(pos, expression) {
    while (true) {
      expression = parseMemberExpressionRest(
        pos,
        expression,
        /*allowOptionalChain*/
        true
      );
      let typeArguments;
      const questionDotToken = parseOptionalToken(29 /* QuestionDotToken */);
      if (questionDotToken) {
        typeArguments = tryParse(parseTypeArgumentsInExpression);
        if (isTemplateStartOfTaggedTemplate()) {
          expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
          continue;
        }
      }
      if (typeArguments || token() === 21 /* OpenParenToken */) {
        if (!questionDotToken && expression.kind === 233 /* ExpressionWithTypeArguments */) {
          typeArguments = expression.typeArguments;
          expression = expression.expression;
        }
        const argumentList = parseArgumentList();
        const callExpr = questionDotToken || tryReparseOptionalChain(expression) ? factoryCreateCallChain(expression, questionDotToken, typeArguments, argumentList) : factoryCreateCallExpression(expression, typeArguments, argumentList);
        expression = finishNode(callExpr, pos);
        continue;
      }
      if (questionDotToken) {
        const name = createMissingNode(
          80 /* Identifier */,
          /*reportAtCurrentPosition*/
          false,
          Diagnostics.Identifier_expected
        );
        expression = finishNode(factoryCreatePropertyAccessChain(expression, questionDotToken, name), pos);
      }
      break;
    }
    return expression;
  }
  function parseArgumentList() {
    parseExpected(21 /* OpenParenToken */);
    const result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression);
    parseExpected(22 /* CloseParenToken */);
    return result;
  }
  function parseTypeArgumentsInExpression() {
    if ((contextFlags & 524288 /* JavaScriptFile */) !== 0) {
      return void 0;
    }
    if (reScanLessThanToken() !== 30 /* LessThanToken */) {
      return void 0;
    }
    nextToken();
    const typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType);
    if (reScanGreaterToken() !== 32 /* GreaterThanToken */) {
      return void 0;
    }
    nextToken();
    return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : void 0;
  }
  function canFollowTypeArgumentsInExpression() {
    switch (token()) {
      // These tokens can follow a type argument list in a call expression.
      case 21 /* OpenParenToken */:
      // foo<x>(
      case 15 /* NoSubstitutionTemplateLiteral */:
      // foo<T> `...`
      case 16 /* TemplateHead */:
        return true;
      // A type argument list followed by `<` never makes sense, and a type argument list followed
      // by `>` is ambiguous with a (re-scanned) `>>` operator, so we disqualify both. Also, in
      // this context, `+` and `-` are unary operators, not binary operators.
      case 30 /* LessThanToken */:
      case 32 /* GreaterThanToken */:
      case 40 /* PlusToken */:
      case 41 /* MinusToken */:
        return false;
    }
    return scanner2.hasPrecedingLineBreak() || isBinaryOperator2() || !isStartOfExpression();
  }
  function parsePrimaryExpression() {
    switch (token()) {
      case 15 /* NoSubstitutionTemplateLiteral */:
        if (scanner2.getTokenFlags() & 26656 /* IsInvalid */) {
          reScanTemplateToken(
            /*isTaggedTemplate*/
            false
          );
        }
      // falls through
      case 9 /* NumericLiteral */:
      case 10 /* BigIntLiteral */:
      case 11 /* StringLiteral */:
        return parseLiteralNode();
      case 110 /* ThisKeyword */:
      case 108 /* SuperKeyword */:
      case 106 /* NullKeyword */:
      case 112 /* TrueKeyword */:
      case 97 /* FalseKeyword */:
        return parseTokenNode();
      case 21 /* OpenParenToken */:
        return parseParenthesizedExpression();
      case 23 /* OpenBracketToken */:
        return parseArrayLiteralExpression();
      case 19 /* OpenBraceToken */:
        return parseObjectLiteralExpression();
      case 134 /* AsyncKeyword */:
        if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) {
          break;
        }
        return parseFunctionExpression();
      case 60 /* AtToken */:
        return parseDecoratedExpression();
      case 86 /* ClassKeyword */:
        return parseClassExpression();
      case 100 /* FunctionKeyword */:
        return parseFunctionExpression();
      case 105 /* NewKeyword */:
        return parseNewExpressionOrNewDotTarget();
      case 44 /* SlashToken */:
      case 69 /* SlashEqualsToken */:
        if (reScanSlashToken() === 14 /* RegularExpressionLiteral */) {
          return parseLiteralNode();
        }
        break;
      case 16 /* TemplateHead */:
        return parseTemplateExpression(
          /*isTaggedTemplate*/
          false
        );
      case 81 /* PrivateIdentifier */:
        return parsePrivateIdentifier();
    }
    return parseIdentifier(Diagnostics.Expression_expected);
  }
  function parseParenthesizedExpression() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    parseExpected(21 /* OpenParenToken */);
    const expression = allowInAnd(parseExpression);
    parseExpected(22 /* CloseParenToken */);
    return withJSDoc(finishNode(factoryCreateParenthesizedExpression(expression), pos), hasJSDoc);
  }
  function parseSpreadElement() {
    const pos = getNodePos();
    parseExpected(26 /* DotDotDotToken */);
    const expression = parseAssignmentExpressionOrHigher(
      /*allowReturnTypeInArrowFunction*/
      true
    );
    return finishNode(factory2.createSpreadElement(expression), pos);
  }
  function parseArgumentOrArrayLiteralElement() {
    return token() === 26 /* DotDotDotToken */ ? parseSpreadElement() : token() === 28 /* CommaToken */ ? finishNode(factory2.createOmittedExpression(), getNodePos()) : parseAssignmentExpressionOrHigher(
      /*allowReturnTypeInArrowFunction*/
      true
    );
  }
  function parseArgumentExpression() {
    return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
  }
  function parseArrayLiteralExpression() {
    const pos = getNodePos();
    const openBracketPosition = scanner2.getTokenStart();
    const openBracketParsed = parseExpected(23 /* OpenBracketToken */);
    const multiLine = scanner2.hasPrecedingLineBreak();
    const elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement);
    parseExpectedMatchingBrackets(23 /* OpenBracketToken */, 24 /* CloseBracketToken */, openBracketParsed, openBracketPosition);
    return finishNode(factoryCreateArrayLiteralExpression(elements, multiLine), pos);
  }
  function parseObjectLiteralElement() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    if (parseOptionalToken(26 /* DotDotDotToken */)) {
      const expression = parseAssignmentExpressionOrHigher(
        /*allowReturnTypeInArrowFunction*/
        true
      );
      return withJSDoc(finishNode(factory2.createSpreadAssignment(expression), pos), hasJSDoc);
    }
    const modifiers = parseModifiers(
      /*allowDecorators*/
      true
    );
    if (parseContextualModifier(139 /* GetKeyword */)) {
      return parseAccessorDeclaration(pos, hasJSDoc, modifiers, 177 /* GetAccessor */, 0 /* None */);
    }
    if (parseContextualModifier(153 /* SetKeyword */)) {
      return parseAccessorDeclaration(pos, hasJSDoc, modifiers, 178 /* SetAccessor */, 0 /* None */);
    }
    const asteriskToken = parseOptionalToken(42 /* AsteriskToken */);
    const tokenIsIdentifier = isIdentifier2();
    const name = parsePropertyName();
    const questionToken = parseOptionalToken(58 /* QuestionToken */);
    const exclamationToken = parseOptionalToken(54 /* ExclamationToken */);
    if (asteriskToken || token() === 21 /* OpenParenToken */ || token() === 30 /* LessThanToken */) {
      return parseMethodDeclaration(pos, hasJSDoc, modifiers, asteriskToken, name, questionToken, exclamationToken);
    }
    let node;
    const isShorthandPropertyAssignment2 = tokenIsIdentifier && token() !== 59 /* ColonToken */;
    if (isShorthandPropertyAssignment2) {
      const equalsToken = parseOptionalToken(64 /* EqualsToken */);
      const objectAssignmentInitializer = equalsToken ? allowInAnd(() => parseAssignmentExpressionOrHigher(
        /*allowReturnTypeInArrowFunction*/
        true
      )) : void 0;
      node = factory2.createShorthandPropertyAssignment(name, objectAssignmentInitializer);
      node.equalsToken = equalsToken;
    } else {
      parseExpected(59 /* ColonToken */);
      const initializer = allowInAnd(() => parseAssignmentExpressionOrHigher(
        /*allowReturnTypeInArrowFunction*/
        true
      ));
      node = factory2.createPropertyAssignment(name, initializer);
    }
    node.modifiers = modifiers;
    node.questionToken = questionToken;
    node.exclamationToken = exclamationToken;
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseObjectLiteralExpression() {
    const pos = getNodePos();
    const openBracePosition = scanner2.getTokenStart();
    const openBraceParsed = parseExpected(19 /* OpenBraceToken */);
    const multiLine = scanner2.hasPrecedingLineBreak();
    const properties = parseDelimitedList(
      12 /* ObjectLiteralMembers */,
      parseObjectLiteralElement,
      /*considerSemicolonAsDelimiter*/
      true
    );
    parseExpectedMatchingBrackets(19 /* OpenBraceToken */, 20 /* CloseBraceToken */, openBraceParsed, openBracePosition);
    return finishNode(factoryCreateObjectLiteralExpression(properties, multiLine), pos);
  }
  function parseFunctionExpression() {
    const savedDecoratorContext = inDecoratorContext();
    setDecoratorContext(
      /*val*/
      false
    );
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    const modifiers = parseModifiers(
      /*allowDecorators*/
      false
    );
    parseExpected(100 /* FunctionKeyword */);
    const asteriskToken = parseOptionalToken(42 /* AsteriskToken */);
    const isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
    const isAsync = some(modifiers, isAsyncModifier) ? 2 /* Await */ : 0 /* None */;
    const name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) : isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) : isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) : parseOptionalBindingIdentifier();
    const typeParameters = parseTypeParameters();
    const parameters = parseParameters(isGenerator | isAsync);
    const type = parseReturnType(
      59 /* ColonToken */,
      /*isType*/
      false
    );
    const body = parseFunctionBlock(isGenerator | isAsync);
    setDecoratorContext(savedDecoratorContext);
    const node = factory2.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseOptionalBindingIdentifier() {
    return isBindingIdentifier() ? parseBindingIdentifier() : void 0;
  }
  function parseNewExpressionOrNewDotTarget() {
    const pos = getNodePos();
    parseExpected(105 /* NewKeyword */);
    if (parseOptional(25 /* DotToken */)) {
      const name = parseIdentifierName();
      return finishNode(factory2.createMetaProperty(105 /* NewKeyword */, name), pos);
    }
    const expressionPos = getNodePos();
    let expression = parseMemberExpressionRest(
      expressionPos,
      parsePrimaryExpression(),
      /*allowOptionalChain*/
      false
    );
    let typeArguments;
    if (expression.kind === 233 /* ExpressionWithTypeArguments */) {
      typeArguments = expression.typeArguments;
      expression = expression.expression;
    }
    if (token() === 29 /* QuestionDotToken */) {
      parseErrorAtCurrentToken(Diagnostics.Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0, getTextOfNodeFromSourceText(sourceText, expression));
    }
    const argumentList = token() === 21 /* OpenParenToken */ ? parseArgumentList() : void 0;
    return finishNode(factoryCreateNewExpression(expression, typeArguments, argumentList), pos);
  }
  function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    const openBracePosition = scanner2.getTokenStart();
    const openBraceParsed = parseExpected(19 /* OpenBraceToken */, diagnosticMessage);
    if (openBraceParsed || ignoreMissingOpenBrace) {
      const multiLine = scanner2.hasPrecedingLineBreak();
      const statements = parseList(1 /* BlockStatements */, parseStatement);
      parseExpectedMatchingBrackets(19 /* OpenBraceToken */, 20 /* CloseBraceToken */, openBraceParsed, openBracePosition);
      const result = withJSDoc(finishNode(factoryCreateBlock(statements, multiLine), pos), hasJSDoc);
      if (token() === 64 /* EqualsToken */) {
        parseErrorAtCurrentToken(Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_whole_assignment_in_parentheses);
        nextToken();
      }
      return result;
    } else {
      const statements = createMissingList();
      return withJSDoc(finishNode(factoryCreateBlock(
        statements,
        /*multiLine*/
        void 0
      ), pos), hasJSDoc);
    }
  }
  function parseFunctionBlock(flags, diagnosticMessage) {
    const savedYieldContext = inYieldContext();
    setYieldContext(!!(flags & 1 /* Yield */));
    const savedAwaitContext = inAwaitContext();
    setAwaitContext(!!(flags & 2 /* Await */));
    const savedTopLevel = topLevel;
    topLevel = false;
    const saveDecoratorContext = inDecoratorContext();
    if (saveDecoratorContext) {
      setDecoratorContext(
        /*val*/
        false
      );
    }
    const block = parseBlock(!!(flags & 16 /* IgnoreMissingOpenBrace */), diagnosticMessage);
    if (saveDecoratorContext) {
      setDecoratorContext(
        /*val*/
        true
      );
    }
    topLevel = savedTopLevel;
    setYieldContext(savedYieldContext);
    setAwaitContext(savedAwaitContext);
    return block;
  }
  function parseEmptyStatement() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    parseExpected(27 /* SemicolonToken */);
    return withJSDoc(finishNode(factory2.createEmptyStatement(), pos), hasJSDoc);
  }
  function parseIfStatement() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    parseExpected(101 /* IfKeyword */);
    const openParenPosition = scanner2.getTokenStart();
    const openParenParsed = parseExpected(21 /* OpenParenToken */);
    const expression = allowInAnd(parseExpression);
    parseExpectedMatchingBrackets(21 /* OpenParenToken */, 22 /* CloseParenToken */, openParenParsed, openParenPosition);
    const thenStatement = parseStatement();
    const elseStatement = parseOptional(93 /* ElseKeyword */) ? parseStatement() : void 0;
    return withJSDoc(finishNode(factoryCreateIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc);
  }
  function parseDoStatement() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    parseExpected(92 /* DoKeyword */);
    const statement = parseStatement();
    parseExpected(117 /* WhileKeyword */);
    const openParenPosition = scanner2.getTokenStart();
    const openParenParsed = parseExpected(21 /* OpenParenToken */);
    const expression = allowInAnd(parseExpression);
    parseExpectedMatchingBrackets(21 /* OpenParenToken */, 22 /* CloseParenToken */, openParenParsed, openParenPosition);
    parseOptional(27 /* SemicolonToken */);
    return withJSDoc(finishNode(factory2.createDoStatement(statement, expression), pos), hasJSDoc);
  }
  function parseWhileStatement() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    parseExpected(117 /* WhileKeyword */);
    const openParenPosition = scanner2.getTokenStart();
    const openParenParsed = parseExpected(21 /* OpenParenToken */);
    const expression = allowInAnd(parseExpression);
    parseExpectedMatchingBrackets(21 /* OpenParenToken */, 22 /* CloseParenToken */, openParenParsed, openParenPosition);
    const statement = parseStatement();
    return withJSDoc(finishNode(factoryCreateWhileStatement(expression, statement), pos), hasJSDoc);
  }
  function parseForOrForInOrForOfStatement() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    parseExpected(99 /* ForKeyword */);
    const awaitToken = parseOptionalToken(135 /* AwaitKeyword */);
    parseExpected(21 /* OpenParenToken */);
    let initializer;
    if (token() !== 27 /* SemicolonToken */) {
      if (token() === 115 /* VarKeyword */ || token() === 121 /* LetKeyword */ || token() === 87 /* ConstKeyword */ || token() === 160 /* UsingKeyword */ && lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLineDisallowOf) || // this one is meant to allow of
      token() === 135 /* AwaitKeyword */ && lookAhead(nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine)) {
        initializer = parseVariableDeclarationList(
          /*inForStatementInitializer*/
          true
        );
      } else {
        initializer = disallowInAnd(parseExpression);
      }
    }
    let node;
    if (awaitToken ? parseExpected(165 /* OfKeyword */) : parseOptional(165 /* OfKeyword */)) {
      const expression = allowInAnd(() => parseAssignmentExpressionOrHigher(
        /*allowReturnTypeInArrowFunction*/
        true
      ));
      parseExpected(22 /* CloseParenToken */);
      node = factoryCreateForOfStatement(awaitToken, initializer, expression, parseStatement());
    } else if (parseOptional(103 /* InKeyword */)) {
      const expression = allowInAnd(parseExpression);
      parseExpected(22 /* CloseParenToken */);
      node = factory2.createForInStatement(initializer, expression, parseStatement());
    } else {
      parseExpected(27 /* SemicolonToken */);
      const condition = token() !== 27 /* SemicolonToken */ && token() !== 22 /* CloseParenToken */ ? allowInAnd(parseExpression) : void 0;
      parseExpected(27 /* SemicolonToken */);
      const incrementor = token() !== 22 /* CloseParenToken */ ? allowInAnd(parseExpression) : void 0;
      parseExpected(22 /* CloseParenToken */);
      node = factoryCreateForStatement(initializer, condition, incrementor, parseStatement());
    }
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseBreakOrContinueStatement(kind) {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    parseExpected(kind === 252 /* BreakStatement */ ? 83 /* BreakKeyword */ : 88 /* ContinueKeyword */);
    const label = canParseSemicolon() ? void 0 : parseIdentifier();
    parseSemicolon();
    const node = kind === 252 /* BreakStatement */ ? factory2.createBreakStatement(label) : factory2.createContinueStatement(label);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseReturnStatement() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    parseExpected(107 /* ReturnKeyword */);
    const expression = canParseSemicolon() ? void 0 : allowInAnd(parseExpression);
    parseSemicolon();
    return withJSDoc(finishNode(factory2.createReturnStatement(expression), pos), hasJSDoc);
  }
  function parseWithStatement() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    parseExpected(118 /* WithKeyword */);
    const openParenPosition = scanner2.getTokenStart();
    const openParenParsed = parseExpected(21 /* OpenParenToken */);
    const expression = allowInAnd(parseExpression);
    parseExpectedMatchingBrackets(21 /* OpenParenToken */, 22 /* CloseParenToken */, openParenParsed, openParenPosition);
    const statement = doInsideOfContext(67108864 /* InWithStatement */, parseStatement);
    return withJSDoc(finishNode(factory2.createWithStatement(expression, statement), pos), hasJSDoc);
  }
  function parseCaseClause() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    parseExpected(84 /* CaseKeyword */);
    const expression = allowInAnd(parseExpression);
    parseExpected(59 /* ColonToken */);
    const statements = parseList(3 /* SwitchClauseStatements */, parseStatement);
    return withJSDoc(finishNode(factory2.createCaseClause(expression, statements), pos), hasJSDoc);
  }
  function parseDefaultClause() {
    const pos = getNodePos();
    parseExpected(90 /* DefaultKeyword */);
    parseExpected(59 /* ColonToken */);
    const statements = parseList(3 /* SwitchClauseStatements */, parseStatement);
    return finishNode(factory2.createDefaultClause(statements), pos);
  }
  function parseCaseOrDefaultClause() {
    return token() === 84 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause();
  }
  function parseCaseBlock() {
    const pos = getNodePos();
    parseExpected(19 /* OpenBraceToken */);
    const clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause);
    parseExpected(20 /* CloseBraceToken */);
    return finishNode(factory2.createCaseBlock(clauses), pos);
  }
  function parseSwitchStatement() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    parseExpected(109 /* SwitchKeyword */);
    parseExpected(21 /* OpenParenToken */);
    const expression = allowInAnd(parseExpression);
    parseExpected(22 /* CloseParenToken */);
    const caseBlock = parseCaseBlock();
    return withJSDoc(finishNode(factory2.createSwitchStatement(expression, caseBlock), pos), hasJSDoc);
  }
  function parseThrowStatement() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    parseExpected(111 /* ThrowKeyword */);
    let expression = scanner2.hasPrecedingLineBreak() ? void 0 : allowInAnd(parseExpression);
    if (expression === void 0) {
      identifierCount++;
      expression = finishNode(factoryCreateIdentifier(""), getNodePos());
    }
    if (!tryParseSemicolon()) {
      parseErrorForMissingSemicolonAfter(expression);
    }
    return withJSDoc(finishNode(factory2.createThrowStatement(expression), pos), hasJSDoc);
  }
  function parseTryStatement() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    parseExpected(113 /* TryKeyword */);
    const tryBlock = parseBlock(
      /*ignoreMissingOpenBrace*/
      false
    );
    const catchClause = token() === 85 /* CatchKeyword */ ? parseCatchClause() : void 0;
    let finallyBlock;
    if (!catchClause || token() === 98 /* FinallyKeyword */) {
      parseExpected(98 /* FinallyKeyword */, Diagnostics.catch_or_finally_expected);
      finallyBlock = parseBlock(
        /*ignoreMissingOpenBrace*/
        false
      );
    }
    return withJSDoc(finishNode(factory2.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc);
  }
  function parseCatchClause() {
    const pos = getNodePos();
    parseExpected(85 /* CatchKeyword */);
    let variableDeclaration;
    if (parseOptional(21 /* OpenParenToken */)) {
      variableDeclaration = parseVariableDeclaration();
      parseExpected(22 /* CloseParenToken */);
    } else {
      variableDeclaration = void 0;
    }
    const block = parseBlock(
      /*ignoreMissingOpenBrace*/
      false
    );
    return finishNode(factory2.createCatchClause(variableDeclaration, block), pos);
  }
  function parseDebuggerStatement() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    parseExpected(89 /* DebuggerKeyword */);
    parseSemicolon();
    return withJSDoc(finishNode(factory2.createDebuggerStatement(), pos), hasJSDoc);
  }
  function parseExpressionOrLabeledStatement() {
    const pos = getNodePos();
    let hasJSDoc = hasPrecedingJSDocComment();
    let node;
    const hasParen = token() === 21 /* OpenParenToken */;
    const expression = allowInAnd(parseExpression);
    if (isIdentifier(expression) && parseOptional(59 /* ColonToken */)) {
      node = factory2.createLabeledStatement(expression, parseStatement());
    } else {
      if (!tryParseSemicolon()) {
        parseErrorForMissingSemicolonAfter(expression);
      }
      node = factoryCreateExpressionStatement(expression);
      if (hasParen) {
        hasJSDoc = false;
      }
    }
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function nextTokenIsIdentifierOrKeywordOnSameLine() {
    nextToken();
    return tokenIsIdentifierOrKeyword(token()) && !scanner2.hasPrecedingLineBreak();
  }
  function nextTokenIsClassKeywordOnSameLine() {
    nextToken();
    return token() === 86 /* ClassKeyword */ && !scanner2.hasPrecedingLineBreak();
  }
  function nextTokenIsFunctionKeywordOnSameLine() {
    nextToken();
    return token() === 100 /* FunctionKeyword */ && !scanner2.hasPrecedingLineBreak();
  }
  function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() {
    nextToken();
    return (tokenIsIdentifierOrKeyword(token()) || token() === 9 /* NumericLiteral */ || token() === 10 /* BigIntLiteral */ || token() === 11 /* StringLiteral */) && !scanner2.hasPrecedingLineBreak();
  }
  function isDeclaration2() {
    while (true) {
      switch (token()) {
        case 115 /* VarKeyword */:
        case 121 /* LetKeyword */:
        case 87 /* ConstKeyword */:
        case 100 /* FunctionKeyword */:
        case 86 /* ClassKeyword */:
        case 94 /* EnumKeyword */:
          return true;
        case 160 /* UsingKeyword */:
          return isUsingDeclaration();
        case 135 /* AwaitKeyword */:
          return isAwaitUsingDeclaration();
        // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers;
        // however, an identifier cannot be followed by another identifier on the same line. This is what we
        // count on to parse out the respective declarations. For instance, we exploit this to say that
        //
        //    namespace n
        //
        // can be none other than the beginning of a namespace declaration, but need to respect that JavaScript sees
        //
        //    namespace
        //    n
        //
        // as the identifier 'namespace' on one line followed by the identifier 'n' on another.
        // We need to look one token ahead to see if it permissible to try parsing a declaration.
        //
        // *Note*: 'interface' is actually a strict mode reserved word. So while
        //
        //   "use strict"
        //   interface
        //   I {}
        //
        // could be legal, it would add complexity for very little gain.
        case 120 /* InterfaceKeyword */:
        case 156 /* TypeKeyword */:
          return nextTokenIsIdentifierOnSameLine();
        case 144 /* ModuleKeyword */:
        case 145 /* NamespaceKeyword */:
          return nextTokenIsIdentifierOrStringLiteralOnSameLine();
        case 128 /* AbstractKeyword */:
        case 129 /* AccessorKeyword */:
        case 134 /* AsyncKeyword */:
        case 138 /* DeclareKeyword */:
        case 123 /* PrivateKeyword */:
        case 124 /* ProtectedKeyword */:
        case 125 /* PublicKeyword */:
        case 148 /* ReadonlyKeyword */:
          const previousToken = token();
          nextToken();
          if (scanner2.hasPrecedingLineBreak()) {
            return false;
          }
          if (previousToken === 138 /* DeclareKeyword */ && token() === 156 /* TypeKeyword */) {
            return true;
          }
          continue;
        case 162 /* GlobalKeyword */:
          nextToken();
          return token() === 19 /* OpenBraceToken */ || token() === 80 /* Identifier */ || token() === 95 /* ExportKeyword */;
        case 102 /* ImportKeyword */:
          nextToken();
          return token() === 11 /* StringLiteral */ || token() === 42 /* AsteriskToken */ || token() === 19 /* OpenBraceToken */ || tokenIsIdentifierOrKeyword(token());
        case 95 /* ExportKeyword */:
          let currentToken2 = nextToken();
          if (currentToken2 === 156 /* TypeKeyword */) {
            currentToken2 = lookAhead(nextToken);
          }
          if (currentToken2 === 64 /* EqualsToken */ || currentToken2 === 42 /* AsteriskToken */ || currentToken2 === 19 /* OpenBraceToken */ || currentToken2 === 90 /* DefaultKeyword */ || currentToken2 === 130 /* AsKeyword */ || currentToken2 === 60 /* AtToken */) {
            return true;
          }
          continue;
        case 126 /* StaticKeyword */:
          nextToken();
          continue;
        default:
          return false;
      }
    }
  }
  function isStartOfDeclaration() {
    return lookAhead(isDeclaration2);
  }
  function isStartOfStatement() {
    switch (token()) {
      case 60 /* AtToken */:
      case 27 /* SemicolonToken */:
      case 19 /* OpenBraceToken */:
      case 115 /* VarKeyword */:
      case 121 /* LetKeyword */:
      case 160 /* UsingKeyword */:
      case 100 /* FunctionKeyword */:
      case 86 /* ClassKeyword */:
      case 94 /* EnumKeyword */:
      case 101 /* IfKeyword */:
      case 92 /* DoKeyword */:
      case 117 /* WhileKeyword */:
      case 99 /* ForKeyword */:
      case 88 /* ContinueKeyword */:
      case 83 /* BreakKeyword */:
      case 107 /* ReturnKeyword */:
      case 118 /* WithKeyword */:
      case 109 /* SwitchKeyword */:
      case 111 /* ThrowKeyword */:
      case 113 /* TryKeyword */:
      case 89 /* DebuggerKeyword */:
      // 'catch' and 'finally' do not actually indicate that the code is part of a statement,
      // however, we say they are here so that we may gracefully parse them and error later.
      // falls through
      case 85 /* CatchKeyword */:
      case 98 /* FinallyKeyword */:
        return true;
      case 102 /* ImportKeyword */:
        return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
      case 87 /* ConstKeyword */:
      case 95 /* ExportKeyword */:
        return isStartOfDeclaration();
      case 134 /* AsyncKeyword */:
      case 138 /* DeclareKeyword */:
      case 120 /* InterfaceKeyword */:
      case 144 /* ModuleKeyword */:
      case 145 /* NamespaceKeyword */:
      case 156 /* TypeKeyword */:
      case 162 /* GlobalKeyword */:
        return true;
      case 129 /* AccessorKeyword */:
      case 125 /* PublicKeyword */:
      case 123 /* PrivateKeyword */:
      case 124 /* ProtectedKeyword */:
      case 126 /* StaticKeyword */:
      case 148 /* ReadonlyKeyword */:
        return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
      default:
        return isStartOfExpression();
    }
  }
  function nextTokenIsBindingIdentifierOrStartOfDestructuring() {
    nextToken();
    return isBindingIdentifier() || token() === 19 /* OpenBraceToken */ || token() === 23 /* OpenBracketToken */;
  }
  function isLetDeclaration() {
    return lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuring);
  }
  function nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLineDisallowOf() {
    return nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine(
      /*disallowOf*/
      true
    );
  }
  function nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine(disallowOf) {
    nextToken();
    if (disallowOf && token() === 165 /* OfKeyword */) return false;
    return (isBindingIdentifier() || token() === 19 /* OpenBraceToken */) && !scanner2.hasPrecedingLineBreak();
  }
  function isUsingDeclaration() {
    return lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine);
  }
  function nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine(disallowOf) {
    if (nextToken() === 160 /* UsingKeyword */) {
      return nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine(disallowOf);
    }
    return false;
  }
  function isAwaitUsingDeclaration() {
    return lookAhead(nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine);
  }
  function parseStatement() {
    switch (token()) {
      case 27 /* SemicolonToken */:
        return parseEmptyStatement();
      case 19 /* OpenBraceToken */:
        return parseBlock(
          /*ignoreMissingOpenBrace*/
          false
        );
      case 115 /* VarKeyword */:
        return parseVariableStatement(
          getNodePos(),
          hasPrecedingJSDocComment(),
          /*modifiers*/
          void 0
        );
      case 121 /* LetKeyword */:
        if (isLetDeclaration()) {
          return parseVariableStatement(
            getNodePos(),
            hasPrecedingJSDocComment(),
            /*modifiers*/
            void 0
          );
        }
        break;
      case 135 /* AwaitKeyword */:
        if (isAwaitUsingDeclaration()) {
          return parseVariableStatement(
            getNodePos(),
            hasPrecedingJSDocComment(),
            /*modifiers*/
            void 0
          );
        }
        break;
      case 160 /* UsingKeyword */:
        if (isUsingDeclaration()) {
          return parseVariableStatement(
            getNodePos(),
            hasPrecedingJSDocComment(),
            /*modifiers*/
            void 0
          );
        }
        break;
      case 100 /* FunctionKeyword */:
        return parseFunctionDeclaration(
          getNodePos(),
          hasPrecedingJSDocComment(),
          /*modifiers*/
          void 0
        );
      case 86 /* ClassKeyword */:
        return parseClassDeclaration(
          getNodePos(),
          hasPrecedingJSDocComment(),
          /*modifiers*/
          void 0
        );
      case 101 /* IfKeyword */:
        return parseIfStatement();
      case 92 /* DoKeyword */:
        return parseDoStatement();
      case 117 /* WhileKeyword */:
        return parseWhileStatement();
      case 99 /* ForKeyword */:
        return parseForOrForInOrForOfStatement();
      case 88 /* ContinueKeyword */:
        return parseBreakOrContinueStatement(251 /* ContinueStatement */);
      case 83 /* BreakKeyword */:
        return parseBreakOrContinueStatement(252 /* BreakStatement */);
      case 107 /* ReturnKeyword */:
        return parseReturnStatement();
      case 118 /* WithKeyword */:
        return parseWithStatement();
      case 109 /* SwitchKeyword */:
        return parseSwitchStatement();
      case 111 /* ThrowKeyword */:
        return parseThrowStatement();
      case 113 /* TryKeyword */:
      // Include 'catch' and 'finally' for error recovery.
      // falls through
      case 85 /* CatchKeyword */:
      case 98 /* FinallyKeyword */:
        return parseTryStatement();
      case 89 /* DebuggerKeyword */:
        return parseDebuggerStatement();
      case 60 /* AtToken */:
        return parseDeclaration();
      case 134 /* AsyncKeyword */:
      case 120 /* InterfaceKeyword */:
      case 156 /* TypeKeyword */:
      case 144 /* ModuleKeyword */:
      case 145 /* NamespaceKeyword */:
      case 138 /* DeclareKeyword */:
      case 87 /* ConstKeyword */:
      case 94 /* EnumKeyword */:
      case 95 /* ExportKeyword */:
      case 102 /* ImportKeyword */:
      case 123 /* PrivateKeyword */:
      case 124 /* ProtectedKeyword */:
      case 125 /* PublicKeyword */:
      case 128 /* AbstractKeyword */:
      case 129 /* AccessorKeyword */:
      case 126 /* StaticKeyword */:
      case 148 /* ReadonlyKeyword */:
      case 162 /* GlobalKeyword */:
        if (isStartOfDeclaration()) {
          return parseDeclaration();
        }
        break;
    }
    return parseExpressionOrLabeledStatement();
  }
  function isDeclareModifier(modifier) {
    return modifier.kind === 138 /* DeclareKeyword */;
  }
  function parseDeclaration() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    const modifiers = parseModifiers(
      /*allowDecorators*/
      true
    );
    const isAmbient = some(modifiers, isDeclareModifier);
    if (isAmbient) {
      const node = tryReuseAmbientDeclaration(pos);
      if (node) {
        return node;
      }
      for (const m of modifiers) {
        m.flags |= 33554432 /* Ambient */;
      }
      return doInsideOfContext(33554432 /* Ambient */, () => parseDeclarationWorker(pos, hasJSDoc, modifiers));
    } else {
      return parseDeclarationWorker(pos, hasJSDoc, modifiers);
    }
  }
  function tryReuseAmbientDeclaration(pos) {
    return doInsideOfContext(33554432 /* Ambient */, () => {
      const node = currentNode(parsingContext, pos);
      if (node) {
        return consumeNode(node);
      }
    });
  }
  function parseDeclarationWorker(pos, hasJSDoc, modifiersIn) {
    switch (token()) {
      case 115 /* VarKeyword */:
      case 121 /* LetKeyword */:
      case 87 /* ConstKeyword */:
      case 160 /* UsingKeyword */:
      case 135 /* AwaitKeyword */:
        return parseVariableStatement(pos, hasJSDoc, modifiersIn);
      case 100 /* FunctionKeyword */:
        return parseFunctionDeclaration(pos, hasJSDoc, modifiersIn);
      case 86 /* ClassKeyword */:
        return parseClassDeclaration(pos, hasJSDoc, modifiersIn);
      case 120 /* InterfaceKeyword */:
        return parseInterfaceDeclaration(pos, hasJSDoc, modifiersIn);
      case 156 /* TypeKeyword */:
        return parseTypeAliasDeclaration(pos, hasJSDoc, modifiersIn);
      case 94 /* EnumKeyword */:
        return parseEnumDeclaration(pos, hasJSDoc, modifiersIn);
      case 162 /* GlobalKeyword */:
      case 144 /* ModuleKeyword */:
      case 145 /* NamespaceKeyword */:
        return parseModuleDeclaration(pos, hasJSDoc, modifiersIn);
      case 102 /* ImportKeyword */:
        return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, modifiersIn);
      case 95 /* ExportKeyword */:
        nextToken();
        switch (token()) {
          case 90 /* DefaultKeyword */:
          case 64 /* EqualsToken */:
            return parseExportAssignment(pos, hasJSDoc, modifiersIn);
          case 130 /* AsKeyword */:
            return parseNamespaceExportDeclaration(pos, hasJSDoc, modifiersIn);
          default:
            return parseExportDeclaration(pos, hasJSDoc, modifiersIn);
        }
      default:
        if (modifiersIn) {
          const missing = createMissingNode(
            282 /* MissingDeclaration */,
            /*reportAtCurrentPosition*/
            true,
            Diagnostics.Declaration_expected
          );
          setTextRangePos(missing, pos);
          missing.modifiers = modifiersIn;
          return missing;
        }
        return void 0;
    }
  }
  function nextTokenIsStringLiteral() {
    return nextToken() === 11 /* StringLiteral */;
  }
  function nextTokenIsFromKeywordOrEqualsToken() {
    nextToken();
    return token() === 161 /* FromKeyword */ || token() === 64 /* EqualsToken */;
  }
  function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
    nextToken();
    return !scanner2.hasPrecedingLineBreak() && (isIdentifier2() || token() === 11 /* StringLiteral */);
  }
  function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
    if (token() !== 19 /* OpenBraceToken */) {
      if (flags & 4 /* Type */) {
        parseTypeMemberSemicolon();
        return;
      }
      if (canParseSemicolon()) {
        parseSemicolon();
        return;
      }
    }
    return parseFunctionBlock(flags, diagnosticMessage);
  }
  function parseArrayBindingElement() {
    const pos = getNodePos();
    if (token() === 28 /* CommaToken */) {
      return finishNode(factory2.createOmittedExpression(), pos);
    }
    const dotDotDotToken = parseOptionalToken(26 /* DotDotDotToken */);
    const name = parseIdentifierOrPattern();
    const initializer = parseInitializer();
    return finishNode(factory2.createBindingElement(
      dotDotDotToken,
      /*propertyName*/
      void 0,
      name,
      initializer
    ), pos);
  }
  function parseObjectBindingElement() {
    const pos = getNodePos();
    const dotDotDotToken = parseOptionalToken(26 /* DotDotDotToken */);
    const tokenIsIdentifier = isBindingIdentifier();
    let propertyName = parsePropertyName();
    let name;
    if (tokenIsIdentifier && token() !== 59 /* ColonToken */) {
      name = propertyName;
      propertyName = void 0;
    } else {
      parseExpected(59 /* ColonToken */);
      name = parseIdentifierOrPattern();
    }
    const initializer = parseInitializer();
    return finishNode(factory2.createBindingElement(dotDotDotToken, propertyName, name, initializer), pos);
  }
  function parseObjectBindingPattern() {
    const pos = getNodePos();
    parseExpected(19 /* OpenBraceToken */);
    const elements = allowInAnd(() => parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement));
    parseExpected(20 /* CloseBraceToken */);
    return finishNode(factory2.createObjectBindingPattern(elements), pos);
  }
  function parseArrayBindingPattern() {
    const pos = getNodePos();
    parseExpected(23 /* OpenBracketToken */);
    const elements = allowInAnd(() => parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement));
    parseExpected(24 /* CloseBracketToken */);
    return finishNode(factory2.createArrayBindingPattern(elements), pos);
  }
  function isBindingIdentifierOrPrivateIdentifierOrPattern() {
    return token() === 19 /* OpenBraceToken */ || token() === 23 /* OpenBracketToken */ || token() === 81 /* PrivateIdentifier */ || isBindingIdentifier();
  }
  function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) {
    if (token() === 23 /* OpenBracketToken */) {
      return parseArrayBindingPattern();
    }
    if (token() === 19 /* OpenBraceToken */) {
      return parseObjectBindingPattern();
    }
    return parseBindingIdentifier(privateIdentifierDiagnosticMessage);
  }
  function parseVariableDeclarationAllowExclamation() {
    return parseVariableDeclaration(
      /*allowExclamation*/
      true
    );
  }
  function parseVariableDeclaration(allowExclamation) {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    const name = parseIdentifierOrPattern(Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations);
    let exclamationToken;
    if (allowExclamation && name.kind === 80 /* Identifier */ && token() === 54 /* ExclamationToken */ && !scanner2.hasPrecedingLineBreak()) {
      exclamationToken = parseTokenNode();
    }
    const type = parseTypeAnnotation();
    const initializer = isInOrOfKeyword(token()) ? void 0 : parseInitializer();
    const node = factoryCreateVariableDeclaration(name, exclamationToken, type, initializer);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseVariableDeclarationList(inForStatementInitializer) {
    const pos = getNodePos();
    let flags = 0;
    switch (token()) {
      case 115 /* VarKeyword */:
        break;
      case 121 /* LetKeyword */:
        flags |= 1 /* Let */;
        break;
      case 87 /* ConstKeyword */:
        flags |= 2 /* Const */;
        break;
      case 160 /* UsingKeyword */:
        flags |= 4 /* Using */;
        break;
      case 135 /* AwaitKeyword */:
        Debug.assert(isAwaitUsingDeclaration());
        flags |= 6 /* AwaitUsing */;
        nextToken();
        break;
      default:
        Debug.fail();
    }
    nextToken();
    let declarations;
    if (token() === 165 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) {
      declarations = createMissingList();
    } else {
      const savedDisallowIn = inDisallowInContext();
      setDisallowInContext(inForStatementInitializer);
      declarations = parseDelimitedList(
        8 /* VariableDeclarations */,
        inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation
      );
      setDisallowInContext(savedDisallowIn);
    }
    return finishNode(factoryCreateVariableDeclarationList(declarations, flags), pos);
  }
  function canFollowContextualOfKeyword() {
    return nextTokenIsIdentifier() && nextToken() === 22 /* CloseParenToken */;
  }
  function parseVariableStatement(pos, hasJSDoc, modifiers) {
    const declarationList = parseVariableDeclarationList(
      /*inForStatementInitializer*/
      false
    );
    parseSemicolon();
    const node = factoryCreateVariableStatement(modifiers, declarationList);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseFunctionDeclaration(pos, hasJSDoc, modifiers) {
    const savedAwaitContext = inAwaitContext();
    const modifierFlags = modifiersToFlags(modifiers);
    parseExpected(100 /* FunctionKeyword */);
    const asteriskToken = parseOptionalToken(42 /* AsteriskToken */);
    const name = modifierFlags & 2048 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier();
    const isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
    const isAsync = modifierFlags & 1024 /* Async */ ? 2 /* Await */ : 0 /* None */;
    const typeParameters = parseTypeParameters();
    if (modifierFlags & 32 /* Export */) setAwaitContext(
      /*value*/
      true
    );
    const parameters = parseParameters(isGenerator | isAsync);
    const type = parseReturnType(
      59 /* ColonToken */,
      /*isType*/
      false
    );
    const body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, Diagnostics.or_expected);
    setAwaitContext(savedAwaitContext);
    const node = factory2.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseConstructorName() {
    if (token() === 137 /* ConstructorKeyword */) {
      return parseExpected(137 /* ConstructorKeyword */);
    }
    if (token() === 11 /* StringLiteral */ && lookAhead(nextToken) === 21 /* OpenParenToken */) {
      return tryParse(() => {
        const literalNode = parseLiteralNode();
        return literalNode.text === "constructor" ? literalNode : void 0;
      });
    }
  }
  function tryParseConstructorDeclaration(pos, hasJSDoc, modifiers) {
    return tryParse(() => {
      if (parseConstructorName()) {
        const typeParameters = parseTypeParameters();
        const parameters = parseParameters(0 /* None */);
        const type = parseReturnType(
          59 /* ColonToken */,
          /*isType*/
          false
        );
        const body = parseFunctionBlockOrSemicolon(0 /* None */, Diagnostics.or_expected);
        const node = factory2.createConstructorDeclaration(modifiers, parameters, body);
        node.typeParameters = typeParameters;
        node.type = type;
        return withJSDoc(finishNode(node, pos), hasJSDoc);
      }
    });
  }
  function parseMethodDeclaration(pos, hasJSDoc, modifiers, asteriskToken, name, questionToken, exclamationToken, diagnosticMessage) {
    const isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
    const isAsync = some(modifiers, isAsyncModifier) ? 2 /* Await */ : 0 /* None */;
    const typeParameters = parseTypeParameters();
    const parameters = parseParameters(isGenerator | isAsync);
    const type = parseReturnType(
      59 /* ColonToken */,
      /*isType*/
      false
    );
    const body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage);
    const node = factory2.createMethodDeclaration(
      modifiers,
      asteriskToken,
      name,
      questionToken,
      typeParameters,
      parameters,
      type,
      body
    );
    node.exclamationToken = exclamationToken;
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parsePropertyDeclaration(pos, hasJSDoc, modifiers, name, questionToken) {
    const exclamationToken = !questionToken && !scanner2.hasPrecedingLineBreak() ? parseOptionalToken(54 /* ExclamationToken */) : void 0;
    const type = parseTypeAnnotation();
    const initializer = doOutsideOfContext(16384 /* YieldContext */ | 65536 /* AwaitContext */ | 8192 /* DisallowInContext */, parseInitializer);
    parseSemicolonAfterPropertyName(name, type, initializer);
    const node = factory2.createPropertyDeclaration(
      modifiers,
      name,
      questionToken || exclamationToken,
      type,
      initializer
    );
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parsePropertyOrMethodDeclaration(pos, hasJSDoc, modifiers) {
    const asteriskToken = parseOptionalToken(42 /* AsteriskToken */);
    const name = parsePropertyName();
    const questionToken = parseOptionalToken(58 /* QuestionToken */);
    if (asteriskToken || token() === 21 /* OpenParenToken */ || token() === 30 /* LessThanToken */) {
      return parseMethodDeclaration(
        pos,
        hasJSDoc,
        modifiers,
        asteriskToken,
        name,
        questionToken,
        /*exclamationToken*/
        void 0,
        Diagnostics.or_expected
      );
    }
    return parsePropertyDeclaration(pos, hasJSDoc, modifiers, name, questionToken);
  }
  function parseAccessorDeclaration(pos, hasJSDoc, modifiers, kind, flags) {
    const name = parsePropertyName();
    const typeParameters = parseTypeParameters();
    const parameters = parseParameters(0 /* None */);
    const type = parseReturnType(
      59 /* ColonToken */,
      /*isType*/
      false
    );
    const body = parseFunctionBlockOrSemicolon(flags);
    const node = kind === 177 /* GetAccessor */ ? factory2.createGetAccessorDeclaration(modifiers, name, parameters, type, body) : factory2.createSetAccessorDeclaration(modifiers, name, parameters, body);
    node.typeParameters = typeParameters;
    if (isSetAccessorDeclaration(node)) node.type = type;
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function isClassMemberStart() {
    let idToken;
    if (token() === 60 /* AtToken */) {
      return true;
    }
    while (isModifierKind(token())) {
      idToken = token();
      if (isClassMemberModifier(idToken)) {
        return true;
      }
      nextToken();
    }
    if (token() === 42 /* AsteriskToken */) {
      return true;
    }
    if (isLiteralPropertyName()) {
      idToken = token();
      nextToken();
    }
    if (token() === 23 /* OpenBracketToken */) {
      return true;
    }
    if (idToken !== void 0) {
      if (!isKeyword(idToken) || idToken === 153 /* SetKeyword */ || idToken === 139 /* GetKeyword */) {
        return true;
      }
      switch (token()) {
        case 21 /* OpenParenToken */:
        // Method declaration
        case 30 /* LessThanToken */:
        // Generic Method declaration
        case 54 /* ExclamationToken */:
        // Non-null assertion on property name
        case 59 /* ColonToken */:
        // Type Annotation for declaration
        case 64 /* EqualsToken */:
        // Initializer for declaration
        case 58 /* QuestionToken */:
          return true;
        default:
          return canParseSemicolon();
      }
    }
    return false;
  }
  function parseClassStaticBlockDeclaration(pos, hasJSDoc, modifiers) {
    parseExpectedToken(126 /* StaticKeyword */);
    const body = parseClassStaticBlockBody();
    const node = withJSDoc(finishNode(factory2.createClassStaticBlockDeclaration(body), pos), hasJSDoc);
    node.modifiers = modifiers;
    return node;
  }
  function parseClassStaticBlockBody() {
    const savedYieldContext = inYieldContext();
    const savedAwaitContext = inAwaitContext();
    setYieldContext(false);
    setAwaitContext(true);
    const body = parseBlock(
      /*ignoreMissingOpenBrace*/
      false
    );
    setYieldContext(savedYieldContext);
    setAwaitContext(savedAwaitContext);
    return body;
  }
  function parseDecoratorExpression() {
    if (inAwaitContext() && token() === 135 /* AwaitKeyword */) {
      const pos = getNodePos();
      const awaitExpression = parseIdentifier(Diagnostics.Expression_expected);
      nextToken();
      const memberExpression = parseMemberExpressionRest(
        pos,
        awaitExpression,
        /*allowOptionalChain*/
        true
      );
      return parseCallExpressionRest(pos, memberExpression);
    }
    return parseLeftHandSideExpressionOrHigher();
  }
  function tryParseDecorator() {
    const pos = getNodePos();
    if (!parseOptional(60 /* AtToken */)) {
      return void 0;
    }
    const expression = doInDecoratorContext(parseDecoratorExpression);
    return finishNode(factory2.createDecorator(expression), pos);
  }
  function tryParseModifier(hasSeenStaticModifier, permitConstAsModifier, stopOnStartOfClassStaticBlock) {
    const pos = getNodePos();
    const kind = token();
    if (token() === 87 /* ConstKeyword */ && permitConstAsModifier) {
      if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) {
        return void 0;
      }
    } else if (stopOnStartOfClassStaticBlock && token() === 126 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) {
      return void 0;
    } else if (hasSeenStaticModifier && token() === 126 /* StaticKeyword */) {
      return void 0;
    } else {
      if (!parseAnyContextualModifier()) {
        return void 0;
      }
    }
    return finishNode(factoryCreateToken(kind), pos);
  }
  function parseModifiers(allowDecorators, permitConstAsModifier, stopOnStartOfClassStaticBlock) {
    const pos = getNodePos();
    let list;
    let decorator, modifier, hasSeenStaticModifier = false, hasLeadingModifier = false, hasTrailingDecorator = false;
    if (allowDecorators && token() === 60 /* AtToken */) {
      while (decorator = tryParseDecorator()) {
        list = append(list, decorator);
      }
    }
    while (modifier = tryParseModifier(hasSeenStaticModifier, permitConstAsModifier, stopOnStartOfClassStaticBlock)) {
      if (modifier.kind === 126 /* StaticKeyword */) hasSeenStaticModifier = true;
      list = append(list, modifier);
      hasLeadingModifier = true;
    }
    if (hasLeadingModifier && allowDecorators && token() === 60 /* AtToken */) {
      while (decorator = tryParseDecorator()) {
        list = append(list, decorator);
        hasTrailingDecorator = true;
      }
    }
    if (hasTrailingDecorator) {
      while (modifier = tryParseModifier(hasSeenStaticModifier, permitConstAsModifier, stopOnStartOfClassStaticBlock)) {
        if (modifier.kind === 126 /* StaticKeyword */) hasSeenStaticModifier = true;
        list = append(list, modifier);
      }
    }
    return list && createNodeArray(list, pos);
  }
  function parseModifiersForArrowFunction() {
    let modifiers;
    if (token() === 134 /* AsyncKeyword */) {
      const pos = getNodePos();
      nextToken();
      const modifier = finishNode(factoryCreateToken(134 /* AsyncKeyword */), pos);
      modifiers = createNodeArray([modifier], pos);
    }
    return modifiers;
  }
  function parseClassElement() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    if (token() === 27 /* SemicolonToken */) {
      nextToken();
      return withJSDoc(finishNode(factory2.createSemicolonClassElement(), pos), hasJSDoc);
    }
    const modifiers = parseModifiers(
      /*allowDecorators*/
      true,
      /*permitConstAsModifier*/
      true,
      /*stopOnStartOfClassStaticBlock*/
      true
    );
    if (token() === 126 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) {
      return parseClassStaticBlockDeclaration(pos, hasJSDoc, modifiers);
    }
    if (parseContextualModifier(139 /* GetKeyword */)) {
      return parseAccessorDeclaration(pos, hasJSDoc, modifiers, 177 /* GetAccessor */, 0 /* None */);
    }
    if (parseContextualModifier(153 /* SetKeyword */)) {
      return parseAccessorDeclaration(pos, hasJSDoc, modifiers, 178 /* SetAccessor */, 0 /* None */);
    }
    if (token() === 137 /* ConstructorKeyword */ || token() === 11 /* StringLiteral */) {
      const constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, modifiers);
      if (constructorDeclaration) {
        return constructorDeclaration;
      }
    }
    if (isIndexSignature()) {
      return parseIndexSignatureDeclaration(pos, hasJSDoc, modifiers);
    }
    if (tokenIsIdentifierOrKeyword(token()) || token() === 11 /* StringLiteral */ || token() === 9 /* NumericLiteral */ || token() === 10 /* BigIntLiteral */ || token() === 42 /* AsteriskToken */ || token() === 23 /* OpenBracketToken */) {
      const isAmbient = some(modifiers, isDeclareModifier);
      if (isAmbient) {
        for (const m of modifiers) {
          m.flags |= 33554432 /* Ambient */;
        }
        return doInsideOfContext(33554432 /* Ambient */, () => parsePropertyOrMethodDeclaration(pos, hasJSDoc, modifiers));
      } else {
        return parsePropertyOrMethodDeclaration(pos, hasJSDoc, modifiers);
      }
    }
    if (modifiers) {
      const name = createMissingNode(
        80 /* Identifier */,
        /*reportAtCurrentPosition*/
        true,
        Diagnostics.Declaration_expected
      );
      return parsePropertyDeclaration(
        pos,
        hasJSDoc,
        modifiers,
        name,
        /*questionToken*/
        void 0
      );
    }
    return Debug.fail("Should not have attempted to parse class member declaration.");
  }
  function parseDecoratedExpression() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    const modifiers = parseModifiers(
      /*allowDecorators*/
      true
    );
    if (token() === 86 /* ClassKeyword */) {
      return parseClassDeclarationOrExpression(pos, hasJSDoc, modifiers, 231 /* ClassExpression */);
    }
    const missing = createMissingNode(
      282 /* MissingDeclaration */,
      /*reportAtCurrentPosition*/
      true,
      Diagnostics.Expression_expected
    );
    setTextRangePos(missing, pos);
    missing.modifiers = modifiers;
    return missing;
  }
  function parseClassExpression() {
    return parseClassDeclarationOrExpression(
      getNodePos(),
      hasPrecedingJSDocComment(),
      /*modifiers*/
      void 0,
      231 /* ClassExpression */
    );
  }
  function parseClassDeclaration(pos, hasJSDoc, modifiers) {
    return parseClassDeclarationOrExpression(pos, hasJSDoc, modifiers, 263 /* ClassDeclaration */);
  }
  function parseClassDeclarationOrExpression(pos, hasJSDoc, modifiers, kind) {
    const savedAwaitContext = inAwaitContext();
    parseExpected(86 /* ClassKeyword */);
    const name = parseNameOfClassDeclarationOrExpression();
    const typeParameters = parseTypeParameters();
    if (some(modifiers, isExportModifier)) setAwaitContext(
      /*value*/
      true
    );
    const heritageClauses = parseHeritageClauses();
    let members;
    if (parseExpected(19 /* OpenBraceToken */)) {
      members = parseClassMembers();
      parseExpected(20 /* CloseBraceToken */);
    } else {
      members = createMissingList();
    }
    setAwaitContext(savedAwaitContext);
    const node = kind === 263 /* ClassDeclaration */ ? factory2.createClassDeclaration(modifiers, name, typeParameters, heritageClauses, members) : factory2.createClassExpression(modifiers, name, typeParameters, heritageClauses, members);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseNameOfClassDeclarationOrExpression() {
    return isBindingIdentifier() && !isImplementsClause() ? createIdentifier(isBindingIdentifier()) : void 0;
  }
  function isImplementsClause() {
    return token() === 119 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword);
  }
  function parseHeritageClauses() {
    if (isHeritageClause2()) {
      return parseList(22 /* HeritageClauses */, parseHeritageClause);
    }
    return void 0;
  }
  function parseHeritageClause() {
    const pos = getNodePos();
    const tok = token();
    Debug.assert(tok === 96 /* ExtendsKeyword */ || tok === 119 /* ImplementsKeyword */);
    nextToken();
    const types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments);
    return finishNode(factory2.createHeritageClause(tok, types), pos);
  }
  function parseExpressionWithTypeArguments() {
    const pos = getNodePos();
    const expression = parseLeftHandSideExpressionOrHigher();
    if (expression.kind === 233 /* ExpressionWithTypeArguments */) {
      return expression;
    }
    const typeArguments = tryParseTypeArguments();
    return finishNode(factory2.createExpressionWithTypeArguments(expression, typeArguments), pos);
  }
  function tryParseTypeArguments() {
    return token() === 30 /* LessThanToken */ ? parseBracketedList(20 /* TypeArguments */, parseType, 30 /* LessThanToken */, 32 /* GreaterThanToken */) : void 0;
  }
  function isHeritageClause2() {
    return token() === 96 /* ExtendsKeyword */ || token() === 119 /* ImplementsKeyword */;
  }
  function parseClassMembers() {
    return parseList(5 /* ClassMembers */, parseClassElement);
  }
  function parseInterfaceDeclaration(pos, hasJSDoc, modifiers) {
    parseExpected(120 /* InterfaceKeyword */);
    const name = parseIdentifier();
    const typeParameters = parseTypeParameters();
    const heritageClauses = parseHeritageClauses();
    const members = parseObjectTypeMembers();
    const node = factory2.createInterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, members);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseTypeAliasDeclaration(pos, hasJSDoc, modifiers) {
    parseExpected(156 /* TypeKeyword */);
    if (scanner2.hasPrecedingLineBreak()) {
      parseErrorAtCurrentToken(Diagnostics.Line_break_not_permitted_here);
    }
    const name = parseIdentifier();
    const typeParameters = parseTypeParameters();
    parseExpected(64 /* EqualsToken */);
    const type = token() === 141 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType();
    parseSemicolon();
    const node = factory2.createTypeAliasDeclaration(modifiers, name, typeParameters, type);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseEnumMember() {
    const pos = getNodePos();
    const hasJSDoc = hasPrecedingJSDocComment();
    const name = parsePropertyName();
    const initializer = allowInAnd(parseInitializer);
    return withJSDoc(finishNode(factory2.createEnumMember(name, initializer), pos), hasJSDoc);
  }
  function parseEnumDeclaration(pos, hasJSDoc, modifiers) {
    parseExpected(94 /* EnumKeyword */);
    const name = parseIdentifier();
    let members;
    if (parseExpected(19 /* OpenBraceToken */)) {
      members = doOutsideOfYieldAndAwaitContext(() => parseDelimitedList(6 /* EnumMembers */, parseEnumMember));
      parseExpected(20 /* CloseBraceToken */);
    } else {
      members = createMissingList();
    }
    const node = factory2.createEnumDeclaration(modifiers, name, members);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseModuleBlock() {
    const pos = getNodePos();
    let statements;
    if (parseExpected(19 /* OpenBraceToken */)) {
      statements = parseList(1 /* BlockStatements */, parseStatement);
      parseExpected(20 /* CloseBraceToken */);
    } else {
      statements = createMissingList();
    }
    return finishNode(factory2.createModuleBlock(statements), pos);
  }
  function parseModuleOrNamespaceDeclaration(pos, hasJSDoc, modifiers, flags) {
    const namespaceFlag = flags & 32 /* Namespace */;
    const name = flags & 8 /* NestedNamespace */ ? parseIdentifierName() : parseIdentifier();
    const body = parseOptional(25 /* DotToken */) ? parseModuleOrNamespaceDeclaration(
      getNodePos(),
      /*hasJSDoc*/
      false,
      /*modifiers*/
      void 0,
      8 /* NestedNamespace */ | namespaceFlag
    ) : parseModuleBlock();
    const node = factory2.createModuleDeclaration(modifiers, name, body, flags);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, modifiersIn) {
    let flags = 0;
    let name;
    if (token() === 162 /* GlobalKeyword */) {
      name = parseIdentifier();
      flags |= 2048 /* GlobalAugmentation */;
    } else {
      name = parseLiteralNode();
      name.text = internIdentifier(name.text);
    }
    let body;
    if (token() === 19 /* OpenBraceToken */) {
      body = parseModuleBlock();
    } else {
      parseSemicolon();
    }
    const node = factory2.createModuleDeclaration(modifiersIn, name, body, flags);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseModuleDeclaration(pos, hasJSDoc, modifiersIn) {
    let flags = 0;
    if (token() === 162 /* GlobalKeyword */) {
      return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, modifiersIn);
    } else if (parseOptional(145 /* NamespaceKeyword */)) {
      flags |= 32 /* Namespace */;
    } else {
      parseExpected(144 /* ModuleKeyword */);
      if (token() === 11 /* StringLiteral */) {
        return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, modifiersIn);
      }
    }
    return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, modifiersIn, flags);
  }
  function isExternalModuleReference2() {
    return token() === 149 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen);
  }
  function nextTokenIsOpenParen() {
    return nextToken() === 21 /* OpenParenToken */;
  }
  function nextTokenIsOpenBrace() {
    return nextToken() === 19 /* OpenBraceToken */;
  }
  function nextTokenIsSlash() {
    return nextToken() === 44 /* SlashToken */;
  }
  function parseNamespaceExportDeclaration(pos, hasJSDoc, modifiers) {
    parseExpected(130 /* AsKeyword */);
    parseExpected(145 /* NamespaceKeyword */);
    const name = parseIdentifier();
    parseSemicolon();
    const node = factory2.createNamespaceExportDeclaration(name);
    node.modifiers = modifiers;
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, modifiers) {
    parseExpected(102 /* ImportKeyword */);
    const afterImportPos = scanner2.getTokenFullStart();
    let identifier;
    if (isIdentifier2()) {
      identifier = parseIdentifier();
    }
    let isTypeOnly = false;
    if ((identifier == null ? void 0 : identifier.escapedText) === "type" && (token() !== 161 /* FromKeyword */ || isIdentifier2() && lookAhead(nextTokenIsFromKeywordOrEqualsToken)) && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
      isTypeOnly = true;
      identifier = isIdentifier2() ? parseIdentifier() : void 0;
    }
    if (identifier && !tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration()) {
      return parseImportEqualsDeclaration(pos, hasJSDoc, modifiers, identifier, isTypeOnly);
    }
    const importClause = tryParseImportClause(identifier, afterImportPos, isTypeOnly);
    const moduleSpecifier = parseModuleSpecifier();
    const attributes = tryParseImportAttributes();
    parseSemicolon();
    const node = factory2.createImportDeclaration(modifiers, importClause, moduleSpecifier, attributes);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function tryParseImportClause(identifier, pos, isTypeOnly, skipJsDocLeadingAsterisks = false) {
    let importClause;
    if (identifier || // import id
    token() === 42 /* AsteriskToken */ || // import *
    token() === 19 /* OpenBraceToken */) {
      importClause = parseImportClause(identifier, pos, isTypeOnly, skipJsDocLeadingAsterisks);
      parseExpected(161 /* FromKeyword */);
    }
    return importClause;
  }
  function tryParseImportAttributes() {
    const currentToken2 = token();
    if ((currentToken2 === 118 /* WithKeyword */ || currentToken2 === 132 /* AssertKeyword */) && !scanner2.hasPrecedingLineBreak()) {
      return parseImportAttributes(currentToken2);
    }
  }
  function parseImportAttribute() {
    const pos = getNodePos();
    const name = tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(11 /* StringLiteral */);
    parseExpected(59 /* ColonToken */);
    const value = parseAssignmentExpressionOrHigher(
      /*allowReturnTypeInArrowFunction*/
      true
    );
    return finishNode(factory2.createImportAttribute(name, value), pos);
  }
  function parseImportAttributes(token2, skipKeyword) {
    const pos = getNodePos();
    if (!skipKeyword) {
      parseExpected(token2);
    }
    const openBracePosition = scanner2.getTokenStart();
    if (parseExpected(19 /* OpenBraceToken */)) {
      const multiLine = scanner2.hasPrecedingLineBreak();
      const elements = parseDelimitedList(
        24 /* ImportAttributes */,
        parseImportAttribute,
        /*considerSemicolonAsDelimiter*/
        true
      );
      if (!parseExpected(20 /* CloseBraceToken */)) {
        const lastError = lastOrUndefined(parseDiagnostics);
        if (lastError && lastError.code === Diagnostics._0_expected.code) {
          addRelatedInfo(
            lastError,
            createDetachedDiagnostic(fileName, sourceText, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
          );
        }
      }
      return finishNode(factory2.createImportAttributes(elements, multiLine, token2), pos);
    } else {
      const elements = createNodeArray(
        [],
        getNodePos(),
        /*end*/
        void 0,
        /*hasTrailingComma*/
        false
      );
      return finishNode(factory2.createImportAttributes(
        elements,
        /*multiLine*/
        false,
        token2
      ), pos);
    }
  }
  function tokenAfterImportDefinitelyProducesImportDeclaration() {
    return token() === 42 /* AsteriskToken */ || token() === 19 /* OpenBraceToken */;
  }
  function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() {
    return token() === 28 /* CommaToken */ || token() === 161 /* FromKeyword */;
  }
  function parseImportEqualsDeclaration(pos, hasJSDoc, modifiers, identifier, isTypeOnly) {
    parseExpected(64 /* EqualsToken */);
    const moduleReference = parseModuleReference();
    parseSemicolon();
    const node = factory2.createImportEqualsDeclaration(modifiers, isTypeOnly, identifier, moduleReference);
    const finished = withJSDoc(finishNode(node, pos), hasJSDoc);
    return finished;
  }
  function parseImportClause(identifier, pos, isTypeOnly, skipJsDocLeadingAsterisks) {
    let namedBindings;
    if (!identifier || parseOptional(28 /* CommaToken */)) {
      if (skipJsDocLeadingAsterisks) scanner2.setSkipJsDocLeadingAsterisks(true);
      namedBindings = token() === 42 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(275 /* NamedImports */);
      if (skipJsDocLeadingAsterisks) scanner2.setSkipJsDocLeadingAsterisks(false);
    }
    return finishNode(factory2.createImportClause(isTypeOnly, identifier, namedBindings), pos);
  }
  function parseModuleReference() {
    return isExternalModuleReference2() ? parseExternalModuleReference() : parseEntityName(
      /*allowReservedWords*/
      false
    );
  }
  function parseExternalModuleReference() {
    const pos = getNodePos();
    parseExpected(149 /* RequireKeyword */);
    parseExpected(21 /* OpenParenToken */);
    const expression = parseModuleSpecifier();
    parseExpected(22 /* CloseParenToken */);
    return finishNode(factory2.createExternalModuleReference(expression), pos);
  }
  function parseModuleSpecifier() {
    if (token() === 11 /* StringLiteral */) {
      const result = parseLiteralNode();
      result.text = internIdentifier(result.text);
      return result;
    } else {
      return parseExpression();
    }
  }
  function parseNamespaceImport() {
    const pos = getNodePos();
    parseExpected(42 /* AsteriskToken */);
    parseExpected(130 /* AsKeyword */);
    const name = parseIdentifier();
    return finishNode(factory2.createNamespaceImport(name), pos);
  }
  function canParseModuleExportName() {
    return tokenIsIdentifierOrKeyword(token()) || token() === 11 /* StringLiteral */;
  }
  function parseModuleExportName(parseName) {
    return token() === 11 /* StringLiteral */ ? parseLiteralNode() : parseName();
  }
  function parseNamedImportsOrExports(kind) {
    const pos = getNodePos();
    const node = kind === 275 /* NamedImports */ ? factory2.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 19 /* OpenBraceToken */, 20 /* CloseBraceToken */)) : factory2.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 19 /* OpenBraceToken */, 20 /* CloseBraceToken */));
    return finishNode(node, pos);
  }
  function parseExportSpecifier() {
    const hasJSDoc = hasPrecedingJSDocComment();
    return withJSDoc(parseImportOrExportSpecifier(281 /* ExportSpecifier */), hasJSDoc);
  }
  function parseImportSpecifier() {
    return parseImportOrExportSpecifier(276 /* ImportSpecifier */);
  }
  function parseImportOrExportSpecifier(kind) {
    const pos = getNodePos();
    let checkIdentifierIsKeyword = isKeyword(token()) && !isIdentifier2();
    let checkIdentifierStart = scanner2.getTokenStart();
    let checkIdentifierEnd = scanner2.getTokenEnd();
    let isTypeOnly = false;
    let propertyName;
    let canParseAsKeyword = true;
    let name = parseModuleExportName(parseIdentifierName);
    if (name.kind === 80 /* Identifier */ && name.escapedText === "type") {
      if (token() === 130 /* AsKeyword */) {
        const firstAs = parseIdentifierName();
        if (token() === 130 /* AsKeyword */) {
          const secondAs = parseIdentifierName();
          if (canParseModuleExportName()) {
            isTypeOnly = true;
            propertyName = firstAs;
            name = parseModuleExportName(parseNameWithKeywordCheck);
            canParseAsKeyword = false;
          } else {
            propertyName = name;
            name = secondAs;
            canParseAsKeyword = false;
          }
        } else if (canParseModuleExportName()) {
          propertyName = name;
          canParseAsKeyword = false;
          name = parseModuleExportName(parseNameWithKeywordCheck);
        } else {
          isTypeOnly = true;
          name = firstAs;
        }
      } else if (canParseModuleExportName()) {
        isTypeOnly = true;
        name = parseModuleExportName(parseNameWithKeywordCheck);
      }
    }
    if (canParseAsKeyword && token() === 130 /* AsKeyword */) {
      propertyName = name;
      parseExpected(130 /* AsKeyword */);
      name = parseModuleExportName(parseNameWithKeywordCheck);
    }
    if (kind === 276 /* ImportSpecifier */) {
      if (name.kind !== 80 /* Identifier */) {
        parseErrorAt(skipTrivia(sourceText, name.pos), name.end, Diagnostics.Identifier_expected);
        name = setTextRangePosEnd(createMissingNode(
          80 /* Identifier */,
          /*reportAtCurrentPosition*/
          false
        ), name.pos, name.pos);
      } else if (checkIdentifierIsKeyword) {
        parseErrorAt(checkIdentifierStart, checkIdentifierEnd, Diagnostics.Identifier_expected);
      }
    }
    const node = kind === 276 /* ImportSpecifier */ ? factory2.createImportSpecifier(isTypeOnly, propertyName, name) : factory2.createExportSpecifier(isTypeOnly, propertyName, name);
    return finishNode(node, pos);
    function parseNameWithKeywordCheck() {
      checkIdentifierIsKeyword = isKeyword(token()) && !isIdentifier2();
      checkIdentifierStart = scanner2.getTokenStart();
      checkIdentifierEnd = scanner2.getTokenEnd();
      return parseIdentifierName();
    }
  }
  function parseNamespaceExport(pos) {
    return finishNode(factory2.createNamespaceExport(parseModuleExportName(parseIdentifierName)), pos);
  }
  function parseExportDeclaration(pos, hasJSDoc, modifiers) {
    const savedAwaitContext = inAwaitContext();
    setAwaitContext(
      /*value*/
      true
    );
    let exportClause;
    let moduleSpecifier;
    let attributes;
    const isTypeOnly = parseOptional(156 /* TypeKeyword */);
    const namespaceExportPos = getNodePos();
    if (parseOptional(42 /* AsteriskToken */)) {
      if (parseOptional(130 /* AsKeyword */)) {
        exportClause = parseNamespaceExport(namespaceExportPos);
      }
      parseExpected(161 /* FromKeyword */);
      moduleSpecifier = parseModuleSpecifier();
    } else {
      exportClause = parseNamedImportsOrExports(279 /* NamedExports */);
      if (token() === 161 /* FromKeyword */ || token() === 11 /* StringLiteral */ && !scanner2.hasPrecedingLineBreak()) {
        parseExpected(161 /* FromKeyword */);
        moduleSpecifier = parseModuleSpecifier();
      }
    }
    const currentToken2 = token();
    if (moduleSpecifier && (currentToken2 === 118 /* WithKeyword */ || currentToken2 === 132 /* AssertKeyword */) && !scanner2.hasPrecedingLineBreak()) {
      attributes = parseImportAttributes(currentToken2);
    }
    parseSemicolon();
    setAwaitContext(savedAwaitContext);
    const node = factory2.createExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, attributes);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  function parseExportAssignment(pos, hasJSDoc, modifiers) {
    const savedAwaitContext = inAwaitContext();
    setAwaitContext(
      /*value*/
      true
    );
    let isExportEquals;
    if (parseOptional(64 /* EqualsToken */)) {
      isExportEquals = true;
    } else {
      parseExpected(90 /* DefaultKeyword */);
    }
    const expression = parseAssignmentExpressionOrHigher(
      /*allowReturnTypeInArrowFunction*/
      true
    );
    parseSemicolon();
    setAwaitContext(savedAwaitContext);
    const node = factory2.createExportAssignment(modifiers, isExportEquals, expression);
    return withJSDoc(finishNode(node, pos), hasJSDoc);
  }
  let ParsingContext;
  ((ParsingContext2) => {
    ParsingContext2[ParsingContext2["SourceElements"] = 0] = "SourceElements";
    ParsingContext2[ParsingContext2["BlockStatements"] = 1] = "BlockStatements";
    ParsingContext2[ParsingContext2["SwitchClauses"] = 2] = "SwitchClauses";
    ParsingContext2[ParsingContext2["SwitchClauseStatements"] = 3] = "SwitchClauseStatements";
    ParsingContext2[ParsingContext2["TypeMembers"] = 4] = "TypeMembers";
    ParsingContext2[ParsingContext2["ClassMembers"] = 5] = "ClassMembers";
    ParsingContext2[ParsingContext2["EnumMembers"] = 6] = "EnumMembers";
    ParsingContext2[ParsingContext2["HeritageClauseElement"] = 7] = "HeritageClauseElement";
    ParsingContext2[ParsingContext2["VariableDeclarations"] = 8] = "VariableDeclarations";
    ParsingContext2[ParsingContext2["ObjectBindingElements"] = 9] = "ObjectBindingElements";
    ParsingContext2[ParsingContext2["ArrayBindingElements"] = 10] = "ArrayBindingElements";
    ParsingContext2[ParsingContext2["ArgumentExpressions"] = 11] = "ArgumentExpressions";
    ParsingContext2[ParsingContext2["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers";
    ParsingContext2[ParsingContext2["JsxAttributes"] = 13] = "JsxAttributes";
    ParsingContext2[ParsingContext2["JsxChildren"] = 14] = "JsxChildren";
    ParsingContext2[ParsingContext2["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers";
    ParsingContext2[ParsingContext2["Parameters"] = 16] = "Parameters";
    ParsingContext2[ParsingContext2["JSDocParameters"] = 17] = "JSDocParameters";
    ParsingContext2[ParsingContext2["RestProperties"] = 18] = "RestProperties";
    ParsingContext2[ParsingContext2["TypeParameters"] = 19] = "TypeParameters";
    ParsingContext2[ParsingContext2["TypeArguments"] = 20] = "TypeArguments";
    ParsingContext2[ParsingContext2["TupleElementTypes"] = 21] = "TupleElementTypes";
    ParsingContext2[ParsingContext2["HeritageClauses"] = 22] = "HeritageClauses";
    ParsingContext2[ParsingContext2["ImportOrExportSpecifiers"] = 23] = "ImportOrExportSpecifiers";
    ParsingContext2[ParsingContext2["ImportAttributes"] = 24] = "ImportAttributes";
    ParsingContext2[ParsingContext2["JSDocComment"] = 25] = "JSDocComment";
    ParsingContext2[ParsingContext2["Count"] = 26] = "Count";
  })(ParsingContext || (ParsingContext = {}));
  let Tristate;
  ((Tristate2) => {
    Tristate2[Tristate2["False"] = 0] = "False";
    Tristate2[Tristate2["True"] = 1] = "True";
    Tristate2[Tristate2["Unknown"] = 2] = "Unknown";
  })(Tristate || (Tristate = {}));
  let JSDocParser;
  ((JSDocParser2) => {
    function parseJSDocTypeExpressionForTests2(content, start, length2) {
      initializeState(
        "file.js",
        content,
        99 /* Latest */,
        /*syntaxCursor*/
        void 0,
        1 /* JS */,
        0 /* ParseAll */
      );
      scanner2.setText(content, start, length2);
      currentToken = scanner2.scan();
      const jsDocTypeExpression = parseJSDocTypeExpression();
      const sourceFile = createSourceFile2(
        "file.js",
        99 /* Latest */,
        1 /* JS */,
        /*isDeclarationFile*/
        false,
        [],
        factoryCreateToken(1 /* EndOfFileToken */),
        0 /* None */,
        noop
      );
      const diagnostics = attachFileToDiagnostics(parseDiagnostics, sourceFile);
      if (jsDocDiagnostics) {
        sourceFile.jsDocDiagnostics = attachFileToDiagnostics(jsDocDiagnostics, sourceFile);
      }
      clearState();
      return jsDocTypeExpression ? { jsDocTypeExpression, diagnostics } : void 0;
    }
    JSDocParser2.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests2;
    function parseJSDocTypeExpression(mayOmitBraces) {
      const pos = getNodePos();
      const hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(19 /* OpenBraceToken */);
      const type = doInsideOfContext(16777216 /* JSDoc */, parseJSDocType);
      if (!mayOmitBraces || hasBrace) {
        parseExpectedJSDoc(20 /* CloseBraceToken */);
      }
      const result = factory2.createJSDocTypeExpression(type);
      fixupParentReferences(result);
      return finishNode(result, pos);
    }
    JSDocParser2.parseJSDocTypeExpression = parseJSDocTypeExpression;
    function parseJSDocNameReference() {
      const pos = getNodePos();
      const hasBrace = parseOptional(19 /* OpenBraceToken */);
      const p2 = getNodePos();
      let entityName = parseEntityName(
        /*allowReservedWords*/
        false
      );
      while (token() === 81 /* PrivateIdentifier */) {
        reScanHashToken();
        nextTokenJSDoc();
        entityName = finishNode(factory2.createJSDocMemberName(entityName, parseIdentifier()), p2);
      }
      if (hasBrace) {
        parseExpectedJSDoc(20 /* CloseBraceToken */);
      }
      const result = factory2.createJSDocNameReference(entityName);
      fixupParentReferences(result);
      return finishNode(result, pos);
    }
    JSDocParser2.parseJSDocNameReference = parseJSDocNameReference;
    function parseIsolatedJSDocComment2(content, start, length2) {
      initializeState(
        "",
        content,
        99 /* Latest */,
        /*syntaxCursor*/
        void 0,
        1 /* JS */,
        0 /* ParseAll */
      );
      const jsDoc = doInsideOfContext(16777216 /* JSDoc */, () => parseJSDocCommentWorker(start, length2));
      const sourceFile = { languageVariant: 0 /* Standard */, text: content };
      const diagnostics = attachFileToDiagnostics(parseDiagnostics, sourceFile);
      clearState();
      return jsDoc ? { jsDoc, diagnostics } : void 0;
    }
    JSDocParser2.parseIsolatedJSDocComment = parseIsolatedJSDocComment2;
    function parseJSDocComment(parent2, start, length2) {
      const saveToken = currentToken;
      const saveParseDiagnosticsLength = parseDiagnostics.length;
      const saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
      const comment = doInsideOfContext(16777216 /* JSDoc */, () => parseJSDocCommentWorker(start, length2));
      setParent(comment, parent2);
      if (contextFlags & 524288 /* JavaScriptFile */) {
        if (!jsDocDiagnostics) {
          jsDocDiagnostics = [];
        }
        addRange(jsDocDiagnostics, parseDiagnostics, saveParseDiagnosticsLength);
      }
      currentToken = saveToken;
      parseDiagnostics.length = saveParseDiagnosticsLength;
      parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
      return comment;
    }
    JSDocParser2.parseJSDocComment = parseJSDocComment;
    let JSDocState;
    ((JSDocState2) => {
      JSDocState2[JSDocState2["BeginningOfLine"] = 0] = "BeginningOfLine";
      JSDocState2[JSDocState2["SawAsterisk"] = 1] = "SawAsterisk";
      JSDocState2[JSDocState2["SavingComments"] = 2] = "SavingComments";
      JSDocState2[JSDocState2["SavingBackticks"] = 3] = "SavingBackticks";
    })(JSDocState || (JSDocState = {}));
    let PropertyLikeParse;
    ((PropertyLikeParse2) => {
      PropertyLikeParse2[PropertyLikeParse2["Property"] = 1] = "Property";
      PropertyLikeParse2[PropertyLikeParse2["Parameter"] = 2] = "Parameter";
      PropertyLikeParse2[PropertyLikeParse2["CallbackParameter"] = 4] = "CallbackParameter";
    })(PropertyLikeParse || (PropertyLikeParse = {}));
    function parseJSDocCommentWorker(start = 0, length2) {
      const content = sourceText;
      const end = length2 === void 0 ? content.length : start + length2;
      length2 = end - start;
      Debug.assert(start >= 0);
      Debug.assert(start <= end);
      Debug.assert(end <= content.length);
      if (!isJSDocLikeText(content, start)) {
        return void 0;
      }
      let tags;
      let tagsPos;
      let tagsEnd;
      let linkEnd;
      let commentsPos;
      let comments = [];
      const parts = [];
      const saveParsingContext = parsingContext;
      parsingContext |= 1 << 25 /* JSDocComment */;
      const result = scanner2.scanRange(start + 3, length2 - 5, doJSDocScan);
      parsingContext = saveParsingContext;
      return result;
      function doJSDocScan() {
        let state = 1 /* SawAsterisk */;
        let margin;
        let indent3 = start - (content.lastIndexOf("\n", start) + 1) + 4;
        function pushComment(text) {
          if (!margin) {
            margin = indent3;
          }
          comments.push(text);
          indent3 += text.length;
        }
        nextTokenJSDoc();
        while (parseOptionalJsdoc(5 /* WhitespaceTrivia */)) ;
        if (parseOptionalJsdoc(4 /* NewLineTrivia */)) {
          state = 0 /* BeginningOfLine */;
          indent3 = 0;
        }
        loop:
          while (true) {
            switch (token()) {
              case 60 /* AtToken */:
                removeTrailingWhitespace(comments);
                if (!commentsPos) commentsPos = getNodePos();
                addTag(parseTag(indent3));
                state = 0 /* BeginningOfLine */;
                margin = void 0;
                break;
              case 4 /* NewLineTrivia */:
                comments.push(scanner2.getTokenText());
                state = 0 /* BeginningOfLine */;
                indent3 = 0;
                break;
              case 42 /* AsteriskToken */:
                const asterisk = scanner2.getTokenText();
                if (state === 1 /* SawAsterisk */) {
                  state = 2 /* SavingComments */;
                  pushComment(asterisk);
                } else {
                  Debug.assert(state === 0 /* BeginningOfLine */);
                  state = 1 /* SawAsterisk */;
                  indent3 += asterisk.length;
                }
                break;
              case 5 /* WhitespaceTrivia */:
                Debug.assert(state !== 2 /* SavingComments */, "whitespace shouldn't come from the scanner while saving top-level comment text");
                const whitespace = scanner2.getTokenText();
                if (margin !== void 0 && indent3 + whitespace.length > margin) {
                  comments.push(whitespace.slice(margin - indent3));
                }
                indent3 += whitespace.length;
                break;
              case 1 /* EndOfFileToken */:
                break loop;
              case 82 /* JSDocCommentTextToken */:
                state = 2 /* SavingComments */;
                pushComment(scanner2.getTokenValue());
                break;
              case 19 /* OpenBraceToken */:
                state = 2 /* SavingComments */;
                const commentEnd = scanner2.getTokenFullStart();
                const linkStart = scanner2.getTokenEnd() - 1;
                const link = parseJSDocLink(linkStart);
                if (link) {
                  if (!linkEnd) {
                    removeLeadingNewlines(comments);
                  }
                  parts.push(finishNode(factory2.createJSDocText(comments.join("")), linkEnd ?? start, commentEnd));
                  parts.push(link);
                  comments = [];
                  linkEnd = scanner2.getTokenEnd();
                  break;
                }
              // fallthrough if it's not a {@link sequence
              default:
                state = 2 /* SavingComments */;
                pushComment(scanner2.getTokenText());
                break;
            }
            if (state === 2 /* SavingComments */) {
              nextJSDocCommentTextToken(
                /*inBackticks*/
                false
              );
            } else {
              nextTokenJSDoc();
            }
          }
        const trimmedComments = comments.join("").trimEnd();
        if (parts.length && trimmedComments.length) {
          parts.push(finishNode(factory2.createJSDocText(trimmedComments), linkEnd ?? start, commentsPos));
        }
        if (parts.length && tags) Debug.assertIsDefined(commentsPos, "having parsed tags implies that the end of the comment span should be set");
        const tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd);
        return finishNode(factory2.createJSDocComment(parts.length ? createNodeArray(parts, start, commentsPos) : trimmedComments.length ? trimmedComments : void 0, tagsArray), start, end);
      }
      function removeLeadingNewlines(comments2) {
        while (comments2.length && (comments2[0] === "\n" || comments2[0] === "\r")) {
          comments2.shift();
        }
      }
      function removeTrailingWhitespace(comments2) {
        while (comments2.length) {
          const trimmed = comments2[comments2.length - 1].trimEnd();
          if (trimmed === "") {
            comments2.pop();
          } else if (trimmed.length < comments2[comments2.length - 1].length) {
            comments2[comments2.length - 1] = trimmed;
            break;
          } else {
            break;
          }
        }
      }
      function isNextNonwhitespaceTokenEndOfFile() {
        while (true) {
          nextTokenJSDoc();
          if (token() === 1 /* EndOfFileToken */) {
            return true;
          }
          if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) {
            return false;
          }
        }
      }
      function skipWhitespace() {
        if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
          if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
            return;
          }
        }
        while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
          nextTokenJSDoc();
        }
      }
      function skipWhitespaceOrAsterisk() {
        if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
          if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
            return "";
          }
        }
        let precedingLineBreak = scanner2.hasPrecedingLineBreak();
        let seenLineBreak = false;
        let indentText = "";
        while (precedingLineBreak && token() === 42 /* AsteriskToken */ || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) {
          indentText += scanner2.getTokenText();
          if (token() === 4 /* NewLineTrivia */) {
            precedingLineBreak = true;
            seenLineBreak = true;
            indentText = "";
          } else if (token() === 42 /* AsteriskToken */) {
            precedingLineBreak = false;
          }
          nextTokenJSDoc();
        }
        return seenLineBreak ? indentText : "";
      }
      function parseTag(margin) {
        Debug.assert(token() === 60 /* AtToken */);
        const start2 = scanner2.getTokenStart();
        nextTokenJSDoc();
        const tagName = parseJSDocIdentifierName(
          /*message*/
          void 0
        );
        const indentText = skipWhitespaceOrAsterisk();
        let tag;
        switch (tagName.escapedText) {
          case "author":
            tag = parseAuthorTag(start2, tagName, margin, indentText);
            break;
          case "implements":
            tag = parseImplementsTag(start2, tagName, margin, indentText);
            break;
          case "augments":
          case "extends":
            tag = parseAugmentsTag(start2, tagName, margin, indentText);
            break;
          case "class":
          case "constructor":
            tag = parseSimpleTag(start2, factory2.createJSDocClassTag, tagName, margin, indentText);
            break;
          case "public":
            tag = parseSimpleTag(start2, factory2.createJSDocPublicTag, tagName, margin, indentText);
            break;
          case "private":
            tag = parseSimpleTag(start2, factory2.createJSDocPrivateTag, tagName, margin, indentText);
            break;
          case "protected":
            tag = parseSimpleTag(start2, factory2.createJSDocProtectedTag, tagName, margin, indentText);
            break;
          case "readonly":
            tag = parseSimpleTag(start2, factory2.createJSDocReadonlyTag, tagName, margin, indentText);
            break;
          case "override":
            tag = parseSimpleTag(start2, factory2.createJSDocOverrideTag, tagName, margin, indentText);
            break;
          case "deprecated":
            hasDeprecatedTag = true;
            tag = parseSimpleTag(start2, factory2.createJSDocDeprecatedTag, tagName, margin, indentText);
            break;
          case "this":
            tag = parseThisTag(start2, tagName, margin, indentText);
            break;
          case "enum":
            tag = parseEnumTag(start2, tagName, margin, indentText);
            break;
          case "arg":
          case "argument":
          case "param":
            return parseParameterOrPropertyTag(start2, tagName, 2 /* Parameter */, margin);
          case "return":
          case "returns":
            tag = parseReturnTag(start2, tagName, margin, indentText);
            break;
          case "template":
            tag = parseTemplateTag(start2, tagName, margin, indentText);
            break;
          case "type":
            tag = parseTypeTag(start2, tagName, margin, indentText);
            break;
          case "typedef":
            tag = parseTypedefTag(start2, tagName, margin, indentText);
            break;
          case "callback":
            tag = parseCallbackTag(start2, tagName, margin, indentText);
            break;
          case "overload":
            tag = parseOverloadTag(start2, tagName, margin, indentText);
            break;
          case "satisfies":
            tag = parseSatisfiesTag(start2, tagName, margin, indentText);
            break;
          case "see":
            tag = parseSeeTag(start2, tagName, margin, indentText);
            break;
          case "exception":
          case "throws":
            tag = parseThrowsTag(start2, tagName, margin, indentText);
            break;
          case "import":
            tag = parseImportTag(start2, tagName, margin, indentText);
            break;
          default:
            tag = parseUnknownTag(start2, tagName, margin, indentText);
            break;
        }
        return tag;
      }
      function parseTrailingTagComments(pos, end2, margin, indentText) {
        if (!indentText) {
          margin += end2 - pos;
        }
        return parseTagComments(margin, indentText.slice(margin));
      }
      function parseTagComments(indent3, initialMargin) {
        const commentsPos2 = getNodePos();
        let comments2 = [];
        const parts2 = [];
        let linkEnd2;
        let state = 0 /* BeginningOfLine */;
        let margin;
        function pushComment(text) {
          if (!margin) {
            margin = indent3;
          }
          comments2.push(text);
          indent3 += text.length;
        }
        if (initialMargin !== void 0) {
          if (initialMargin !== "") {
            pushComment(initialMargin);
          }
          state = 1 /* SawAsterisk */;
        }
        let tok = token();
        loop:
          while (true) {
            switch (tok) {
              case 4 /* NewLineTrivia */:
                state = 0 /* BeginningOfLine */;
                comments2.push(scanner2.getTokenText());
                indent3 = 0;
                break;
              case 60 /* AtToken */:
                scanner2.resetTokenState(scanner2.getTokenEnd() - 1);
                break loop;
              case 1 /* EndOfFileToken */:
                break loop;
              case 5 /* WhitespaceTrivia */:
                Debug.assert(state !== 2 /* SavingComments */ && state !== 3 /* SavingBackticks */, "whitespace shouldn't come from the scanner while saving comment text");
                const whitespace = scanner2.getTokenText();
                if (margin !== void 0 && indent3 + whitespace.length > margin) {
                  comments2.push(whitespace.slice(margin - indent3));
                  state = 2 /* SavingComments */;
                }
                indent3 += whitespace.length;
                break;
              case 19 /* OpenBraceToken */:
                state = 2 /* SavingComments */;
                const commentEnd = scanner2.getTokenFullStart();
                const linkStart = scanner2.getTokenEnd() - 1;
                const link = parseJSDocLink(linkStart);
                if (link) {
                  parts2.push(finishNode(factory2.createJSDocText(comments2.join("")), linkEnd2 ?? commentsPos2, commentEnd));
                  parts2.push(link);
                  comments2 = [];
                  linkEnd2 = scanner2.getTokenEnd();
                } else {
                  pushComment(scanner2.getTokenText());
                }
                break;
              case 62 /* BacktickToken */:
                if (state === 3 /* SavingBackticks */) {
                  state = 2 /* SavingComments */;
                } else {
                  state = 3 /* SavingBackticks */;
                }
                pushComment(scanner2.getTokenText());
                break;
              case 82 /* JSDocCommentTextToken */:
                if (state !== 3 /* SavingBackticks */) {
                  state = 2 /* SavingComments */;
                }
                pushComment(scanner2.getTokenValue());
                break;
              case 42 /* AsteriskToken */:
                if (state === 0 /* BeginningOfLine */) {
                  state = 1 /* SawAsterisk */;
                  indent3 += 1;
                  break;
                }
              // record the * as a comment
              // falls through
              default:
                if (state !== 3 /* SavingBackticks */) {
                  state = 2 /* SavingComments */;
                }
                pushComment(scanner2.getTokenText());
                break;
            }
            if (state === 2 /* SavingComments */ || state === 3 /* SavingBackticks */) {
              tok = nextJSDocCommentTextToken(state === 3 /* SavingBackticks */);
            } else {
              tok = nextTokenJSDoc();
            }
          }
        removeLeadingNewlines(comments2);
        const trimmedComments = comments2.join("").trimEnd();
        if (parts2.length) {
          if (trimmedComments.length) {
            parts2.push(finishNode(factory2.createJSDocText(trimmedComments), linkEnd2 ?? commentsPos2));
          }
          return createNodeArray(parts2, commentsPos2, scanner2.getTokenEnd());
        } else if (trimmedComments.length) {
          return trimmedComments;
        }
      }
      function parseJSDocLink(start2) {
        const linkType = tryParse(parseJSDocLinkPrefix);
        if (!linkType) {
          return void 0;
        }
        nextTokenJSDoc();
        skipWhitespace();
        const name = parseJSDocLinkName();
        const text = [];
        while (token() !== 20 /* CloseBraceToken */ && token() !== 4 /* NewLineTrivia */ && token() !== 1 /* EndOfFileToken */) {
          text.push(scanner2.getTokenText());
          nextTokenJSDoc();
        }
        const create = linkType === "link" ? factory2.createJSDocLink : linkType === "linkcode" ? factory2.createJSDocLinkCode : factory2.createJSDocLinkPlain;
        return finishNode(create(name, text.join("")), start2, scanner2.getTokenEnd());
      }
      function parseJSDocLinkName() {
        if (tokenIsIdentifierOrKeyword(token())) {
          const pos = getNodePos();
          let name = parseIdentifierName();
          while (parseOptional(25 /* DotToken */)) {
            name = finishNode(factory2.createQualifiedName(name, token() === 81 /* PrivateIdentifier */ ? createMissingNode(
              80 /* Identifier */,
              /*reportAtCurrentPosition*/
              false
            ) : parseIdentifierName()), pos);
          }
          while (token() === 81 /* PrivateIdentifier */) {
            reScanHashToken();
            nextTokenJSDoc();
            name = finishNode(factory2.createJSDocMemberName(name, parseIdentifier()), pos);
          }
          return name;
        }
        return void 0;
      }
      function parseJSDocLinkPrefix() {
        skipWhitespaceOrAsterisk();
        if (token() === 19 /* OpenBraceToken */ && nextTokenJSDoc() === 60 /* AtToken */ && tokenIsIdentifierOrKeyword(nextTokenJSDoc())) {
          const kind = scanner2.getTokenValue();
          if (isJSDocLinkTag(kind)) return kind;
        }
      }
      function isJSDocLinkTag(kind) {
        return kind === "link" || kind === "linkcode" || kind === "linkplain";
      }
      function parseUnknownTag(start2, tagName, indent3, indentText) {
        return finishNode(factory2.createJSDocUnknownTag(tagName, parseTrailingTagComments(start2, getNodePos(), indent3, indentText)), start2);
      }
      function addTag(tag) {
        if (!tag) {
          return;
        }
        if (!tags) {
          tags = [tag];
          tagsPos = tag.pos;
        } else {
          tags.push(tag);
        }
        tagsEnd = tag.end;
      }
      function tryParseTypeExpression() {
        skipWhitespaceOrAsterisk();
        return token() === 19 /* OpenBraceToken */ ? parseJSDocTypeExpression() : void 0;
      }
      function parseBracketNameInPropertyAndParamTag() {
        const isBracketed = parseOptionalJsdoc(23 /* OpenBracketToken */);
        if (isBracketed) {
          skipWhitespace();
        }
        const isBackquoted = parseOptionalJsdoc(62 /* BacktickToken */);
        const name = parseJSDocEntityName();
        if (isBackquoted) {
          parseExpectedTokenJSDoc(62 /* BacktickToken */);
        }
        if (isBracketed) {
          skipWhitespace();
          if (parseOptionalToken(64 /* EqualsToken */)) {
            parseExpression();
          }
          parseExpected(24 /* CloseBracketToken */);
        }
        return { name, isBracketed };
      }
      function isObjectOrObjectArrayTypeReference(node) {
        switch (node.kind) {
          case 151 /* ObjectKeyword */:
            return true;
          case 188 /* ArrayType */:
            return isObjectOrObjectArrayTypeReference(node.elementType);
          default:
            return isTypeReferenceNode(node) && isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments;
        }
      }
      function parseParameterOrPropertyTag(start2, tagName, target, indent3) {
        let typeExpression = tryParseTypeExpression();
        let isNameFirst = !typeExpression;
        skipWhitespaceOrAsterisk();
        const { name, isBracketed } = parseBracketNameInPropertyAndParamTag();
        const indentText = skipWhitespaceOrAsterisk();
        if (isNameFirst && !lookAhead(parseJSDocLinkPrefix)) {
          typeExpression = tryParseTypeExpression();
        }
        const comment = parseTrailingTagComments(start2, getNodePos(), indent3, indentText);
        const nestedTypeLiteral = parseNestedTypeLiteral(typeExpression, name, target, indent3);
        if (nestedTypeLiteral) {
          typeExpression = nestedTypeLiteral;
          isNameFirst = true;
        }
        const result2 = target === 1 /* Property */ ? factory2.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) : factory2.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment);
        return finishNode(result2, start2);
      }
      function parseNestedTypeLiteral(typeExpression, name, target, indent3) {
        if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) {
          const pos = getNodePos();
          let child;
          let children;
          while (child = tryParse(() => parseChildParameterOrPropertyTag(target, indent3, name))) {
            if (child.kind === 341 /* JSDocParameterTag */ || child.kind === 348 /* JSDocPropertyTag */) {
              children = append(children, child);
            } else if (child.kind === 345 /* JSDocTemplateTag */) {
              parseErrorAtRange(child.tagName, Diagnostics.A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag);
            }
          }
          if (children) {
            const literal = finishNode(factory2.createJSDocTypeLiteral(children, typeExpression.type.kind === 188 /* ArrayType */), pos);
            return finishNode(factory2.createJSDocTypeExpression(literal), pos);
          }
        }
      }
      function parseReturnTag(start2, tagName, indent3, indentText) {
        if (some(tags, isJSDocReturnTag)) {
          parseErrorAt(tagName.pos, scanner2.getTokenStart(), Diagnostics._0_tag_already_specified, unescapeLeadingUnderscores(tagName.escapedText));
        }
        const typeExpression = tryParseTypeExpression();
        return finishNode(factory2.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start2, getNodePos(), indent3, indentText)), start2);
      }
      function parseTypeTag(start2, tagName, indent3, indentText) {
        if (some(tags, isJSDocTypeTag)) {
          parseErrorAt(tagName.pos, scanner2.getTokenStart(), Diagnostics._0_tag_already_specified, unescapeLeadingUnderscores(tagName.escapedText));
        }
        const typeExpression = parseJSDocTypeExpression(
          /*mayOmitBraces*/
          true
        );
        const comments2 = indent3 !== void 0 && indentText !== void 0 ? parseTrailingTagComments(start2, getNodePos(), indent3, indentText) : void 0;
        return finishNode(factory2.createJSDocTypeTag(tagName, typeExpression, comments2), start2);
      }
      function parseSeeTag(start2, tagName, indent3, indentText) {
        const isMarkdownOrJSDocLink = token() === 23 /* OpenBracketToken */ || lookAhead(() => nextTokenJSDoc() === 60 /* AtToken */ && tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner2.getTokenValue()));
        const nameExpression = isMarkdownOrJSDocLink ? void 0 : parseJSDocNameReference();
        const comments2 = indent3 !== void 0 && indentText !== void 0 ? parseTrailingTagComments(start2, getNodePos(), indent3, indentText) : void 0;
        return finishNode(factory2.createJSDocSeeTag(tagName, nameExpression, comments2), start2);
      }
      function parseThrowsTag(start2, tagName, indent3, indentText) {
        const typeExpression = tryParseTypeExpression();
        const comment = parseTrailingTagComments(start2, getNodePos(), indent3, indentText);
        return finishNode(factory2.createJSDocThrowsTag(tagName, typeExpression, comment), start2);
      }
      function parseAuthorTag(start2, tagName, indent3, indentText) {
        const commentStart = getNodePos();
        const textOnly = parseAuthorNameAndEmail();
        let commentEnd = scanner2.getTokenFullStart();
        const comments2 = parseTrailingTagComments(start2, commentEnd, indent3, indentText);
        if (!comments2) {
          commentEnd = scanner2.getTokenFullStart();
        }
        const allParts = typeof comments2 !== "string" ? createNodeArray(concatenate([finishNode(textOnly, commentStart, commentEnd)], comments2), commentStart) : textOnly.text + comments2;
        return finishNode(factory2.createJSDocAuthorTag(tagName, allParts), start2);
      }
      function parseAuthorNameAndEmail() {
        const comments2 = [];
        let inEmail = false;
        let token2 = scanner2.getToken();
        while (token2 !== 1 /* EndOfFileToken */ && token2 !== 4 /* NewLineTrivia */) {
          if (token2 === 30 /* LessThanToken */) {
            inEmail = true;
          } else if (token2 === 60 /* AtToken */ && !inEmail) {
            break;
          } else if (token2 === 32 /* GreaterThanToken */ && inEmail) {
            comments2.push(scanner2.getTokenText());
            scanner2.resetTokenState(scanner2.getTokenEnd());
            break;
          }
          comments2.push(scanner2.getTokenText());
          token2 = nextTokenJSDoc();
        }
        return factory2.createJSDocText(comments2.join(""));
      }
      function parseImplementsTag(start2, tagName, margin, indentText) {
        const className = parseExpressionWithTypeArgumentsForAugments();
        return finishNode(factory2.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start2, getNodePos(), margin, indentText)), start2);
      }
      function parseAugmentsTag(start2, tagName, margin, indentText) {
        const className = parseExpressionWithTypeArgumentsForAugments();
        return finishNode(factory2.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start2, getNodePos(), margin, indentText)), start2);
      }
      function parseSatisfiesTag(start2, tagName, margin, indentText) {
        const typeExpression = parseJSDocTypeExpression(
          /*mayOmitBraces*/
          false
        );
        const comments2 = margin !== void 0 && indentText !== void 0 ? parseTrailingTagComments(start2, getNodePos(), margin, indentText) : void 0;
        return finishNode(factory2.createJSDocSatisfiesTag(tagName, typeExpression, comments2), start2);
      }
      function parseImportTag(start2, tagName, margin, indentText) {
        const afterImportTagPos = scanner2.getTokenFullStart();
        let identifier;
        if (isIdentifier2()) {
          identifier = parseIdentifier();
        }
        const importClause = tryParseImportClause(
          identifier,
          afterImportTagPos,
          /*isTypeOnly*/
          true,
          /*skipJsDocLeadingAsterisks*/
          true
        );
        const moduleSpecifier = parseModuleSpecifier();
        const attributes = tryParseImportAttributes();
        const comments2 = margin !== void 0 && indentText !== void 0 ? parseTrailingTagComments(start2, getNodePos(), margin, indentText) : void 0;
        return finishNode(factory2.createJSDocImportTag(tagName, importClause, moduleSpecifier, attributes, comments2), start2);
      }
      function parseExpressionWithTypeArgumentsForAugments() {
        const usedBrace = parseOptional(19 /* OpenBraceToken */);
        const pos = getNodePos();
        const expression = parsePropertyAccessEntityNameExpression();
        scanner2.setSkipJsDocLeadingAsterisks(true);
        const typeArguments = tryParseTypeArguments();
        scanner2.setSkipJsDocLeadingAsterisks(false);
        const node = factory2.createExpressionWithTypeArguments(expression, typeArguments);
        const res = finishNode(node, pos);
        if (usedBrace) {
          parseExpected(20 /* CloseBraceToken */);
        }
        return res;
      }
      function parsePropertyAccessEntityNameExpression() {
        const pos = getNodePos();
        let node = parseJSDocIdentifierName();
        while (parseOptional(25 /* DotToken */)) {
          const name = parseJSDocIdentifierName();
          node = finishNode(factoryCreatePropertyAccessExpression(node, name), pos);
        }
        return node;
      }
      function parseSimpleTag(start2, createTag, tagName, margin, indentText) {
        return finishNode(createTag(tagName, parseTrailingTagComments(start2, getNodePos(), margin, indentText)), start2);
      }
      function parseThisTag(start2, tagName, margin, indentText) {
        const typeExpression = parseJSDocTypeExpression(
          /*mayOmitBraces*/
          true
        );
        skipWhitespace();
        return finishNode(factory2.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start2, getNodePos(), margin, indentText)), start2);
      }
      function parseEnumTag(start2, tagName, margin, indentText) {
        const typeExpression = parseJSDocTypeExpression(
          /*mayOmitBraces*/
          true
        );
        skipWhitespace();
        return finishNode(factory2.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start2, getNodePos(), margin, indentText)), start2);
      }
      function parseTypedefTag(start2, tagName, indent3, indentText) {
        let typeExpression = tryParseTypeExpression();
        skipWhitespaceOrAsterisk();
        const fullName = parseJSDocTypeNameWithNamespace();
        skipWhitespace();
        let comment = parseTagComments(indent3);
        let end2;
        if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) {
          let child;
          let childTypeTag;
          let jsDocPropertyTags;
          let hasChildren = false;
          while (child = tryParse(() => parseChildPropertyTag(indent3))) {
            if (child.kind === 345 /* JSDocTemplateTag */) {
              break;
            }
            hasChildren = true;
            if (child.kind === 344 /* JSDocTypeTag */) {
              if (childTypeTag) {
                const lastError = parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
                if (lastError) {
                  addRelatedInfo(lastError, createDetachedDiagnostic(fileName, sourceText, 0, 0, Diagnostics.The_tag_was_first_specified_here));
                }
                break;
              } else {
                childTypeTag = child;
              }
            } else {
              jsDocPropertyTags = append(jsDocPropertyTags, child);
            }
          }
          if (hasChildren) {
            const isArrayType = typeExpression && typeExpression.type.kind === 188 /* ArrayType */;
            const jsdocTypeLiteral = factory2.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType);
            typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : finishNode(jsdocTypeLiteral, start2);
            end2 = typeExpression.end;
          }
        }
        end2 = end2 || comment !== void 0 ? getNodePos() : (fullName ?? typeExpression ?? tagName).end;
        if (!comment) {
          comment = parseTrailingTagComments(start2, end2, indent3, indentText);
        }
        const typedefTag = factory2.createJSDocTypedefTag(tagName, typeExpression, fullName, comment);
        return finishNode(typedefTag, start2, end2);
      }
      function parseJSDocTypeNameWithNamespace(nested) {
        const start2 = scanner2.getTokenStart();
        if (!tokenIsIdentifierOrKeyword(token())) {
          return void 0;
        }
        const typeNameOrNamespaceName = parseJSDocIdentifierName();
        if (parseOptional(25 /* DotToken */)) {
          const body = parseJSDocTypeNameWithNamespace(
            /*nested*/
            true
          );
          const jsDocNamespaceNode = factory2.createModuleDeclaration(
            /*modifiers*/
            void 0,
            typeNameOrNamespaceName,
            body,
            nested ? 8 /* NestedNamespace */ : void 0
          );
          return finishNode(jsDocNamespaceNode, start2);
        }
        if (nested) {
          typeNameOrNamespaceName.flags |= 4096 /* IdentifierIsInJSDocNamespace */;
        }
        return typeNameOrNamespaceName;
      }
      function parseCallbackTagParameters(indent3) {
        const pos = getNodePos();
        let child;
        let parameters;
        while (child = tryParse(() => parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent3))) {
          if (child.kind === 345 /* JSDocTemplateTag */) {
            parseErrorAtRange(child.tagName, Diagnostics.A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag);
            break;
          }
          parameters = append(parameters, child);
        }
        return createNodeArray(parameters || [], pos);
      }
      function parseJSDocSignature(start2, indent3) {
        const parameters = parseCallbackTagParameters(indent3);
        const returnTag = tryParse(() => {
          if (parseOptionalJsdoc(60 /* AtToken */)) {
            const tag = parseTag(indent3);
            if (tag && tag.kind === 342 /* JSDocReturnTag */) {
              return tag;
            }
          }
        });
        return finishNode(factory2.createJSDocSignature(
          /*typeParameters*/
          void 0,
          parameters,
          returnTag
        ), start2);
      }
      function parseCallbackTag(start2, tagName, indent3, indentText) {
        const fullName = parseJSDocTypeNameWithNamespace();
        skipWhitespace();
        let comment = parseTagComments(indent3);
        const typeExpression = parseJSDocSignature(start2, indent3);
        if (!comment) {
          comment = parseTrailingTagComments(start2, getNodePos(), indent3, indentText);
        }
        const end2 = comment !== void 0 ? getNodePos() : typeExpression.end;
        return finishNode(factory2.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start2, end2);
      }
      function parseOverloadTag(start2, tagName, indent3, indentText) {
        skipWhitespace();
        let comment = parseTagComments(indent3);
        const typeExpression = parseJSDocSignature(start2, indent3);
        if (!comment) {
          comment = parseTrailingTagComments(start2, getNodePos(), indent3, indentText);
        }
        const end2 = comment !== void 0 ? getNodePos() : typeExpression.end;
        return finishNode(factory2.createJSDocOverloadTag(tagName, typeExpression, comment), start2, end2);
      }
      function escapedTextsEqual(a, b) {
        while (!isIdentifier(a) || !isIdentifier(b)) {
          if (!isIdentifier(a) && !isIdentifier(b) && a.right.escapedText === b.right.escapedText) {
            a = a.left;
            b = b.left;
          } else {
            return false;
          }
        }
        return a.escapedText === b.escapedText;
      }
      function parseChildPropertyTag(indent3) {
        return parseChildParameterOrPropertyTag(1 /* Property */, indent3);
      }
      function parseChildParameterOrPropertyTag(target, indent3, name) {
        let canParseTag = true;
        let seenAsterisk = false;
        while (true) {
          switch (nextTokenJSDoc()) {
            case 60 /* AtToken */:
              if (canParseTag) {
                const child = tryParseChildTag(target, indent3);
                if (child && (child.kind === 341 /* JSDocParameterTag */ || child.kind === 348 /* JSDocPropertyTag */) && name && (isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
                  return false;
                }
                return child;
              }
              seenAsterisk = false;
              break;
            case 4 /* NewLineTrivia */:
              canParseTag = true;
              seenAsterisk = false;
              break;
            case 42 /* AsteriskToken */:
              if (seenAsterisk) {
                canParseTag = false;
              }
              seenAsterisk = true;
              break;
            case 80 /* Identifier */:
              canParseTag = false;
              break;
            case 1 /* EndOfFileToken */:
              return false;
          }
        }
      }
      function tryParseChildTag(target, indent3) {
        Debug.assert(token() === 60 /* AtToken */);
        const start2 = scanner2.getTokenFullStart();
        nextTokenJSDoc();
        const tagName = parseJSDocIdentifierName();
        const indentText = skipWhitespaceOrAsterisk();
        let t;
        switch (tagName.escapedText) {
          case "type":
            return target === 1 /* Property */ && parseTypeTag(start2, tagName);
          case "prop":
          case "property":
            t = 1 /* Property */;
            break;
          case "arg":
          case "argument":
          case "param":
            t = 2 /* Parameter */ | 4 /* CallbackParameter */;
            break;
          case "template":
            return parseTemplateTag(start2, tagName, indent3, indentText);
          case "this":
            return parseThisTag(start2, tagName, indent3, indentText);
          default:
            return false;
        }
        if (!(target & t)) {
          return false;
        }
        return parseParameterOrPropertyTag(start2, tagName, target, indent3);
      }
      function parseTemplateTagTypeParameter() {
        const typeParameterPos = getNodePos();
        const isBracketed = parseOptionalJsdoc(23 /* OpenBracketToken */);
        if (isBracketed) {
          skipWhitespace();
        }
        const modifiers = parseModifiers(
          /*allowDecorators*/
          false,
          /*permitConstAsModifier*/
          true
        );
        const name = parseJSDocIdentifierName(Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces);
        let defaultType;
        if (isBracketed) {
          skipWhitespace();
          parseExpected(64 /* EqualsToken */);
          defaultType = doInsideOfContext(16777216 /* JSDoc */, parseJSDocType);
          parseExpected(24 /* CloseBracketToken */);
        }
        if (nodeIsMissing(name)) {
          return void 0;
        }
        return finishNode(factory2.createTypeParameterDeclaration(
          modifiers,
          name,
          /*constraint*/
          void 0,
          defaultType
        ), typeParameterPos);
      }
      function parseTemplateTagTypeParameters() {
        const pos = getNodePos();
        const typeParameters = [];
        do {
          skipWhitespace();
          const node = parseTemplateTagTypeParameter();
          if (node !== void 0) {
            typeParameters.push(node);
          }
          skipWhitespaceOrAsterisk();
        } while (parseOptionalJsdoc(28 /* CommaToken */));
        return createNodeArray(typeParameters, pos);
      }
      function parseTemplateTag(start2, tagName, indent3, indentText) {
        const constraint = token() === 19 /* OpenBraceToken */ ? parseJSDocTypeExpression() : void 0;
        const typeParameters = parseTemplateTagTypeParameters();
        return finishNode(factory2.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start2, getNodePos(), indent3, indentText)), start2);
      }
      function parseOptionalJsdoc(t) {
        if (token() === t) {
          nextTokenJSDoc();
          return true;
        }
        return false;
      }
      function parseJSDocEntityName() {
        let entity = parseJSDocIdentifierName();
        if (parseOptional(23 /* OpenBracketToken */)) {
          parseExpected(24 /* CloseBracketToken */);
        }
        while (parseOptional(25 /* DotToken */)) {
          const name = parseJSDocIdentifierName();
          if (parseOptional(23 /* OpenBracketToken */)) {
            parseExpected(24 /* CloseBracketToken */);
          }
          entity = createQualifiedName(entity, name);
        }
        return entity;
      }
      function parseJSDocIdentifierName(message) {
        if (!tokenIsIdentifierOrKeyword(token())) {
          return createMissingNode(
            80 /* Identifier */,
            /*reportAtCurrentPosition*/
            !message,
            message || Diagnostics.Identifier_expected
          );
        }
        identifierCount++;
        const start2 = scanner2.getTokenStart();
        const end2 = scanner2.getTokenEnd();
        const originalKeywordKind = token();
        const text = internIdentifier(scanner2.getTokenValue());
        const result2 = finishNode(factoryCreateIdentifier(text, originalKeywordKind), start2, end2);
        nextTokenJSDoc();
        return result2;
      }
    }
  })(JSDocParser = Parser2.JSDocParser || (Parser2.JSDocParser = {}));
})(Parser || (Parser = {}));
var incrementallyParsedFiles = /* @__PURE__ */ new WeakSet();
function markAsIncrementallyParsed(sourceFile) {
  if (incrementallyParsedFiles.has(sourceFile)) {
    Debug.fail("Source file has already been incrementally parsed");
  }
  incrementallyParsedFiles.add(sourceFile);
}
var intersectingChangeSet = /* @__PURE__ */ new WeakSet();
function intersectsIncrementalChange(node) {
  return intersectingChangeSet.has(node);
}
function markAsIntersectingIncrementalChange(node) {
  intersectingChangeSet.add(node);
}
var IncrementalParser;
((IncrementalParser2) => {
  function updateSourceFile2(sourceFile, newText, textChangeRange, aggressiveChecks) {
    aggressiveChecks = aggressiveChecks || Debug.shouldAssert(2 /* Aggressive */);
    checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks);
    if (textChangeRangeIsUnchanged(textChangeRange)) {
      return sourceFile;
    }
    if (sourceFile.statements.length === 0) {
      return Parser.parseSourceFile(
        sourceFile.fileName,
        newText,
        sourceFile.languageVersion,
        /*syntaxCursor*/
        void 0,
        /*setParentNodes*/
        true,
        sourceFile.scriptKind,
        sourceFile.setExternalModuleIndicator,
        sourceFile.jsDocParsingMode
      );
    }
    markAsIncrementallyParsed(sourceFile);
    Parser.fixupParentReferences(sourceFile);
    const oldText = sourceFile.text;
    const syntaxCursor = createSyntaxCursor(sourceFile);
    const changeRange = extendToAffectedRange(sourceFile, textChangeRange);
    checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks);
    Debug.assert(changeRange.span.start <= textChangeRange.span.start);
    Debug.assert(textSpanEnd(changeRange.span) === textSpanEnd(textChangeRange.span));
    Debug.assert(textSpanEnd(textChangeRangeNewSpan(changeRange)) === textSpanEnd(textChangeRangeNewSpan(textChangeRange)));
    const delta = textChangeRangeNewSpan(changeRange).length - changeRange.span.length;
    updateTokenPositionsAndMarkElements(sourceFile, changeRange.span.start, textSpanEnd(changeRange.span), textSpanEnd(textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks);
    const result = Parser.parseSourceFile(
      sourceFile.fileName,
      newText,
      sourceFile.languageVersion,
      syntaxCursor,
      /*setParentNodes*/
      true,
      sourceFile.scriptKind,
      sourceFile.setExternalModuleIndicator,
      sourceFile.jsDocParsingMode
    );
    result.commentDirectives = getNewCommentDirectives(
      sourceFile.commentDirectives,
      result.commentDirectives,
      changeRange.span.start,
      textSpanEnd(changeRange.span),
      delta,
      oldText,
      newText,
      aggressiveChecks
    );
    result.impliedNodeFormat = sourceFile.impliedNodeFormat;
    transferSourceFileChildren(sourceFile, result);
    return result;
  }
  IncrementalParser2.updateSourceFile = updateSourceFile2;
  function getNewCommentDirectives(oldDirectives, newDirectives, changeStart, changeRangeOldEnd, delta, oldText, newText, aggressiveChecks) {
    if (!oldDirectives) return newDirectives;
    let commentDirectives;
    let addedNewlyScannedDirectives = false;
    for (const directive of oldDirectives) {
      const { range, type } = directive;
      if (range.end < changeStart) {
        commentDirectives = append(commentDirectives, directive);
      } else if (range.pos > changeRangeOldEnd) {
        addNewlyScannedDirectives();
        const updatedDirective = {
          range: { pos: range.pos + delta, end: range.end + delta },
          type
        };
        commentDirectives = append(commentDirectives, updatedDirective);
        if (aggressiveChecks) {
          Debug.assert(oldText.substring(range.pos, range.end) === newText.substring(updatedDirective.range.pos, updatedDirective.range.end));
        }
      }
    }
    addNewlyScannedDirectives();
    return commentDirectives;
    function addNewlyScannedDirectives() {
      if (addedNewlyScannedDirectives) return;
      addedNewlyScannedDirectives = true;
      if (!commentDirectives) {
        commentDirectives = newDirectives;
      } else if (newDirectives) {
        commentDirectives.push(...newDirectives);
      }
    }
  }
  function moveElementEntirelyPastChangeRange(element, origSourceFile, isArray2, delta, oldText, newText, aggressiveChecks) {
    if (isArray2) {
      visitArray2(element);
    } else {
      visitNode3(element);
    }
    return;
    function visitNode3(node) {
      let text = "";
      if (aggressiveChecks && shouldCheckNode(node)) {
        text = oldText.substring(node.pos, node.end);
      }
      unsetNodeChildren(node, origSourceFile);
      setTextRangePosEnd(node, node.pos + delta, node.end + delta);
      if (aggressiveChecks && shouldCheckNode(node)) {
        Debug.assert(text === newText.substring(node.pos, node.end));
      }
      forEachChild(node, visitNode3, visitArray2);
      if (hasJSDocNodes(node)) {
        for (const jsDocComment of node.jsDoc) {
          visitNode3(jsDocComment);
        }
      }
      checkNodePositions(node, aggressiveChecks);
    }
    function visitArray2(array) {
      setTextRangePosEnd(array, array.pos + delta, array.end + delta);
      for (const node of array) {
        visitNode3(node);
      }
    }
  }
  function shouldCheckNode(node) {
    switch (node.kind) {
      case 11 /* StringLiteral */:
      case 9 /* NumericLiteral */:
      case 80 /* Identifier */:
        return true;
    }
    return false;
  }
  function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) {
    Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range");
    Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range");
    Debug.assert(element.pos <= element.end);
    const pos = Math.min(element.pos, changeRangeNewEnd);
    const end = element.end >= changeRangeOldEnd ? (
      // Element ends after the change range.  Always adjust the end pos.
      element.end + delta
    ) : (
      // Element ends in the change range.  The element will keep its position if
      // possible. Or Move backward to the new-end if it's in the 'Y' range.
      Math.min(element.end, changeRangeNewEnd)
    );
    Debug.assert(pos <= end);
    if (element.parent) {
      const parent2 = element.parent;
      Debug.assertGreaterThanOrEqual(pos, parent2.pos);
      Debug.assertLessThanOrEqual(end, parent2.end);
    }
    setTextRangePosEnd(element, pos, end);
  }
  function checkNodePositions(node, aggressiveChecks) {
    if (aggressiveChecks) {
      let pos = node.pos;
      const visitNode3 = (child) => {
        Debug.assert(child.pos >= pos);
        pos = child.end;
      };
      if (hasJSDocNodes(node)) {
        for (const jsDocComment of node.jsDoc) {
          visitNode3(jsDocComment);
        }
      }
      forEachChild(node, visitNode3);
      Debug.assert(pos <= node.end);
    }
  }
  function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) {
    visitNode3(sourceFile);
    return;
    function visitNode3(child) {
      Debug.assert(child.pos <= child.end);
      if (child.pos > changeRangeOldEnd) {
        moveElementEntirelyPastChangeRange(
          child,
          sourceFile,
          /*isArray*/
          false,
          delta,
          oldText,
          newText,
          aggressiveChecks
        );
        return;
      }
      const fullEnd = child.end;
      if (fullEnd >= changeStart) {
        markAsIntersectingIncrementalChange(child);
        unsetNodeChildren(child, sourceFile);
        adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
        forEachChild(child, visitNode3, visitArray2);
        if (hasJSDocNodes(child)) {
          for (const jsDocComment of child.jsDoc) {
            visitNode3(jsDocComment);
          }
        }
        checkNodePositions(child, aggressiveChecks);
        return;
      }
      Debug.assert(fullEnd < changeStart);
    }
    function visitArray2(array) {
      Debug.assert(array.pos <= array.end);
      if (array.pos > changeRangeOldEnd) {
        moveElementEntirelyPastChangeRange(
          array,
          sourceFile,
          /*isArray*/
          true,
          delta,
          oldText,
          newText,
          aggressiveChecks
        );
        return;
      }
      const fullEnd = array.end;
      if (fullEnd >= changeStart) {
        markAsIntersectingIncrementalChange(array);
        adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
        for (const node of array) {
          visitNode3(node);
        }
        return;
      }
      Debug.assert(fullEnd < changeStart);
    }
  }
  function extendToAffectedRange(sourceFile, changeRange) {
    const maxLookahead = 1;
    let start = changeRange.span.start;
    for (let i = 0; start > 0 && i <= maxLookahead; i++) {
      const nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start);
      Debug.assert(nearestNode.pos <= start);
      const position = nearestNode.pos;
      start = Math.max(0, position - 1);
    }
    const finalSpan = createTextSpanFromBounds(start, textSpanEnd(changeRange.span));
    const finalLength = changeRange.newLength + (changeRange.span.start - start);
    return createTextChangeRange(finalSpan, finalLength);
  }
  function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) {
    let bestResult = sourceFile;
    let lastNodeEntirelyBeforePosition;
    forEachChild(sourceFile, visit);
    if (lastNodeEntirelyBeforePosition) {
      const lastChildOfLastEntireNodeBeforePosition = getLastDescendant(lastNodeEntirelyBeforePosition);
      if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) {
        bestResult = lastChildOfLastEntireNodeBeforePosition;
      }
    }
    return bestResult;
    function getLastDescendant(node) {
      while (true) {
        const lastChild = getLastChild(node);
        if (lastChild) {
          node = lastChild;
        } else {
          return node;
        }
      }
    }
    function visit(child) {
      if (nodeIsMissing(child)) {
        return;
      }
      if (child.pos <= position) {
        if (child.pos >= bestResult.pos) {
          bestResult = child;
        }
        if (position < child.end) {
          forEachChild(child, visit);
          return true;
        } else {
          Debug.assert(child.end <= position);
          lastNodeEntirelyBeforePosition = child;
        }
      } else {
        Debug.assert(child.pos > position);
        return true;
      }
    }
  }
  function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) {
    const oldText = sourceFile.text;
    if (textChangeRange) {
      Debug.assert(oldText.length - textCh