     1→import type * as ESTree from './estree';
     2→import { type Token } from './token';
     3→
     4→/**
     5→ * Function calls when semicolon inserted.
     6→ */
     7→type OnInsertedSemicolon = (pos: number) => any;
     8→
     9→type SourceType = 'script' | 'module' | 'commonjs';
    10→
    11→/**
    12→ * Token process function.
    13→ */
    14→export type OnToken = (token: string, start: number, end: number, loc: ESTree.SourceLocation) => any;
    15→
    16→/**
    17→ * Comment process function.
    18→ */
    19→export type OnComment = (
    20→  type: ESTree.CommentType,
    21→  value: string,
    22→  start: number,
    23→  end: number,
    24→  loc: ESTree.SourceLocation,
    25→) => any;
    26→
    27→/**
    28→ * The parser options.
    29→ */
    30→export interface Options {
    31→  // Indicate the mode the code should be parsed in 'script', 'module', or 'commonjs' mode
    32→  sourceType?: SourceType;
    33→  // Enable stage 3 support (ESNext)
    34→  next?: boolean;
    35→  // Enable start and end offsets to each node
    36→  ranges?: boolean;
    37→  // Enable web compatibility
    38→  webcompat?: boolean;
    39→  // Enable line/column location information to each node
    40→  loc?: boolean;
    41→  // Attach raw property to each literal and identifier node
    42→  raw?: boolean;
    43→  // Enable implied strict mode
    44→  impliedStrict?: boolean;
    45→  // Enable non-standard parenthesized expression node
    46→  preserveParens?: boolean;
    47→  // Enable lexical binding and scope tracking
    48→  lexical?: boolean;
    49→  // Adds a source attribute in every node’s loc object when the locations option is `true`
    50→  source?: string;
    51→  // Enable React JSX parsing
    52→  jsx?: boolean;
    53→  // Allows comment extraction. Accepts either a callback function or an array
    54→  onComment?: ESTree.Comment[] | OnComment;
    55→  // Allows detection of automatic semicolon insertion. Accepts a callback function that will be passed the character offset where the semicolon was inserted
    56→  onInsertedSemicolon?: OnInsertedSemicolon;
    57→  // Allows token extraction. Accepts either a callback function or an array
    58→  onToken?: Token[] | OnToken;
    59→  // Throw errors for invalid regexps
    60→  validateRegex?: boolean;
    61→
    62→  // Allow module code
    63→  /** @deprecated Use `sourceType` instead. */
    64→  module?: boolean;
    65→  // Allow return in the global scope
    66→  /** @deprecated Use `sourceType: 'commonjs'` instead. */
    67→  globalReturn?: boolean;
    68→}
    69→
    70→export type NormalizedOptions = Omit<Options, 'validateRegex' | 'onComment' | 'onToken'> & {
    71→  validateRegex: boolean;
    72→  onComment?: OnComment;
    73→  onToken?: OnToken;
    74→};
    75→
    76→export function normalizeOptions(rawOptions: Options): NormalizedOptions {
    77→  const options = {
    78→    validateRegex: true,
    79→    ...rawOptions,
    80→  } as NormalizedOptions;
    81→
    82→  if (options.module && !options.sourceType) {
    83→    options.sourceType = 'module';
    84→  }
    85→
    86→  if (options.globalReturn && (!options.sourceType || options.sourceType === 'script')) {
    87→    options.sourceType = 'commonjs';
    88→  }
    89→
    90→  return options;
    91→}
