{"version":3,"file":"useLinking.js","names":["getStateFromPathDefault","getPathFromStateDefault","getActionFromStateDefault","getStateFromPath","getPathFromState","getActionFromState","routerRootState"],"sources":["esm/fork/useLinking.js"],"sourcesContent":["import {\n  findFocusedRoute,\n  getActionFromState as getActionFromStateDefault,\n  getPathFromState as getPathFromStateDefault,\n  useNavigationIndependentTree\n} from \"@react-navigation/core\";\nimport { getStateFromPath as getStateFromPathDefault } from \"./getStateFromPath\";\nimport isEqual from \"fast-deep-equal\";\nimport * as React from \"react\";\nimport { stripGroupSegmentsFromPath } from \"../router/matchers\";\nimport {\n  setNavigationType,\n  isReturningFromIntercept,\n  setReturningFromIntercept,\n  restoreInterceptFromHistory\n} from \"../router/interceptRoutes\";\nimport {\n  consumePendingNavigationAction,\n  rootState as routerRootState,\n  routeNode\n} from \"../router/router\";\nimport { isStateAwaitingNavigatorMount } from \"../router/isStateAwaitingNavigatorMount\";\nimport { ServerLocationContext } from \"../router/serverLocationContext\";\nimport { clearAllSlotStates } from \"../views/Navigator\";\nimport { createMemoryHistory } from \"./createMemoryHistory\";\nimport { appendBaseUrl } from \"./getPathFromState-mods\";\nconst getPartialState = (state) => {\n  if (!state) return void 0;\n  const { key, routeNames, stale, routes, ...partial } = state;\n  return {\n    ...partial,\n    stale: true,\n    routes: routes.map(({ key: routeKey, state: childState, ...route }) => ({\n      ...route,\n      ...childState ? { state: getPartialState(childState) } : null\n    }))\n  };\n};\nfunction getFocusedRouteDepth(state) {\n  const length = getTotalHistoryLength(state);\n  const focusedRoute = state.routes[state.index];\n  const child = focusedRoute?.state;\n  if (child) {\n    return length + getFocusedRouteDepth(child);\n  }\n  return length;\n}\nconst getTotalHistoryLength = (state) => {\n  const activeRoutes = state.routes.slice(0, state.index + 1);\n  const baseHistoryLength = state.history ? state.history.length : activeRoutes.length;\n  const routeHistoryLength = activeRoutes.reduce((acc, r) => {\n    return acc + (r.history ? r.history.length : 0);\n  }, 0);\n  return baseHistoryLength + routeHistoryLength;\n};\nfunction getDynamicParamNames(routeName) {\n  return Array.from(routeName.matchAll(/\\[(?:\\.\\.\\.)?([^\\]]+)\\]/g), (match) => match[1]);\n}\nfunction hasMissingDynamicParams(route) {\n  if (!route) return false;\n  const dynamicParamNames = getDynamicParamNames(route.name);\n  if (dynamicParamNames.length === 0) return false;\n  return dynamicParamNames.some((name) => route.params?.[name] == null);\n}\nfunction currentUrlHasDynamicParams(route, getStateFromPath, config) {\n  const currentPath = window.location.pathname + window.location.search;\n  const currentState = getStateFromPath(currentPath, config);\n  const currentRoute = currentState ? findFocusedRoute(currentState) : void 0;\n  return currentRoute?.name === route.name && !hasMissingDynamicParams(currentRoute);\n}\nconst findMatchingState = (a, b) => {\n  if (a === void 0 || b === void 0 || a.key !== b.key) {\n    return [void 0, void 0];\n  }\n  const aHistoryLength = getTotalHistoryLength(a);\n  const bHistoryLength = getTotalHistoryLength(b);\n  const aRoute = a.routes[a.index];\n  const bRoute = b.routes[b.index];\n  const aChildState = aRoute.state;\n  const bChildState = bRoute.state;\n  if (aHistoryLength !== bHistoryLength || aRoute.key !== bRoute.key || aChildState === void 0 || bChildState === void 0 || aChildState.key !== bChildState.key || (aRoute.history?.length || 0) !== (bRoute.history?.length || 0)) {\n    return [a, b];\n  }\n  return findMatchingState(aChildState, bChildState);\n};\nconst series = (cb) => {\n  let queue = Promise.resolve();\n  const callback = () => {\n    queue = queue.then(cb);\n  };\n  return callback;\n};\nconst linkingHandlers = /* @__PURE__ */ new Set();\nfunction useLinking(ref, {\n  enabled = true,\n  config,\n  getStateFromPath = getStateFromPathDefault,\n  getPathFromState = getPathFromStateDefault,\n  getActionFromState = getActionFromStateDefault\n}) {\n  if (typeof window === \"undefined\") {\n    const getInitialState2 = React.useCallback(() => {\n      return {\n        then(fn) {\n          return Promise.resolve(fn ? fn(void 0) : void 0);\n        },\n        catch() {\n          return this;\n        }\n      };\n    }, []);\n    return { getInitialState: getInitialState2 };\n  }\n  const independent = useNavigationIndependentTree();\n  React.useEffect(() => {\n    if (process.env.NODE_ENV === \"production\") {\n      return void 0;\n    }\n    if (independent) {\n      return void 0;\n    }\n    if (enabled !== false && linkingHandlers.size) {\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        ].join(\"\\n\").trim()\n      );\n    }\n    const handler = /* @__PURE__ */ Symbol();\n    if (enabled !== false) {\n      linkingHandlers.add(handler);\n    }\n    return () => {\n      linkingHandlers.delete(handler);\n    };\n  }, [enabled, independent]);\n  const [history] = React.useState(createMemoryHistory);\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  const restoringFromTempLocationRef = React.useRef(false);\n  const initialHistorySetupDoneRef = React.useRef(false);\n  const maskedDisplayPathRef = React.useRef(void 0);\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  const validateRoutesNotExistInRootState = React.useCallback(\n    (state) => {\n      const navigation = ref.current;\n      const rootState = navigation?.getRootState();\n      const routeNames = rootState?.routeNames;\n      if (!routeNames) {\n        return false;\n      }\n      return state?.routes.some((r) => !routeNames.includes(r.name));\n    },\n    [ref]\n  );\n  const location = React.useContext(ServerLocationContext);\n  const server = { location };\n  const getInitialState = React.useCallback(() => {\n    setNavigationType(\"hard\");\n    clearAllSlotStates();\n    let value;\n    if (enabledRef.current) {\n      const location2 = server?.location ?? (typeof window !== \"undefined\" ? window.location : void 0);\n      let path = location2 ? location2.pathname + location2.search + (location2.hash ?? \"\") : void 0;\n      if (location2 && typeof window !== \"undefined\") {\n        const historyState = window.history.state;\n        if (historyState) {\n          const { __tempLocation, __tempKey } = historyState;\n          if (__tempLocation?.pathname && !__tempKey) {\n            path = __tempLocation.pathname + (__tempLocation.search || \"\");\n            restoringFromTempLocationRef.current = true;\n          }\n        }\n      }\n      if (process.env.ONE_DEBUG_ROUTER) {\n        console.info(`[one] \\u{1F50D} getInitialState path=${path}`);\n      }\n      if (path) {\n        value = getStateFromPathRef.current(path, configRef.current);\n      }\n    }\n    const thenable = {\n      // biome-ignore lint/suspicious/noThenProperty: don't check copied code\n      then(onfulfilled) {\n        return Promise.resolve(onfulfilled ? onfulfilled(value) : value);\n      },\n      catch() {\n        return thenable;\n      }\n    };\n    return thenable;\n  }, []);\n  const previousIndexRef = React.useRef(void 0);\n  const previousStateRef = React.useRef(void 0);\n  const pendingPopStatePathRef = React.useRef(void 0);\n  React.useEffect(() => {\n    previousIndexRef.current = history.index;\n    return history.listen(() => {\n      const navigation = ref.current;\n      if (!navigation || !enabled) {\n        return;\n      }\n      if (isReturningFromIntercept()) {\n        setReturningFromIntercept(false);\n        clearAllSlotStates();\n        return;\n      }\n      if (restoreInterceptFromHistory()) {\n        return;\n      }\n      setNavigationType(\"hard\");\n      clearAllSlotStates();\n      maskedDisplayPathRef.current = void 0;\n      const { location: location2 } = window;\n      const path = location2.pathname + location2.search;\n      const index = history.index;\n      const previousIndex = previousIndexRef.current ?? 0;\n      if (process.env.ONE_DEBUG_ROUTER) {\n        console.info(\n          `[one] \\u{1F4DC} history.listen path=${path} index=${index} prevIndex=${previousIndex}`\n        );\n      }\n      previousIndexRef.current = index;\n      pendingPopStatePathRef.current = path;\n      const record = history.get(index);\n      const pathMatches = record?.path === path || record?.displayPath === path;\n      if (pathMatches && record?.state) {\n        if (process.env.ONE_DEBUG_ROUTER) {\n          console.info(`[one] \\u{1F4DC} history record found, resetRoot to:`, record.state);\n        }\n        navigation.resetRoot(getPartialState(record.state));\n        return;\n      }\n      const state = getStateFromPathRef.current(path, configRef.current);\n      if (process.env.ONE_DEBUG_ROUTER) {\n        console.info(`[one] \\u{1F4DC} getStateFromPath result:`, state);\n      }\n      if (state) {\n        if (validateRoutesNotExistInRootState(state)) {\n          if (process.env.ONE_DEBUG_ROUTER) {\n            console.info(`[one] \\u{1F4DC} routes not in root state, skipping`);\n          }\n          return;\n        }\n        if (index > previousIndex || index === previousIndex && (!record || `${record?.path}${location2.hash}` === path)) {\n          const action = getActionFromStateRef.current(state, configRef.current);\n          if (process.env.ONE_DEBUG_ROUTER) {\n            console.info(`[one] \\u{1F4DC} dispatching action:`, action);\n          }\n          if (action !== void 0) {\n            try {\n              navigation.dispatch(action);\n            } catch (e) {\n              console.warn(\n                `An error occurred when trying to handle the link '${path}': ${typeof e === \"object\" && e != null && \"message\" in e ? e.message : e}`\n              );\n            }\n          } else {\n            if (process.env.ONE_DEBUG_ROUTER) {\n              console.info(`[one] \\u{1F4DC} no action, resetRoot`);\n            }\n            navigation.resetRoot(state);\n          }\n        } else {\n          if (process.env.ONE_DEBUG_ROUTER) {\n            console.info(`[one] \\u{1F4DC} going back, resetRoot`);\n          }\n          navigation.resetRoot(state);\n        }\n      } else {\n        if (process.env.ONE_DEBUG_ROUTER) {\n          console.info(`[one] \\u{1F4DC} no state for path, resetRoot to undefined`);\n        }\n        navigation.resetRoot(state);\n      }\n    });\n  }, [enabled, history, ref, validateRoutesNotExistInRootState]);\n  React.useEffect(() => {\n    if (!enabled) {\n      return;\n    }\n    const getPathForRoute = (route, state) => {\n      let path;\n      if (process.env.ONE_DEBUG_ROUTER) {\n        console.info(`[one] \\u{1F4DC} getPathForRoute - route:`, route);\n        console.info(`[one] \\u{1F4DC} getPathForRoute - state:`, JSON.stringify(state, null, 2));\n      }\n      if (route?.path) {\n        const stateForPath = getStateFromPathRef.current(route.path, configRef.current);\n        if (stateForPath) {\n          const focusedRoute = findFocusedRoute(stateForPath);\n          if (focusedRoute && focusedRoute.name === route.name && isEqual(focusedRoute.params, route.params)) {\n            path = appendBaseUrl(route.path);\n          }\n        }\n      }\n      if (path == null) {\n        path = getPathFromStateRef.current(state, configRef.current);\n        if (process.env.ONE_DEBUG_ROUTER) {\n          console.info(`[one] \\u{1F4DC} getPathForRoute - computed from state:`, path);\n        }\n      }\n      return path;\n    };\n    if (ref.current) {\n      const refState = ref.current.getRootState();\n      const state = routerRootState || refState;\n      if (process.env.ONE_DEBUG_ROUTER) {\n        console.info(\n          `[one] \\u{1F4DC} useEffect initial state check - refState:`,\n          JSON.stringify(refState, null, 2)\n        );\n        console.info(\n          `[one] \\u{1F4DC} useEffect initial state check - routerRootState:`,\n          JSON.stringify(routerRootState, null, 2)\n        );\n      }\n      if (state) {\n        const route = findFocusedRoute(state);\n        if (process.env.ONE_DEBUG_ROUTER) {\n          console.info(`[one] \\u{1F4DC} useEffect focused route:`, route);\n        }\n        const path = getPathForRoute(route, state);\n        if (process.env.ONE_DEBUG_ROUTER) {\n          console.info(\n            `[one] \\u{1F4DC} initial history.replace - state:`,\n            JSON.stringify(state, null, 2)\n          );\n          console.info(`[one] \\u{1F4DC} initial history.replace - focusedRoute:`, route);\n          console.info(`[one] \\u{1F4DC} initial history.replace - computed path:`, path);\n        }\n        if (previousStateRef.current === void 0) {\n          previousStateRef.current = refState;\n        }\n        if (!initialHistorySetupDoneRef.current) {\n          const historyState = window.history.state;\n          const isRestoringFromMask = restoringFromTempLocationRef.current || historyState?.__tempLocation?.pathname && !historyState.__tempKey;\n          if (isRestoringFromMask) {\n            const displayPath = window.location.pathname + window.location.search;\n            history.replace({ path, state, displayPath });\n            restoringFromTempLocationRef.current = false;\n            maskedDisplayPathRef.current = { displayPath, actualPath: path };\n          } else {\n            history.replace({ path, state });\n          }\n          initialHistorySetupDoneRef.current = true;\n        }\n      }\n    }\n    const onStateChange = async () => {\n      const navigation = ref.current;\n      if (!navigation || !enabled) {\n        return;\n      }\n      const previousState = previousStateRef.current;\n      const refState = navigation.getRootState();\n      const state = routerRootState || refState;\n      if (!state) {\n        return;\n      }\n      const pendingPath = pendingPopStatePathRef.current;\n      const route = findFocusedRoute(state);\n      if (isStateAwaitingNavigatorMount(state, routeNode)) {\n        if (process.env.ONE_DEBUG_ROUTER) {\n          console.info(\n            `[one] \\u{1F4DC} onStateChange - skipping: navigator below`,\n            route?.name,\n            `has not mounted`\n          );\n        }\n        return;\n      }\n      if (route && hasMissingDynamicParams(route) && currentUrlHasDynamicParams(route, getStateFromPathRef.current, configRef.current)) {\n        if (process.env.ONE_DEBUG_ROUTER) {\n          console.info(\n            `[one] \\u{1F4DC} onStateChange - skipping: focused dynamic route is missing params`,\n            route.name\n          );\n        }\n        return;\n      }\n      let path = getPathForRoute(route, state);\n      if (typeof window !== \"undefined\" && !route?.params) {\n        const currentSearch = window.location.search;\n        if (currentSearch && !path.includes(\"?\") && window.location.pathname === path) {\n          path = path + currentSearch;\n        }\n      }\n      const maskOptions = state.linkOptions?.mask;\n      const maskHref = maskOptions?.href;\n      const maskedInfo = maskedDisplayPathRef.current;\n      let displayPath;\n      if (maskedInfo) {\n        if (path === maskedInfo.actualPath) {\n          displayPath = maskedInfo.displayPath;\n        }\n        maskedDisplayPathRef.current = void 0;\n      }\n      if (!displayPath && maskHref) {\n        displayPath = appendBaseUrl(stripGroupSegmentsFromPath(maskHref) || \"/\");\n      }\n      const unmaskOnReload = maskOptions?.unmaskOnReload;\n      const pendingNavigationAction = consumePendingNavigationAction();\n      previousStateRef.current = refState;\n      pendingPopStatePathRef.current = void 0;\n      if (pendingNavigationAction === \"PUSH\" && path !== pendingPath) {\n        history.push({ path, state, displayPath, unmaskOnReload });\n        return;\n      }\n      if (pendingNavigationAction === \"REPLACE\" && path !== pendingPath) {\n        history.replace({ path, state, displayPath, unmaskOnReload });\n        return;\n      }\n      const [previousFocusedState, focusedState] = findMatchingState(previousState, state);\n      if (previousFocusedState && focusedState && // 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        const historyDelta = getFocusedRouteDepth(focusedState) - getFocusedRouteDepth(previousFocusedState);\n        if (historyDelta > 0) {\n          const currentRecord = history.get(history.index);\n          const samePath = currentRecord?.path === path || currentRecord?.displayPath === path;\n          if (samePath) {\n            history.replace({ path, state, displayPath, unmaskOnReload });\n          } else {\n            history.push({ path, state, displayPath, unmaskOnReload });\n          }\n        } else if (historyDelta < 0) {\n          const nextIndex = history.backIndex({ path });\n          const currentIndex = history.index;\n          try {\n            if (nextIndex !== -1 && nextIndex < currentIndex && // We should only go back if the entry exists and it's less than current index\n            history.get(nextIndex - currentIndex)) {\n              await history.go(nextIndex - currentIndex);\n            } else {\n              await history.go(historyDelta);\n            }\n            history.replace({ path, state });\n          } catch (e) {\n          }\n        } else {\n          history.replace({ path, state, displayPath, unmaskOnReload });\n        }\n      } else {\n        history.replace({ path, state, displayPath, unmaskOnReload });\n      }\n    };\n    return ref.current?.addListener(\"state\", series(onStateChange));\n  }, [enabled, history, ref]);\n  return {\n    getInitialState\n  };\n}\nexport {\n  series,\n  useLinking\n};\n//# sourceMappingURL=useLinking.js.map\n"],"mappings":";;;;;;;;;;;;;;AA0BA,MAAM,mBAAmB,UAAU;CACjC,IAAI,CAAC,OAAO,OAAO,KAAK;CACxB,MAAM,EAAE,KAAK,YAAY,OAAO,QAAQ,GAAG,YAAY;CACvD,OAAO;EACL,GAAG;EACH,OAAO;EACP,QAAQ,OAAO,KAAK,EAAE,KAAK,UAAU,OAAO,YAAY,GAAG,aAAa;GACtE,GAAG;GACH,GAAG,aAAa,EAAE,OAAO,gBAAgB,UAAU,EAAE,IAAI;EAC3D,EAAE;CACJ;AACF;AACA,SAAS,qBAAqB,OAAO;CACnC,MAAM,SAAS,sBAAsB,KAAK;CAC1C,MAAM,eAAe,MAAM,OAAO,MAAM;CACxC,MAAM,QAAQ,cAAc;CAC5B,IAAI,OAAO;EACT,OAAO,SAAS,qBAAqB,KAAK;CAC5C;CACA,OAAO;AACT;AACA,MAAM,yBAAyB,UAAU;CACvC,MAAM,eAAe,MAAM,OAAO,MAAM,GAAG,MAAM,QAAQ,CAAC;CAC1D,MAAM,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