{"ast":null,"code":"\"use strict\";\n\nimport _objectWithoutProperties from \"@babel/runtime/helpers/objectWithoutProperties\";\nvar _excluded = [\"state\"];\nimport * as React from 'react';\nimport { isRecordEqual } from \"./isRecordEqual.js\";\nexport var CHILD_STATE = Symbol('CHILD_STATE');\nexport function useRouteCache(routes) {\n  var cache = React.useMemo(function () {\n    return {\n      current: new Map()\n    };\n  }, []);\n  if (process.env.NODE_ENV === 'production') {\n    return routes;\n  }\n  cache.current = routes.reduce(function (acc, route) {\n    var previous = cache.current.get(route.key);\n    var state = route.state,\n      routeWithoutState = _objectWithoutProperties(route, _excluded);\n    var proxy;\n    if (previous && isRecordEqual(previous, routeWithoutState)) {\n      proxy = previous;\n    } else {\n      proxy = routeWithoutState;\n    }\n    if (process.env.NODE_ENV !== 'production') {\n      for (var key in proxy) {\n        var value = proxy[key];\n        Object.defineProperty(proxy, key, {\n          enumerable: true,\n          configurable: true,\n          writable: false,\n          value: value\n        });\n      }\n    }\n    Object.defineProperty(proxy, CHILD_STATE, {\n      enumerable: false,\n      configurable: true,\n      value: state\n    });\n    acc.set(route.key, proxy);\n    return acc;\n  }, new Map());\n  return Array.from(cache.current.values());\n}","map":{"version":3,"names":["React","isRecordEqual","CHILD_STATE","Symbol","useRouteCache","routes","cache","useMemo","current","Map","process","env","NODE_ENV","reduce","acc","route","previous","get","key","state","routeWithoutState","_objectWithoutProperties","_excluded","proxy","value","Object","defineProperty","enumerable","configurable","writable","set","Array","from","values"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/@react-navigation/core/src/useRouteCache.tsx"],"sourcesContent":["import type { NavigationState, ParamListBase } from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport { isRecordEqual } from './isRecordEqual';\nimport type { RouteProp } from './types';\n\ntype RouteCache = Map<string, RouteProp<ParamListBase>>;\n\n/**\n * Utilities such as `getFocusedRouteNameFromRoute` need to access state.\n * So we need a way to suppress the warning for those use cases.\n * This is fine since they are internal utilities and this is not public API.\n */\nexport const CHILD_STATE = Symbol('CHILD_STATE');\n\n/**\n * Hook to cache route props for each screen in the navigator.\n * This lets add warnings and modifications to the route object but keep references between renders.\n */\nexport function useRouteCache<State extends NavigationState>(\n  routes: State['routes']\n) {\n  // Cache object which holds route objects for each screen\n  const cache = React.useMemo(() => ({ current: new Map() as RouteCache }), []);\n\n  if (process.env.NODE_ENV === 'production') {\n    // We don't want the overhead of creating extra maps every render in prod\n    return routes;\n  }\n\n  cache.current = routes.reduce((acc, route) => {\n    const previous = cache.current.get(route.key);\n    const { state, ...routeWithoutState } = route;\n\n    let proxy;\n\n    if (previous && isRecordEqual(previous, routeWithoutState)) {\n      // If a cached route object already exists, reuse it\n      proxy = previous;\n    } else {\n      proxy = routeWithoutState;\n    }\n\n    if (process.env.NODE_ENV !== 'production') {\n      // FIXME: since the state is updated with mutation, the route object cannot be frozen\n      // As a workaround, loop through the object and make the properties readonly\n      for (const key in proxy) {\n        // @ts-expect-error: this is fine since we are looping through the object\n        const value = proxy[key];\n\n        Object.defineProperty(proxy, key, {\n          enumerable: true,\n          configurable: true,\n          writable: false,\n          value,\n        });\n      }\n    }\n\n    Object.defineProperty(proxy, CHILD_STATE, {\n      enumerable: false,\n      configurable: true,\n      value: state,\n    });\n\n    acc.set(route.key, proxy);\n\n    return acc;\n  }, new Map() as RouteCache);\n\n  return Array.from(cache.current.values());\n}\n"],"mappings":";;;;AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,SAASC,aAAa;AAUtB,OAAO,IAAMC,WAAW,GAAGC,MAAM,CAAC,aAAa,CAAC;AAMhD,OAAO,SAASC,aAAaA,CAC3BC,MAAuB,EACvB;EAEA,IAAMC,KAAK,GAAGN,KAAK,CAACO,OAAO,CAAC;IAAA,OAAO;MAAEC,OAAO,EAAE,IAAIC,GAAG,CAAC;IAAgB,CAAC;EAAA,CAAC,EAAE,EAAE,CAAC;EAE7E,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EA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