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gBACA,+GAA+G;gBAC/G,sBAAsB;gBACtB,UAAU,CAAC;gBACX,gBAAgB,OAAO,GAAG;gBAC1B;YACF,OACE,eAAe,IAAM,gBAAgB,CAAA,GAAA,yBAAQ;;QAIjD,gBAAgB,OAAO,GAAG;IAC5B;IAEA,kHAAkH;IAClH,CAAA,GAAA,yCAAc,EAAE;QACd,gBAAgB,CAAA,KAAM;IACxB,GAAG;QAAC;KAAO;IAEX,IAAI,WAAW,CAAA,GAAA,wBAAU,EAAE;QACzB,WAAW,CAAA,GAAA,yBAAQ;IACrB,GAAG;QAAC;KAAW;IAEf,sEAAsE;IACtE,wDAAwD;IACxD,CAAA,GAAA,2CAAgB,EAAE;aAAC;QAAK,KAAK;kBAAc;IAAQ;IAEnD,IAAI,QAA6B;QAC/B,iGAAiG;QACjG,SAAS;QACT,GAAG,WAAW,KAAK;IACrB;IAEA,IAAI,oBAAoB,cAAc;QACpC,MAAM,SAAS,GAAG;QAClB,MAAM,SAAS,GAAG;IACpB,OAAO,IAAI,oBAAoB,cAAc,YAAY,KAAK,KAAK,MAAM,IAAI,CAAC,KAAK,EAAE;QACnF,mFAAmF;QACnF,6FAA6F;QAC7F,iFAAiF;QACjF,MAAM,SAAS,GAAG;QAClB,MAAM,SAAS,GAAG;IACpB,OACE,MAAM,QAAQ,GAAG;IAGnB,aAAa;QACX,OAAO,OAAO,QAAQ,CAAC,YAAY,KAAK,IAAI,YAAY,KAAK,GAAG;QAChE,QAAQ,OAAO,QAAQ,CAAC,YAAY,MAAM,IAAI,YAAY,MAAM,GAAG;QACnE,eAAe,cAAc,SAAS;QACtC,UAAU;QACV,GAAG,UAAU;IACf;IAEA,OAAO;qBACL;QACA,iBAAiB;YACf,GAAG,UAAU;mBACb;QACF;QACA,cAAc;YACZ,MAAM;YACN,OAAO;QACT;IACF;AACF","sources":["packages/react-aria/src/virtualizer/ScrollView.tsx"],"sourcesContent":["/*\n * Copyright 2020 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\n// @ts-ignore\nimport {flushSync} from 'react-dom';\nimport {getEventTarget, nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {getScrollLeft} from './utils';\nimport {Point, Rect, Size} from 'react-stately/useVirtualizerState';\nimport React, {\n  CSSProperties,\n  ForwardedRef,\n  HTMLAttributes,\n  ReactNode,\n  RefObject,\n  useCallback,\n  useEffect,\n  useRef,\n  useState\n} from 'react';\nimport {useEffectEvent} from '../utils/useEffectEvent';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\nimport {useLocale} from '../i18n/I18nProvider';\nimport {useObjectRef} from '../utils/useObjectRef';\nimport {useResizeObserver} from '../utils/useResizeObserver';\n\ninterface ScrollViewProps extends Omit<HTMLAttributes<HTMLElement>, 'onScroll'> {\n  contentSize: Size;\n  onVisibleRectChange: (rect: Rect) => void;\n  onSizeChange?: (size: Size) => void;\n  children?: ReactNode;\n  innerStyle?: CSSProperties;\n  onScrollStart?: () => void;\n  onScrollEnd?: () => void;\n  scrollDirection?: 'horizontal' | 'vertical' | 'both';\n  onScroll?: (e: Event) => void;\n  allowsWindowScrolling?: boolean;\n}\n\nfunction ScrollView(props: ScrollViewProps, ref: ForwardedRef<HTMLDivElement | null>) {\n  ref = useObjectRef(ref);\n  let {scrollViewProps, contentProps} = useScrollView(props, ref);\n\n  return (\n    <div role=\"presentation\" {...scrollViewProps} ref={ref}>\n      <div {...contentProps}>{props.children}</div>\n    </div>\n  );\n}\n\nconst ScrollViewForwardRef: React.ForwardRefExoticComponent<\n  ScrollViewProps & React.RefAttributes<HTMLDivElement | null>\n> = React.forwardRef(ScrollView);\nexport {ScrollViewForwardRef as ScrollView};\n\ninterface ScrollViewAria {\n  isScrolling: boolean;\n  scrollViewProps: HTMLAttributes<HTMLElement>;\n  contentProps: HTMLAttributes<HTMLElement>;\n}\n\nexport function useScrollView(\n  props: ScrollViewProps,\n  ref: RefObject<HTMLElement | null>\n): ScrollViewAria {\n  let {\n    contentSize,\n    onVisibleRectChange,\n    onSizeChange,\n    innerStyle,\n    onScrollStart,\n    onScrollEnd,\n    scrollDirection = 'both',\n    onScroll: onScrollProp,\n    allowsWindowScrolling,\n    ...otherProps\n  } = props;\n\n  let state = useRef({\n    // Internal scroll position of the scroll view.\n    scrollPosition: new Point(),\n    // Size of the scroll view.\n    size: new Size(),\n    // Offset of the scroll view relative to the window viewport.\n    viewportOffset: new Point(),\n    // Size of the window viewport.\n    viewportSize: new Size(),\n    scrollEndTime: 0,\n    scrollTimeout: null as ReturnType<typeof setTimeout> | null,\n    isScrolling: false,\n    lastVisibleRect: new Rect()\n  }).current;\n  let {direction} = useLocale();\n\n  let updateVisibleRect = useCallback(() => {\n    // Intersect the window viewport with the scroll view itself to find the actual visible rectangle.\n    // This allows virtualized components to have unbounded height but still virtualize when scrolled with the page.\n    // While there may be other scrollable elements between the <body> and the scroll view, we do not take\n    // their sizes into account for performance reasons. Their scroll positions are accounted for in viewportOffset\n    // though (due to getBoundingClientRect). This may result in more rows than absolutely necessary being rendered,\n    // but no more than the entire height of the viewport which is good enough for virtualization use cases.\n    let visibleRect = allowsWindowScrolling\n      ? new Rect(\n          state.viewportOffset.x + state.scrollPosition.x,\n          state.viewportOffset.y + state.scrollPosition.y,\n          Math.max(\n            0,\n            Math.min(state.size.width - state.viewportOffset.x, state.viewportSize.width)\n          ),\n          Math.max(\n            0,\n            Math.min(state.size.height - state.viewportOffset.y, state.viewportSize.height)\n          )\n        )\n      : new Rect(\n          state.scrollPosition.x,\n          state.scrollPosition.y,\n          state.size.width,\n          state.size.height\n        );\n    // Don't emit updates if the visible area is zero and the last emitted area was also zero.\n    if (visibleRect.area > 0 || state.lastVisibleRect.area > 0) {\n      onVisibleRectChange(visibleRect);\n      state.lastVisibleRect = visibleRect;\n    }\n  }, [state, allowsWindowScrolling, onVisibleRectChange]);\n\n  let [isScrolling, setScrolling] = useState(false);\n\n  let onScroll = useCallback(\n    (e: Event) => {\n      let target = getEventTarget(e) as Element;\n      if (!nodeContains(target, ref.current!)) {\n        return;\n      }\n\n      if (onScrollProp && target === ref.current) {\n        onScrollProp(e);\n      }\n\n      if (target !== ref.current) {\n        // An ancestor element or the window was scrolled. Update the position of the scroll view relative to the viewport.\n        let boundingRect = ref.current!.getBoundingClientRect();\n        let x = boundingRect.x < 0 ? -boundingRect.x : 0;\n        let y = boundingRect.y < 0 ? -boundingRect.y : 0;\n        if (x === state.viewportOffset.x && y === state.viewportOffset.y) {\n          return;\n        }\n\n        state.viewportOffset = new Point(x, y);\n      } else {\n        // The scroll view itself was scrolled. Update the local scroll position.\n        // Prevent rubber band scrolling from shaking when scrolling out of bounds\n        let scrollTop = target.scrollTop;\n        let scrollLeft = getScrollLeft(target, direction);\n        state.scrollPosition = new Point(\n          Math.max(0, Math.min(scrollLeft, contentSize.width - state.size.width)),\n          Math.max(0, Math.min(scrollTop, contentSize.height - state.size.height))\n        );\n      }\n\n      flushSync(() => {\n        updateVisibleRect();\n\n        if (!state.isScrolling) {\n          state.isScrolling = true;\n          setScrolling(true);\n\n          // Pause typekit MutationObserver during scrolling.\n          window.dispatchEvent(new Event('tk.disconnect-observer'));\n          if (onScrollStart) {\n            onScrollStart();\n          }\n        }\n\n        // So we don't constantly call clearTimeout and setTimeout,\n        // keep track of the current timeout time and only reschedule\n        // the timer when it is getting close.\n        let now = Date.now();\n        if (state.scrollEndTime <= now + 50) {\n          state.scrollEndTime = now + 300;\n\n          if (state.scrollTimeout != null) {\n            clearTimeout(state.scrollTimeout);\n          }\n\n          state.scrollTimeout = setTimeout(() => {\n            state.isScrolling = false;\n            setScrolling(false);\n            state.scrollTimeout = null;\n\n            window.dispatchEvent(new Event('tk.connect-observer'));\n            if (onScrollEnd) {\n              onScrollEnd();\n            }\n          }, 300);\n        }\n      });\n    },\n    [\n      onScrollProp,\n      ref,\n      direction,\n      state,\n      contentSize,\n      updateVisibleRect,\n      onScrollStart,\n      onScrollEnd\n    ]\n  );\n\n  // Attach a document-level capturing scroll listener so we can account for scrollable ancestors.\n  useEffect(() => {\n    document.addEventListener('scroll', onScroll, true);\n    return () => document.removeEventListener('scroll', onScroll, true);\n  }, [onScroll]);\n\n  useEffect(() => {\n    return () => {\n      if (state.scrollTimeout != null) {\n        clearTimeout(state.scrollTimeout);\n      }\n\n      if (state.isScrolling) {\n        window.dispatchEvent(new Event('tk.connect-observer'));\n      }\n    };\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n\n  let isUpdatingSize = useRef(false);\n  let updateSize = useCallback(\n    (flush: typeof flushSync) => {\n      let dom = ref.current;\n      if (!dom || isUpdatingSize.current) {\n        return;\n      }\n\n      // Prevent reentrancy when resize observer fires, triggers re-layout that results in\n      // content size update, causing below layout effect to fire. This avoids infinite loops.\n      isUpdatingSize.current = true;\n\n      let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;\n      let isClientWidthMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes(\n        'clientWidth'\n      );\n      let isClientHeightMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes(\n        'clientHeight'\n      );\n      let clientWidth = dom.clientWidth;\n      let clientHeight = dom.clientHeight;\n      let w = isTestEnv && !isClientWidthMocked ? Infinity : clientWidth;\n      let h = isTestEnv && !isClientHeightMocked ? Infinity : clientHeight;\n\n      // Update the window viewport size.\n      let viewportWidth = window.innerWidth;\n      let viewportHeight = window.innerHeight;\n      let viewportSizeChanged =\n        state.viewportSize.width !== viewportWidth || state.viewportSize.height !== viewportHeight;\n      if (viewportSizeChanged) {\n        state.viewportSize = new Size(viewportWidth, viewportHeight);\n      }\n\n      if (state.size.width !== w || state.size.height !== h || viewportSizeChanged) {\n        state.size = new Size(w, h);\n        flush(() => {\n          updateVisibleRect();\n          onSizeChange?.(state.size);\n        });\n\n        // If the clientWidth or clientHeight changed, scrollbars appeared or disappeared as\n        // a result of the layout update. In this case, re-layout again to account for the\n        // adjusted space. In very specific cases this might result in the scrollbars disappearing\n        // again, resulting in extra padding. We stop after a maximum of two layout passes to avoid\n        // an infinite loop. This matches how browsers behavior with native CSS grid layout.\n        if ((!isTestEnv && clientWidth !== dom.clientWidth) || clientHeight !== dom.clientHeight) {\n          state.size = new Size(dom.clientWidth, dom.clientHeight);\n          flush(() => {\n            updateVisibleRect();\n            onSizeChange?.(state.size);\n          });\n        }\n      }\n\n      isUpdatingSize.current = false;\n    },\n    [ref, state, updateVisibleRect, onSizeChange]\n  );\n  let updateSizeEvent = useEffectEvent(updateSize);\n\n  // Track the size of the entire window viewport, which is used to bound the size of the virtualizer's visible rectangle.\n  useLayoutEffect(() => {\n    // Initialize viewportRect before updating size for the first time.\n    state.viewportSize = new Size(window.innerWidth, window.innerHeight);\n\n    let onWindowResize = () => {\n      updateSizeEvent(flushSync);\n    };\n\n    window.addEventListener('resize', onWindowResize);\n    return () => window.removeEventListener('resize', onWindowResize);\n  }, [state]);\n\n  // Update visible rect when the content size changes, in case scrollbars need to appear or disappear.\n  let lastContentSize = useRef<Size | null>(null);\n  let [update, setUpdate] = useState({});\n  // We only contain a call to setState in here for testing environments.\n  // eslint-disable-next-line react-hooks/exhaustive-deps\n  useLayoutEffect(() => {\n    if (\n      !isUpdatingSize.current &&\n      (lastContentSize.current == null || !contentSize.equals(lastContentSize.current))\n    ) {\n      // React doesn't allow flushSync inside effects, so queue a microtask.\n      // We also need to wait until all refs are set (e.g. when passing a ref down from a parent).\n      // If we are in an `act` environment, update immediately without a microtask so you don't need\n      // to mock timers in tests. In this case, the update is synchronous already.\n      // IS_REACT_ACT_ENVIRONMENT is used by React 18. Previous versions checked for the `jest` global.\n      // https://github.com/reactwg/react-18/discussions/102\n      if (\n        // @ts-ignore\n        typeof IS_REACT_ACT_ENVIRONMENT === 'boolean'\n          ? // @ts-ignore\n            IS_REACT_ACT_ENVIRONMENT\n          : typeof jest !== 'undefined'\n      ) {\n        // This is so we update size in a separate render but within the same act. Needs to be setState instead of refs\n        // due to strict mode.\n        setUpdate({});\n        lastContentSize.current = contentSize;\n        return;\n      } else {\n        queueMicrotask(() => updateSizeEvent(flushSync));\n      }\n    }\n\n    lastContentSize.current = contentSize;\n  });\n\n  // Will only run in tests, needs to be in separate effect so it is properly run in the next render in strict mode.\n  useLayoutEffect(() => {\n    updateSizeEvent(fn => fn());\n  }, [update]);\n\n  let onResize = useCallback(() => {\n    updateSize(flushSync);\n  }, [updateSize]);\n\n  // Watch border-box instead of of content-box so that we don't go into\n  // an infinite loop when scrollbars appear or disappear.\n  useResizeObserver({ref, box: 'border-box', onResize});\n\n  let style: React.CSSProperties = {\n    // Reset padding so that relative positioning works correctly. Padding will be done in JS layout.\n    padding: 0,\n    ...otherProps.style\n  };\n\n  if (scrollDirection === 'horizontal') {\n    style.overflowX = 'auto';\n    style.overflowY = 'hidden';\n  } else if (scrollDirection === 'vertical' || contentSize.width === state.size.width) {\n    // Set overflow-x: hidden if content size is equal to the width of the scroll view.\n    // This prevents horizontal scrollbars from flickering during resizing due to resize observer\n    // firing slower than the frame rate, which may cause an infinite re-render loop.\n    style.overflowY = 'auto';\n    style.overflowX = 'hidden';\n  } else {\n    style.overflow = 'auto';\n  }\n\n  innerStyle = {\n    width: Number.isFinite(contentSize.width) ? contentSize.width : undefined,\n    height: Number.isFinite(contentSize.height) ? contentSize.height : undefined,\n    pointerEvents: isScrolling ? 'none' : 'auto',\n    position: 'relative',\n    ...innerStyle\n  };\n\n  return {\n    isScrolling,\n    scrollViewProps: {\n      ...otherProps,\n      style\n    },\n    contentProps: {\n      role: 'presentation',\n      style: innerStyle\n    }\n  };\n}\n"],"names":[],"version":3,"file":"ScrollView.cjs.map"}