/**
 * Copyright (c) 2015-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */ import type { StackFrame } from './stack-frame' ; import { parse } from './parser' ; import { map } from './mapper' ; import { unmap } from './unmapper' ; import { toExclude } from '../../presets' ; function getStackFrames ( error , unhandledRejection = false , contextSize = 3 ) { const parsedFrames = parse ( error ) ; let enhancedFramesPromise ; if ( ( error as unknown as { __unmap_source : string | { uri : string ; contents : string ; } ; } ) . __unmap_source ) { enhancedFramesPromise = unmap ( ( error as unknown as { __unmap_source : string | { uri : string ; contents : string ; } ; } ) . __unmap_source , parsedFrames , contextSize ) ; } else { enhancedFramesPromise = map ( parsedFrames , contextSize ) ; } return enhancedFramesPromise . then ( ( enhancedFrames ) => { return enhancedFrames . filter ( ( { functionName , fileName } ) => ( functionName == null || functionName . indexOf ( '__stack_frame_overlay_proxy_console__' ) === - 1 ) && ! toExclude . test ( fileName ! ) ) ; } ) ; } export default getStackFrames ; export { getStackFrames } ;