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AgB,GAAI,OAAO4B,EAAM,CAAC,EAAId,EAAS,KAAM,IAAI,EAE7D,IAAMe,GAAiBtE,EAAKD,GAAK,iBAAVC,EAAU,eAAmB0C,EAAQ,IAAI6B,CAAa,GAGvE9D,IAFaR,EAAKF,GAAK,aAAVE,EAAU,WAAeuE,GAAerE,EAAgBJ,CAAG,EAAGuE,CAAa,IAEnE7B,CAAW,EAAEnC,CAAI,EAC5C,GAAIG,GAAY,KAAM,OAAO4D,EAAM,CAAC,EAAId,EAAS,KAAM,IAAI,EAE3D,IAAMC,EAAOc,EAAc7B,CAAW,EAEtC,GAAI4B,EAAK,OAAOR,GAAwBpD,EAAU+C,EAAMlD,EAAMC,EAAQQ,CAAI,EAE1E,IAAML,EAAQC,EAAqBF,EAAU+C,EAAMlD,EAAMC,EAAQQ,CAAI,EACrE,GAAIL,IAAU,GAAI,OAAO6C,EAAS,KAAM,IAAI,EAE5C,IAAMpC,EAAUV,EAASC,CAAK,EAC9B,OAAO6C,EAASpC,EAAQgD,CAAkB,EAAI,EAAGhD,EAAQiD,CAAoB,CAAC,CAChF","names":["encode","decode","resolveUri","stripFilename","path","index","resolver","mapUrl","sourceRoot","from","prefix","source","COLUMN","SOURCES_INDEX","SOURCE_LINE","SOURCE_COLUMN","NAMES_INDEX","REV_GENERATED_LINE","REV_GENERATED_COLUMN","maybeSort","mappings","owned","unsortedIndex","nextUnsortedSegmentLine","i","sortSegments","start","isSorted","line","j","sortComparator","a","b","buildBySources","decoded","memos","sources","seg","sourceIndex","sourceLine","sourceColumn","found","binarySearch","haystack","needle","low","high","mid","cmp","upperBound","lowerBound","memoizedState","memoizedBinarySearch","state","key","lastKey","lastNeedle","lastIndex","parse","map","FlattenMap","parsed","TraceMap","sourcesContent","names","ignoreList","recurse","joined","presortedDecodedMap","input","lineOffset","columnOffset","stopLine","stopColumn","sections","offset","sl","sc","nextOffset","addSection","sourcesOffset","namesOffset","decodedMappings","resolvedSources","contents","ignores","append","lineI","out","getLine","cOffset","column","sourcesIndex","arr","other","LINE_GTR_ZERO","COL_GTR_EQ_ZERO","LEAST_UPPER_BOUND","GREATEST_LOWER_BOUND","isString","version","file","resolve","encodedMappings","map","_a","_b","encode","decodedMappings","decode","traceSegment","line","column","decoded","segments","index","traceSegmentInternal","GREATEST_LOWER_BOUND","originalPositionFor","needle","bias","LINE_GTR_ZERO","COL_GTR_EQ_ZERO","OMapping","segment","names","resolvedSources","SOURCES_INDEX","SOURCE_LINE","SOURCE_COLUMN","NAMES_INDEX","generatedPositionFor","source","generatedPosition","allGeneratedPositionsFor","LEAST_UPPER_BOUND","eachMapping","cb","i","j","seg","generatedLine","generatedColumn","originalLine","originalColumn","name","sourceIndex","sources","sourceContentFor","sourcesContent","isIgnored","ignoreList","presortedDecodedMap","mapUrl","tracer","TraceMap","clone","decodedMap","encodedMap","mappings","GMapping","memo","memoizedBinarySearch","found","upperBound","lowerBound","sliceGeneratedPositions","min","matchedColumn","COLUMN","max","result","REV_GENERATED_LINE","REV_GENERATED_COLUMN","all","bySourceMemos","memoizedState","buildBySources"],"sources":["../esm/npm/@jridgewell/trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/trace-mapping.ts","../esm/npm/@jridgewell/trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/resolve.ts","../esm/npm/@jridgewell/trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/strip-filename.ts","../esm/npm/@jridgewell/trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/sourcemap-segment.ts","../esm/npm/@jridgewell/trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/sort.ts","../esm/npm/@jridgewell/trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/by-source.ts","../esm/npm/@jridgewell/trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/binary-search.ts","../esm/npm/@jridgewell/trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/types.ts","../esm/npm/@jridgewell/trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/flatten-map.ts"],"sourcesContent":["import { encode, decode } from '@jridgewell/sourcemap-codec';\n\nimport resolver from './resolve';\nimport maybeSort from './sort';\nimport buildBySources from './by-source';\nimport {\n  memoizedState,\n  memoizedBinarySearch,\n  upperBound,\n  lowerBound,\n  found as bsFound,\n} from './binary-search';\nimport {\n  COLUMN,\n  SOURCES_INDEX,\n  SOURCE_LINE,\n  SOURCE_COLUMN,\n  NAMES_INDEX,\n  REV_GENERATED_LINE,\n  REV_GENERATED_COLUMN,\n} from './sourcemap-segment';\nimport { parse } from './types';\n\nimport type { SourceMapSegment, ReverseSegment } from './sourcemap-segment';\nimport type {\n  SourceMapV3,\n  DecodedSourceMap,\n  EncodedSourceMap,\n  InvalidOriginalMapping,\n  OriginalMapping,\n  InvalidGeneratedMapping,\n  GeneratedMapping,\n  SourceMapInput,\n  Needle,\n  SourceNeedle,\n  SourceMap,\n  EachMapping,\n  Bias,\n  XInput,\n  SectionedSourceMap,\n  Ro,\n} from './types';\nimport type { Source } from './by-source';\nimport type { MemoState } from './binary-search';\n\nexport type { SourceMapSegment } from './sourcemap-segment';\nexport type {\n  SourceMap,\n  DecodedSourceMap,\n  EncodedSourceMap,\n  Section,\n  SectionedSourceMap,\n  SourceMapV3,\n  Bias,\n  EachMapping,\n  GeneratedMapping,\n  InvalidGeneratedMapping,\n  InvalidOriginalMapping,\n  Needle,\n  OriginalMapping,\n  OriginalMapping as Mapping,\n  SectionedSourceMapInput,\n  SourceMapInput,\n  SourceNeedle,\n  XInput,\n  EncodedSourceMapXInput,\n  DecodedSourceMapXInput,\n  SectionedSourceMapXInput,\n  SectionXInput,\n} from './types';\n\ninterface PublicMap {\n  _encoded: TraceMap['_encoded'];\n  _decoded: TraceMap['_decoded'];\n  _decodedMemo: TraceMap['_decodedMemo'];\n  _bySources: TraceMap['_bySources'];\n  _bySourceMemos: TraceMap['_bySourceMemos'];\n}\n\nconst LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';\nconst COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';\n\nexport const LEAST_UPPER_BOUND = -1;\nexport const GREATEST_LOWER_BOUND = 1;\n\nexport { FlattenMap, FlattenMap as AnyMap } from './flatten-map';\n\nexport class TraceMap implements SourceMap {\n  declare version: SourceMapV3['version'];\n  declare file: SourceMapV3['file'];\n  declare names: SourceMapV3['names'];\n  declare sourceRoot: SourceMapV3['sourceRoot'];\n  declare sources: SourceMapV3['sources'];\n  declare sourcesContent: SourceMapV3['sourcesContent'];\n  declare ignoreList: SourceMapV3['ignoreList'];\n\n  declare resolvedSources: string[];\n  declare private _encoded: string | undefined;\n\n  declare private _decoded: SourceMapSegment[][] | undefined;\n  declare private _decodedMemo: MemoState;\n\n  declare private _bySources: Source[] | undefined;\n  declare private _bySourceMemos: MemoState[] | undefined;\n\n  constructor(map: Ro\u003cSourceMapInput\u003e, mapUrl?: string | null) {\n    const isString = typeof map === 'string';\n    if (!isString \u0026\u0026 (map as unknown as { _decodedMemo: any })._decodedMemo) return map as TraceMap;\n\n    const parsed = parse(map as Exclude\u003cSourceMapInput, TraceMap\u003e);\n\n    const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;\n    this.version = version;\n    this.file = file;\n    this.names = names || [];\n    this.sourceRoot = sourceRoot;\n    this.sources = sources;\n    this.sourcesContent = sourcesContent;\n    this.ignoreList = parsed.ignoreList || (parsed as XInput).x_google_ignoreList || undefined;\n\n    const resolve = resolver(mapUrl, sourceRoot);\n    this.resolvedSources = sources.map(resolve);\n\n    const { mappings } = parsed;\n    if (typeof mappings === 'string') {\n      this._encoded = mappings;\n      this._decoded = undefined;\n    } else if (Array.isArray(mappings)) {\n      this._encoded = undefined;\n      this._decoded = maybeSort(mappings, isString);\n    } else if ((parsed as unknown as SectionedSourceMap).sections) {\n      throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);\n    } else {\n      throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);\n    }\n\n    this._decodedMemo = memoizedState();\n    this._bySources = undefined;\n    this._bySourceMemos = undefined;\n  }\n}\n\n/**\n * Typescript doesn't allow friend access to private fields, so this just casts the map into a type\n * with public access modifiers.\n */\nfunction cast(map: unknown): PublicMap {\n  return map as any;\n}\n\n/**\n * Returns the encoded (VLQ string) form of the SourceMap's mappings field.\n */\nexport function encodedMappings(map: TraceMap): EncodedSourceMap['mappings'] {\n  return (cast(map)._encoded ??= encode(cast(map)._decoded!));\n}\n\n/**\n * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.\n */\nexport function decodedMappings(map: TraceMap): Readonly\u003cDecodedSourceMap['mappings']\u003e {\n  return (cast(map)._decoded ||= decode(cast(map)._encoded!));\n}\n\n/**\n * A low-level API to find the segment associated with a generated line/column (think, from a\n * stack trace). Line and column here are 0-based, unlike `originalPositionFor`.\n */\nexport function traceSegment(\n  map: TraceMap,\n  line: number,\n  column: number,\n): Readonly\u003cSourceMapSegment\u003e | null {\n  const decoded = decodedMappings(map);\n\n  // It's common for parent source maps to have pointers to lines that have no\n  // mapping (like a \"//# sourceMappingURL=\") at the end of the child file.\n  if (line \u003e= decoded.length) return null;\n\n  const segments = decoded[line];\n  const index = traceSegmentInternal(\n    segments,\n    cast(map)._decodedMemo,\n    line,\n    column,\n    GREATEST_LOWER_BOUND,\n  );\n\n  return index === -1 ? null : segments[index];\n}\n\n/**\n * A higher-level API to find the source/line/column associated with a generated line/column\n * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in\n * `source-map` library.\n */\nexport function originalPositionFor(\n  map: TraceMap,\n  needle: Needle,\n): OriginalMapping | InvalidOriginalMapping {\n  let { line, column, bias } = needle;\n  line--;\n  if (line \u003c 0) throw new Error(LINE_GTR_ZERO);\n  if (column \u003c 0) throw new Error(COL_GTR_EQ_ZERO);\n\n  const decoded = decodedMappings(map);\n\n  // It's common for parent source maps to have pointers to lines that have no\n  // mapping (like a \"//# sourceMappingURL=\") at the end of the child file.\n  if (line \u003e= decoded.length) return OMapping(null, null, null, null);\n\n  const segments = decoded[line];\n  const index = traceSegmentInternal(\n    segments,\n    cast(map)._decodedMemo,\n    line,\n    column,\n    bias || GREATEST_LOWER_BOUND,\n  );\n\n  if (index === -1) return OMapping(null, null, null, null);\n\n  const segment = segments[index];\n  if (segment.length === 1) return OMapping(null, null, null, null);\n\n  const { names, resolvedSources } = map;\n  return OMapping(\n    resolvedSources[segment[SOURCES_INDEX]],\n    segment[SOURCE_LINE] + 1,\n    segment[SOURCE_COLUMN],\n    segment.length === 5 ? names[segment[NAMES_INDEX]] : null,\n  );\n}\n\n/**\n * Finds the generated line/column position of the provided source/line/column source position.\n */\nexport function generatedPositionFor(\n  map: TraceMap,\n  needle: SourceNeedle,\n): GeneratedMapping | InvalidGeneratedMapping {\n  const { source, line, column, bias } = needle;\n  return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);\n}\n\n/**\n * Finds all generated line/column positions of the provided source/line/column source position.\n */\nexport function allGeneratedPositionsFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping[] {\n  const { source, line, column, bias } = needle;\n  // SourceMapConsumer uses LEAST_UPPER_BOUND for some reason, so we follow suit.\n  return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true);\n}\n\n/**\n * Iterates each mapping in generated position order.\n */\nexport function eachMapping(map: TraceMap, cb: (mapping: EachMapping) =\u003e void): void {\n  const decoded = decodedMappings(map);\n  const { names, resolvedSources } = map;\n\n  for (let i = 0; i \u003c decoded.length; i++) {\n    const line = decoded[i];\n    for (let j = 0; j \u003c line.length; j++) {\n      const seg = line[j];\n\n      const generatedLine = i + 1;\n      const generatedColumn = seg[0];\n      let source = null;\n      let originalLine = null;\n      let originalColumn = null;\n      let name = null;\n      if (seg.length !== 1) {\n        source = resolvedSources[seg[1]];\n        originalLine = seg[2] + 1;\n        originalColumn = seg[3];\n      }\n      if (seg.length === 5) name = names[seg[4]];\n\n      cb({\n        generatedLine,\n        generatedColumn,\n        source,\n        originalLine,\n        originalColumn,\n        name,\n      } as EachMapping);\n    }\n  }\n}\n\nfunction sourceIndex(map: TraceMap, source: string): number {\n  const { sources, resolvedSources } = map;\n  let index = sources.indexOf(source);\n  if (index === -1) index = resolvedSources.indexOf(source);\n  return index;\n}\n\n/**\n * Retrieves the source content for a particular source, if its found. Returns null if not.\n */\nexport function sourceContentFor(map: TraceMap, source: string): string | null {\n  const { sourcesContent } = map;\n  if (sourcesContent == null) return null;\n  const index = sourceIndex(map, source);\n  return index === -1 ? null : sourcesContent[index];\n}\n\n/**\n * Determines if the source is marked to ignore by the source map.\n */\nexport function isIgnored(map: TraceMap, source: string): boolean {\n  const { ignoreList } = map;\n  if (ignoreList == null) return false;\n  const index = sourceIndex(map, source);\n  return index === -1 ? false : ignoreList.includes(index);\n}\n\n/**\n * A helper that skips sorting of the input map's mappings array, which can be expensive for larger\n * maps.\n */\nexport function presortedDecodedMap(map: DecodedSourceMap, mapUrl?: string): TraceMap {\n  const tracer = new TraceMap(clone(map, []), mapUrl);\n  cast(tracer)._decoded = map.mappings;\n  return tracer;\n}\n\n/**\n * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects\n * a sourcemap, or to JSON.stringify.\n */\nexport function decodedMap(\n  map: TraceMap,\n): Omit\u003cDecodedSourceMap, 'mappings'\u003e \u0026 { mappings: readonly SourceMapSegment[][] } {\n  return clone(map, decodedMappings(map));\n}\n\n/**\n * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects\n * a sourcemap, or to JSON.stringify.\n */\nexport function encodedMap(map: TraceMap): EncodedSourceMap {\n  return clone(map, encodedMappings(map));\n}\n\nfunction clone\u003cT extends string | readonly SourceMapSegment[][]\u003e(\n  map: TraceMap | DecodedSourceMap,\n  mappings: T,\n): T extends string ? EncodedSourceMap : DecodedSourceMap {\n  return {\n    version: map.version,\n    file: map.file,\n    names: map.names,\n    sourceRoot: map.sourceRoot,\n    sources: map.sources,\n    sourcesContent: map.sourcesContent,\n    mappings,\n    ignoreList: map.ignoreList || (map as XInput).x_google_ignoreList,\n  } as any;\n}\n\nfunction OMapping(source: null, line: null, column: null, name: null): InvalidOriginalMapping;\nfunction OMapping(\n  source: string,\n  line: number,\n  column: number,\n  name: string | null,\n): OriginalMapping;\nfunction OMapping(\n  source: string | null,\n  line: number | null,\n  column: number | null,\n  name: string | null,\n): OriginalMapping | InvalidOriginalMapping {\n  return { source, line, column, name } as any;\n}\n\nfunction GMapping(line: null, column: null): InvalidGeneratedMapping;\nfunction GMapping(line: number, column: number): GeneratedMapping;\nfunction GMapping(\n  line: number | null,\n  column: number | null,\n): GeneratedMapping | InvalidGeneratedMapping {\n  return { line, column } as any;\n}\n\nfunction traceSegmentInternal(\n  segments: SourceMapSegment[],\n  memo: MemoState,\n  line: number,\n  column: number,\n  bias: Bias,\n): number;\nfunction traceSegmentInternal(\n  segments: ReverseSegment[],\n  memo: MemoState,\n  line: number,\n  column: number,\n  bias: Bias,\n): number;\nfunction traceSegmentInternal(\n  segments: SourceMapSegment[] | ReverseSegment[],\n  memo: MemoState,\n  line: number,\n  column: number,\n  bias: Bias,\n): number {\n  let index = memoizedBinarySearch(segments, column, memo, line);\n  if (bsFound) {\n    index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);\n  } else if (bias === LEAST_UPPER_BOUND) index++;\n\n  if (index === -1 || index === segments.length) return -1;\n  return index;\n}\n\nfunction sliceGeneratedPositions(\n  segments: ReverseSegment[],\n  memo: MemoState,\n  line: number,\n  column: number,\n  bias: Bias,\n): GeneratedMapping[] {\n  let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND);\n\n  // We ignored the bias when tracing the segment so that we're guarnateed to find the first (in\n  // insertion order) segment that matched. Even if we did respect the bias when tracing, we would\n  // still need to call `lowerBound()` to find the first segment, which is slower than just looking\n  // for the GREATEST_LOWER_BOUND to begin with. The only difference that matters for us is when the\n  // binary search didn't match, in which case GREATEST_LOWER_BOUND just needs to increment to\n  // match LEAST_UPPER_BOUND.\n  if (!bsFound \u0026\u0026 bias === LEAST_UPPER_BOUND) min++;\n\n  if (min === -1 || min === segments.length) return [];\n\n  // We may have found the segment that started at an earlier column. If this is the case, then we\n  // need to slice all generated segments that match _that_ column, because all such segments span\n  // to our desired column.\n  const matchedColumn = bsFound ? column : segments[min][COLUMN];\n\n  // The binary search is not guaranteed to find the lower bound when a match wasn't found.\n  if (!bsFound) min = lowerBound(segments, matchedColumn, min);\n  const max = upperBound(segments, matchedColumn, min);\n\n  const result = [];\n  for (; min \u003c= max; min++) {\n    const segment = segments[min];\n    result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]));\n  }\n  return result;\n}\n\nfunction generatedPosition(\n  map: TraceMap,\n  source: string,\n  line: number,\n  column: number,\n  bias: Bias,\n  all: false,\n): GeneratedMapping | InvalidGeneratedMapping;\nfunction generatedPosition(\n  map: TraceMap,\n  source: string,\n  line: number,\n  column: number,\n  bias: Bias,\n  all: true,\n): GeneratedMapping[];\nfunction generatedPosition(\n  map: TraceMap,\n  source: string,\n  line: number,\n  column: number,\n  bias: Bias,\n  all: boolean,\n): GeneratedMapping | InvalidGeneratedMapping | GeneratedMapping[] {\n  line--;\n  if (line \u003c 0) throw new Error(LINE_GTR_ZERO);\n  if (column \u003c 0) throw new Error(COL_GTR_EQ_ZERO);\n\n  const { sources, resolvedSources } = map;\n  let sourceIndex = sources.indexOf(source);\n  if (sourceIndex === -1) sourceIndex = resolvedSources.indexOf(source);\n  if (sourceIndex === -1) return all ? [] : GMapping(null, null);\n\n  const bySourceMemos = (cast(map)._bySourceMemos ||= sources.map(memoizedState));\n  const generated = (cast(map)._bySources ||= buildBySources(decodedMappings(map), bySourceMemos));\n\n  const segments = generated[sourceIndex][line];\n  if (segments == null) return all ? [] : GMapping(null, null);\n\n  const memo = bySourceMemos[sourceIndex];\n\n  if (all) return sliceGeneratedPositions(segments, memo, line, column, bias);\n\n  const index = traceSegmentInternal(segments, memo, line, column, bias);\n  if (index === -1) return GMapping(null, null);\n\n  const segment = segments[index];\n  return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);\n}\n","import resolveUri from '@jridgewell/resolve-uri';\nimport stripFilename from './strip-filename';\n\ntype Resolve = (source: string | null) =\u003e string;\nexport default function resolver(\n  mapUrl: string | null | undefined,\n  sourceRoot: string | undefined,\n): Resolve {\n  const from = stripFilename(mapUrl);\n  // The sourceRoot is always treated as a directory, if it's not empty.\n  // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327\n  // https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401\n  const prefix = sourceRoot ? sourceRoot + '/' : '';\n\n  return (source) =\u003e resolveUri(prefix + (source || ''), from);\n}\n","/**\n * Removes everything after the last \"/\", but leaves the slash.\n */\nexport default function stripFilename(path: string | undefined | null): string {\n  if (!path) return '';\n  const index = path.lastIndexOf('/');\n  return path.slice(0, index + 1);\n}\n","type GeneratedColumn = number;\ntype SourcesIndex = number;\ntype SourceLine = number;\ntype SourceColumn = number;\ntype NamesIndex = number;\n\ntype GeneratedLine = number;\n\nexport type SourceMapSegment =\n  | [GeneratedColumn]\n  | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn]\n  | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];\n\nexport type ReverseSegment = [SourceColumn, GeneratedLine, GeneratedColumn];\n\nexport const COLUMN = 0;\nexport const SOURCES_INDEX = 1;\nexport const SOURCE_LINE = 2;\nexport const SOURCE_COLUMN = 3;\nexport const NAMES_INDEX = 4;\n\nexport const REV_GENERATED_LINE = 1;\nexport const REV_GENERATED_COLUMN = 2;\n","import { COLUMN } from './sourcemap-segment';\n\nimport type { ReverseSegment, SourceMapSegment } from './sourcemap-segment';\n\nexport default function maybeSort(\n  mappings: SourceMapSegment[][],\n  owned: boolean,\n): SourceMapSegment[][] {\n  const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);\n  if (unsortedIndex === mappings.length) return mappings;\n\n  // If we own the array (meaning we parsed it from JSON), then we're free to directly mutate it. If\n  // not, we do not want to modify the consumer's input array.\n  if (!owned) mappings = mappings.slice();\n\n  for (let i = unsortedIndex; i \u003c mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {\n    mappings[i] = sortSegments(mappings[i], owned);\n  }\n  return mappings;\n}\n\nfunction nextUnsortedSegmentLine(mappings: SourceMapSegment[][], start: number): number {\n  for (let i = start; i \u003c mappings.length; i++) {\n    if (!isSorted(mappings[i])) return i;\n  }\n  return mappings.length;\n}\n\nfunction isSorted(line: SourceMapSegment[]): boolean {\n  for (let j = 1; j \u003c line.length; j++) {\n    if (line[j][COLUMN] \u003c line[j - 1][COLUMN]) {\n      return false;\n    }\n  }\n  return true;\n}\n\nfunction sortSegments(line: SourceMapSegment[], owned: boolean): SourceMapSegment[] {\n  if (!owned) line = line.slice();\n  return line.sort(sortComparator);\n}\n\nexport function sortComparator\u003cT extends SourceMapSegment | ReverseSegment\u003e(a: T, b: T): number {\n  return a[COLUMN] - b[COLUMN];\n}\n","import { COLUMN, SOURCES_INDEX, SOURCE_LINE, SOURCE_COLUMN } from './sourcemap-segment';\nimport { sortComparator } from './sort';\n\nimport type { ReverseSegment, SourceMapSegment } from './sourcemap-segment';\n\nexport type Source = ReverseSegment[][];\n\n// Rebuilds the original source files, with mappings that are ordered by source line/column instead\n// of generated line/column.\nexport default function buildBySources(\n  decoded: readonly SourceMapSegment[][],\n  memos: unknown[],\n): Source[] {\n  const sources: Source[] = memos.map(() =\u003e []);\n\n  for (let i = 0; i \u003c decoded.length; i++) {\n    const line = decoded[i];\n    for (let j = 0; j \u003c line.length; j++) {\n      const seg = line[j];\n      if (seg.length === 1) continue;\n\n      const sourceIndex = seg[SOURCES_INDEX];\n      const sourceLine = seg[SOURCE_LINE];\n      const sourceColumn = seg[SOURCE_COLUMN];\n\n      const source = sources[sourceIndex];\n      const segs = (source[sourceLine] ||= []);\n      segs.push([sourceColumn, i, seg[COLUMN]]);\n    }\n  }\n\n  for (let i = 0; i \u003c sources.length; i++) {\n    const source = sources[i];\n    for (let j = 0; j \u003c source.length; j++) {\n      const line = source[j];\n      if (line) line.sort(sortComparator);\n    }\n  }\n\n  return sources;\n}\n","import type { SourceMapSegment, ReverseSegment } from './sourcemap-segment';\nimport { COLUMN } from './sourcemap-segment';\n\nexport type MemoState = {\n  lastKey: number;\n  lastNeedle: number;\n  lastIndex: number;\n};\n\nexport let found = false;\n\n/**\n * A binary search implementation that returns the index if a match is found.\n * If no match is found, then the left-index (the index associated with the item that comes just\n * before the desired index) is returned. To maintain proper sort order, a splice would happen at\n * the next index:\n *\n * ```js\n * const array = [1, 3];\n * const needle = 2;\n * const index = binarySearch(array, needle, (item, needle) =\u003e item - needle);\n *\n * assert.equal(index, 0);\n * array.splice(index + 1, 0, needle);\n * assert.deepEqual(array, [1, 2, 3]);\n * ```\n */\nexport function binarySearch(\n  haystack: SourceMapSegment[] | ReverseSegment[],\n  needle: number,\n  low: number,\n  high: number,\n): number {\n  while (low \u003c= high) {\n    const mid = low + ((high - low) \u003e\u003e 1);\n    const cmp = haystack[mid][COLUMN] - needle;\n\n    if (cmp === 0) {\n      found = true;\n      return mid;\n    }\n\n    if (cmp \u003c 0) {\n      low = mid + 1;\n    } else {\n      high = mid - 1;\n    }\n  }\n\n  found = false;\n  return low - 1;\n}\n\nexport function upperBound(\n  haystack: SourceMapSegment[] | ReverseSegment[],\n  needle: number,\n  index: number,\n): number {\n  for (let i = index + 1; i \u003c haystack.length; index = i++) {\n    if (haystack[i][COLUMN] !== needle) break;\n  }\n  return index;\n}\n\nexport function lowerBound(\n  haystack: SourceMapSegment[] | ReverseSegment[],\n  needle: number,\n  index: number,\n): number {\n  for (let i = index - 1; i \u003e= 0; index = i--) {\n    if (haystack[i][COLUMN] !== needle) break;\n  }\n  return index;\n}\n\nexport function memoizedState(): MemoState {\n  return {\n    lastKey: -1,\n    lastNeedle: -1,\n    lastIndex: -1,\n  };\n}\n\n/**\n * This overly complicated beast is just to record the last tested line/column and the resulting\n * index, allowing us to skip a few tests if mappings are monotonically increasing.\n */\nexport function memoizedBinarySearch(\n  haystack: SourceMapSegment[] | ReverseSegment[],\n  needle: number,\n  state: MemoState,\n  key: number,\n): number {\n  const { lastKey, lastNeedle, lastIndex } = state;\n\n  let low = 0;\n  let high = haystack.length - 1;\n  if (key === lastKey) {\n    if (needle === lastNeedle) {\n      found = lastIndex !== -1 \u0026\u0026 haystack[lastIndex][COLUMN] === needle;\n      return lastIndex;\n    }\n\n    if (needle \u003e= lastNeedle) {\n      // lastIndex may be -1 if the previous needle was not found.\n      low = lastIndex === -1 ? 0 : lastIndex;\n    } else {\n      high = lastIndex;\n    }\n  }\n  state.lastKey = key;\n  state.lastNeedle = needle;\n\n  return (state.lastIndex = binarySearch(haystack, needle, low, high));\n}\n","import type { SourceMapSegment } from './sourcemap-segment';\nimport type { GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND, TraceMap } from './trace-mapping';\n\nexport interface SourceMapV3 {\n  file?: string | null;\n  names: string[];\n  sourceRoot?: string;\n  sources: (string | null)[];\n  sourcesContent?: (string | null)[];\n  version: 3;\n  ignoreList?: number[];\n}\n\nexport interface EncodedSourceMap extends SourceMapV3 {\n  mappings: string;\n}\n\nexport interface DecodedSourceMap extends SourceMapV3 {\n  mappings: SourceMapSegment[][];\n}\n\nexport interface Section {\n  offset: { line: number; column: number };\n  map: EncodedSourceMap | DecodedSourceMap | SectionedSourceMap;\n}\n\nexport interface SectionedSourceMap {\n  file?: string | null;\n  sections: Section[];\n  version: 3;\n}\n\nexport type OriginalMapping = {\n  source: string | null;\n  line: number;\n  column: number;\n  name: string | null;\n};\n\nexport type InvalidOriginalMapping = {\n  source: null;\n  line: null;\n  column: null;\n  name: null;\n};\n\nexport type GeneratedMapping = {\n  line: number;\n  column: number;\n};\nexport type InvalidGeneratedMapping = {\n  line: null;\n  column: null;\n};\n\nexport type Bias = typeof GREATEST_LOWER_BOUND | typeof LEAST_UPPER_BOUND;\n\nexport type XInput = { x_google_ignoreList?: SourceMapV3['ignoreList'] };\nexport type EncodedSourceMapXInput = EncodedSourceMap \u0026 XInput;\nexport type DecodedSourceMapXInput = DecodedSourceMap \u0026 XInput;\nexport type SectionedSourceMapXInput = Omit\u003cSectionedSourceMap, 'sections'\u003e \u0026 {\n  sections: SectionXInput[];\n};\nexport type SectionXInput = Omit\u003cSection, 'map'\u003e \u0026 {\n  map: SectionedSourceMapInput;\n};\n\nexport type SourceMapInput = string | EncodedSourceMapXInput | DecodedSourceMapXInput | TraceMap;\nexport type SectionedSourceMapInput = SourceMapInput | SectionedSourceMapXInput;\n\nexport type Needle = { line: number; column: number; bias?: Bias };\nexport type SourceNeedle = { source: string; line: number; column: number; bias?: Bias };\n\nexport type EachMapping =\n  | {\n      generatedLine: number;\n      generatedColumn: number;\n      source: null;\n      originalLine: null;\n      originalColumn: null;\n      name: null;\n    }\n  | {\n      generatedLine: number;\n      generatedColumn: number;\n      source: string | null;\n      originalLine: number;\n      originalColumn: number;\n      name: string | null;\n    };\n\nexport abstract class SourceMap {\n  declare version: SourceMapV3['version'];\n  declare file: SourceMapV3['file'];\n  declare names: SourceMapV3['names'];\n  declare sourceRoot: SourceMapV3['sourceRoot'];\n  declare sources: SourceMapV3['sources'];\n  declare sourcesContent: SourceMapV3['sourcesContent'];\n  declare resolvedSources: SourceMapV3['sources'];\n  declare ignoreList: SourceMapV3['ignoreList'];\n}\n\nexport type Ro\u003cT\u003e =\n  T extends Array\u003cinfer V\u003e\n    ? V[] | Readonly\u003cV[]\u003e | RoArray\u003cV\u003e | Readonly\u003cRoArray\u003cV\u003e\u003e\n    : T extends object\n      ? T | Readonly\u003cT\u003e | RoObject\u003cT\u003e | Readonly\u003cRoObject\u003cT\u003e\u003e\n      : T;\ntype RoArray\u003cT\u003e = Ro\u003cT\u003e[];\ntype RoObject\u003cT\u003e = { [K in keyof T]: T[K] | Ro\u003cT[K]\u003e };\n\nexport function parse\u003cT\u003e(map: T): Exclude\u003cT, string\u003e {\n  return typeof map === 'string' ? JSON.parse(map) : (map as Exclude\u003cT, string\u003e);\n}\n","import { TraceMap, presortedDecodedMap, decodedMappings } from './trace-mapping';\nimport {\n  COLUMN,\n  SOURCES_INDEX,\n  SOURCE_LINE,\n  SOURCE_COLUMN,\n  NAMES_INDEX,\n} from './sourcemap-segment';\nimport { parse } from './types';\n\nimport type {\n  DecodedSourceMap,\n  DecodedSourceMapXInput,\n  EncodedSourceMapXInput,\n  SectionedSourceMapXInput,\n  SectionedSourceMapInput,\n  SectionXInput,\n  Ro,\n} from './types';\nimport type { SourceMapSegment } from './sourcemap-segment';\n\ntype FlattenMap = {\n  new (map: Ro\u003cSectionedSourceMapInput\u003e, mapUrl?: string | null): TraceMap;\n  (map: Ro\u003cSectionedSourceMapInput\u003e, mapUrl?: string | null): TraceMap;\n};\n\nexport const FlattenMap: FlattenMap = function (map, mapUrl) {\n  const parsed = parse(map as SectionedSourceMapInput);\n\n  if (!('sections' in parsed)) {\n    return new TraceMap(parsed as DecodedSourceMapXInput | EncodedSourceMapXInput, mapUrl);\n  }\n\n  const mappings: SourceMapSegment[][] = [];\n  const sources: string[] = [];\n  const sourcesContent: (string | null)[] = [];\n  const names: string[] = [];\n  const ignoreList: number[] = [];\n\n  recurse(\n    parsed,\n    mapUrl,\n    mappings,\n    sources,\n    sourcesContent,\n    names,\n    ignoreList,\n    0,\n    0,\n    Infinity,\n    Infinity,\n  );\n\n  const joined: DecodedSourceMap = {\n    version: 3,\n    file: parsed.file,\n    names,\n    sources,\n    sourcesContent,\n    mappings,\n    ignoreList,\n  };\n\n  return presortedDecodedMap(joined);\n} as FlattenMap;\n\nfunction recurse(\n  input: SectionedSourceMapXInput,\n  mapUrl: string | null | undefined,\n  mappings: SourceMapSegment[][],\n  sources: string[],\n  sourcesContent: (string | null)[],\n  names: string[],\n  ignoreList: number[],\n  lineOffset: number,\n  columnOffset: number,\n  stopLine: number,\n  stopColumn: number,\n) {\n  const { sections } = input;\n  for (let i = 0; i \u003c sections.length; i++) {\n    const { map, offset } = sections[i];\n\n    let sl = stopLine;\n    let sc = stopColumn;\n    if (i + 1 \u003c sections.length) {\n      const nextOffset = sections[i + 1].offset;\n      sl = Math.min(stopLine, lineOffset + nextOffset.line);\n\n      if (sl === stopLine) {\n        sc = Math.min(stopColumn, columnOffset + nextOffset.column);\n      } else if (sl \u003c stopLine) {\n        sc = columnOffset + nextOffset.column;\n      }\n    }\n\n    addSection(\n      map,\n      mapUrl,\n      mappings,\n      sources,\n      sourcesContent,\n      names,\n      ignoreList,\n      lineOffset + offset.line,\n      columnOffset + offset.column,\n      sl,\n      sc,\n    );\n  }\n}\n\nfunction addSection(\n  input: SectionXInput['map'],\n  mapUrl: string | null | undefined,\n  mappings: SourceMapSegment[][],\n  sources: string[],\n  sourcesContent: (string | null)[],\n  names: string[],\n  ignoreList: number[],\n  lineOffset: number,\n  columnOffset: number,\n  stopLine: number,\n  stopColumn: number,\n) {\n  const parsed = parse(input);\n  if ('sections' in parsed) return recurse(...(arguments as unknown as Parameters\u003ctypeof recurse\u003e));\n\n  const map = new TraceMap(parsed, mapUrl);\n  const sourcesOffset = sources.length;\n  const namesOffset = names.length;\n  const decoded = decodedMappings(map);\n  const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map;\n\n  append(sources, resolvedSources);\n  append(names, map.names);\n\n  if (contents) append(sourcesContent, contents);\n  else for (let i = 0; i \u003c resolvedSources.length; i++) sourcesContent.push(null);\n\n  if (ignores) for (let i = 0; i \u003c ignores.length; i++) ignoreList.push(ignores[i] + sourcesOffset);\n\n  for (let i = 0; i \u003c decoded.length; i++) {\n    const lineI = lineOffset + i;\n\n    // We can only add so many lines before we step into the range that the next section's map\n    // controls. When we get to the last line, then we'll start checking the segments to see if\n    // they've crossed into the column range. But it may not have any columns that overstep, so we\n    // still need to check that we don't overstep lines, too.\n    if (lineI \u003e stopLine) return;\n\n    // The out line may already exist in mappings (if we're continuing the line started by a\n    // previous section). Or, we may have jumped ahead several lines to start this section.\n    const out = getLine(mappings, lineI);\n    // On the 0th loop, the section's column offset shifts us forward. On all other lines (since the\n    // map can be multiple lines), it doesn't.\n    const cOffset = i === 0 ? columnOffset : 0;\n\n    const line = decoded[i];\n    for (let j = 0; j \u003c line.length; j++) {\n      const seg = line[j];\n      const column = cOffset + seg[COLUMN];\n\n      // If this segment steps into the column range that the next section's map controls, we need\n      // to stop early.\n      if (lineI === stopLine \u0026\u0026 column \u003e= stopColumn) return;\n\n      if (seg.length === 1) {\n        out.push([column]);\n        continue;\n      }\n\n      const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX];\n      const sourceLine = seg[SOURCE_LINE];\n      const sourceColumn = seg[SOURCE_COLUMN];\n      out.push(\n        seg.length === 4\n          ? [column, sourcesIndex, sourceLine, sourceColumn]\n          : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]],\n      );\n    }\n  }\n}\n\nfunction append\u003cT\u003e(arr: T[], other: T[]) {\n  for (let i = 0; i \u003c other.length; i++) arr.push(other[i]);\n}\n\nfunction getLine\u003cT\u003e(arr: T[][], index: number): T[] {\n  for (let i = arr.length; i \u003c= index; i++) arr[i] = [];\n  return arr[index];\n}\n"],"version":3}
