{"ast":null,"code":"\"use strict\";\n\nimport _asyncToGenerator from \"@babel/runtime/helpers/asyncToGenerator\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport { findFocusedRoute, getActionFromState as getActionFromStateDefault, getPathFromState as getPathFromStateDefault, getStateFromPath as getStateFromPathDefault, useNavigationIndependentTree } from '@react-navigation/core';\nimport isEqual from 'fast-deep-equal';\nimport * as React from 'react';\nimport { createMemoryHistory } from \"./createMemoryHistory.js\";\nimport { ServerContext } from \"./ServerContext.js\";\nvar _findMatchingState = function findMatchingState(a, b) {\n  if (a === undefined || b === undefined || a.key !== b.key) {\n    return [undefined, undefined];\n  }\n  var aHistoryLength = a.history ? a.history.length : a.routes.length;\n  var bHistoryLength = b.history ? b.history.length : b.routes.length;\n  var aRoute = a.routes[a.index];\n  var bRoute = b.routes[b.index];\n  var aChildState = aRoute.state;\n  var bChildState = bRoute.state;\n  if (aHistoryLength !== bHistoryLength || aRoute.key !== bRoute.key || aChildState === undefined || bChildState === undefined || aChildState.key !== bChildState.key) {\n    return [a, b];\n  }\n  return _findMatchingState(aChildState, bChildState);\n};\nexport var series = function series(cb) {\n  var queue = Promise.resolve();\n  var callback = function callback() {\n    queue = queue.then(cb);\n  };\n  return callback;\n};\nvar linkingHandlers = [];\nexport function useLinking(ref, _ref, onUnhandledLinking) {\n  var _ref$enabled = _ref.enabled,\n    enabled = _ref$enabled === void 0 ? true : _ref$enabled,\n    config = _ref.config,\n    _ref$getStateFromPath = _ref.getStateFromPath,\n    getStateFromPath = _ref$getStateFromPath === void 0 ? getStateFromPathDefault : _ref$getStateFromPath,\n    _ref$getPathFromState = _ref.getPathFromState,\n    getPathFromState = _ref$getPathFromState === void 0 ? getPathFromStateDefault : _ref$getPathFromState,\n    _ref$getActionFromSta = _ref.getActionFromState,\n    getActionFromState = _ref$getActionFromSta === void 0 ? getActionFromStateDefault : _ref$getActionFromSta;\n  var independent = useNavigationIndependentTree();\n  React.useEffect(function () {\n    if (process.env.NODE_ENV === 'production') {\n      return undefined;\n    }\n    if (independent) {\n      return undefined;\n    }\n    if (enabled !== false && linkingHandlers.length) {\n      console.error(['Looks like you have configured linking in multiple places. This is likely an error since deep links should only be handled in one place to avoid conflicts. Make sure that:', \"- You don't have multiple NavigationContainers in the app each with 'linking' enabled\", '- Only a single instance of the root component is rendered'].join('\\n').trim());\n    }\n    var handler = Symbol();\n    if (enabled !== false) {\n      linkingHandlers.push(handler);\n    }\n    return function () {\n      var index = linkingHandlers.indexOf(handler);\n      if (index > -1) {\n        linkingHandlers.splice(index, 1);\n      }\n    };\n  }, [enabled, independent]);\n  var _React$useState = React.useState(createMemoryHistory),\n    _React$useState2 = _slicedToArray(_React$useState, 1),\n    history = _React$useState2[0];\n  var enabledRef = React.useRef(enabled);\n  var configRef = React.useRef(config);\n  var getStateFromPathRef = React.useRef(getStateFromPath);\n  var getPathFromStateRef = React.useRef(getPathFromState);\n  var getActionFromStateRef = React.useRef(getActionFromState);\n  React.useEffect(function () {\n    enabledRef.current = enabled;\n    configRef.current = config;\n    getStateFromPathRef.current = getStateFromPath;\n    getPathFromStateRef.current = getPathFromState;\n    getActionFromStateRef.current = getActionFromState;\n  });\n  var validateRoutesNotExistInRootState = React.useCallback(function (state) {\n    var navigation = ref.current;\n    var rootState = navigation == null ? void 0 : navigation.getRootState();\n    return state == null ? void 0 : state.routes.some(function (r) {\n      return !(rootState != null && rootState.routeNames.includes(r.name));\n    });\n  }, [ref]);\n  var server = React.useContext(ServerContext);\n  var getInitialState = React.useCallback(function () {\n    var value;\n    if (enabledRef.current) {\n      var _server$location;\n      var _location = (_server$location = server == null ? void 0 : server.location) != null ? _server$location : typeof window !== 'undefined' ? window.location : undefined;\n      var path = _location ? _location.pathname + _location.search : undefined;\n      if (path) {\n        value = getStateFromPathRef.current(path, configRef.current);\n      }\n      onUnhandledLinking(path);\n    }\n    var thenable = {\n      then: function then(onfulfilled) {\n        return Promise.resolve(onfulfilled ? onfulfilled(value) : value);\n      },\n      catch: function _catch() {\n        return thenable;\n      }\n    };\n    return thenable;\n  }, []);\n  var previousIndexRef = React.useRef(undefined);\n  var previousStateRef = React.useRef(undefined);\n  var pendingPopStatePathRef = React.useRef(undefined);\n  React.useEffect(function () {\n    previousIndexRef.current = history.index;\n    return history.listen(function () {\n      var _previousIndexRef$cur;\n      var navigation = ref.current;\n      if (!navigation || !enabled) {\n        return;\n      }\n      var _window = window,\n        location = _window.location;\n      var path = location.pathname + location.search;\n      var index = history.index;\n      var previousIndex = (_previousIndexRef$cur = previousIndexRef.current) != null ? _previousIndexRef$cur : 0;\n      previousIndexRef.current = index;\n      pendingPopStatePathRef.current = path;\n      var record = history.get(index);\n      if ((record == null ? void 0 : record.path) === path && record != null && record.state) {\n        navigation.resetRoot(record.state);\n        return;\n      }\n      var state = getStateFromPathRef.current(path, configRef.current);\n      if (state) {\n        onUnhandledLinking(path);\n        if (validateRoutesNotExistInRootState(state)) {\n          return;\n        }\n        if (index > previousIndex) {\n          var action = getActionFromStateRef.current(state, configRef.current);\n          if (action !== undefined) {\n            try {\n              navigation.dispatch(action);\n            } catch (e) {\n              console.warn(`An error occurred when trying to handle the link '${path}': ${typeof e === 'object' && e != null && 'message' in e ? e.message : e}`);\n            }\n          } else {\n            navigation.resetRoot(state);\n          }\n        } else {\n          navigation.resetRoot(state);\n        }\n      } else {\n        navigation.resetRoot(state);\n      }\n    });\n  }, [enabled, history, onUnhandledLinking, ref, validateRoutesNotExistInRootState]);\n  React.useEffect(function () {\n    var _ref$current;\n    if (!enabled) {\n      return;\n    }\n    var getPathForRoute = function getPathForRoute(route, state) {\n      var path;\n      if (route != null && route.path) {\n        var stateForPath = getStateFromPathRef.current(route.path, configRef.current);\n        if (stateForPath) {\n          var focusedRoute = findFocusedRoute(stateForPath);\n          if (focusedRoute && focusedRoute.name === route.name && isEqual(focusedRoute.params, route.params)) {\n            path = route.path;\n          }\n        }\n      }\n      if (path == null) {\n        path = getPathFromStateRef.current(state, configRef.current);\n      }\n      var previousRoute = previousStateRef.current ? findFocusedRoute(previousStateRef.current) : undefined;\n      if (previousRoute && route && 'key' in previousRoute && 'key' in route && previousRoute.key === route.key) {\n        path = path + location.hash;\n      }\n      return path;\n    };\n    if (ref.current) {\n      var state = ref.current.getRootState();\n      if (state) {\n        var route = findFocusedRoute(state);\n        var path = getPathForRoute(route, state);\n        if (previousStateRef.current === undefined) {\n          previousStateRef.current = state;\n        }\n        history.replace({\n          path: path,\n          state: state\n        });\n      }\n    }\n    var onStateChange = function () {\n      var _ref2 = _asyncToGenerator(function* () {\n        var navigation = ref.current;\n        if (!navigation || !enabled) {\n          return;\n        }\n        var previousState = previousStateRef.current;\n        var state = navigation.getRootState();\n        if (!state) {\n          return;\n        }\n        var pendingPath = pendingPopStatePathRef.current;\n        var route = findFocusedRoute(state);\n        var path = getPathForRoute(route, state);\n        previousStateRef.current = state;\n        pendingPopStatePathRef.current = undefined;\n        var _findMatchingState2 = _findMatchingState(previousState, state),\n          _findMatchingState3 = _slicedToArray(_findMatchingState2, 2),\n          previousFocusedState = _findMatchingState3[0],\n          focusedState = _findMatchingState3[1];\n        if (previousFocusedState && focusedState && path !== pendingPath) {\n          var historyDelta = (focusedState.history ? focusedState.history.length : focusedState.routes.length) - (previousFocusedState.history ? previousFocusedState.history.length : previousFocusedState.routes.length);\n          if (historyDelta > 0) {\n            history.push({\n              path: path,\n              state: state\n            });\n          } else if (historyDelta < 0) {\n            var nextIndex = history.backIndex({\n              path: path\n            });\n            var currentIndex = history.index;\n            try {\n              if (nextIndex !== -1 && nextIndex < currentIndex && history.get(nextIndex)) {\n                yield history.go(nextIndex - currentIndex);\n              } else {\n                yield history.go(historyDelta);\n              }\n              history.replace({\n                path: path,\n                state: state\n              });\n            } catch (e) {}\n          } else {\n            history.replace({\n              path: path,\n              state: state\n            });\n          }\n        } else {\n          history.replace({\n            path: path,\n            state: state\n          });\n        }\n      });\n      return function onStateChange() {\n        return _ref2.apply(this, arguments);\n      };\n    }();\n    return (_ref$current = ref.current) == null ? void 0 : _ref$current.addListener('state', series(onStateChange));\n  }, [enabled, history, ref]);\n  return {\n    getInitialState: getInitialState\n  };\n}","map":{"version":3,"names":["findFocusedRoute","getActionFromState","getActionFromStateDefault","getPathFromState","getPathFromStateDefault","getStateFromPath","getStateFromPathDefault","useNavigationIndependentTree","isEqual","React","createMemoryHistory","ServerContext","findMatchingState","a","b","undefined","key","aHistoryLength","history","length","routes","bHistoryLength","aRoute","index","bRoute","aChildState","state","bChildState","series","cb","queue","Promise","resolve","callback","then","linkingHandlers","useLinking","ref","_ref","onUnhandledLinking","_ref$enabled","enabled","config","_ref$getStateFromPath","_ref$getPathFromState","_ref$getActionFromSta","independent","useEffect","process","env","NODE_ENV","console","error","join","trim","handler","Symbol","push","indexOf","splice","_React$useState","useState","_React$useState2","_slicedToArray","enabledRef","useRef","configRef","getStateFromPathRef","getPathFromStateRef","getActionFromStateRef","current","validateRoutesNotExistInRootState","useCallback","navigation","rootState","getRootState","some","r","routeNames","includes","name","server","useContext","getInitialState","value","_server$location","location","window","path","pathname","search","thenable","onfulfilled","catch","previousIndexRef","previousStateRef","pendingPopStatePathRef","listen","_previousIndexRef$cur","_window","previousIndex","record","get","resetRoot","action","dispatch","e","warn","message","_ref$current","getPathForRoute","route","stateForPath","focusedRoute","params","previousRoute","hash","replace","onStateChange","_ref2","_asyncToGenerator","previousState","pendingPath","_findMatchingState2","_findMatchingState3","previousFocusedState","focusedState","historyDelta","nextIndex","backIndex","currentIndex","go","apply","arguments","addListener"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/@react-navigation/native/src/useLinking.tsx"],"sourcesContent":["import {\n  findFocusedRoute,\n  getActionFromState as getActionFromStateDefault,\n  getPathFromState as getPathFromStateDefault,\n  getStateFromPath as getStateFromPathDefault,\n  type NavigationContainerRef,\n  type NavigationState,\n  type ParamListBase,\n  useNavigationIndependentTree,\n} from '@react-navigation/core';\nimport isEqual from 'fast-deep-equal';\nimport * as React from 'react';\n\nimport { createMemoryHistory } from './createMemoryHistory';\nimport { ServerContext } from './ServerContext';\nimport type { LinkingOptions } from './types';\n\ntype ResultState = ReturnType<typeof getStateFromPathDefault>;\n\n/**\n * Find the matching navigation state that changed between 2 navigation states\n * e.g.: a -> b -> c -> d and a -> b -> c -> e -> f, if history in b changed, b is the matching state\n */\nconst findMatchingState = <T extends NavigationState>(\n  a: T | undefined,\n  b: T | undefined\n): [T | undefined, T | undefined] => {\n  if (a === undefined || b === undefined || a.key !== b.key) {\n    return [undefined, undefined];\n  }\n\n  // Tab and drawer will have `history` property, but stack will have history in `routes`\n  const aHistoryLength = a.history ? a.history.length : a.routes.length;\n  const bHistoryLength = b.history ? b.history.length : b.routes.length;\n\n  const aRoute = a.routes[a.index];\n  const bRoute = b.routes[b.index];\n\n  const aChildState = aRoute.state as T | undefined;\n  const bChildState = bRoute.state as T | undefined;\n\n  // Stop here if this is the state object that changed:\n  // - history length is different\n  // - focused routes are different\n  // - one of them doesn't have child state\n  // - child state keys are different\n  if (\n    aHistoryLength !== bHistoryLength ||\n    aRoute.key !== bRoute.key ||\n    aChildState === undefined ||\n    bChildState === undefined ||\n    aChildState.key !== bChildState.key\n  ) {\n    return [a, b];\n  }\n\n  return findMatchingState(aChildState, bChildState);\n};\n\n/**\n * Run async function in series as it's called.\n */\nexport const series = (cb: () => Promise<void>) => {\n  let queue = Promise.resolve();\n  const callback = () => {\n    // eslint-disable-next-line promise/no-callback-in-promise\n    queue = queue.then(cb);\n  };\n  return callback;\n};\n\nconst linkingHandlers: symbol[] = [];\n\ntype Options = LinkingOptions<ParamListBase>;\n\nexport function useLinking(\n  ref: React.RefObject<NavigationContainerRef<ParamListBase> | null>,\n  {\n    enabled = true,\n    config,\n    getStateFromPath = getStateFromPathDefault,\n    getPathFromState = getPathFromStateDefault,\n    getActionFromState = getActionFromStateDefault,\n  }: Options,\n  onUnhandledLinking: (lastUnhandledLining: string | undefined) => void\n) {\n  const independent = useNavigationIndependentTree();\n\n  React.useEffect(() => {\n    if (process.env.NODE_ENV === 'production') {\n      return undefined;\n    }\n\n    if (independent) {\n      return undefined;\n    }\n\n    if (enabled !== false && linkingHandlers.length) {\n      console.error(\n        [\n          'Looks like you have configured linking in multiple places. This is likely an error since deep links should only be handled in one place to avoid conflicts. Make sure that:',\n          \"- You don't have multiple NavigationContainers in the app each with 'linking' enabled\",\n          '- Only a single instance of the root component is rendered',\n        ]\n          .join('\\n')\n          .trim()\n      );\n    }\n\n    const handler = Symbol();\n\n    if (enabled !== false) {\n      linkingHandlers.push(handler);\n    }\n\n    return () => {\n      const index = linkingHandlers.indexOf(handler);\n\n      if (index > -1) {\n        linkingHandlers.splice(index, 1);\n      }\n    };\n  }, [enabled, independent]);\n\n  const [history] = React.useState(createMemoryHistory);\n\n  // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners\n  // This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`\n  // Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect\n  const enabledRef = React.useRef(enabled);\n  const configRef = React.useRef(config);\n  const getStateFromPathRef = React.useRef(getStateFromPath);\n  const getPathFromStateRef = React.useRef(getPathFromState);\n  const getActionFromStateRef = React.useRef(getActionFromState);\n\n  React.useEffect(() => {\n    enabledRef.current = enabled;\n    configRef.current = config;\n    getStateFromPathRef.current = getStateFromPath;\n    getPathFromStateRef.current = getPathFromState;\n    getActionFromStateRef.current = getActionFromState;\n  });\n\n  const validateRoutesNotExistInRootState = React.useCallback(\n    (state: ResultState) => {\n      const navigation = ref.current;\n      const rootState = navigation?.getRootState();\n      // Make sure that the routes in the state exist in the root navigator\n      // Otherwise there's an error in the linking configuration\n      return state?.routes.some((r) => !rootState?.routeNames.includes(r.name));\n    },\n    [ref]\n  );\n\n  const server = React.useContext(ServerContext);\n\n  const getInitialState = React.useCallback(() => {\n    let value: ResultState | undefined;\n\n    if (enabledRef.current) {\n      const location =\n        server?.location ??\n        (typeof window !== 'undefined' ? window.location : undefined);\n\n      const path = location ? location.pathname + location.search : undefined;\n\n      if (path) {\n        value = getStateFromPathRef.current(path, configRef.current);\n      }\n\n      // If the link were handled, it gets cleared in NavigationContainer\n      onUnhandledLinking(path);\n    }\n\n    const thenable = {\n      then(onfulfilled?: (state: ResultState | undefined) => void) {\n        return Promise.resolve(onfulfilled ? onfulfilled(value) : value);\n      },\n      catch() {\n        return thenable;\n      },\n    };\n\n    return thenable as PromiseLike<ResultState | undefined>;\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n\n  const previousIndexRef = React.useRef<number | undefined>(undefined);\n  const previousStateRef = React.useRef<NavigationState | undefined>(undefined);\n  const pendingPopStatePathRef = React.useRef<string | undefined>(undefined);\n\n  React.useEffect(() => {\n    previousIndexRef.current = history.index;\n\n    return history.listen(() => {\n      const navigation = ref.current;\n\n      if (!navigation || !enabled) {\n        return;\n      }\n\n      const { location } = window;\n\n      const path = location.pathname + location.search;\n      const index = history.index;\n\n      const previousIndex = previousIndexRef.current ?? 0;\n\n      previousIndexRef.current = index;\n      pendingPopStatePathRef.current = path;\n\n      // When browser back/forward is clicked, we first need to check if state object for this index exists\n      // If it does we'll reset to that state object\n      // Otherwise, we'll handle it like a regular deep link\n      const record = history.get(index);\n\n      if (record?.path === path && record?.state) {\n        navigation.resetRoot(record.state);\n        return;\n      }\n\n      const state = getStateFromPathRef.current(path, configRef.current);\n\n      // We should only dispatch an action when going forward\n      // Otherwise the action will likely add items to history, which would mess things up\n      if (state) {\n        // If the link were handled, it gets cleared in NavigationContainer\n        onUnhandledLinking(path);\n        // Make sure that the routes in the state exist in the root navigator\n        // Otherwise there's an error in the linking configuration\n        if (validateRoutesNotExistInRootState(state)) {\n          return;\n        }\n\n        if (index > previousIndex) {\n          const action = getActionFromStateRef.current(\n            state,\n            configRef.current\n          );\n\n          if (action !== undefined) {\n            try {\n              navigation.dispatch(action);\n            } catch (e) {\n              // Ignore any errors from deep linking.\n              // This could happen in case of malformed links, navigation object not being initialized etc.\n              console.warn(\n                `An error occurred when trying to handle the link '${path}': ${\n                  typeof e === 'object' && e != null && 'message' in e\n                    ? e.message\n                    : e\n                }`\n              );\n            }\n          } else {\n            navigation.resetRoot(state);\n          }\n        } else {\n          navigation.resetRoot(state);\n        }\n      } else {\n        // if current path didn't return any state, we should revert to initial state\n        navigation.resetRoot(state);\n      }\n    });\n  }, [\n    enabled,\n    history,\n    onUnhandledLinking,\n    ref,\n    validateRoutesNotExistInRootState,\n  ]);\n\n  React.useEffect(() => {\n    if (!enabled) {\n      return;\n    }\n\n    const getPathForRoute = (\n      route: ReturnType<typeof findFocusedRoute>,\n      state: NavigationState\n    ): string => {\n      let path;\n\n      // If the `route` object contains a `path`, use that path as long as `route.name` and `params` still match\n      // This makes sure that we preserve the original URL for wildcard routes\n      if (route?.path) {\n        const stateForPath = getStateFromPathRef.current(\n          route.path,\n          configRef.current\n        );\n\n        if (stateForPath) {\n          const focusedRoute = findFocusedRoute(stateForPath);\n\n          if (\n            focusedRoute &&\n            focusedRoute.name === route.name &&\n            isEqual(focusedRoute.params, route.params)\n          ) {\n            path = route.path;\n          }\n        }\n      }\n\n      if (path == null) {\n        path = getPathFromStateRef.current(state, configRef.current);\n      }\n\n      const previousRoute = previousStateRef.current\n        ? findFocusedRoute(previousStateRef.current)\n        : undefined;\n\n      // Preserve the hash if the route didn't change\n      if (\n        previousRoute &&\n        route &&\n        'key' in previousRoute &&\n        'key' in route &&\n        previousRoute.key === route.key\n      ) {\n        path = path + location.hash;\n      }\n\n      return path;\n    };\n\n    if (ref.current) {\n      // We need to record the current metadata on the first render if they aren't set\n      // This will allow the initial state to be in the history entry\n      const state = ref.current.getRootState();\n\n      if (state) {\n        const route = findFocusedRoute(state);\n        const path = getPathForRoute(route, state);\n\n        if (previousStateRef.current === undefined) {\n          previousStateRef.current = state;\n        }\n\n        history.replace({ path, state });\n      }\n    }\n\n    const onStateChange = async () => {\n      const navigation = ref.current;\n\n      if (!navigation || !enabled) {\n        return;\n      }\n\n      const previousState = previousStateRef.current;\n      const state = navigation.getRootState();\n\n      // root state may not available, for example when root navigators switch inside the container\n      if (!state) {\n        return;\n      }\n\n      const pendingPath = pendingPopStatePathRef.current;\n      const route = findFocusedRoute(state);\n      const path = getPathForRoute(route, state);\n\n      previousStateRef.current = state;\n      pendingPopStatePathRef.current = undefined;\n\n      // To detect the kind of state change, we need to:\n      // - Find the common focused navigation state in previous and current state\n      // - If only the route keys changed, compare history/routes.length to check if we go back/forward/replace\n      // - If no common focused navigation state found, it's a replace\n      const [previousFocusedState, focusedState] = findMatchingState(\n        previousState,\n        state\n      );\n\n      if (\n        previousFocusedState &&\n        focusedState &&\n        // We should only handle push/pop if path changed from what was in last `popstate`\n        // Otherwise it's likely a change triggered by `popstate`\n        path !== pendingPath\n      ) {\n        const historyDelta =\n          (focusedState.history\n            ? focusedState.history.length\n            : focusedState.routes.length) -\n          (previousFocusedState.history\n            ? previousFocusedState.history.length\n            : previousFocusedState.routes.length);\n\n        if (historyDelta > 0) {\n          // If history length is increased, we should pushState\n          // Note that path might not actually change here, for example, drawer open should pushState\n          history.push({ path, state });\n        } else if (historyDelta < 0) {\n          // If history length is decreased, i.e. entries were removed, we want to go back\n\n          const nextIndex = history.backIndex({ path });\n          const currentIndex = history.index;\n\n          try {\n            if (\n              nextIndex !== -1 &&\n              nextIndex < currentIndex &&\n              // We should only go back if the entry exists and it's less than current index\n              history.get(nextIndex)\n            ) {\n              // An existing entry for this path exists and it's less than current index, go back to that\n              await history.go(nextIndex - currentIndex);\n            } else {\n              // We couldn't find an existing entry to go back to, so we'll go back by the delta\n              // This won't be correct if multiple routes were pushed in one go before\n              // Usually this shouldn't happen and this is a fallback for that\n              await history.go(historyDelta);\n            }\n\n            // Store the updated state as well as fix the path if incorrect\n            history.replace({ path, state });\n          } catch (e) {\n            // The navigation was interrupted\n          }\n        } else {\n          // If history length is unchanged, we want to replaceState\n          history.replace({ path, state });\n        }\n      } else {\n        // If no common navigation state was found, assume it's a replace\n        // This would happen if the user did a reset/conditionally changed navigators\n        history.replace({ path, state });\n      }\n    };\n\n    // We debounce onStateChange coz we don't want multiple state changes to be handled at one time\n    // This could happen since `history.go(n)` is asynchronous\n    // If `pushState` or `replaceState` were called before `history.go(n)` completes, it'll mess stuff up\n    return ref.current?.addListener('state', series(onStateChange));\n  }, [enabled, history, ref]);\n\n  return {\n    getInitialState,\n  };\n}\n"],"mappings":";;;;AAAA,SACEA,gBAAgB,EAChBC,kBAAkB,IAAIC,yBAAyB,EAC/CC,gBAAgB,IAAIC,uBAAuB,EAC3CC,gBAAgB,IAAIC,uBAAuB,EAI3CC,4BAA4B,QACvB,wBAAwB;AAC/B,OAAOC,OAAO,MAAM,iBAAiB;AACrC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,SAASC,mBAAmB;AAC5B,SAASC,aAAa;AAStB,IAAMC,kBAAiB,GAAG,SAApBA,iBAAiBA,CACrBC,CAAgB,EAChBC,CAAgB,EACmB;EACnC,IAAID,CAAC,KAAKE,SAAS,IAAID,CAAC,KAAKC,SAAS,IAAIF,CAAC,CAACG,GAAG,KAAKF,CAAC,CAACE,GAAG,EAAE;IACzD,OAAO,CAACD,SAAS,EAAEA,SAAS,CAAC;EAC/B;EAGA,IAAME,cAAc,GAAGJ,CAAC,CAACK,OAAO,GAAGL,CAAC,CAACK,OAAO,CAACC,MAAM,GAAGN,CAAC,CAACO,MAAM,CAACD,MAAM;EACrE,IAAME,cAAc,GAAGP,CAAC,CAACI,OAAO,GAAGJ,CAAC,CAACI,OAAO,CAACC,MAAM,GAAGL,CAAC,CAACM,MAAM,CAACD,MAAM;EAErE,IAAMG,MAAM,GAAGT,CAAC,CAACO,MAAM,CAACP,CAAC,CAACU,KAAK,CAAC;EAChC,IAAMC,MAAM,GAAGV,CAAC,CAACM,MAAM,CAACN,CAAC,CAACS,KAAK,CAAC;EAEhC,IAAME,WAAW,GAAGH,MAAM,CAACI,KAAsB;EACjD,IAAMC,WAAW,GAAGH,MAAM,CAACE,KAAsB;EAOjD,IACET,cAAc,KAAKI,cAAc,I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