{"version":3,"file":"scrolling.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk-experimental/scrolling/scrolling-module.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {coerceNumberProperty, NumberInput} from '@angular/cdk/coercion';\nimport {ListRange} from '@angular/cdk/collections';\nimport {\n  CdkVirtualScrollViewport,\n  VIRTUAL_SCROLL_STRATEGY,\n  VirtualScrollStrategy,\n} from '@angular/cdk/scrolling';\nimport {Directive, forwardRef, Input, OnChanges} from '@angular/core';\nimport {Observable} from 'rxjs';\n\n/**\n * A class that tracks the size of items that have been seen and uses it to estimate the average\n * item size.\n */\nexport class ItemSizeAverager {\n  /** The total amount of weight behind the current average. */\n  private _totalWeight = 0;\n\n  /** The current average item size. */\n  private _averageItemSize: number;\n\n  /** The default size to use for items when no data is available. */\n  private _defaultItemSize: number;\n\n  /** @param defaultItemSize The default size to use for items when no data is available. */\n  constructor(defaultItemSize = 50) {\n    this._defaultItemSize = defaultItemSize;\n    this._averageItemSize = defaultItemSize;\n  }\n\n  /** Returns the average item size. */\n  getAverageItemSize(): number {\n    return this._averageItemSize;\n  }\n\n  /**\n   * Adds a measurement sample for the estimator to consider.\n   * @param range The measured range.\n   * @param size The measured size of the given range in pixels.\n   */\n  addSample(range: ListRange, size: number) {\n    const newTotalWeight = this._totalWeight + range.end - range.start;\n    if (newTotalWeight) {\n      const newAverageItemSize =\n        (size + this._averageItemSize * this._totalWeight) / newTotalWeight;\n      if (newAverageItemSize) {\n        this._averageItemSize = newAverageItemSize;\n        this._totalWeight = newTotalWeight;\n      }\n    }\n  }\n\n  /** Resets the averager. */\n  reset() {\n    this._averageItemSize = this._defaultItemSize;\n    this._totalWeight = 0;\n  }\n}\n\n/** Virtual scrolling strategy for lists with items of unknown or dynamic size. */\nexport class AutoSizeVirtualScrollStrategy implements VirtualScrollStrategy {\n  /** @docs-private Implemented as part of VirtualScrollStrategy. */\n  scrolledIndexChange = new Observable<number>(() => {\n    // TODO(mmalerba): Implement.\n    if (typeof ngDevMode === 'undefined' || ngDevMode) {\n      throw Error(\n        'cdk-virtual-scroll: scrolledIndexChange is currently not supported for the' +\n          ' autosize scroll strategy',\n      );\n    }\n  });\n\n  /** The attached viewport. */\n  private _viewport: CdkVirtualScrollViewport | null = null;\n\n  /** The minimum amount of buffer rendered beyond the viewport (in pixels). */\n  private _minBufferPx: number;\n\n  /** The number of buffer items to render beyond the edge of the viewport (in pixels). */\n  private _maxBufferPx: number;\n\n  /** The estimator used to estimate the size of unseen items. */\n  private _averager: ItemSizeAverager;\n\n  /** The last measured scroll offset of the viewport. */\n  private _lastScrollOffset!: number;\n\n  /** The last measured size of the rendered content in the viewport. */\n  private _lastRenderedContentSize!: number;\n\n  /** The last measured size of the rendered content in the viewport. */\n  private _lastRenderedContentOffset!: number;\n\n  /**\n   * The number of consecutive cycles where removing extra items has failed. Failure here means that\n   * we estimated how many items we could safely remove, but our estimate turned out to be too much\n   * and it wasn't safe to remove that many elements.\n   */\n  private _removalFailures = 0;\n\n  /**\n   * @param minBufferPx The minimum amount of buffer rendered beyond the viewport (in pixels).\n   *     If the amount of buffer dips below this number, more items will be rendered.\n   * @param maxBufferPx The number of pixels worth of buffer to shoot for when rendering new items.\n   *     If the actual amount turns out to be less it will not necessarily trigger an additional\n   *     rendering cycle (as long as the amount of buffer is still greater than `minBufferPx`).\n   * @param averager The averager used to estimate the size of unseen items.\n   */\n  constructor(minBufferPx: number, maxBufferPx: number, averager = new ItemSizeAverager()) {\n    this._minBufferPx = minBufferPx;\n    this._maxBufferPx = maxBufferPx;\n    this._averager = averager;\n  }\n\n  /**\n   * Attaches this scroll strategy to a viewport.\n   * @param viewport The viewport to attach this strategy to.\n   */\n  attach(viewport: CdkVirtualScrollViewport) {\n    this._averager.reset();\n    this._viewport = viewport;\n    this._renderContentForCurrentOffset();\n  }\n\n  /** Detaches this scroll strategy from the currently attached viewport. */\n  detach() {\n    this._viewport = null;\n  }\n\n  /** @docs-private Implemented as part of VirtualScrollStrategy. */\n  onContentScrolled() {\n    if (this._viewport) {\n      this._updateRenderedContentAfterScroll();\n    }\n  }\n\n  /** @docs-private Implemented as part of VirtualScrollStrategy. */\n  onDataLengthChanged() {\n    if (this._viewport) {\n      this._renderContentForCurrentOffset();\n      this._checkRenderedContentSize();\n    }\n  }\n\n  /** @docs-private Implemented as part of VirtualScrollStrategy. */\n  onContentRendered() {\n    if (this._viewport) {\n      this._checkRenderedContentSize();\n    }\n  }\n\n  /** @docs-private Implemented as part of VirtualScrollStrategy. */\n  onRenderedOffsetChanged() {\n    if (this._viewport) {\n      this._checkRenderedContentOffset();\n    }\n  }\n\n  /** Scroll to the offset for the given index. */\n  scrollToIndex(): void {\n    if (typeof ngDevMode === 'undefined' || ngDevMode) {\n      // TODO(mmalerba): Implement.\n      throw Error(\n        'cdk-virtual-scroll: scrollToIndex is currently not supported for the autosize' +\n          ' scroll strategy',\n      );\n    }\n  }\n\n  /**\n   * Update the buffer parameters.\n   * @param minBufferPx The minimum amount of buffer rendered beyond the viewport (in pixels).\n   * @param maxBufferPx The number of buffer items to render beyond the edge of the viewport (in\n   *     pixels).\n   */\n  updateBufferSize(minBufferPx: number, maxBufferPx: number) {\n    if (maxBufferPx < minBufferPx) {\n      throw Error('CDK virtual scroll: maxBufferPx must be greater than or equal to minBufferPx');\n    }\n    this._minBufferPx = minBufferPx;\n    this._maxBufferPx = maxBufferPx;\n  }\n\n  /** Update the rendered content after the user scrolls. */\n  private _updateRenderedContentAfterScroll() {\n    const viewport = this._viewport!;\n\n    // The current scroll offset.\n    const scrollOffset = viewport.measureScrollOffset();\n    // The delta between the current scroll offset and the previously recorded scroll offset.\n    let scrollDelta = scrollOffset - this._lastScrollOffset;\n    // The magnitude of the scroll delta.\n    let scrollMagnitude = Math.abs(scrollDelta);\n\n    // The currently rendered range.\n    const renderedRange = viewport.getRenderedRange();\n\n    // If we're scrolling toward the top, we need to account for the fact that the predicted amount\n    // of content and the actual amount of scrollable space may differ. We address this by slowly\n    // correcting the difference on each scroll event.\n    let offsetCorrection = 0;\n    if (scrollDelta < 0) {\n      // The content offset we would expect based on the average item size.\n      const predictedOffset = renderedRange.start * this._averager.getAverageItemSize();\n      // The difference between the predicted size of the un-rendered content at the beginning and\n      // the actual available space to scroll over. We need to reduce this to zero by the time the\n      // user scrolls to the top.\n      // - 0 indicates that the predicted size and available space are the same.\n      // - A negative number that the predicted size is smaller than the available space.\n      // - A positive number indicates the predicted size is larger than the available space\n      const offsetDifference = predictedOffset - this._lastRenderedContentOffset;\n      // The amount of difference to correct during this scroll event. We calculate this as a\n      // percentage of the total difference based on the percentage of the distance toward the top\n      // that the user scrolled.\n      offsetCorrection = Math.round(\n        offsetDifference *\n          Math.max(0, Math.min(1, scrollMagnitude / (scrollOffset + scrollMagnitude))),\n      );\n\n      // Based on the offset correction above, we pretend that the scroll delta was bigger or\n      // smaller than it actually was, this way we can start to eliminate the difference.\n      scrollDelta = scrollDelta - offsetCorrection;\n      scrollMagnitude = Math.abs(scrollDelta);\n    }\n\n    // The current amount of buffer past the start of the viewport.\n    const startBuffer = this._lastScrollOffset - this._lastRenderedContentOffset;\n    // The current amount of buffer past the end of the viewport.\n    const endBuffer =\n      this._lastRenderedContentOffset +\n      this._lastRenderedContentSize -\n      (this._lastScrollOffset + viewport.getViewportSize());\n    // The amount of unfilled space that should be filled on the side the user is scrolling toward\n    // in order to safely absorb the scroll delta.\n    const underscan =\n      scrollMagnitude + this._minBufferPx - (scrollDelta < 0 ? startBuffer : endBuffer);\n\n    // Check if there's unfilled space that we need to render new elements to fill.\n    if (underscan > 0) {\n      // Check if the scroll magnitude was larger than the viewport size. In this case the user\n      // won't notice a discontinuity if we just jump to the new estimated position in the list.\n      // However, if the scroll magnitude is smaller than the viewport the user might notice some\n      // jitteriness if we just jump to the estimated position. Instead we make sure to scroll by\n      // the same number of pixels as the scroll magnitude.\n      if (scrollMagnitude >= viewport.getViewportSize()) {\n        this._renderContentForCurrentOffset();\n      } else {\n        // The number of new items to render on the side the user is scrolling towards. Rather than\n        // just filling the underscan space, we actually fill enough to have a buffer size of\n        // `maxBufferPx`. This gives us a little wiggle room in case our item size estimate is off.\n        const addItems = Math.max(\n          0,\n          Math.ceil(\n            (underscan - this._minBufferPx + this._maxBufferPx) /\n              this._averager.getAverageItemSize(),\n          ),\n        );\n        // The amount of filled space beyond what is necessary on the side the user is scrolling\n        // away from.\n        const overscan =\n          (scrollDelta < 0 ? endBuffer : startBuffer) - this._minBufferPx + scrollMagnitude;\n        // The number of currently rendered items to remove on the side the user is scrolling away\n        // from. If removal has failed in recent cycles we are less aggressive in how much we try to\n        // remove.\n        const unboundedRemoveItems = Math.floor(\n          overscan / this._averager.getAverageItemSize() / (this._removalFailures + 1),\n        );\n        const removeItems = Math.min(\n          renderedRange.end - renderedRange.start,\n          Math.max(0, unboundedRemoveItems),\n        );\n\n        // The new range we will tell the viewport to render. We first expand it to include the new\n        // items we want rendered, we then contract the opposite side to remove items we no longer\n        // want rendered.\n        const range = this._expandRange(\n          renderedRange,\n          scrollDelta < 0 ? addItems : 0,\n          scrollDelta > 0 ? addItems : 0,\n        );\n        if (scrollDelta < 0) {\n          range.end = Math.max(range.start + 1, range.end - removeItems);\n        } else {\n          range.start = Math.min(range.end - 1, range.start + removeItems);\n        }\n\n        // The new offset we want to set on the rendered content. To determine this we measure the\n        // number of pixels we removed and then adjust the offset to the start of the rendered\n        // content or to the end of the rendered content accordingly (whichever one doesn't require\n        // that the newly added items to be rendered to calculate.)\n        let contentOffset: number;\n        let contentOffsetTo: 'to-start' | 'to-end';\n        if (scrollDelta < 0) {\n          let removedSize = viewport.measureRangeSize({\n            start: range.end,\n            end: renderedRange.end,\n          });\n          // Check that we're not removing too much.\n          if (removedSize <= overscan) {\n            contentOffset =\n              this._lastRenderedContentOffset + this._lastRenderedContentSize - removedSize;\n            this._removalFailures = 0;\n          } else {\n            // If the removal is more than the overscan can absorb just undo it and record the fact\n            // that the removal failed so we can be less aggressive next time.\n            range.end = renderedRange.end;\n            contentOffset = this._lastRenderedContentOffset + this._lastRenderedContentSize;\n            this._removalFailures++;\n          }\n          contentOffsetTo = 'to-end';\n        } else {\n          const removedSize = viewport.measureRangeSize({\n            start: renderedRange.start,\n            end: range.start,\n          });\n          // Check that we're not removing too much.\n          if (removedSize <= overscan) {\n            contentOffset = this._lastRenderedContentOffset + removedSize;\n            this._removalFailures = 0;\n          } else {\n            // If the removal is more than the overscan can absorb just undo it and record the fact\n            // that the removal failed so we can be less aggressive next time.\n            range.start = renderedRange.start;\n            contentOffset = this._lastRenderedContentOffset;\n            this._removalFailures++;\n          }\n          contentOffsetTo = 'to-start';\n        }\n\n        // Set the range and offset we calculated above.\n        viewport.setRenderedRange(range);\n        viewport.setRenderedContentOffset(contentOffset + offsetCorrection, contentOffsetTo);\n      }\n    } else if (offsetCorrection) {\n      // Even if the rendered range didn't change, we may still need to adjust the content offset to\n      // simulate scrolling slightly slower or faster than the user actually scrolled.\n      viewport.setRenderedContentOffset(this._lastRenderedContentOffset + offsetCorrection);\n    }\n\n    // Save the scroll offset to be compared to the new value on the next scroll event.\n    this._lastScrollOffset = scrollOffset;\n  }\n\n  /**\n   * Checks the size of the currently rendered content and uses it to update the estimated item size\n   * and estimated total content size.\n   */\n  private _checkRenderedContentSize() {\n    const viewport = this._viewport!;\n    this._lastRenderedContentSize = viewport.measureRenderedContentSize();\n    this._averager.addSample(viewport.getRenderedRange(), this._lastRenderedContentSize);\n    this._updateTotalContentSize(this._lastRenderedContentSize);\n  }\n\n  /** Checks the currently rendered content offset and saves the value for later use. */\n  private _checkRenderedContentOffset() {\n    const viewport = this._viewport!;\n    this._lastRenderedContentOffset = viewport.getOffsetToRenderedContentStart()!;\n  }\n\n  /**\n   * Recalculates the rendered content based on our estimate of what should be shown at the current\n   * scroll offset.\n   */\n  private _renderContentForCurrentOffset() {\n    const viewport = this._viewport!;\n    const scrollOffset = viewport.measureScrollOffset();\n    this._lastScrollOffset = scrollOffset;\n    this._removalFailures = 0;\n\n    const itemSize = this._averager.getAverageItemSize();\n    const firstVisibleIndex = Math.min(\n      viewport.getDataLength() - 1,\n      Math.floor(scrollOffset / itemSize),\n    );\n    const bufferSize = Math.ceil(this._maxBufferPx / itemSize);\n    const range = this._expandRange(\n      this._getVisibleRangeForIndex(firstVisibleIndex),\n      bufferSize,\n      bufferSize,\n    );\n\n    viewport.setRenderedRange(range);\n    viewport.setRenderedContentOffset(itemSize * range.start);\n  }\n\n  // TODO: maybe move to base class, can probably share with fixed size strategy.\n  /**\n   * Gets the visible range of data for the given start index. If the start index is too close to\n   * the end of the list it may be backed up to ensure the estimated size of the range is enough to\n   * fill the viewport.\n   * Note: must not be called if `this._viewport` is null\n   * @param startIndex The index to start the range at\n   * @return a range estimated to be large enough to fill the viewport when rendered.\n   */\n  private _getVisibleRangeForIndex(startIndex: number): ListRange {\n    const viewport = this._viewport!;\n    const range: ListRange = {\n      start: startIndex,\n      end: startIndex + Math.ceil(viewport.getViewportSize() / this._averager.getAverageItemSize()),\n    };\n    const extra = range.end - viewport.getDataLength();\n    if (extra > 0) {\n      range.start = Math.max(0, range.start - extra);\n    }\n    return range;\n  }\n\n  // TODO: maybe move to base class, can probably share with fixed size strategy.\n  /**\n   * Expand the given range by the given amount in either direction.\n   * Note: must not be called if `this._viewport` is null\n   * @param range The range to expand\n   * @param expandStart The number of items to expand the start of the range by.\n   * @param expandEnd The number of items to expand the end of the range by.\n   * @return The expanded range.\n   */\n  private _expandRange(range: ListRange, expandStart: number, expandEnd: number): ListRange {\n    const viewport = this._viewport!;\n    const start = Math.max(0, range.start - expandStart);\n    const end = Math.min(viewport.getDataLength(), range.end + expandEnd);\n    return {start, end};\n  }\n\n  /** Update the viewport's total content size. */\n  private _updateTotalContentSize(renderedContentSize: number) {\n    const viewport = this._viewport!;\n    const renderedRange = viewport.getRenderedRange();\n    const totalSize =\n      renderedContentSize +\n      (viewport.getDataLength() - (renderedRange.end - renderedRange.start)) *\n        this._averager.getAverageItemSize();\n    viewport.setTotalContentSize(totalSize);\n  }\n}\n\n/**\n * Provider factory for `AutoSizeVirtualScrollStrategy` that simply extracts the already created\n * `AutoSizeVirtualScrollStrategy` from the given directive.\n * @param autoSizeDir The instance of `CdkAutoSizeVirtualScroll` to extract the\n *     `AutoSizeVirtualScrollStrategy` from.\n */\nexport function _autoSizeVirtualScrollStrategyFactory(autoSizeDir: CdkAutoSizeVirtualScroll) {\n  return autoSizeDir._scrollStrategy;\n}\n\n/** A virtual scroll strategy that supports unknown or dynamic size items. */\n@Directive({\n  selector: 'cdk-virtual-scroll-viewport[autosize]',\n  providers: [\n    {\n      provide: VIRTUAL_SCROLL_STRATEGY,\n      useFactory: _autoSizeVirtualScrollStrategyFactory,\n      deps: [forwardRef(() => CdkAutoSizeVirtualScroll)],\n    },\n  ],\n})\nexport class CdkAutoSizeVirtualScroll implements OnChanges {\n  /**\n   * The minimum amount of buffer rendered beyond the viewport (in pixels).\n   * If the amount of buffer dips below this number, more items will be rendered. Defaults to 100px.\n   */\n  @Input()\n  get minBufferPx(): number {\n    return this._minBufferPx;\n  }\n  set minBufferPx(value: NumberInput) {\n    this._minBufferPx = coerceNumberProperty(value);\n  }\n  _minBufferPx = 100;\n\n  /**\n   * The number of pixels worth of buffer to shoot for when rendering new items.\n   * If the actual amount turns out to be less it will not necessarily trigger an additional\n   * rendering cycle (as long as the amount of buffer is still greater than `minBufferPx`).\n   * Defaults to 200px.\n   */\n  @Input()\n  get maxBufferPx(): number {\n    return this._maxBufferPx;\n  }\n  set maxBufferPx(value: NumberInput) {\n    this._maxBufferPx = coerceNumberProperty(value);\n  }\n  _maxBufferPx = 200;\n\n  /** The scroll strategy used by this directive. */\n  _scrollStrategy = new AutoSizeVirtualScrollStrategy(this.minBufferPx, this.maxBufferPx);\n\n  ngOnChanges() {\n    this._scrollStrategy.updateBufferSize(this.minBufferPx, this.maxBufferPx);\n  }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {NgModule} from '@angular/core';\nimport {CdkAutoSizeVirtualScroll} from './auto-size-virtual-scroll';\n\n@NgModule({\n  imports: [CdkAutoSizeVirtualScroll],\n  exports: [CdkAutoSizeVirtualScroll],\n})\nexport class ScrollingModule {}\n"],"names":[],"mappings":";;;;;;MAsBa,gBAAgB,CAAA;AAEnB,EAAA,YAAY,GAAG,CAAC;EAGhB,gBAAgB;EAGhB,gBAAgB;AAGxB,EAAA,WAAA,CAAY,eAAe,GAAG,EAAE,EAAA;IAC9B,IAAI,CAAC,gBAAgB,GAAG,eAAe;IACvC,IAAI,CAAC,gBAAgB,GAAG,eAAe;AACzC,EAAA;AAGA,EAAA,kBAAkB,GAAA;IAChB,OAAO,IAAI,CAAC,gBAAgB;AAC9B,EAAA;AAOA,EAAA,SAAS,CAAC,KAAgB,EAAE,IAAY,EAAA;AACtC,IAAA,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK;AAClE,IAAA,IAAI,cAAc,EAAE;AAClB,MAAA,MAAM,kBAAkB,GACtB,CAAC,IAAI,GAAG,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,YAAY,IAAI,cAAc;AACrE,MAAA,IAAI,kBAAkB,EAAE;QACtB,IAAI,CAAC,gBAAgB,GAAG,kBAAkB;QAC1C,IAAI,CAAC,YAAY,GAAG,cAAc;AACpC,MAAA;AACF,IAAA;AACF,EAAA;AAGA,EAAA,KAAK,GAAA;AACH,IAAA,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB;IAC7C,IAAI,CAAC,YAAY,GAAG,CAAC;AACvB,EAAA;AACD;MAGY,6BAA6B,C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