{"ast":null,"code":"import { ContextualKeyword } from \"../parser/tokenizer/keywords\";\nimport { TokenType as tt } from \"../parser/tokenizer/types\";\nimport Transformer from \"./Transformer\";\nexport default class FlowTransformer extends Transformer {\n  constructor(rootTransformer, tokens, isImportsTransformEnabled) {\n    super();\n    this.rootTransformer = rootTransformer;\n    this.tokens = tokens;\n    this.isImportsTransformEnabled = isImportsTransformEnabled;\n    ;\n  }\n  process() {\n    if (this.rootTransformer.processPossibleArrowParamEnd() || this.rootTransformer.processPossibleAsyncArrowWithTypeParams() || this.rootTransformer.processPossibleTypeRange()) {\n      return true;\n    }\n    if (this.tokens.matches1(tt._enum)) {\n      this.processEnum();\n      return true;\n    }\n    if (this.tokens.matches2(tt._export, tt._enum)) {\n      this.processNamedExportEnum();\n      return true;\n    }\n    if (this.tokens.matches3(tt._export, tt._default, tt._enum)) {\n      this.processDefaultExportEnum();\n      return true;\n    }\n    return false;\n  }\n\n  /**\n   * Handle a declaration like:\n   * export enum E ...\n   *\n   * With this imports transform, this becomes:\n   * const E = [[enum]]; exports.E = E;\n   *\n   * otherwise, it becomes:\n   * export const E = [[enum]];\n   */\n  processNamedExportEnum() {\n    if (this.isImportsTransformEnabled) {\n      // export\n      this.tokens.removeInitialToken();\n      const enumName = this.tokens.identifierNameAtRelativeIndex(1);\n      this.processEnum();\n      this.tokens.appendCode(` exports.${enumName} = ${enumName};`);\n    } else {\n      this.tokens.copyToken();\n      this.processEnum();\n    }\n  }\n\n  /**\n   * Handle a declaration like:\n   * export default enum E\n   *\n   * With the imports transform, this becomes:\n   * const E = [[enum]]; exports.default = E;\n   *\n   * otherwise, it becomes:\n   * const E = [[enum]]; export default E;\n   */\n  processDefaultExportEnum() {\n    // export\n    this.tokens.removeInitialToken();\n    // default\n    this.tokens.removeToken();\n    const enumName = this.tokens.identifierNameAtRelativeIndex(1);\n    this.processEnum();\n    if (this.isImportsTransformEnabled) {\n      this.tokens.appendCode(` exports.default = ${enumName};`);\n    } else {\n      this.tokens.appendCode(` export default ${enumName};`);\n    }\n  }\n\n  /**\n   * Transpile flow enums to invoke the \"flow-enums-runtime\" library.\n   *\n   * Currently, the transpiled code always uses `require(\"flow-enums-runtime\")`,\n   * but if future flexibility is needed, we could expose a config option for\n   * this string (similar to configurable JSX). Even when targeting ESM, the\n   * default behavior of babel-plugin-transform-flow-enums is to use require\n   * rather than injecting an import.\n   *\n   * Flow enums are quite a bit simpler than TS enums and have some convenient\n   * constraints:\n   * - Element initializers must be either always present or always absent. That\n   *   means that we can use fixed lookahead on the first element (if any) and\n   *   assume that all elements are like that.\n   * - The right-hand side of an element initializer must be a literal value,\n   *   not a complex expression and not referencing other elements. That means\n   *   we can simply copy a single token.\n   *\n   * Enums can be broken up into three basic cases:\n   *\n   * Mirrored enums:\n   * enum E {A, B}\n   *   ->\n   * const E = require(\"flow-enums-runtime\").Mirrored([\"A\", \"B\"]);\n   *\n   * Initializer enums:\n   * enum E {A = 1, B = 2}\n   *   ->\n   * const E = require(\"flow-enums-runtime\")({A: 1, B: 2});\n   *\n   * Symbol enums:\n   * enum E of symbol {A, B}\n   *   ->\n   * const E = require(\"flow-enums-runtime\")({A: Symbol(\"A\"), B: Symbol(\"B\")});\n   *\n   * We can statically detect which of the three cases this is by looking at the\n   * \"of\" declaration (if any) and seeing if the first element has an initializer.\n   * Since the other transform details are so similar between the three cases, we\n   * use a single implementation and vary the transform within processEnumElement\n   * based on case.\n   */\n  processEnum() {\n    // enum E -> const E\n    this.tokens.replaceToken(\"const\");\n    this.tokens.copyExpectedToken(tt.name);\n    let isSymbolEnum = false;\n    if (this.tokens.matchesContextual(ContextualKeyword._of)) {\n      this.tokens.removeToken();\n      isSymbolEnum = this.tokens.matchesContextual(ContextualKeyword._symbol);\n      this.tokens.removeToken();\n    }\n    const hasInitializers = this.tokens.matches3(tt.braceL, tt.name, tt.eq);\n    this.tokens.appendCode(' = require(\"flow-enums-runtime\")');\n    const isMirrored = !isSymbolEnum && !hasInitializers;\n    this.tokens.replaceTokenTrimmingLeftWhitespace(isMirrored ? \".Mirrored([\" : \"({\");\n    while (!this.tokens.matches1(tt.braceR)) {\n      // ... is allowed at the end and has no runtime behavior.\n      if (this.tokens.matches1(tt.ellipsis)) {\n        this.tokens.removeToken();\n        break;\n      }\n      this.processEnumElement(isSymbolEnum, hasInitializers);\n      if (this.tokens.matches1(tt.comma)) {\n        this.tokens.copyToken();\n      }\n    }\n    this.tokens.replaceToken(isMirrored ? \"]);\" : \"});\");\n  }\n\n  /**\n   * Process an individual enum element, producing either an array element or an\n   * object element based on what type of enum this is.\n   */\n  processEnumElement(isSymbolEnum, hasInitializers) {\n    if (isSymbolEnum) {\n      // Symbol enums never have initializers and are expanded to object elements.\n      // A, -> A: Symbol(\"A\"),\n      const elementName = this.tokens.identifierName();\n      this.tokens.copyToken();\n      this.tokens.appendCode(`: Symbol(\"${elementName}\")`);\n    } else if (hasInitializers) {\n      // Initializers are expanded to object elements.\n      // A = 1, -> A: 1,\n      this.tokens.copyToken();\n      this.tokens.replaceTokenTrimmingLeftWhitespace(\":\");\n      this.tokens.copyToken();\n    } else {\n      // Enum elements without initializers become string literal array elements.\n      // A, -> \"A\",\n      this.tokens.replaceToken(`\"${this.tokens.identifierName()}\"`);\n    }\n  }\n}","map":{"version":3,"names":["ContextualKeyword","TokenType","tt","Transformer","FlowTransformer","constructor","rootTransformer","tokens","isImportsTransformEnabled","process","processPossibleArrowParamEnd","processPossibleAsyncArrowWithTypeParams","processPossibleTypeRange","matches1","_enum","processEnum","matches2","_export","processNamedExportEnum","matches3","_default","processDefaultExportEnum","removeInitialToken","enumName","identifierNameAtRelativeIndex","appendCode","copyToken","removeToken","replaceToken","copyExpectedToken","name","isSymbolEnum","matchesContextual","_of","_symbol","hasInitializers","braceL","eq","isMirrored","replaceTokenTrimmingLeftWhitespace","braceR","ellipsis","processEnumElement","comma","elementName","identifierName"],"sources":["C:/Users/user/Desktop/000newport/node_modules/sucrase/dist/esm/transformers/FlowTransformer.js"],"sourcesContent":["import {ContextualKeyword} from \"../parser/tokenizer/keywords\";\nimport {TokenType as tt} from \"../parser/tokenizer/types\";\n\n\nimport Transformer from \"./Transformer\";\n\nexport default class FlowTransformer extends Transformer {\n  constructor(\n     rootTransformer,\n     tokens,\n     isImportsTransformEnabled,\n  ) {\n    super();this.rootTransformer = rootTransformer;this.tokens = tokens;this.isImportsTransformEnabled = isImportsTransformEnabled;;\n  }\n\n  process() {\n    if (\n      this.rootTransformer.processPossibleArrowParamEnd() ||\n      this.rootTransformer.processPossibleAsyncArrowWithTypeParams() ||\n      this.rootTransformer.processPossibleTypeRange()\n    ) {\n      return true;\n    }\n    if (this.tokens.matches1(tt._enum)) {\n      this.processEnum();\n      return true;\n    }\n    if (this.tokens.matches2(tt._export, tt._enum)) {\n      this.processNamedExportEnum();\n      return true;\n    }\n    if (this.tokens.matches3(tt._export, tt._default, tt._enum)) {\n      this.processDefaultExportEnum();\n      return true;\n    }\n    return false;\n  }\n\n  /**\n   * Handle a declaration like:\n   * export enum E ...\n   *\n   * With this imports transform, this becomes:\n   * const E = [[enum]]; exports.E = E;\n   *\n   * otherwise, it becomes:\n   * export const E = [[enum]];\n   */\n  processNamedExportEnum() {\n    if (this.isImportsTransformEnabled) {\n      // export\n      this.tokens.removeInitialToken();\n      const enumName = this.tokens.identifierNameAtRelativeIndex(1);\n      this.processEnum();\n      this.tokens.appendCode(` exports.${enumName} = ${enumName};`);\n    } else {\n      this.tokens.copyToken();\n      this.processEnum();\n    }\n  }\n\n  /**\n   * Handle a declaration like:\n   * export default enum E\n   *\n   * With the imports transform, this becomes:\n   * const E = [[enum]]; exports.default = E;\n   *\n   * otherwise, it becomes:\n   * const E = [[enum]]; export default E;\n   */\n  processDefaultExportEnum() {\n    // export\n    this.tokens.removeInitialToken();\n    // default\n    this.tokens.removeToken();\n    const enumName = this.tokens.identifierNameAtRelativeIndex(1);\n    this.processEnum();\n    if (this.isImportsTransformEnabled) {\n      this.tokens.appendCode(` exports.default = ${enumName};`);\n    } else {\n      this.tokens.appendCode(` export default ${enumName};`);\n    }\n  }\n\n  /**\n   * Transpile flow enums to invoke the \"flow-enums-runtime\" library.\n   *\n   * Currently, the transpiled code always uses `require(\"flow-enums-runtime\")`,\n   * but if future flexibility is needed, we could expose a config option for\n   * this string (similar to configurable JSX). Even when targeting ESM, the\n   * default behavior of babel-plugin-transform-flow-enums is to use require\n   * rather than injecting an import.\n   *\n   * Flow enums are quite a bit simpler than TS enums and have some convenient\n   * constraints:\n   * - Element initializers must be either always present or always absent. That\n   *   means that we can use fixed lookahead on the first element (if any) and\n   *   assume that all elements are like that.\n   * - The right-hand side of an element initializer must be a literal value,\n   *   not a complex expression and not referencing other elements. That means\n   *   we can simply copy a single token.\n   *\n   * Enums can be broken up into three basic cases:\n   *\n   * Mirrored enums:\n   * enum E {A, B}\n   *   ->\n   * const E = require(\"flow-enums-runtime\").Mirrored([\"A\", \"B\"]);\n   *\n   * Initializer enums:\n   * enum E {A = 1, B = 2}\n   *   ->\n   * const E = require(\"flow-enums-runtime\")({A: 1, B: 2});\n   *\n   * Symbol enums:\n   * enum E of symbol {A, B}\n   *   ->\n   * const E = require(\"flow-enums-runtime\")({A: Symbol(\"A\"), B: Symbol(\"B\")});\n   *\n   * We can statically detect which of the three cases this is by looking at the\n   * \"of\" declaration (if any) and seeing if the first element has an initializer.\n   * Since the other transform details are so similar between the three cases, we\n   * use a single implementation and vary the transform within processEnumElement\n   * based on case.\n   */\n  processEnum() {\n    // enum E -> const E\n    this.tokens.replaceToken(\"const\");\n    this.tokens.copyExpectedToken(tt.name);\n\n    let isSymbolEnum = false;\n    if (this.tokens.matchesContextual(ContextualKeyword._of)) {\n      this.tokens.removeToken();\n      isSymbolEnum = this.tokens.matchesContextual(ContextualKeyword._symbol);\n      this.tokens.removeToken();\n    }\n    const hasInitializers = this.tokens.matches3(tt.braceL, tt.name, tt.eq);\n    this.tokens.appendCode(' = require(\"flow-enums-runtime\")');\n\n    const isMirrored = !isSymbolEnum && !hasInitializers;\n    this.tokens.replaceTokenTrimmingLeftWhitespace(isMirrored ? \".Mirrored([\" : \"({\");\n\n    while (!this.tokens.matches1(tt.braceR)) {\n      // ... is allowed at the end and has no runtime behavior.\n      if (this.tokens.matches1(tt.ellipsis)) {\n        this.tokens.removeToken();\n        break;\n      }\n      this.processEnumElement(isSymbolEnum, hasInitializers);\n      if (this.tokens.matches1(tt.comma)) {\n        this.tokens.copyToken();\n      }\n    }\n\n    this.tokens.replaceToken(isMirrored ? \"]);\" : \"});\");\n  }\n\n  /**\n   * Process an individual enum element, producing either an array element or an\n   * object element based on what type of enum this is.\n   */\n  processEnumElement(isSymbolEnum, hasInitializers) {\n    if (isSymbolEnum) {\n      // Symbol enums never have initializers and are expanded to object elements.\n      // A, -> A: Symbol(\"A\"),\n      const elementName = this.tokens.identifierName();\n      this.tokens.copyToken();\n      this.tokens.appendCode(`: Symbol(\"${elementName}\")`);\n    } else if (hasInitializers) {\n      // Initializers are expanded to object elements.\n      // A = 1, -> A: 1,\n      this.tokens.copyToken();\n      this.tokens.replaceTokenTrimmingLeftWhitespace(\":\");\n      this.tokens.copyToken();\n    } else {\n      // Enum elements without initializers become string literal array elements.\n      // A, -> \"A\",\n      this.tokens.replaceToken(`\"${this.tokens.identifierName()}\"`);\n    }\n  }\n}\n"],"mappings":"AAAA,SAAQA,iBAAiB,QAAO,8BAA8B;AAC9D,SAAQC,SAAS,IAAIC,EAAE,QAAO,2BAA2B;AAGzD,OAAOC,WAAW,MAAM,eAAe;AAEvC,eAAe,MAAMC,eAAe,SAASD,WAAW,CAAC;EACvDE,WAAWA,CACRC,eAAe,EACfC,MAAM,EACNC,yBAAyB,EAC1B;IACA,KAAK,CAAC,CAAC;IAAC,IAAI,CAACF,eAAe,GAAGA,eAAe;IAAC,IAAI,CAACC,MAAM,GAAGA,MAAM;IAAC,IAAI,CAACC,yBAAyB,GAAGA,yBAAyB;IAAC;EACjI;EAEAC,OAAOA,CAAA,EAAG;IACR,IACE,IAAI,CAACH,eAAe,CAACI,4BAA4B,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