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,KAA0C;IAChF,IAAI,mBAAC,eAAe,WAAE,OAAO,YAAE,QAAQ,EAAC,GAAG;IAC3C,IAAI,aAAC,SAAS,iBAAE,aAAa,kBAAE,cAAc,EAAE,GAAG,WAAU,GAAG;IAC/D,IAAI,SAAC,KAAK,kBAAE,cAAc,wBAAE,oBAAoB,MAAE,EAAE,iBAAE,aAAa,EAAC,GAAG;IACvE,IAAI,qBAAC,iBAAiB,EAAC,GAAG,CAAA,GAAA,uBAAS,EAAE;IAErC,wCAAkB;eAAC;IAAK;IAExB,iGAAiG;IACjG,8EAA8E;IAC9E,IAAI,mBAAmB,kBAAmB,wBAAwB,CAAC,CAAC;IACpE,IAAI,SAA0F;QAC5F,GAAG,eAAe;QAClB,WAAW,CAAC,CAAC;2BACb;QACA,gBAAgB;IAClB;IACA,IAAI,iBAAiB,OAAO,aAAa,aAAa,SAAS,UAAU;IACzE,gFAAgF;IAChF,IAAI,mBAAmB;QACrB,GAAG,SAAS;QACZ,gBAAgB,YAAY,SAAS;QACrC,eAAe;QACf,SAAS,UAAU,IAAI,IAAI,QAAQ,gBAAgB,IAAM,MAAM,SAAS,CAAC,MAAM;IACjF;IACA,qBAAO,0DAAC,CAAA,GAAA,kCAAO;QAAE,QAAQ;YAAC;gBAAC,CAAA,GAAA,qCAAU;gBAAG;aAAiB;SAAC;OAAG;AAC/D;AAOO,SAAS,0CACd,KAAoC;IAEpC,qBACE,0DAAC,CAAA,GAAA,qCAAU;QAAE,WAAU;QAAoC,GAAG,KAAK;OAChE,MAAM,QAAQ;AAGrB;AAOO,SAAS,0CAAqB,KAAgC;IACnE,qBACE,0DAAC,CAAA,GAAA,oCAAS;QAAE,WAAU;QAAmC,GAAG,KAAK;OAC9D,MAAM,QAAQ;AAGrB","sources":["packages/react-aria-components/src/NavigationTree.tsx"],"sourcesContent":["/*\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n  ChildrenOrFunction,\n  ClassNameOrFunction,\n  ContextValue,\n  dom,\n  Provider,\n  StyleRenderProps,\n  useContextProps\n} from './utils';\nimport {Collection, forwardRefType, Key, Node, RouterOptions} from '@react-types/shared';\nimport {getScrollParent} from 'react-aria/private/utils/getScrollParent';\nimport {LinkContext} from './Link';\nimport {nodeContains} from 'react-aria/private/utils/shadowdom/DOMFunctions';\nimport React, {\n  createContext,\n  ForwardedRef,\n  forwardRef,\n  ReactNode,\n  RefObject,\n  useContext,\n  useEffect,\n  useMemo,\n  useRef,\n  useState\n} from 'react';\nimport {scrollIntoView} from 'react-aria/private/utils/scrollIntoView';\nimport {\n  Tree,\n  TreeHeader,\n  TreeHeaderProps,\n  TreeItem,\n  TreeItemContent,\n  TreeItemContentRenderProps,\n  TreeItemProps,\n  TreeItemRenderProps,\n  TreeProps,\n  TreeRenderProps,\n  TreeSection,\n  TreeSectionProps\n} from './Tree';\nimport {TreeState} from 'react-stately/useTreeState';\nimport {useObjectRef} from 'react-aria/useObjectRef';\n\nexport const NavigationTreeContext =\n  createContext<ContextValue<NavigationTreeProps<any>, HTMLDivElement>>(null);\n\ninterface InternalNavigationTreeContextValue {\n  /** The route that is currently selected. */\n  selectedRoute?: string | null;\n  /** The last route the focused key was synced to; dedupes the focus sync across items. */\n  syncedRouteRef?: RefObject<string | undefined>;\n  /** The NavigationTree's root element, used to keep current-route scrolling inside the tree. */\n  treeRef?: RefObject<HTMLDivElement | null>;\n}\nconst InternalNavigationTreeContext = createContext<InternalNavigationTreeContextValue>({});\n\ninterface NavigationTreeItemLinkContextValue {\n  href?: string;\n  hrefLang?: string;\n  target?: string;\n  rel?: string;\n  download?: string | boolean;\n  ping?: string;\n  referrerPolicy?: ReferrerPolicy;\n  routerOptions?: RouterOptions;\n  isCurrent?: boolean;\n  // Whether the item's link (as opposed to another focusable child such as a button) is focused.\n  isLinkFocused?: boolean;\n  setLinkFocused?: (isFocused: boolean) => void;\n}\nconst NavigationTreeItemLinkContext = createContext<NavigationTreeItemLinkContextValue>({});\n\nexport const NavigationTreeItemStateContext = createContext<{isCurrentAncestor: boolean}>({\n  isCurrentAncestor: false\n});\n\nexport interface NavigationTreeRenderProps extends Pick<\n  TreeRenderProps,\n  'isEmpty' | 'isFocused' | 'isFocusVisible' | 'state'\n> {}\n\nexport interface NavigationTreeProps<T>\n  extends\n    Omit<\n      TreeProps<T>,\n      | 'selectionMode'\n      | 'selectionBehavior'\n      | 'selectedKeys'\n      | 'defaultSelectedKeys'\n      | 'onSelectionChange'\n      | 'disallowEmptySelection'\n      | 'disabledBehavior'\n      | 'keyboardNavigationBehavior'\n      | 'escapeKeyBehavior'\n      | 'shouldSelectOnPressUp'\n      | 'dragAndDropHooks'\n      | 'renderEmptyState'\n      | 'onAction'\n      | 'className'\n      | 'style'\n      | 'render'\n    >,\n    StyleRenderProps<NavigationTreeRenderProps> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element. A function may be provided to compute the class based on component state.\n   *\n   * @default 'react-aria-NavigationTree'\n   */\n  className?: ClassNameOrFunction<NavigationTreeRenderProps>;\n  /** The route that is currently selected, matched against each item's `href`. */\n  selectedRoute?: string | null;\n}\n\n/**\n * A NavigationTree provides users with a way to navigate a nested, hierarchical set of links.\n */\nexport const NavigationTree = /*#__PURE__*/ (forwardRef as forwardRefType)(function NavigationTree<\n  T\n>(props: NavigationTreeProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n  [props, ref] = useContextProps(props, ref, NavigationTreeContext);\n  let {className, style, children, selectedRoute, ...rest} = props;\n  let syncedRouteRef = useRef<string | undefined>(undefined);\n  let treeRef = useObjectRef(ref);\n  let context = useMemo(() => ({selectedRoute, syncedRouteRef, treeRef}), [selectedRoute, treeRef]);\n\n  return (\n    <InternalNavigationTreeContext.Provider value={context}>\n      <Tree\n        {...rest}\n        ref={treeRef}\n        className={className ?? 'react-aria-NavigationTree'}\n        style={style}\n        selectionMode=\"none\"\n        keyboardNavigationBehavior=\"tab\">\n        {children}\n      </Tree>\n    </InternalNavigationTreeContext.Provider>\n  );\n});\n\nexport interface NavigationTreeItemRenderProps extends TreeItemRenderProps {\n  /**\n   * Whether this item is the current route (its `href` matches the NavigationTree's\n   * `selectedRoute`).\n   *\n   * @selector [data-current]\n   */\n  isCurrent: boolean;\n  /**\n   * Whether this item is an ancestor of the current-route item (at any level, regardless of whether\n   * it is expanded or collapsed).\n   *\n   * @selector [data-current-ancestor]\n   */\n  isCurrentAncestor: boolean;\n}\n\nexport interface NavigationTreeItemProps<T = object>\n  extends\n    Omit<\n      TreeItemProps<T>,\n      | 'className'\n      | 'style'\n      | 'render'\n      | 'onAction'\n      | 'allowsArrowNavigation'\n      | 'focusMode'\n      | 'value'\n    >,\n    StyleRenderProps<NavigationTreeItemRenderProps> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element. A function may be provided to compute the class based on component state.\n   *\n   * @default 'react-aria-NavigationTreeItem'\n   */\n  className?: ClassNameOrFunction<NavigationTreeItemRenderProps>;\n  /**\n   * The content of the side nav item along with any nested children. Supports static nested side\n   * nav items or use of a Collection to dynamically render nested side nav items.\n   */\n  children: ReactNode;\n}\n\n/**\n * A NavigationTreeItem represents an individual item in a NavigationTree.\n */\nexport const NavigationTreeItem = /*#__PURE__*/ (forwardRef as forwardRefType)(\n  function NavigationTreeItem<T extends object>(\n    props: NavigationTreeItemProps<T>,\n    ref: ForwardedRef<HTMLDivElement>\n  ) {\n    let {\n      href,\n      hrefLang,\n      target,\n      rel,\n      download,\n      ping,\n      referrerPolicy,\n      routerOptions,\n      className,\n      style,\n      render,\n      ...rest\n    } = props;\n    let {selectedRoute, treeRef} = useContext(InternalNavigationTreeContext);\n    let hasLink = href != null && href.length > 0;\n    let isCurrent = hasLink && href === selectedRoute;\n    let [isLinkFocused, setLinkFocused] = useState(false);\n    // Additional render props NavigationTreeItem adds to what TreeItem already provides.\n    let getItemRenderProps = <R extends TreeItemRenderProps>(\n      renderProps: R\n    ): R & {isCurrent: boolean; isCurrentAncestor: boolean} => ({\n      ...renderProps,\n      isCurrent,\n      isCurrentAncestor: hasSelectedDescendant(renderProps.id, renderProps.state, selectedRoute),\n      isFocusVisible:\n        renderProps.isFocusVisible || (renderProps.isFocusVisibleWithin && isLinkFocused)\n    });\n\n    let objRef = useObjectRef(ref);\n    useEffect(() => {\n      if (isCurrent && objRef.current) {\n        let scrollParent = getScrollParent(objRef.current, true) as HTMLElement;\n        // Only scroll the tree's own scroll container into view — never an outer ancestor such as the\n        // page. When the tree isn't its own scroll container the nearest scroll parent is outside the\n        // tree, so we skip rather than hijack the surrounding scroll position.\n        let treeRoot = treeRef?.current;\n        if (treeRoot && nodeContains(treeRoot, scrollParent)) {\n          scrollIntoView(scrollParent, objRef.current, {block: 'center'});\n        }\n      }\n    }, [isCurrent, objRef, treeRef]);\n\n    return (\n      <NavigationTreeItemLinkContext.Provider\n        value={{\n          href,\n          hrefLang,\n          target,\n          rel,\n          download,\n          ping,\n          referrerPolicy,\n          routerOptions,\n          isCurrent,\n          isLinkFocused,\n          setLinkFocused\n        }}>\n        <TreeItem\n          {...rest}\n          ref={objRef}\n          href={href}\n          focusMode={hasLink ? 'child' : undefined}\n          allowsArrowNavigation\n          data-current={isCurrent || undefined}\n          className={\n            typeof className === 'function'\n              ? renderProps => className(getItemRenderProps(renderProps))\n              : (className ?? 'react-aria-NavigationTreeItem')\n          }\n          style={\n            typeof style === 'function'\n              ? renderProps => style(getItemRenderProps(renderProps))\n              : style\n          }\n          render={(domProps, renderProps) => {\n            let values = getItemRenderProps(renderProps);\n            let {children: rowChildren, ...domRest} = domProps;\n            let dataProps = {\n              'data-focus-visible': values.isFocusVisible || undefined,\n              'data-current-ancestor': values.isCurrentAncestor || undefined\n            };\n            let content = (\n              <NavigationTreeItemStateContext.Provider\n                value={{isCurrentAncestor: values.isCurrentAncestor}}>\n                {rowChildren}\n              </NavigationTreeItemStateContext.Provider>\n            );\n            return typeof render === 'function' ? (\n              render({...domRest, ...dataProps, children: content}, values)\n            ) : (\n              <dom.div {...domRest} {...dataProps}>\n                {content}\n              </dom.div>\n            );\n          }}\n        />\n      </NavigationTreeItemLinkContext.Provider>\n    );\n  }\n);\n\nexport interface NavigationTreeItemContentRenderProps extends NavigationTreeItemRenderProps {}\n\nexport interface NavigationTreeItemContentProps {\n  /**\n   * The children of the component. A function may be provided to alter the children based on\n   * component state.\n   */\n  children: ChildrenOrFunction<NavigationTreeItemContentRenderProps>;\n}\n\n// The collection key of the item whose href matches `route`, or null.\nfunction findKeyForRoute(collection: Collection<Node<unknown>>, route: string): Key | null {\n  for (let key of collection.getKeys()) {\n    if (collection.getItem(key)?.props?.href === route) {\n      return key;\n    }\n  }\n  return null;\n}\n\n// Walks up from `key` to the closest ancestor that is actually rendered (all ancestors expanded).\n// Returns `key` unchanged when already visible. A collapsed ancestor hides everything beneath it,\n// so the highest collapsed ancestor is the closest visible row.\nfunction closestVisibleKey(\n  collection: Collection<Node<unknown>>,\n  expandedKeys: Set<Key>,\n  key: Key\n): Key {\n  let target = key;\n  let node = collection.getItem(key);\n  while (node?.parentKey != null) {\n    let parent = collection.getItem(node.parentKey);\n    if (parent?.type === 'item' && !expandedKeys.has(node.parentKey)) {\n      target = node.parentKey;\n    }\n    node = parent;\n  }\n  return target;\n}\n\n// Moves the tree's focused key to the item matching selectedRoute. Runs when the route or the\n// collection changes; the shared syncedRouteRef dedupes across items so it fires once per change.\nfunction useRouteFocusSync({state}: {state: TreeState<unknown>}): void {\n  let {selectedRoute, syncedRouteRef} = useContext(InternalNavigationTreeContext);\n  let {collection, selectionManager, expandedKeys} = state;\n  useEffect(() => {\n    if (\n      selectedRoute == null ||\n      syncedRouteRef == null ||\n      syncedRouteRef.current === selectedRoute\n    ) {\n      return;\n    }\n    let key = findKeyForRoute(collection, selectedRoute);\n    if (key != null) {\n      key = closestVisibleKey(collection, expandedKeys, key);\n      syncedRouteRef.current = selectedRoute;\n      selectionManager.setFocusedKey(key);\n    }\n  }, [selectedRoute, collection, expandedKeys, syncedRouteRef, selectionManager]);\n}\n\n// Cache so each row doesn't have to walk up the tree every time.\nlet selectedAncestorsCache = new WeakMap<\n  Collection<Node<unknown>>,\n  {selection: unknown; ancestors: Set<Key>}\n>();\n\n// The set of collection keys that are ancestors of the item matching `selectedRoute`.\nfunction getSelectedAncestors(state: TreeState<unknown>, selectedRoute: string): Set<Key> {\n  let {collection} = state;\n  let cached = selectedAncestorsCache.get(collection);\n  if (cached && cached.selection === selectedRoute) {\n    return cached.ancestors;\n  }\n  let matchKey = findKeyForRoute(collection, selectedRoute);\n  let ancestors = new Set<Key>();\n  let node = matchKey != null ? collection.getItem(matchKey) : null;\n  while (node?.parentKey != null && !ancestors.has(node.parentKey)) {\n    ancestors.add(node.parentKey);\n    node = collection.getItem(node.parentKey);\n  }\n  selectedAncestorsCache.set(collection, {selection: selectedRoute, ancestors});\n  return ancestors;\n}\n\n// Whether the row `id` is an ancestor of the item matching `selectedRoute`.\nfunction hasSelectedDescendant(\n  id: Key | undefined,\n  state: TreeState<unknown>,\n  selectedRoute: string | undefined | null\n): boolean {\n  if (id == null || selectedRoute == null || !state) {\n    return false;\n  }\n  return getSelectedAncestors(state, selectedRoute).has(id);\n}\n\nexport function NavigationTreeItemContent(props: NavigationTreeItemContentProps): ReactNode {\n  let linkCtx = useContext(NavigationTreeItemLinkContext);\n  return (\n    <TreeItemContent {...props}>\n      {(treeRenderProps: TreeItemContentRenderProps & {defaultChildren: ReactNode | undefined}) => (\n        <NavigationTreeItemContentInner\n          treeRenderProps={treeRenderProps}\n          linkCtx={linkCtx}\n          children={props.children}\n        />\n      )}\n    </TreeItemContent>\n  );\n}\n\ninterface NavigationTreeItemContentInnerProps {\n  treeRenderProps: TreeItemContentRenderProps & {defaultChildren: ReactNode | undefined};\n  linkCtx: NavigationTreeItemLinkContextValue;\n  children: ChildrenOrFunction<NavigationTreeItemContentRenderProps>;\n}\n\nfunction NavigationTreeItemContentInner(props: NavigationTreeItemContentInnerProps): ReactNode {\n  let {treeRenderProps, linkCtx, children} = props;\n  let {isCurrent, isLinkFocused, setLinkFocused, ...linkProps} = linkCtx;\n  let {state, isFocusVisible, isFocusVisibleWithin, id, hasChildItems} = treeRenderProps;\n  let {isCurrentAncestor} = useContext(NavigationTreeItemStateContext);\n\n  useRouteFocusSync({state});\n\n  // isFocusVisible follows the link: true when the row itself is keyboard focused, or when a child\n  // is keyboard focused and that child is the link (not another button/action).\n  let linkFocusVisible = isFocusVisible || (isFocusVisibleWithin && !!isLinkFocused);\n  let values: NavigationTreeItemContentRenderProps & {defaultChildren: ReactNode | undefined} = {\n    ...treeRenderProps,\n    isCurrent: !!isCurrent,\n    isCurrentAncestor,\n    isFocusVisible: linkFocusVisible\n  };\n  let renderChildren = typeof children === 'function' ? children(values) : children;\n  // Provide onFocusChange so the link reports its focus up to NavigationTreeItem.\n  let linkContextValue = {\n    ...linkProps,\n    'aria-current': isCurrent ? 'page' : undefined,\n    onFocusChange: setLinkFocused,\n    onPress: linkProps.href == null && hasChildItems ? () => state.toggleKey(id) : undefined\n  };\n  return <Provider values={[[LinkContext, linkContextValue]]}>{renderChildren}</Provider>;\n}\n\nexport interface NavigationTreeSectionProps<T> extends Omit<TreeSectionProps<T>, 'value'> {}\n\n/**\n * A NavigationTreeSection represents a section within a NavigationTree.\n */\nexport function NavigationTreeSection<T extends object>(\n  props: NavigationTreeSectionProps<T>\n): ReactNode {\n  return (\n    <TreeSection className=\"react-aria-NavigationTreeSection\" {...props}>\n      {props.children}\n    </TreeSection>\n  );\n}\n\nexport interface NavigationTreeHeaderProps extends TreeHeaderProps {}\n\n/**\n * A NavigationTreeHeader renders the header of a NavigationTreeSection.\n */\nexport function NavigationTreeHeader(props: NavigationTreeHeaderProps): ReactNode {\n  return (\n    <TreeHeader className=\"react-aria-NavigationTreeHeader\" {...props}>\n      {props.children}\n    </TreeHeader>\n  );\n}\n"],"names":[],"version":3,"file":"NavigationTree.cjs.map"}