{"version":3,"file":"Menu.mjs","names":[],"sources":["../../../src/menu/Menu.tsx"],"sourcesContent":["/*!\n *\n *  Copyright (c) \"Neo4j\"\n *  Neo4j Sweden AB [http://neo4j.com]\n *\n *  This file is part of Neo4j.\n *\n *  Neo4j is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n  autoUpdate,\n  flip,\n  FloatingFocusManager,\n  FloatingList,\n  FloatingNode,\n  FloatingPortal,\n  FloatingTree,\n  offset,\n  type OpenChangeReason,\n  safePolygon,\n  shift,\n  useClick,\n  useDismiss,\n  useFloating,\n  useFloatingNodeId,\n  useFloatingParentNodeId,\n  useFloatingTree,\n  useHover,\n  useInteractions,\n  useListItem,\n  useListNavigation,\n  useMergeRefs,\n  useRole,\n  useTypeahead,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport {\n  createContext,\n  useCallback,\n  useContext,\n  useEffect,\n  useId,\n  useLayoutEffect,\n  useRef,\n  useState,\n} from 'react';\n\nimport {\n  type CommonProps,\n  type PolymorphicCommonProps,\n} from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { Divider } from '../divider';\nimport { CheckIconOutline } from '../icons/generated/heroIcons/CheckIconOutline';\nimport { ChevronRightIconOutline } from '../icons/generated/heroIcons/ChevronRightIconOutline';\nimport { placementTranslation } from '../popover';\nimport { useNeedleTheme } from '../theme';\nimport type {\n  CategoryItemProps,\n  MenuGroupProps,\n  MenuItemComponentProps,\n  MenuItemProps,\n  MenuItemsProps,\n  MenuProps,\n  NestedMenuItemProps,\n  RadioItemProps,\n} from './menu-types';\n\nconst MenuContext = createContext<{\n  getItemProps: (\n    userProps?: React.HTMLProps<HTMLElement>,\n  ) => Record<string, unknown>;\n  activeIndex: number | null;\n  setActiveIndex: React.Dispatch<React.SetStateAction<number | null>>;\n  setHasFocusInside: React.Dispatch<React.SetStateAction<boolean>>;\n  isOpen: boolean;\n}>({\n  activeIndex: null,\n  getItemProps: () => ({}),\n  isOpen: false,\n  // oxlint-disable-next-line @typescript-eslint/no-empty-function\n  setActiveIndex: () => {},\n  // oxlint-disable-next-line @typescript-eslint/no-empty-function\n  setHasFocusInside: () => {},\n});\n\nconst MenuGroupContext = createContext<{\n  labelId: string;\n  setHasLabel: React.Dispatch<React.SetStateAction<boolean>>;\n} | null>(null);\n\ntype MenuCloseReason = Parameters<NonNullable<MenuProps['onClose']>>[1];\n\n// `list-navigation` covers arrowing out of a nested menu, which surfaced as\n// `escapeKeyDown` back when the close type was derived from the event instance.\nconst closeTypeByOpenChangeReason: Partial<\n  Record<OpenChangeReason, MenuCloseReason['type']>\n> = {\n  'escape-key': 'escapeKeyDown',\n  'focus-out': 'focusOut',\n  'list-navigation': 'escapeKeyDown',\n  'outside-press': 'backdropClick',\n};\n\nconst MenuWrapper = (props: React.ComponentProps<typeof MenuComponent>) => {\n  const parentId = useFloatingParentNodeId();\n\n  if (parentId === null) {\n    return (\n      <FloatingTree>\n        <MenuComponent {...props} isRoot />\n      </FloatingTree>\n    );\n  }\n\n  return <MenuComponent {...props} />;\n};\n\nconst MenuComponent = <T extends React.ElementType = 'div'>({\n  children,\n  isOpen: controlledOpen,\n  onClose,\n  isRoot,\n  anchorRef,\n  as,\n  className,\n  placement,\n  minWidth,\n  title,\n  isDisabled,\n  description,\n  leadingVisual,\n  isPortaled = true,\n  portalTarget,\n  htmlAttributes,\n  strategy,\n  ref: forwardedRef,\n  style,\n}: PolymorphicCommonProps<T, MenuProps>) => {\n  const [isUncontrolledOpen, setIsUncontrolledOpen] = useState(false);\n  const [hasFocusInside, setHasFocusInside] = useState(false);\n  const [activeIndex, setActiveIndex] = useState<number | null>(null);\n\n  const elementsRef = useRef<Array<HTMLButtonElement | null>>([]);\n  const labelsRef = useRef<Array<string | null>>([]);\n  const parent = useContext(MenuContext);\n\n  const isInsideDialog = useIsInsideDialog();\n  const tree = useFloatingTree();\n  const nodeId = useFloatingNodeId();\n  const parentId = useFloatingParentNodeId();\n  const item = useListItem();\n  const { themeClassName } = useNeedleTheme();\n  const isOpen = controlledOpen ?? isUncontrolledOpen;\n\n  useEffect(() => {\n    if (isOpen) {\n      setActiveIndex(0);\n    }\n  }, [isOpen]);\n\n  // Unmounting is deferred by one pre-paint commit so that anything an item's\n  // action focused (e.g. an autofocused input mounted by onClick) is already\n  // the active element when the focus manager cleans up. floating-ui then\n  // respects the moved focus instead of returning it to the trigger.\n  // See https://github.com/floating-ui/floating-ui/issues/2607\n  const [isMounted, setIsMounted] = useState(false);\n  useLayoutEffect(() => {\n    setIsMounted(isOpen);\n  }, [isOpen]);\n\n  // A single interaction can reach us twice, since floating-ui's focus manager\n  // reports a focus-out after a dismissal without checking whether the menu is\n  // still open. Ignoring an already closed menu keeps `onClose` to one call.\n  // Pass no close reason to close without notifying the consumer.\n  const requestClose = useCallback(\n    (event: Event | undefined, closeReason: MenuCloseReason | undefined) => {\n      if (!isOpen) {\n        return;\n      }\n\n      if (controlledOpen === undefined) {\n        setIsUncontrolledOpen(false);\n      }\n\n      if (closeReason !== undefined) {\n        onClose?.(event, closeReason);\n      }\n    },\n    [controlledOpen, isOpen, onClose],\n  );\n\n  const Component = as ?? 'div';\n\n  const isNested = parentId !== null;\n\n  const defaultPlacement = isNested ? 'right-start' : 'bottom-start';\n\n  const { floatingStyles, refs, context } = useFloating<HTMLButtonElement>({\n    elements: {\n      reference: anchorRef?.current,\n    },\n    middleware: [\n      offset({\n        alignmentAxis: isNested ? -4 : 0,\n        mainAxis: isNested ? 0 : 4,\n      }),\n      ...(isNested ? [shift()] : []),\n      flip(\n        isNested\n          ? {\n              fallbackPlacements: ['left-start', 'bottom-start', 'top-start'],\n              fallbackStrategy: 'bestFit',\n            }\n          : { fallbackPlacements: ['left-start', 'right-start'] },\n      ),\n      shift(),\n    ],\n    nodeId,\n    onOpenChange: (open, event, reason) => {\n      if (isDisabled) {\n        return;\n      }\n\n      if (open) {\n        if (controlledOpen === undefined) {\n          setIsUncontrolledOpen(true);\n        }\n        return;\n      }\n\n      const closeType = reason\n        ? closeTypeByOpenChangeReason[reason]\n        : undefined;\n      requestClose(event, closeType ? { type: closeType } : undefined);\n    },\n    open: isOpen,\n    placement: placement ? placementTranslation[placement] : defaultPlacement,\n    strategy: strategy ?? (isInsideDialog ? 'fixed' : 'absolute'),\n    whileElementsMounted: autoUpdate,\n  });\n\n  const hover = useHover(context, {\n    delay: { open: 75 },\n    enabled: isNested,\n    handleClose: safePolygon({ blockPointerEvents: true }),\n  });\n  const click = useClick(context, {\n    event: 'mousedown',\n    ignoreMouse: isNested,\n    toggle: !isNested,\n  });\n  const role = useRole(context, { role: 'menu' });\n  // floating-ui registers its escape handler on both the floating element and\n  // the document. Firefox runs both before React re-renders, so the menu is\n  // still open for the second one and the consumer is notified twice. Closing\n  // on Escape ourselves keeps it to a single notification.\n  const dismiss = useDismiss(context, { bubbles: true, escapeKey: false });\n  const listNavigation = useListNavigation(context, {\n    activeIndex,\n    // Don't disable indices; that way disabled items are still focusable. See: https://www.w3.org/WAI/ARIA/apg/patterns/menubar/\n    disabledIndices: [],\n    listRef: elementsRef,\n    nested: isNested,\n    onNavigate: setActiveIndex,\n  });\n  const typeahead = useTypeahead(context, {\n    activeIndex,\n    listRef: labelsRef,\n    onMatch: isOpen ? setActiveIndex : undefined,\n  });\n\n  const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions(\n    [hover, click, role, dismiss, listNavigation, typeahead],\n  );\n\n  // Event emitter allows you to communicate across tree components.\n  // This effect closes all menus when an item gets clicked anywhere\n  // in the tree.\n  useEffect(() => {\n    if (!tree) {\n      return;\n    }\n\n    function handleTreeClick(data: { id?: string }) {\n      requestClose(undefined, { id: data?.id, type: 'itemClick' });\n    }\n\n    function onSubMenuOpen(event: { nodeId: string; parentId: string }) {\n      if (event.nodeId !== nodeId && event.parentId === parentId) {\n        requestClose(undefined, { type: 'itemClick' });\n      }\n    }\n\n    tree.events.on('click', handleTreeClick);\n    tree.events.on('menuopen', onSubMenuOpen);\n\n    return () => {\n      tree.events.off('click', handleTreeClick);\n      tree.events.off('menuopen', onSubMenuOpen);\n    };\n  }, [tree, nodeId, parentId, requestClose]);\n\n  useEffect(() => {\n    if (isOpen && tree) {\n      tree.events.emit('menuopen', { nodeId, parentId });\n    }\n  }, [tree, isOpen, nodeId, parentId]);\n\n  const handleFloatingKeyDown = useCallback(\n    (event: React.KeyboardEvent<HTMLElement>) => {\n      // React propagates through the component tree, so a nested menu's Escape\n      // reaches its ancestors here too and closes the whole tree.\n      if (event.key === 'Escape' && !event.nativeEvent.isComposing) {\n        if (isRoot === true) {\n          event.stopPropagation();\n        }\n        requestClose(event.nativeEvent, { type: 'escapeKeyDown' });\n        return;\n      }\n\n      // Workaround for floating-ui bug where Shift+Tab doesn't trigger\n      // closeOnFocusOut.\n      // We detect Shift+Tab and check after guards redirect focus whether\n      // focus has actually left the floating element.\n      // TODO: check every now and then if floating ui addresses this\n      if (event.key === 'Tab' && event.shiftKey) {\n        requestAnimationFrame(() => {\n          const floatingEl = refs.floating.current;\n          if (floatingEl && !floatingEl.contains(document.activeElement)) {\n            requestClose(undefined, { type: 'focusOut' });\n          }\n        });\n      }\n    },\n    [isRoot, refs, requestClose],\n  );\n\n  const menuClasses = classNames('ndl-menu', themeClassName, className);\n  const ref = useMergeRefs([refs.setReference, item.ref, forwardedRef]);\n\n  return (\n    <FloatingNode id={nodeId}>\n      {isRoot !== true && (\n        <NestedMenuItem\n          ref={ref}\n          className={isNested ? 'MenuItem' : 'RootMenu'}\n          isDisabled={isDisabled}\n          style={style}\n          htmlAttributes={{\n            'data-focus-inside': hasFocusInside ? '' : undefined,\n            'data-nested': isNested ? '' : undefined,\n            'data-open': isOpen ? '' : undefined,\n            role: isNested ? 'menuitem' : undefined,\n            tabIndex: !isNested\n              ? undefined\n              : parent.activeIndex === item.index\n                ? 0\n                : -1,\n            ...htmlAttributes,\n            ...getReferenceProps(\n              parent.getItemProps({\n                onFocus(event: React.FocusEvent<HTMLButtonElement>) {\n                  htmlAttributes?.onFocus?.(event);\n                  setHasFocusInside(false);\n                  parent.setHasFocusInside(true);\n                },\n              }),\n            ),\n          }}\n          title={title}\n          description={description}\n          leadingVisual={leadingVisual}\n        />\n      )}\n      <MenuContext.Provider\n        value={{\n          activeIndex,\n          getItemProps,\n          isOpen: isDisabled === true ? false : isOpen,\n          setActiveIndex,\n          setHasFocusInside,\n        }}\n      >\n        <FloatingList elementsRef={elementsRef} labelsRef={labelsRef}>\n          {(isOpen || isMounted) && (\n            <ConditionalWrap\n              shouldWrap={isPortaled}\n              wrap={(wrapChildren) => (\n                <FloatingPortal root={portalTarget}>\n                  {wrapChildren}\n                </FloatingPortal>\n              )}\n            >\n              <FloatingFocusManager\n                context={context}\n                modal={false}\n                initialFocus={0}\n                returnFocus={!isNested}\n                closeOnFocusOut={true}\n                guards={true}\n              >\n                <Component\n                  ref={refs.setFloating}\n                  className={menuClasses}\n                  style={{\n                    minWidth:\n                      minWidth !== undefined ? `${minWidth}px` : undefined,\n                    ...floatingStyles,\n                    ...style,\n                  }}\n                  {...getFloatingProps({\n                    onKeyDown: handleFloatingKeyDown,\n                  })}\n                >\n                  {children}\n                </Component>\n              </FloatingFocusManager>\n            </ConditionalWrap>\n          )}\n        </FloatingList>\n      </MenuContext.Provider>\n    </FloatingNode>\n  );\n};\n\n/**\n * @internal This is used to build the menu item components. Do not export this component.\n */\nconst MenuItemComponent = <T extends React.ElementType = 'button'>({\n  title,\n  leadingContent,\n  trailingContent,\n  preLeadingContent,\n  description,\n  isDisabled,\n  as,\n  className,\n  style,\n  htmlAttributes,\n  ref,\n  ...restProps\n}: PolymorphicCommonProps<T, MenuItemComponentProps>) => {\n  const classes = classNames(`ndl-menu-item`, className, {\n    'ndl-disabled': isDisabled,\n  });\n\n  const Component = as ?? 'button';\n\n  return (\n    <Component\n      className={classes}\n      ref={ref}\n      type=\"button\"\n      role=\"menuitem\"\n      aria-disabled={isDisabled}\n      style={style}\n      {...restProps}\n      {...htmlAttributes}\n    >\n      <div className=\"ndl-menu-item-inner\">\n        {Boolean(preLeadingContent) && (\n          <div className=\"ndl-menu-item-pre-leading-content\">\n            {preLeadingContent}\n          </div>\n        )}\n        {Boolean(leadingContent) && (\n          <div className=\"ndl-menu-item-leading-content\">{leadingContent}</div>\n        )}\n\n        <div className=\"ndl-menu-item-title-wrapper\">\n          <div className=\"ndl-menu-item-title\">{title}</div>\n          {Boolean(description) && (\n            <div className=\"ndl-menu-item-description\">{description}</div>\n          )}\n        </div>\n\n        {Boolean(trailingContent) && (\n          <div className=\"ndl-menu-item-trailing-content\">\n            {trailingContent}\n          </div>\n        )}\n      </div>\n    </Component>\n  );\n};\n\nconst MenuItem = <T extends React.ElementType = 'button'>({\n  title,\n  className,\n  style,\n  leadingVisual,\n  trailingContent,\n  description,\n  isDisabled,\n  as,\n  onClick,\n  onFocus,\n  htmlAttributes,\n  id,\n  ref,\n  ...restProps\n}: PolymorphicCommonProps<T, MenuItemProps>) => {\n  const menu = useContext(MenuContext);\n  const itemLabel = typeof title === 'string' ? title : undefined;\n  const item = useListItem({ label: itemLabel });\n  const tree = useFloatingTree();\n  const isActive = item.index === menu.activeIndex;\n\n  const mergedRefs = useMergeRefs([item.ref, ref]);\n\n  return (\n    <MenuItemComponent\n      as={as ?? 'button'}\n      style={style}\n      className={className}\n      ref={mergedRefs}\n      title={title}\n      description={description}\n      leadingContent={leadingVisual}\n      trailingContent={trailingContent}\n      isDisabled={isDisabled}\n      htmlAttributes={{\n        ...htmlAttributes,\n        tabIndex: isActive ? 0 : -1,\n        ...menu.getItemProps({\n          id: id,\n          onClick(event: React.MouseEvent<HTMLButtonElement>) {\n            if (isDisabled) {\n              event.preventDefault();\n              event.stopPropagation();\n              return;\n            }\n            onClick?.(event);\n            tree?.events.emit('click', { id });\n          },\n          onFocus(event: React.FocusEvent<HTMLButtonElement>) {\n            onFocus?.(event);\n            menu.setHasFocusInside(true);\n          },\n        }),\n      }}\n      {...restProps}\n    />\n  );\n};\n\nconst NestedMenuItem = <T extends React.ElementType = 'button'>({\n  title,\n  isDisabled,\n  description,\n  leadingVisual,\n  as,\n  onFocus,\n  onClick,\n  className,\n  style,\n  htmlAttributes,\n  id,\n  ref,\n}: PolymorphicCommonProps<T, NestedMenuItemProps>) => {\n  const menu = useContext(MenuContext);\n  const itemLabel = typeof title === 'string' ? title : undefined;\n  const item = useListItem({ label: itemLabel });\n  const isActive = item.index === menu.activeIndex;\n  const mergedRefs = useMergeRefs([item.ref, ref]);\n\n  return (\n    <MenuItemComponent\n      as={as ?? 'button'}\n      style={style}\n      className={className}\n      ref={mergedRefs}\n      title={title}\n      description={description}\n      leadingContent={leadingVisual}\n      trailingContent={\n        <ChevronRightIconOutline className=\"ndl-menu-item-chevron\" />\n      }\n      isDisabled={isDisabled}\n      htmlAttributes={{\n        ...htmlAttributes,\n        tabIndex: isActive ? 0 : -1,\n        ...menu.getItemProps({\n          onClick(event: React.MouseEvent<HTMLButtonElement>) {\n            if (isDisabled) {\n              event.preventDefault();\n              event.stopPropagation();\n              return;\n            }\n            onClick?.(event);\n          },\n          onFocus(event: React.FocusEvent<HTMLButtonElement>) {\n            onFocus?.(event);\n            menu.setHasFocusInside(true);\n          },\n          onTouchStart() {\n            menu.setHasFocusInside(true);\n          },\n        }),\n        id: id,\n      }}\n    />\n  );\n};\n\nconst CategoryItem = <T extends React.ElementType = 'button'>({\n  children,\n  className,\n  style,\n  as,\n  htmlAttributes,\n  ref,\n  ...restProps\n}: PolymorphicCommonProps<T, CategoryItemProps>) => {\n  const classes = classNames('ndl-menu-category-item', className);\n  const Component: React.ElementType = as ?? 'div';\n  const groupContext = useContext(MenuGroupContext);\n\n  useEffect(() => {\n    if (groupContext) {\n      groupContext.setHasLabel(true);\n      return () => groupContext.setHasLabel(false);\n    }\n  }, [groupContext]);\n\n  return (\n    <Component\n      className={classes}\n      style={style}\n      ref={ref}\n      {...(groupContext\n        ? { id: groupContext.labelId, role: 'presentation' }\n        : { role: 'separator' })}\n      {...restProps}\n      {...htmlAttributes}\n    >\n      {children}\n    </Component>\n  );\n};\n\nconst RadioItem = <T extends React.ElementType = 'button'>({\n  title,\n  leadingVisual,\n  trailingContent,\n  description,\n  isDisabled,\n  isChecked = false,\n  onClick,\n  onFocus,\n  className,\n  style,\n  as,\n  id,\n  htmlAttributes,\n  ref,\n  ...restProps\n}: PolymorphicCommonProps<T, RadioItemProps>) => {\n  const menu = useContext(MenuContext);\n  const itemLabel = typeof title === 'string' ? title : undefined;\n  const item = useListItem({ label: itemLabel });\n  const tree = useFloatingTree();\n  const isActive = item.index === menu.activeIndex;\n\n  const mergedRefs = useMergeRefs([item.ref, ref]);\n  const classes = classNames('ndl-menu-radio-item', className, {\n    'ndl-checked': isChecked,\n  });\n\n  return (\n    <MenuItemComponent\n      as={as ?? 'button'}\n      style={style}\n      className={classes}\n      ref={mergedRefs}\n      title={title}\n      description={description}\n      preLeadingContent={\n        isChecked ? (\n          <CheckIconOutline className=\"ndl-menu-radio-item-check\" />\n        ) : null\n      }\n      leadingContent={leadingVisual}\n      trailingContent={trailingContent}\n      isDisabled={isDisabled}\n      htmlAttributes={{\n        ...htmlAttributes,\n        'aria-checked': isChecked,\n        role: 'menuitemradio',\n        tabIndex: isActive ? 0 : -1,\n        ...menu.getItemProps({\n          id: id,\n          onClick(event: React.MouseEvent<HTMLButtonElement>) {\n            if (isDisabled) {\n              event.preventDefault();\n              event.stopPropagation();\n              return;\n            }\n            onClick?.(event);\n            tree?.events.emit('click', { id });\n          },\n          onFocus(event: React.FocusEvent<HTMLButtonElement>) {\n            onFocus?.(event);\n            menu.setHasFocusInside(true);\n          },\n        }),\n      }}\n      {...restProps}\n    />\n  );\n};\n\nconst MenuItems = <T extends React.ElementType = 'div'>({\n  as,\n  children,\n  className,\n  htmlAttributes,\n  style,\n  ref,\n  ...restProps\n}: PolymorphicCommonProps<T, MenuItemsProps>) => {\n  const classes = classNames('ndl-menu-items', className);\n  const Component: React.ElementType = as ?? 'div';\n  return (\n    <Component\n      className={classes}\n      style={style}\n      ref={ref}\n      {...restProps}\n      {...htmlAttributes}\n    >\n      {children}\n    </Component>\n  );\n};\n\nconst MenuGroup = ({\n  children,\n  className,\n  htmlAttributes,\n  style,\n  ref,\n  ...restProps\n}: CommonProps<'div', MenuGroupProps>) => {\n  const classes = classNames('ndl-menu-group', className);\n  const labelId = useId();\n  const [hasLabel, setHasLabel] = useState(false);\n\n  return (\n    <MenuGroupContext.Provider value={{ labelId, setHasLabel }}>\n      <div\n        className={classes}\n        style={style}\n        ref={ref}\n        role=\"group\"\n        aria-labelledby={hasLabel ? labelId : undefined}\n        {...restProps}\n        {...htmlAttributes}\n      >\n        {children}\n      </div>\n    </MenuGroupContext.Provider>\n  );\n};\n\n/**\n * @remarks\n * `isRoot` is determined internally by checking for a parent context menu. If no parent exists, the component renders as the root menu; otherwise, a nested menu item trigger is rendered. When `isRoot` is `false`, the `title`, `description`, `icon`, and `isDisabled` props are forwarded to the nested menu item trigger component.\n *\n * @remarks\n * The `placement` prop defaults to `bottom-start` when it is the root menu and `right-start` when it is a nested menu item trigger.\n *\n * @remarks\n * The `strategy` prop is set to `fixed` when the context menu is inside a `Dialog` otherwise it is set to `absolute`.\n */\nconst Menu = Object.assign(MenuWrapper, {\n  CategoryItem: CategoryItem,\n  Divider: Divider,\n  Group: MenuGroup,\n  Item: MenuItem,\n  /**\n   * @deprecated Use Menu.Group instead if you want to group items together. If not, you can just omit this component in your implementation.\n   */\n  Items: MenuItems,\n  RadioItem: RadioItem,\n});\nexport { Menu };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;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