@getflip/swirl-components 0.533.0 → 0.534.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/components.json +158 -1
  2. package/dist/cjs/index-D-n4TKMG.js +4 -4
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{media-query.service-B8u-DqoO.js → media-query.service-C1jMjjiy.js} +1 -1
  5. package/dist/cjs/swirl-action-list_2.cjs.entry.js +2 -2
  6. package/dist/cjs/swirl-app-layout.cjs.entry.js +2 -2
  7. package/dist/cjs/swirl-autocomplete.cjs.entry.js +1 -1
  8. package/dist/cjs/swirl-banner.cjs.entry.js +2 -2
  9. package/dist/cjs/swirl-button.cjs.entry.js +2 -2
  10. package/dist/cjs/swirl-carousel.cjs.entry.js +1 -1
  11. package/dist/cjs/swirl-components.cjs.js +1 -1
  12. package/dist/cjs/swirl-console-layout.cjs.entry.js +1 -1
  13. package/dist/cjs/swirl-date-input.cjs.entry.js +2 -2
  14. package/dist/cjs/swirl-date-picker_2.cjs.entry.js +1 -1
  15. package/dist/cjs/swirl-file-chip.cjs.entry.js +1 -1
  16. package/dist/cjs/swirl-file-viewer-audio_7.cjs.entry.js +1 -1
  17. package/dist/cjs/swirl-file-viewer_7.cjs.entry.js +1 -1
  18. package/dist/cjs/swirl-form-control.cjs.entry.js +1 -1
  19. package/dist/cjs/swirl-icon-check-small_3.cjs.entry.js +2 -2
  20. package/dist/cjs/swirl-icon-error_3.cjs.entry.js +2 -2
  21. package/dist/cjs/swirl-image-grid-item.cjs.entry.js +1 -1
  22. package/dist/cjs/swirl-inline-status.cjs.entry.js +2 -2
  23. package/dist/cjs/swirl-lightbox.cjs.entry.js +1 -1
  24. package/dist/cjs/swirl-menu-item.cjs.entry.js +1 -1
  25. package/dist/cjs/swirl-menu.cjs.entry.js +1 -1
  26. package/dist/cjs/swirl-modal.cjs.entry.js +1 -1
  27. package/dist/cjs/swirl-option-list.cjs.entry.js +1 -1
  28. package/dist/cjs/swirl-pagination.cjs.entry.js +1 -1
  29. package/dist/cjs/swirl-pdf-reader.cjs.entry.js +1 -1
  30. package/dist/cjs/swirl-popover_2.cjs.entry.js +1 -1
  31. package/dist/cjs/swirl-resource-list-file-item.cjs.entry.js +2 -2
  32. package/dist/cjs/swirl-resource-list-item.cjs.entry.js +2 -2
  33. package/dist/cjs/swirl-search.cjs.entry.js +2 -2
  34. package/dist/cjs/swirl-select.cjs.entry.js +1 -1
  35. package/dist/cjs/swirl-shell-layout.cjs.entry.js +1 -1
  36. package/dist/cjs/swirl-tab-bar.cjs.entry.js +1 -1
  37. package/dist/cjs/swirl-table-column.cjs.entry.js +1 -1
  38. package/dist/cjs/swirl-table-row.cjs.entry.js +1 -1
  39. package/dist/cjs/swirl-table.cjs.entry.js +2287 -2
  40. package/dist/cjs/swirl-tabs.cjs.entry.js +1 -1
  41. package/dist/cjs/swirl-text-input.cjs.entry.js +2 -2
  42. package/dist/cjs/swirl-time-input.cjs.entry.js +2 -2
  43. package/dist/cjs/swirl-toast.cjs.entry.js +2 -2
  44. package/dist/cjs/swirl-toolbar.cjs.entry.js +1 -1
  45. package/dist/cjs/swirl-tooltip.cjs.entry.js +1 -1
  46. package/dist/cjs/{utils-UfZG-xPD.js → utils-C4tLdXqU.js} +33 -0
  47. package/dist/collection/components/swirl-table/swirl-table-virtualizer.js +224 -0
  48. package/dist/collection/components/swirl-table/swirl-table.js +253 -2
  49. package/dist/collection/components/swirl-table/swirl-table.stories.js +190 -0
  50. package/dist/collection/utils.js +32 -0
  51. package/dist/components/media-query.service.js +1 -1
  52. package/dist/components/swirl-file-viewer-pdf2.js +1 -1
  53. package/dist/components/swirl-popover2.js +1 -1
  54. package/dist/components/swirl-tab-bar2.js +1 -1
  55. package/dist/components/swirl-table.js +1 -1
  56. package/dist/components/swirl-tabs.js +1 -1
  57. package/dist/components/swirl-tooltip2.js +1 -1
  58. package/dist/components/utils.js +1 -1
  59. package/dist/esm/index-Dz56lJ37.js +4 -4
  60. package/dist/esm/loader.js +1 -1
  61. package/dist/esm/{media-query.service-CCYT6DU8.js → media-query.service-Bbqqduao.js} +1 -1
  62. package/dist/esm/swirl-action-list_2.entry.js +2 -2
  63. package/dist/esm/swirl-app-layout.entry.js +2 -2
  64. package/dist/esm/swirl-autocomplete.entry.js +1 -1
  65. package/dist/esm/swirl-banner.entry.js +2 -2
  66. package/dist/esm/swirl-button.entry.js +2 -2
  67. package/dist/esm/swirl-carousel.entry.js +1 -1
  68. package/dist/esm/swirl-components.js +1 -1
  69. package/dist/esm/swirl-console-layout.entry.js +1 -1
  70. package/dist/esm/swirl-date-input.entry.js +2 -2
  71. package/dist/esm/swirl-date-picker_2.entry.js +1 -1
  72. package/dist/esm/swirl-file-chip.entry.js +1 -1
  73. package/dist/esm/swirl-file-viewer-audio_7.entry.js +1 -1
  74. package/dist/esm/swirl-file-viewer_7.entry.js +1 -1
  75. package/dist/esm/swirl-form-control.entry.js +1 -1
  76. package/dist/esm/swirl-icon-check-small_3.entry.js +2 -2
  77. package/dist/esm/swirl-icon-error_3.entry.js +2 -2
  78. package/dist/esm/swirl-image-grid-item.entry.js +1 -1
  79. package/dist/esm/swirl-inline-status.entry.js +2 -2
  80. package/dist/esm/swirl-lightbox.entry.js +1 -1
  81. package/dist/esm/swirl-menu-item.entry.js +1 -1
  82. package/dist/esm/swirl-menu.entry.js +1 -1
  83. package/dist/esm/swirl-modal.entry.js +1 -1
  84. package/dist/esm/swirl-option-list.entry.js +1 -1
  85. package/dist/esm/swirl-pagination.entry.js +1 -1
  86. package/dist/esm/swirl-pdf-reader.entry.js +1 -1
  87. package/dist/esm/swirl-popover_2.entry.js +1 -1
  88. package/dist/esm/swirl-resource-list-file-item.entry.js +2 -2
  89. package/dist/esm/swirl-resource-list-item.entry.js +2 -2
  90. package/dist/esm/swirl-search.entry.js +2 -2
  91. package/dist/esm/swirl-select.entry.js +1 -1
  92. package/dist/esm/swirl-shell-layout.entry.js +1 -1
  93. package/dist/esm/swirl-tab-bar.entry.js +1 -1
  94. package/dist/esm/swirl-table-column.entry.js +1 -1
  95. package/dist/esm/swirl-table-row.entry.js +1 -1
  96. package/dist/esm/swirl-table.entry.js +2288 -3
  97. package/dist/esm/swirl-tabs.entry.js +1 -1
  98. package/dist/esm/swirl-text-input.entry.js +2 -2
  99. package/dist/esm/swirl-time-input.entry.js +2 -2
  100. package/dist/esm/swirl-toast.entry.js +2 -2
  101. package/dist/esm/swirl-toolbar.entry.js +1 -1
  102. package/dist/esm/swirl-tooltip.entry.js +1 -1
  103. package/dist/esm/{utils-CCck-DTo.js → utils-D23VxAsw.js} +33 -1
  104. package/dist/swirl-components/p-0cb6bbde.entry.js +1 -0
  105. package/dist/swirl-components/{p-ea6bdee5.entry.js → p-20354a36.entry.js} +1 -1
  106. package/dist/swirl-components/{p-8d078f8a.entry.js → p-247ada6e.entry.js} +1 -1
  107. package/dist/swirl-components/{p-270be9f2.entry.js → p-29fed244.entry.js} +1 -1
  108. package/dist/swirl-components/{p-c924fc96.entry.js → p-437ac2fa.entry.js} +1 -1
  109. package/dist/swirl-components/{p-97deaddc.entry.js → p-48c1b8e4.entry.js} +1 -1
  110. package/dist/swirl-components/{p-40be5fde.entry.js → p-48c559a4.entry.js} +1 -1
  111. package/dist/swirl-components/p-4a1d3582.entry.js +1 -0
  112. package/dist/swirl-components/{p-ad4fd14f.entry.js → p-5c6fc0bc.entry.js} +1 -1
  113. package/dist/swirl-components/{p-73a8e8a0.entry.js → p-6242f9bb.entry.js} +1 -1
  114. package/dist/swirl-components/{p-0c0acfd3.entry.js → p-641bb5b1.entry.js} +1 -1
  115. package/dist/swirl-components/{p-993dae75.entry.js → p-6528e39b.entry.js} +1 -1
  116. package/dist/swirl-components/{p-b45902de.entry.js → p-6785b8a5.entry.js} +1 -1
  117. package/dist/swirl-components/{p-dcf08d9a.entry.js → p-692dd291.entry.js} +1 -1
  118. package/dist/swirl-components/{p-418a8b7b.entry.js → p-6e0825ae.entry.js} +1 -1
  119. package/dist/swirl-components/{p-22931b7b.entry.js → p-71e1f20d.entry.js} +1 -1
  120. package/dist/swirl-components/{p-f015fc2d.entry.js → p-78af0765.entry.js} +1 -1
  121. package/dist/swirl-components/{p-2ddf4a93.entry.js → p-7a9bb681.entry.js} +1 -1
  122. package/dist/swirl-components/{p-b36ee49f.entry.js → p-84cfb27a.entry.js} +1 -1
  123. package/dist/swirl-components/{p-c6bceca5.entry.js → p-91b316f9.entry.js} +1 -1
  124. package/dist/swirl-components/{p-da6fa0fa.entry.js → p-958aa736.entry.js} +1 -1
  125. package/dist/swirl-components/{p-fbdb4aff.entry.js → p-95d6d7ad.entry.js} +1 -1
  126. package/dist/swirl-components/{p-577174d9.entry.js → p-984c4d86.entry.js} +1 -1
  127. package/dist/swirl-components/{p-CCck-DTo.js → p-D23VxAsw.js} +1 -1
  128. package/dist/swirl-components/{p-Bfn7CHM9.js → p-_iAIu_AF.js} +1 -1
  129. package/dist/swirl-components/{p-d0275263.entry.js → p-a11ba0b5.entry.js} +1 -1
  130. package/dist/swirl-components/{p-1bf78baf.entry.js → p-ae978c57.entry.js} +1 -1
  131. package/dist/swirl-components/{p-95a403cf.entry.js → p-b08aa57d.entry.js} +1 -1
  132. package/dist/swirl-components/{p-26362ab2.entry.js → p-bb4c80bf.entry.js} +1 -1
  133. package/dist/swirl-components/{p-e63650e3.entry.js → p-c182f4c1.entry.js} +1 -1
  134. package/dist/swirl-components/{p-d763ce05.entry.js → p-c4dad69d.entry.js} +1 -1
  135. package/dist/swirl-components/{p-47b02bc4.entry.js → p-cf855c44.entry.js} +1 -1
  136. package/dist/swirl-components/{p-fbcc5141.entry.js → p-d26aa1e7.entry.js} +1 -1
  137. package/dist/swirl-components/{p-3340670b.entry.js → p-d298c94c.entry.js} +1 -1
  138. package/dist/swirl-components/{p-9ad61433.entry.js → p-d8924470.entry.js} +1 -1
  139. package/dist/swirl-components/{p-268ddaee.entry.js → p-dab890a1.entry.js} +2 -2
  140. package/dist/swirl-components/{p-3e6fb027.entry.js → p-de5a7b4a.entry.js} +1 -1
  141. package/dist/swirl-components/p-ea36e3ec.entry.js +1 -0
  142. package/dist/swirl-components/{p-96c9486a.entry.js → p-eb297822.entry.js} +1 -1
  143. package/dist/swirl-components/{p-bee027a0.entry.js → p-ec10ca71.entry.js} +1 -1
  144. package/dist/swirl-components/{p-94e6a907.entry.js → p-f6c37730.entry.js} +1 -1
  145. package/dist/swirl-components/{p-b581b1e6.entry.js → p-fd188df6.entry.js} +1 -1
  146. package/dist/swirl-components/swirl-components.esm.js +1 -1
  147. package/dist/types/components/swirl-table/swirl-table-virtualizer.d.ts +60 -0
  148. package/dist/types/components/swirl-table/swirl-table.d.ts +43 -0
  149. package/dist/types/components/swirl-table/swirl-table.stories.d.ts +2 -0
  150. package/dist/types/components.d.ts +57 -2
  151. package/dist/types/utils.d.ts +12 -0
  152. package/package.json +2 -1
  153. package/vscode-data.json +16 -0
  154. package/dist/swirl-components/p-0c0b46e1.entry.js +0 -1
  155. package/dist/swirl-components/p-2943bc69.entry.js +0 -1
  156. package/dist/swirl-components/p-5fa1c77c.entry.js +0 -1
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, c as createEvent, h, a as Host, d as getElement } from './index-Dz56lJ37.js';
2
2
  import { g as getDefaultExportFromCjs, c as classnames } from './index-orsBiyT_.js';
3
3
  import { S as Sortable } from './sortable.esm-CMrz6687.js';
4
- import { d as debounce, i as isMobileViewport, q as querySelectorAllDeep } from './utils-CCck-DTo.js';
4
+ import { d as debounce$1, u as getScrollParent, i as isMobileViewport, q as querySelectorAllDeep } from './utils-D23VxAsw.js';
5
5
 
6
6
  var dist;
7
7
  var hasRequiredDist;
@@ -87,6 +87,2157 @@ function requireDist () {
87
87
  var distExports = requireDist();
88
88
  var debouncePromise = /*@__PURE__*/getDefaultExportFromCjs(distExports);
89
89
 
90
+ function getMeasurementKey(item) {
91
+ return typeof item === "object" ? item.key : item;
92
+ }
93
+ function createLazyMeasurementsView(cache, flat) {
94
+ const count = cache.length;
95
+ return new Proxy(cache, {
96
+ get(target, prop, receiver) {
97
+ if (typeof prop === "string") {
98
+ const c = prop.charCodeAt(0);
99
+ if (c >= 48 && c <= 57) {
100
+ const i = +prop;
101
+ if (Number.isInteger(i) && i >= 0 && i < count) {
102
+ let v = target[i];
103
+ if (typeof v !== "object") {
104
+ const s = flat[i * 2];
105
+ v = target[i] = {
106
+ index: i,
107
+ key: v,
108
+ start: s,
109
+ size: flat[i * 2 + 1],
110
+ end: s + flat[i * 2 + 1],
111
+ lane: 0
112
+ };
113
+ }
114
+ return v;
115
+ }
116
+ }
117
+ if (prop === "length") return count;
118
+ }
119
+ return Reflect.get(target, prop, receiver);
120
+ }
121
+ });
122
+ }
123
+
124
+ function memo(getDeps, fn, opts) {
125
+ let deps = opts.initialDeps ?? [];
126
+ let result;
127
+ let isInitial = true;
128
+ function memoizedFunction() {
129
+ const newDeps = getDeps();
130
+ const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
131
+ if (!depsChanged) {
132
+ return result;
133
+ }
134
+ deps = newDeps;
135
+ result = fn(...newDeps);
136
+ if ((opts == null ? void 0 : opts.onChange) && !(isInitial && opts.skipInitialOnChange)) {
137
+ opts.onChange(result);
138
+ }
139
+ isInitial = false;
140
+ return result;
141
+ }
142
+ memoizedFunction.updateDeps = (newDeps) => {
143
+ deps = newDeps;
144
+ };
145
+ return memoizedFunction;
146
+ }
147
+ function notUndefined(value, msg) {
148
+ if (value === void 0) {
149
+ throw new Error(`Unexpected undefined${""}`);
150
+ } else {
151
+ return value;
152
+ }
153
+ }
154
+ const approxEqual = (a, b) => Math.abs(a - b) < 1.01;
155
+ const debounce = (targetWindow, fn, ms) => {
156
+ let timeoutId;
157
+ return Object.assign(
158
+ function(...args) {
159
+ targetWindow.clearTimeout(timeoutId);
160
+ timeoutId = targetWindow.setTimeout(() => fn.apply(this, args), ms);
161
+ },
162
+ {
163
+ // The handle is closure-local, so a caller that has already
164
+ // unsubscribed has no way to stop a queued call. Teardown paths use
165
+ // this to drop the pending invocation instead of letting it land.
166
+ cancel: () => {
167
+ targetWindow.clearTimeout(timeoutId);
168
+ }
169
+ }
170
+ );
171
+ };
172
+
173
+ function classifyScrollEvent({
174
+ offset,
175
+ isScrolling,
176
+ elementMax,
177
+ holdOffset,
178
+ scrollOffset,
179
+ pendingWrite,
180
+ clampedMaxAtWrite
181
+ }) {
182
+ var _a;
183
+ if (isScrolling && pendingWrite === null && offset === scrollOffset) {
184
+ return "spurious";
185
+ }
186
+ if (pendingWrite !== null && Math.abs(offset - pendingWrite.target) < 1.5) {
187
+ return "readBack";
188
+ }
189
+ if (pendingWrite !== null && !pendingWrite.smooth && elementMax !== null && pendingWrite.target > elementMax + holdOffset + 0.5 && Math.abs(offset - (elementMax + holdOffset)) < 1.5) {
190
+ return "clampedReadBack";
191
+ }
192
+ if (pendingWrite !== null && !pendingWrite.smooth && ((_a = pendingWrite.lowMaxes) == null ? void 0 : _a.some((max) => Math.abs(offset - max) < 1.5))) {
193
+ return "clampedReadBack";
194
+ }
195
+ if (clampedMaxAtWrite !== null && Math.abs(offset - clampedMaxAtWrite) < 1.5) {
196
+ return "clampedEcho";
197
+ }
198
+ return "external";
199
+ }
200
+ const isAnimating = (phase) => phase === "smooth" || phase === "smoothFinishing";
201
+ function externalRetiresCommand({
202
+ kind,
203
+ offset,
204
+ command,
205
+ target
206
+ }) {
207
+ return kind !== "spurious" && kind !== "readBack" && // Our own write, clamped (`clampedReadBack`, #1310): the command is not
208
+ // retired by it, and reconcile retargets below the new max.
209
+ kind !== "clampedReadBack" && (command == null ? void 0 : command.index) != null && // Nothing has been written for a command waiting for the tail; these
210
+ // are the fling's events.
211
+ command.phase !== "queued" && // A non-smooth write lands at once, so any other scroll event is the
212
+ // user's, even before reconcile saw the target reached (the target may
213
+ // keep moving, or iOS ignored the write under a finger). A write the
214
+ // browser clamped because the sizer hasn't grown yet reads back at the
215
+ // max, which is also where the fresh target clamps, so the check below
216
+ // keeps it reconciling (#1294). While a smooth scroll's animation may
217
+ // still report, its events look like a user's, so it yields only once it
218
+ // has landed.
219
+ !isAnimating(command.phase) && !approxEqual(offset, command.lastTargetOffset) && !approxEqual(offset, target()) && // A compensation write's clamped echo (#1258) keeps the command. The
220
+ // order is deliberate, not tidiness: this clause stays after `target()`
221
+ // (and `clampedReadBack` before it) because `target()` can rebuild the
222
+ // measurements, so it must run for exactly the events it always did.
223
+ kind !== "clampedEcho";
224
+ }
225
+ const FLING_WINDOW_MS = 40;
226
+ function flingSpedUp(samples) {
227
+ const last = samples[samples.length - 1];
228
+ if (last === void 0) return false;
229
+ let j = samples.length - 2;
230
+ while (j >= 0 && last.t - samples[j].t < FLING_WINDOW_MS) j--;
231
+ if (j < 0) return false;
232
+ const mid = samples[j];
233
+ let k = j - 1;
234
+ while (k >= 0 && mid.t - samples[k].t < FLING_WINDOW_MS) k--;
235
+ if (k < 0) return false;
236
+ const first = samples[k];
237
+ const recent = (last.offset - mid.offset) / (last.t - mid.t);
238
+ const before = (mid.offset - first.offset) / (mid.t - first.t);
239
+ return recent * before >= 0 && Math.abs(recent) >= 2 * Math.abs(before) && Math.abs(recent) - Math.abs(before) >= 0.8;
240
+ }
241
+ function flingCaught(samples) {
242
+ const last = samples[samples.length - 1];
243
+ if (last === void 0) return false;
244
+ let j = samples.length - 2;
245
+ while (j >= 0 && last.t - samples[j].t < FLING_WINDOW_MS) j--;
246
+ if (j < 0) return false;
247
+ const from = samples[j];
248
+ return Math.abs(last.offset - from.offset) / (last.t - from.t) >= 0.05;
249
+ }
250
+
251
+ let _isIOSResult;
252
+ const isIOSWebKit = () => {
253
+ if (_isIOSResult !== void 0) return _isIOSResult;
254
+ if (typeof navigator === "undefined") return _isIOSResult = false;
255
+ if (/iP(hone|od|ad)/.test(navigator.userAgent)) return _isIOSResult = true;
256
+ const mtp = navigator.maxTouchPoints;
257
+ return _isIOSResult = navigator.platform === "MacIntel" && mtp !== void 0 && mtp > 0;
258
+ };
259
+ let _iosMomentumOverridesWritesResult;
260
+ const iosMomentumOverridesWrites = () => {
261
+ if (_iosMomentumOverridesWritesResult !== void 0) {
262
+ return _iosMomentumOverridesWritesResult;
263
+ }
264
+ return _iosMomentumOverridesWritesResult = isIOSWebKit() && typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("overflow-anchor: auto");
265
+ };
266
+ const momentumOverridesWrites = () => !isIOSWebKit() || iosMomentumOverridesWrites();
267
+ const touchListenerOptions = {
268
+ capture: true,
269
+ passive: true
270
+ };
271
+ class IosGesture {
272
+ constructor(host) {
273
+ this.host = host;
274
+ this._touch = null;
275
+ this.inMotion = () => this._touch !== null && this._touch.phase !== "lateFling";
276
+ this.dragging = () => {
277
+ var _a;
278
+ return ((_a = this._touch) == null ? void 0 : _a.phase) === "down" && this._touch.moved;
279
+ };
280
+ this.tail = () => {
281
+ var _a;
282
+ return ((_a = this._touch) == null ? void 0 : _a.phase) === "tail" ? this._touch.moved ? "fling" : "tap" : null;
283
+ };
284
+ this.onScroll = ({
285
+ isScrolling,
286
+ ownReadBack,
287
+ moved,
288
+ external
289
+ }) => {
290
+ var _a, _b, _c;
291
+ if (isScrolling && ((_a = this._touch) == null ? void 0 : _a.phase) === "tail") {
292
+ this._openTail(this._touch.moved || !ownReadBack, false);
293
+ } else if (((_b = this._touch) == null ? void 0 : _b.phase) === "lateFling") {
294
+ if (this.host.now() > this._touch.until) {
295
+ this._touch = null;
296
+ } else if (external && isScrolling && moved) {
297
+ this._openTail(true, false);
298
+ }
299
+ }
300
+ if (!ownReadBack && isScrolling && moved && ((_c = this._touch) == null ? void 0 : _c.phase) === "down") {
301
+ this._touch.moved = true;
302
+ return true;
303
+ }
304
+ return false;
305
+ };
306
+ this.touchStart = () => {
307
+ this.end();
308
+ this._touch = { phase: "down", moved: false };
309
+ };
310
+ this.touchEnd = () => {
311
+ var _a;
312
+ const moved = ((_a = this._touch) == null ? void 0 : _a.phase) === "down" && this._touch.moved;
313
+ this.end();
314
+ this._openTail(moved, moved);
315
+ };
316
+ this.end = () => {
317
+ var _a;
318
+ const win = this.host.getWindow();
319
+ if (((_a = this._touch) == null ? void 0 : _a.phase) === "tail" && win != null) {
320
+ win.clearTimeout(this._touch.timerId);
321
+ }
322
+ this._touch = null;
323
+ };
324
+ this.listen = (target) => {
325
+ const onTouchStart = () => this.touchStart();
326
+ const onTouchEnd = () => this.touchEnd();
327
+ target.addEventListener("touchstart", onTouchStart, touchListenerOptions);
328
+ target.addEventListener("touchend", onTouchEnd, touchListenerOptions);
329
+ target.addEventListener("touchcancel", onTouchEnd, touchListenerOptions);
330
+ return () => {
331
+ target.removeEventListener(
332
+ "touchstart",
333
+ onTouchStart,
334
+ touchListenerOptions
335
+ );
336
+ target.removeEventListener("touchend", onTouchEnd, touchListenerOptions);
337
+ target.removeEventListener(
338
+ "touchcancel",
339
+ onTouchEnd,
340
+ touchListenerOptions
341
+ );
342
+ this.end();
343
+ };
344
+ };
345
+ this._openTail = (moved, awaitingFling) => {
346
+ const win = this.host.getWindow();
347
+ if (win == null) return;
348
+ this.end();
349
+ const tail = {
350
+ phase: "tail",
351
+ moved,
352
+ awaitingFling,
353
+ // Only fires while this tail is current: `end` clears it otherwise.
354
+ timerId: win.setTimeout(() => {
355
+ if (this.host.tailStillMoving()) {
356
+ this._openTail(tail.moved, tail.awaitingFling);
357
+ return;
358
+ }
359
+ this._touch = tail.awaitingFling ? { phase: "lateFling", until: this.host.now() + 1e3 } : null;
360
+ this.host.onTailClosed();
361
+ }, 150)
362
+ };
363
+ this._touch = tail;
364
+ };
365
+ }
366
+ get touch() {
367
+ return this._touch;
368
+ }
369
+ }
370
+
371
+ const getRect = (element) => {
372
+ const { clientWidth, clientHeight } = element;
373
+ return { width: clientWidth, height: clientHeight };
374
+ };
375
+ const createFrameQueue = (targetWindow) => {
376
+ const ids = /* @__PURE__ */ new Set();
377
+ return {
378
+ schedule: (fn) => {
379
+ const id = targetWindow.requestAnimationFrame(() => {
380
+ ids.delete(id);
381
+ fn();
382
+ });
383
+ ids.add(id);
384
+ },
385
+ cancel: () => {
386
+ ids.forEach((id) => targetWindow.cancelAnimationFrame(id));
387
+ ids.clear();
388
+ }
389
+ };
390
+ };
391
+ const defaultKeyExtractor = (index) => index;
392
+ const defaultRangeExtractor = (range) => {
393
+ const overscan = range.overscan * Math.max(range.lanes ?? 1, 1);
394
+ const start = Math.max(range.startIndex - overscan, 0);
395
+ const end = Math.min(range.endIndex + overscan, range.count - 1);
396
+ const len = end - start + 1;
397
+ const arr = new Array(len);
398
+ for (let i = 0; i < len; i++) {
399
+ arr[i] = start + i;
400
+ }
401
+ return arr;
402
+ };
403
+ const observeElementRect = (instance, cb) => {
404
+ const element = instance.scrollElement;
405
+ if (!element) {
406
+ return;
407
+ }
408
+ const targetWindow = instance.targetWindow;
409
+ if (!targetWindow) {
410
+ return;
411
+ }
412
+ const handler = (rect) => {
413
+ const { width, height } = rect;
414
+ cb({ width: Math.round(width), height: Math.round(height) });
415
+ };
416
+ handler(getRect(element));
417
+ if (!targetWindow.ResizeObserver) {
418
+ return () => {
419
+ };
420
+ }
421
+ const frames = createFrameQueue(targetWindow);
422
+ const observer = new targetWindow.ResizeObserver(() => {
423
+ const run = () => {
424
+ handler(getRect(element));
425
+ };
426
+ instance.options.useAnimationFrameWithResizeObserver ? frames.schedule(run) : run();
427
+ });
428
+ observer.observe(element, { box: "content-box" });
429
+ return () => {
430
+ observer.unobserve(element);
431
+ frames.cancel();
432
+ };
433
+ };
434
+ const addEventListenerOptions = {
435
+ passive: true
436
+ };
437
+ const observeWindowRect = (instance, cb) => {
438
+ const element = instance.scrollElement;
439
+ if (!element) {
440
+ return;
441
+ }
442
+ const handler = () => {
443
+ cb({ width: element.innerWidth, height: element.innerHeight });
444
+ };
445
+ handler();
446
+ element.addEventListener("resize", handler, addEventListenerOptions);
447
+ return () => {
448
+ element.removeEventListener("resize", handler);
449
+ };
450
+ };
451
+ const supportsScrollend = typeof window == "undefined" ? true : "onscrollend" in window;
452
+ const observeOffset = (instance, cb, readOffset) => {
453
+ const element = instance.scrollElement;
454
+ if (!element) {
455
+ return;
456
+ }
457
+ const targetWindow = instance.targetWindow;
458
+ if (!targetWindow) {
459
+ return;
460
+ }
461
+ const registerScrollendEvent = instance.options.useScrollendEvent && supportsScrollend;
462
+ let offset = 0;
463
+ const fallback = registerScrollendEvent ? null : debounce(
464
+ targetWindow,
465
+ () => cb(readOffset(element), false),
466
+ instance.options.isScrollingResetDelay
467
+ );
468
+ const createHandler = (isScrolling) => () => {
469
+ offset = readOffset(element);
470
+ fallback == null ? void 0 : fallback();
471
+ cb(offset, isScrolling);
472
+ };
473
+ const handler = createHandler(true);
474
+ const endHandler = createHandler(false);
475
+ element.addEventListener("scroll", handler, addEventListenerOptions);
476
+ if (registerScrollendEvent) {
477
+ element.addEventListener("scrollend", endHandler, addEventListenerOptions);
478
+ }
479
+ return () => {
480
+ element.removeEventListener("scroll", handler);
481
+ if (registerScrollendEvent) {
482
+ element.removeEventListener("scrollend", endHandler);
483
+ }
484
+ fallback == null ? void 0 : fallback.cancel();
485
+ };
486
+ };
487
+ const observeElementOffset = (instance, cb) => observeOffset(instance, cb, (el) => {
488
+ const { horizontal, isRtl } = instance.options;
489
+ return horizontal ? el.scrollLeft * (isRtl && -1 || 1) : el.scrollTop;
490
+ });
491
+ const observeWindowOffset = (instance, cb) => observeOffset(
492
+ instance,
493
+ cb,
494
+ (win) => instance.options.horizontal ? win.scrollX : win.scrollY
495
+ );
496
+ const measureElement = (element, entry, instance) => {
497
+ if (instance.options.useCachedMeasurements) {
498
+ const index = instance.indexFromElement(element);
499
+ const key = instance.options.getItemKey(index);
500
+ return instance.itemSizeCache.get(key) ?? instance.options.estimateSize(index);
501
+ }
502
+ if (entry == null ? void 0 : entry.borderBoxSize) {
503
+ const box = entry.borderBoxSize[0];
504
+ if (box) {
505
+ const size = Math.round(
506
+ box[instance.options.horizontal ? "inlineSize" : "blockSize"]
507
+ );
508
+ return size;
509
+ }
510
+ }
511
+ if (!entry) {
512
+ const index = instance.indexFromElement(element);
513
+ const key = instance.options.getItemKey(index);
514
+ const cachedSize = instance.itemSizeCache.get(key);
515
+ if (cachedSize !== void 0) {
516
+ return cachedSize;
517
+ }
518
+ }
519
+ return element[instance.options.horizontal ? "offsetWidth" : "offsetHeight"];
520
+ };
521
+ const scrollWithAdjustments = (offset, {
522
+ adjustments = 0,
523
+ behavior
524
+ }, instance) => {
525
+ var _a, _b;
526
+ (_b = (_a = instance.scrollElement) == null ? void 0 : _a.scrollTo) == null ? void 0 : _b.call(_a, {
527
+ [instance.options.horizontal ? "left" : "top"]: offset + adjustments,
528
+ behavior
529
+ });
530
+ };
531
+ const windowScroll = scrollWithAdjustments;
532
+ const elementScroll = scrollWithAdjustments;
533
+ const initialScrollPhase = (behavior, atTarget) => behavior === "smooth" ? atTarget ? "smoothLanded" : "smooth" : "instant";
534
+ const isSmoothScroll = (state) => (state == null ? void 0 : state.phase) === "smooth" || (state == null ? void 0 : state.phase) === "smoothLanded";
535
+ function isAppendWithTrim(prevCount, nextCount, getPreviousKey, getNextKey) {
536
+ if (nextCount === 0) return false;
537
+ const firstKey = getNextKey(0);
538
+ const removedKeys = /* @__PURE__ */ new Set();
539
+ let removedCount = 0;
540
+ while (removedCount < prevCount) {
541
+ const key = getPreviousKey(removedCount);
542
+ if (key === firstKey) break;
543
+ removedKeys.add(key);
544
+ removedCount++;
545
+ }
546
+ const retainedCount = prevCount - removedCount;
547
+ if (retainedCount === 0 || retainedCount >= nextCount) return false;
548
+ for (let i = 0; i < retainedCount; i++) {
549
+ if (getNextKey(i) !== getPreviousKey(removedCount + i)) return false;
550
+ }
551
+ for (let i = retainedCount; i < nextCount; i++) {
552
+ if (removedKeys.has(getNextKey(i))) return false;
553
+ }
554
+ return true;
555
+ }
556
+ class Virtualizer {
557
+ constructor(opts) {
558
+ this.unsubs = [];
559
+ this.scrollElement = null;
560
+ this.targetWindow = null;
561
+ this.isScrolling = false;
562
+ this.scrollState = null;
563
+ this.measurementsCache = [];
564
+ this._singleLaneMeasurements = null;
565
+ this.itemSizeCache = /* @__PURE__ */ new Map();
566
+ this.itemSizeCacheVersion = 0;
567
+ this.laneAssignments = /* @__PURE__ */ new Map();
568
+ this.pendingMin = null;
569
+ this.prevLanes = void 0;
570
+ this.lanesChangedFlag = false;
571
+ this.lanesSettling = false;
572
+ this.pendingScrollAnchor = null;
573
+ this.scrollRect = null;
574
+ this.scrollOffset = null;
575
+ this.scrollDirection = null;
576
+ this._holdOffset = 0;
577
+ this._reportedOverscroll = false;
578
+ this._iosGesture = new IosGesture({
579
+ getWindow: () => this.targetWindow,
580
+ now: () => this.now(),
581
+ // The end of a fling can move less than a pixel per scroll event, so
582
+ // events can stop for 150ms while the fling is still running (seen on
583
+ // an iPhone, 27.0.1). A command waiting for it would then be written
584
+ // into the fling and overridden. The element having moved since the
585
+ // last event means it has not ended: wait again. Not while our own
586
+ // write has yet to report: that moved it.
587
+ tailStillMoving: () => {
588
+ const state = this.scrollState;
589
+ if ((state == null ? void 0 : state.phase) !== "queued" || this.pendingWrite !== null) {
590
+ return false;
591
+ }
592
+ const now = this._readElementOffset();
593
+ if (now === null || this._lastElementOffset === null || Math.abs(now - this._lastElementOffset) < 1) {
594
+ return false;
595
+ }
596
+ this._lastElementOffset = now;
597
+ state.samples = [...state.samples ?? [], { t: this.now(), offset: now }];
598
+ return true;
599
+ },
600
+ onTailClosed: () => {
601
+ const state = this.scrollState;
602
+ if ((state == null ? void 0 : state.phase) === "queued" && flingCaught(state.samples ?? [])) {
603
+ this.scrollState = null;
604
+ }
605
+ this._flushHoldIfReady(true);
606
+ this._writeAwaitingCommand();
607
+ this._retryClampedAdjustment();
608
+ }
609
+ });
610
+ this._lastElementOffset = null;
611
+ this.pendingWrite = null;
612
+ this._clampedAdjustment = null;
613
+ this.elementsCache = /* @__PURE__ */ new Map();
614
+ this._resizeBatch = null;
615
+ this.now = () => {
616
+ var _a, _b, _c;
617
+ return ((_c = (_b = (_a = this.targetWindow) == null ? void 0 : _a.performance) == null ? void 0 : _b.now) == null ? void 0 : _c.call(_b)) ?? Date.now();
618
+ };
619
+ this.observer = /* @__PURE__ */ (() => {
620
+ let _ro = null;
621
+ let _frames = null;
622
+ let delivering = false;
623
+ let observeQueued = false;
624
+ const pendingObservations = /* @__PURE__ */ new Set();
625
+ const get = () => {
626
+ if (_ro) {
627
+ return _ro;
628
+ }
629
+ const targetWindow = this.targetWindow;
630
+ if (!targetWindow || !targetWindow.ResizeObserver) {
631
+ return null;
632
+ }
633
+ const frames = _frames = createFrameQueue(targetWindow);
634
+ return _ro = new targetWindow.ResizeObserver((entries) => {
635
+ const run = () => {
636
+ const batch = { sync: false };
637
+ this._resizeBatch = batch;
638
+ try {
639
+ entries.forEach(measureEntry);
640
+ } finally {
641
+ this._resizeBatch = null;
642
+ if (batch.notify) {
643
+ this.notify(batch.sync);
644
+ this._noteClampMax();
645
+ this._flushHoldIfReady(true);
646
+ this._retryClampedAdjustment();
647
+ this.measureElement(null);
648
+ }
649
+ }
650
+ };
651
+ if (this.options.useAnimationFrameWithResizeObserver) {
652
+ frames.schedule(run);
653
+ } else {
654
+ delivering = true;
655
+ try {
656
+ run();
657
+ } finally {
658
+ delivering = false;
659
+ }
660
+ }
661
+ });
662
+ };
663
+ const measureEntry = (entry) => {
664
+ const node = entry.target;
665
+ const index = this.indexFromElement(node);
666
+ if (!node.isConnected) {
667
+ this.observer.unobserve(node);
668
+ for (const [cacheKey, cachedNode] of this.elementsCache) {
669
+ if (cachedNode === node) {
670
+ this.elementsCache.delete(cacheKey);
671
+ break;
672
+ }
673
+ }
674
+ return;
675
+ }
676
+ if (!this.isIndexInRange(index)) return;
677
+ if (this.shouldMeasureDuringScroll(index)) {
678
+ this.resizeItem(index, this.options.measureElement(node, entry, this));
679
+ }
680
+ };
681
+ return {
682
+ disconnect: () => {
683
+ var _a;
684
+ (_a = get()) == null ? void 0 : _a.disconnect();
685
+ _frames == null ? void 0 : _frames.cancel();
686
+ pendingObservations.clear();
687
+ observeQueued = false;
688
+ _ro = null;
689
+ _frames = null;
690
+ },
691
+ observe: (target) => {
692
+ const observer = get();
693
+ if (!observer) return;
694
+ if (!delivering) {
695
+ observer.observe(target, { box: "border-box" });
696
+ return;
697
+ }
698
+ pendingObservations.add(target);
699
+ if (!observeQueued) {
700
+ observeQueued = true;
701
+ _frames == null ? void 0 : _frames.schedule(() => {
702
+ observeQueued = false;
703
+ pendingObservations.forEach((node) => {
704
+ if (node.isConnected) _ro == null ? void 0 : _ro.observe(node, { box: "border-box" });
705
+ });
706
+ pendingObservations.clear();
707
+ });
708
+ }
709
+ },
710
+ unobserve: (target) => {
711
+ var _a;
712
+ pendingObservations.delete(target);
713
+ (_a = get()) == null ? void 0 : _a.unobserve(target);
714
+ }
715
+ };
716
+ })();
717
+ this.range = null;
718
+ this.setOptions = (opts2) => {
719
+ var _a;
720
+ const merged = {
721
+ debug: false,
722
+ initialOffset: 0,
723
+ overscan: 1,
724
+ paddingStart: 0,
725
+ paddingEnd: 0,
726
+ scrollPaddingStart: 0,
727
+ scrollPaddingEnd: 0,
728
+ horizontal: false,
729
+ getItemKey: defaultKeyExtractor,
730
+ rangeExtractor: defaultRangeExtractor,
731
+ onChange: () => {
732
+ },
733
+ measureElement,
734
+ initialRect: { width: 0, height: 0 },
735
+ scrollMargin: 0,
736
+ gap: 0,
737
+ indexAttribute: "data-index",
738
+ initialMeasurementsCache: [],
739
+ lanes: 1,
740
+ anchorTo: "start",
741
+ followOnAppend: false,
742
+ scrollEndThreshold: 1,
743
+ isScrollingResetDelay: 150,
744
+ enabled: true,
745
+ isRtl: false,
746
+ useScrollendEvent: false,
747
+ useAnimationFrameWithResizeObserver: false,
748
+ laneAssignmentMode: "estimate",
749
+ useCachedMeasurements: false
750
+ };
751
+ for (const key in opts2) {
752
+ const v = opts2[key];
753
+ if (v !== void 0) merged[key] = v;
754
+ }
755
+ const prevOptions = this.options;
756
+ let anchor = null;
757
+ let followOnAppend = null;
758
+ let edgeKeysChanged = false;
759
+ if (prevOptions !== void 0 && prevOptions.enabled && merged.enabled && merged.anchorTo === "end" && this.scrollElement !== null) {
760
+ const prevCount = prevOptions.count;
761
+ const nextCount = merged.count;
762
+ const measurements = this.getMeasurements();
763
+ const previousItems = ((_a = this._singleLaneMeasurements) == null ? void 0 : _a.items) ?? measurements;
764
+ const getPreviousKey = (index) => getMeasurementKey(previousItems[index]);
765
+ const prevFirstKey = prevCount > 0 ? getPreviousKey(0) : null;
766
+ const prevLastKey = prevCount > 0 ? getPreviousKey(prevCount - 1) : null;
767
+ const didCountChange = nextCount !== prevCount;
768
+ const didEdgeKeysChange = didCountChange || prevCount > 0 && nextCount > 0 && (merged.getItemKey(0) !== prevFirstKey || merged.getItemKey(nextCount - 1) !== prevLastKey);
769
+ if (didEdgeKeysChange) {
770
+ edgeKeysChanged = true;
771
+ const item = prevCount > 0 ? this.getVirtualItemForOffset(this.getScrollOffset()) ?? measurements[0] : null;
772
+ if (item) {
773
+ anchor = [item.key, this.getScrollOffset() - item.start];
774
+ }
775
+ const behavior = merged.followOnAppend === true ? "auto" : merged.followOnAppend || null;
776
+ if (behavior && nextCount > 0 && this.isAtEnd(prevOptions.scrollEndThreshold) && (prevCount === 0 || merged.getItemKey(nextCount - 1) !== prevLastKey)) {
777
+ if (nextCount > prevCount || isAppendWithTrim(
778
+ prevCount,
779
+ nextCount,
780
+ getPreviousKey,
781
+ merged.getItemKey
782
+ )) {
783
+ followOnAppend = behavior;
784
+ }
785
+ }
786
+ }
787
+ }
788
+ this.options = merged;
789
+ if (edgeKeysChanged) {
790
+ this.pendingMin = 0;
791
+ this.itemSizeCacheVersion++;
792
+ }
793
+ let anchorDelta = null;
794
+ if (anchor && this.scrollOffset !== null && !this._awaitingCommandReadBack()) {
795
+ const [anchorKey, anchorOffset] = anchor;
796
+ const newMeasurements = this.getMeasurements();
797
+ const { count, getItemKey } = this.options;
798
+ let idx = 0;
799
+ while (idx < count && getItemKey(idx) !== anchorKey) {
800
+ idx++;
801
+ }
802
+ if (idx < count) {
803
+ const anchorItem = newMeasurements[idx];
804
+ if (anchorItem) {
805
+ const newOffset = Math.max(0, anchorItem.start + anchorOffset);
806
+ if (!followOnAppend && newOffset !== this.scrollOffset) {
807
+ anchorDelta = newOffset - this.scrollOffset;
808
+ this.scrollOffset = newOffset;
809
+ }
810
+ }
811
+ }
812
+ }
813
+ if (followOnAppend) {
814
+ this.pendingScrollAnchor = { kind: "follow", behavior: followOnAppend };
815
+ } else if (anchorDelta !== null) {
816
+ if (this._canWriteScroll()) {
817
+ this.pendingScrollAnchor = { kind: "anchor", delta: anchorDelta };
818
+ } else {
819
+ this._holdOffset += anchorDelta;
820
+ this._followOffsetTarget(anchorDelta);
821
+ }
822
+ }
823
+ };
824
+ this.notify = (sync) => {
825
+ var _a, _b;
826
+ (_b = (_a = this.options).onChange) == null ? void 0 : _b.call(_a, this, sync);
827
+ };
828
+ this.maybeNotify = memo(
829
+ () => {
830
+ this.calculateRange();
831
+ return [
832
+ this.isScrolling,
833
+ this.range ? this.range.startIndex : null,
834
+ this.range ? this.range.endIndex : null
835
+ ];
836
+ },
837
+ (isScrolling) => {
838
+ this.notify(isScrolling);
839
+ },
840
+ {
841
+ key: "production" !== "production",
842
+ debug: () => this.options.debug,
843
+ initialDeps: [
844
+ this.isScrolling,
845
+ this.range ? this.range.startIndex : null,
846
+ this.range ? this.range.endIndex : null
847
+ ]
848
+ }
849
+ );
850
+ this.cleanup = () => {
851
+ var _a;
852
+ this.unsubs.filter(Boolean).forEach((d) => d());
853
+ this.unsubs = [];
854
+ this.observer.disconnect();
855
+ if (this.rafId != null && this.targetWindow) {
856
+ this.targetWindow.cancelAnimationFrame(this.rafId);
857
+ this.rafId = null;
858
+ }
859
+ this.scrollState = null;
860
+ (_a = this._momentumStop) == null ? void 0 : _a.restore();
861
+ this._momentumStop = null;
862
+ this.isScrolling = false;
863
+ this.scrollDirection = null;
864
+ this._holdOffset = 0;
865
+ this._reportedOverscroll = false;
866
+ this._clampedAdjustment = null;
867
+ this.pendingWrite = null;
868
+ this.scrollElement = null;
869
+ this.targetWindow = null;
870
+ };
871
+ this._didMount = () => {
872
+ return () => {
873
+ this.cleanup();
874
+ };
875
+ };
876
+ this._willUpdate = () => {
877
+ var _a;
878
+ const scrollElement = this.options.enabled ? this.options.getScrollElement() : null;
879
+ if (this.scrollElement !== scrollElement) {
880
+ this.cleanup();
881
+ if (!scrollElement) {
882
+ this.maybeNotify();
883
+ return;
884
+ }
885
+ this.scrollElement = scrollElement;
886
+ if (this.scrollElement && "ownerDocument" in this.scrollElement) {
887
+ this.targetWindow = this.scrollElement.ownerDocument.defaultView;
888
+ } else {
889
+ this.targetWindow = ((_a = this.scrollElement) == null ? void 0 : _a.window) ?? null;
890
+ }
891
+ this.elementsCache.forEach((cached) => {
892
+ this.observer.observe(cached);
893
+ });
894
+ this.unsubs.push(
895
+ this.options.observeElementRect(this, (rect) => {
896
+ this.scrollRect = rect;
897
+ this.maybeNotify();
898
+ })
899
+ );
900
+ this.unsubs.push(
901
+ this.options.observeElementOffset(this, (offset, isScrolling) => {
902
+ var _a2, _b, _c, _d;
903
+ const elementMax = isScrolling ? this._elementMaxScrollOffset() : null;
904
+ const wasOverscrolled = this._reportedOverscroll;
905
+ this._reportedOverscroll = offset < 0 || elementMax !== null && offset > elementMax + 1;
906
+ const elementOffset = offset;
907
+ this._lastElementOffset = elementOffset;
908
+ offset = this._toLayoutOffset(offset);
909
+ const kind = this._classifyScrollEvent(
910
+ offset,
911
+ isScrolling,
912
+ elementMax
913
+ );
914
+ if (kind === "spurious") return;
915
+ if (kind === "readBack") {
916
+ offset = this.pendingWrite.target;
917
+ } else if (kind === "clampedReadBack" && ((_a2 = this.scrollState) == null ? void 0 : _a2.index) != null && // Not `elementMax`: an adapter can report the read-back at rest.
918
+ offset < this.getMaxScrollOffset() - 1.5) {
919
+ this.scrollState.lastTargetOffset = offset;
920
+ } else if (externalRetiresCommand({
921
+ kind,
922
+ offset,
923
+ command: this.scrollState,
924
+ target: () => this.getScrollStateTarget(this.scrollState)
925
+ })) {
926
+ this.scrollState = null;
927
+ }
928
+ this.pendingWrite = null;
929
+ if (this._clampedAdjustment !== null && Math.abs(offset - this._clampedAdjustment.maxAtWrite) >= 1.5) {
930
+ this._clampedAdjustment = null;
931
+ }
932
+ const prevOffset = this.getScrollOffset();
933
+ const prevDirection = this.scrollDirection;
934
+ this.scrollDirection = isScrolling ? prevOffset === offset ? this.scrollDirection : prevOffset < offset ? "forward" : "backward" : null;
935
+ this.scrollOffset = offset;
936
+ this.isScrolling = isScrolling;
937
+ const queued = this.scrollState;
938
+ if ((queued == null ? void 0 : queued.phase) === "queued" && kind === "external" && isScrolling) {
939
+ if (wasOverscrolled || this._reportedOverscroll) {
940
+ queued.samples = [];
941
+ } else {
942
+ const t = this.now();
943
+ queued.samples = [
944
+ ...(queued.samples ?? []).filter(
945
+ (sample) => t - sample.t <= 200
946
+ ),
947
+ { t, offset: elementOffset }
948
+ ];
949
+ if (prevDirection !== null && this.scrollDirection !== prevDirection || flingSpedUp(queued.samples)) {
950
+ this.scrollState = null;
951
+ }
952
+ }
953
+ }
954
+ if (this._iosGesture.onScroll({
955
+ isScrolling,
956
+ ownReadBack: kind === "readBack",
957
+ moved: offset !== prevOffset,
958
+ // Neither our write's read-back nor a frame of our smooth
959
+ // animation: the user or a fling moved it.
960
+ external: kind === "external" && ((_b = this.scrollState) == null ? void 0 : _b.phase) !== "smooth" && ((_c = this.scrollState) == null ? void 0 : _c.phase) !== "smoothFinishing"
961
+ }) && // The user scrolls: a command still waiting for the tail is
962
+ // theirs to override, like a written one would be.
963
+ ((_d = this.scrollState) == null ? void 0 : _d.phase) === "queued") {
964
+ this.scrollState = null;
965
+ }
966
+ this._flushHoldIfReady(true);
967
+ if (this.scrollState) {
968
+ this.scheduleScrollReconcile();
969
+ }
970
+ this.maybeNotify();
971
+ })
972
+ );
973
+ if ("addEventListener" in this.scrollElement) {
974
+ this.unsubs.push(
975
+ this._iosGesture.listen(this.scrollElement)
976
+ );
977
+ }
978
+ this._scrollToOffset(this.getScrollOffset());
979
+ }
980
+ this._noteClampMax();
981
+ const anchor = this.pendingScrollAnchor;
982
+ this.pendingScrollAnchor = null;
983
+ if (anchor && this.scrollElement && this.options.enabled) {
984
+ if (anchor.kind === "anchor") {
985
+ if (!this._canWriteScroll()) {
986
+ this._holdOffset += anchor.delta;
987
+ this._followOffsetTarget(anchor.delta);
988
+ this.notify(false);
989
+ } else if (isSmoothScroll(this.scrollState) && !approxEqual(
990
+ this.getScrollOffset() - anchor.delta,
991
+ this.scrollState.lastTargetOffset
992
+ )) ;
993
+ else {
994
+ this._followOffsetTarget(anchor.delta);
995
+ this._scrollToOffset(this.getScrollOffset());
996
+ }
997
+ } else {
998
+ this.scrollToEnd({ behavior: anchor.behavior });
999
+ }
1000
+ }
1001
+ this._flushHoldIfReady(false);
1002
+ this._retryClampedAdjustment();
1003
+ };
1004
+ this._classifyScrollEvent = (offset, isScrolling, elementMax) => {
1005
+ var _a;
1006
+ return classifyScrollEvent({
1007
+ offset,
1008
+ isScrolling,
1009
+ elementMax,
1010
+ holdOffset: this._holdOffset,
1011
+ scrollOffset: this.scrollOffset,
1012
+ pendingWrite: this.pendingWrite,
1013
+ clampedMaxAtWrite: ((_a = this._clampedAdjustment) == null ? void 0 : _a.maxAtWrite) ?? null
1014
+ });
1015
+ };
1016
+ this._retryClampedAdjustment = () => {
1017
+ if (this._clampedAdjustment === null || !this.scrollElement || !this.options.enabled || !this._canWriteScroll()) {
1018
+ return;
1019
+ }
1020
+ const { target, maxAtWrite } = this._clampedAdjustment;
1021
+ const max = this.getMaxScrollOffset();
1022
+ if (max > maxAtWrite + 0.5) {
1023
+ this._clampedAdjustment = target > max + 0.5 ? { target, maxAtWrite: max } : null;
1024
+ this._scrollToOffset(target);
1025
+ }
1026
+ };
1027
+ this._writeAwaitingCommand = () => {
1028
+ const state = this.scrollState;
1029
+ if (state === null || state.phase !== "queued") return;
1030
+ const { behavior } = state;
1031
+ this.getMeasurements();
1032
+ const offset = this.getScrollStateTarget(state);
1033
+ state.lastTargetOffset = offset;
1034
+ this._clampedAdjustment = null;
1035
+ state.phase = initialScrollPhase(
1036
+ behavior,
1037
+ state.index != null && approxEqual(offset, this.getScrollOffset())
1038
+ );
1039
+ this._scrollToOffset(offset, { behavior });
1040
+ this.scheduleScrollReconcile();
1041
+ };
1042
+ this._readElementOffset = () => {
1043
+ const el = this.scrollElement;
1044
+ if (el == null) return null;
1045
+ const { horizontal, isRtl } = this.options;
1046
+ if (typeof el.scrollTop === "number") {
1047
+ return horizontal ? el.scrollLeft * (isRtl && -1 || 1) : el.scrollTop;
1048
+ }
1049
+ if (typeof el.scrollY === "number") {
1050
+ return horizontal ? el.scrollX : el.scrollY;
1051
+ }
1052
+ return null;
1053
+ };
1054
+ this._canWriteScroll = () => !(isIOSWebKit() && this._iosGesture.inMotion()) && !this._reportedOverscroll;
1055
+ this._flushHoldIfReady = (sync) => {
1056
+ var _a;
1057
+ if (this._holdOffset === 0) return;
1058
+ if (!this.scrollElement || !this.options.enabled) return;
1059
+ if (!this._canWriteScroll()) return;
1060
+ if (((_a = this.scrollState) == null ? void 0 : _a.phase) === "smooth") return;
1061
+ this._holdOffset = 0;
1062
+ if (this.scrollOffset !== null && this.scrollOffset < 0) {
1063
+ this.scrollOffset = 0;
1064
+ }
1065
+ this.notify(sync);
1066
+ const target = this.getCommandWrittenOffset() ?? this.getScrollOffset();
1067
+ this._clampedAdjustment = this._clampedBy(target);
1068
+ this._scrollToOffset(target);
1069
+ };
1070
+ this.rafId = null;
1071
+ this.getSize = () => {
1072
+ if (!this.options.enabled) {
1073
+ this.scrollRect = null;
1074
+ return 0;
1075
+ }
1076
+ this.scrollRect = this.scrollRect ?? this.options.initialRect;
1077
+ return this.scrollRect[this.options.horizontal ? "width" : "height"];
1078
+ };
1079
+ this.getScrollOffset = () => {
1080
+ if (!this.options.enabled) {
1081
+ this.scrollOffset = null;
1082
+ return 0;
1083
+ }
1084
+ this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset === "function" ? this.options.initialOffset() : this.options.initialOffset);
1085
+ return this.scrollOffset;
1086
+ };
1087
+ this.getMeasurementOptions = memo(
1088
+ () => [
1089
+ this.options.count,
1090
+ this.options.paddingStart,
1091
+ this.options.scrollMargin,
1092
+ this.options.getItemKey,
1093
+ this.options.enabled,
1094
+ this.options.lanes,
1095
+ this.options.laneAssignmentMode,
1096
+ this.options.gap
1097
+ ],
1098
+ (count, paddingStart, scrollMargin, getItemKey, enabled, lanes, laneAssignmentMode, gap) => {
1099
+ const lanesChanged = this.prevLanes !== void 0 && this.prevLanes !== lanes;
1100
+ if (lanesChanged) {
1101
+ this.lanesChangedFlag = true;
1102
+ }
1103
+ this.prevLanes = lanes;
1104
+ this.pendingMin = null;
1105
+ return {
1106
+ count,
1107
+ paddingStart,
1108
+ scrollMargin,
1109
+ getItemKey,
1110
+ enabled,
1111
+ lanes,
1112
+ laneAssignmentMode,
1113
+ gap
1114
+ };
1115
+ },
1116
+ {
1117
+ key: false
1118
+ }
1119
+ );
1120
+ this.isIndexInRange = (index) => index >= 0 && index < this.options.count;
1121
+ this.getMeasurements = memo(
1122
+ () => [this.getMeasurementOptions(), this.itemSizeCacheVersion],
1123
+ ({
1124
+ count,
1125
+ paddingStart,
1126
+ scrollMargin,
1127
+ getItemKey,
1128
+ enabled,
1129
+ lanes,
1130
+ laneAssignmentMode,
1131
+ gap
1132
+ }, _itemSizeCacheVersion) => {
1133
+ var _a;
1134
+ const itemSizeCache = this.itemSizeCache;
1135
+ if (!enabled) {
1136
+ this.measurementsCache = [];
1137
+ this._singleLaneMeasurements = null;
1138
+ this.itemSizeCache.clear();
1139
+ this.laneAssignments.clear();
1140
+ return [];
1141
+ }
1142
+ if (this.laneAssignments.size > count) {
1143
+ for (const index of this.laneAssignments.keys()) {
1144
+ if (index >= count) {
1145
+ this.laneAssignments.delete(index);
1146
+ }
1147
+ }
1148
+ }
1149
+ if (this.lanesChangedFlag) {
1150
+ this.lanesChangedFlag = false;
1151
+ this.lanesSettling = true;
1152
+ this.measurementsCache = [];
1153
+ this._singleLaneMeasurements = null;
1154
+ this.itemSizeCache.clear();
1155
+ this.laneAssignments.clear();
1156
+ this.pendingMin = null;
1157
+ }
1158
+ if (this.measurementsCache.length === 0 && !this.lanesSettling) {
1159
+ this.measurementsCache = this.options.initialMeasurementsCache;
1160
+ this.measurementsCache.forEach((item) => {
1161
+ this.itemSizeCache.set(item.key, item.size);
1162
+ });
1163
+ }
1164
+ const min = this.lanesSettling ? 0 : this.pendingMin ?? 0;
1165
+ this.pendingMin = null;
1166
+ if (this.lanesSettling && this.measurementsCache.length === count) {
1167
+ this.lanesSettling = false;
1168
+ }
1169
+ if (lanes === 1) {
1170
+ const need = count * 2;
1171
+ let flat = (_a = this._singleLaneMeasurements) == null ? void 0 : _a.flat;
1172
+ if (!flat || flat.length < need) {
1173
+ const next = new Float64Array(need);
1174
+ if (flat && min > 0) next.set(flat.subarray(0, min * 2));
1175
+ flat = next;
1176
+ }
1177
+ const items = min === 0 ? new Array(count) : this._singleLaneMeasurements.items.slice();
1178
+ let runningStart;
1179
+ if (min === 0) {
1180
+ runningStart = paddingStart + scrollMargin;
1181
+ } else {
1182
+ const prevIdx = min - 1;
1183
+ runningStart = flat[prevIdx * 2] + flat[prevIdx * 2 + 1] + gap;
1184
+ }
1185
+ for (let i = min; i < count; i++) {
1186
+ const key = getItemKey(i);
1187
+ items[i] = key;
1188
+ const measuredSize = itemSizeCache.get(key);
1189
+ const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
1190
+ flat[i * 2] = runningStart;
1191
+ flat[i * 2 + 1] = size;
1192
+ runningStart += size + gap;
1193
+ }
1194
+ this._singleLaneMeasurements = { flat, items };
1195
+ const view = createLazyMeasurementsView(items, flat);
1196
+ this.measurementsCache = view;
1197
+ return view;
1198
+ }
1199
+ const measurements = this.measurementsCache.slice(0, min);
1200
+ const laneLastIndex = new Array(lanes).fill(
1201
+ void 0
1202
+ );
1203
+ const laneEnds = new Float64Array(lanes);
1204
+ let filledLanes = 0;
1205
+ for (let m = 0; m < min; m++) {
1206
+ const item = measurements[m];
1207
+ if (item) {
1208
+ if (laneLastIndex[item.lane] === void 0) filledLanes++;
1209
+ laneLastIndex[item.lane] = m;
1210
+ laneEnds[item.lane] = item.end;
1211
+ }
1212
+ }
1213
+ for (let i = min; i < count; i++) {
1214
+ const key = getItemKey(i);
1215
+ const cachedLane = this.laneAssignments.get(i);
1216
+ let lane;
1217
+ let start;
1218
+ const shouldCacheLane = laneAssignmentMode === "estimate" || itemSizeCache.has(key);
1219
+ if (cachedLane !== void 0 && this.options.lanes > 1) {
1220
+ lane = cachedLane;
1221
+ const prevIndex = laneLastIndex[lane];
1222
+ const prevInLane = prevIndex !== void 0 ? measurements[prevIndex] : void 0;
1223
+ start = prevInLane ? prevInLane.end + gap : paddingStart + scrollMargin;
1224
+ } else if (filledLanes === lanes) {
1225
+ let bestLane = 0;
1226
+ let bestEnd = laneEnds[0];
1227
+ let bestIdx = laneLastIndex[0];
1228
+ for (let l = 1; l < lanes; l++) {
1229
+ const e = laneEnds[l];
1230
+ if (e < bestEnd || e === bestEnd && laneLastIndex[l] < bestIdx) {
1231
+ bestLane = l;
1232
+ bestEnd = e;
1233
+ bestIdx = laneLastIndex[l];
1234
+ }
1235
+ }
1236
+ lane = bestLane;
1237
+ start = bestEnd + gap;
1238
+ if (shouldCacheLane) {
1239
+ this.laneAssignments.set(i, lane);
1240
+ }
1241
+ } else {
1242
+ lane = i % this.options.lanes;
1243
+ start = paddingStart + scrollMargin;
1244
+ if (shouldCacheLane) {
1245
+ this.laneAssignments.set(i, lane);
1246
+ }
1247
+ }
1248
+ const measuredSize = itemSizeCache.get(key);
1249
+ const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
1250
+ const end = start + size;
1251
+ measurements[i] = {
1252
+ index: i,
1253
+ start,
1254
+ size,
1255
+ end,
1256
+ key,
1257
+ lane
1258
+ };
1259
+ if (laneLastIndex[lane] === void 0) filledLanes++;
1260
+ laneLastIndex[lane] = i;
1261
+ laneEnds[lane] = end;
1262
+ }
1263
+ this.measurementsCache = measurements;
1264
+ return measurements;
1265
+ },
1266
+ {
1267
+ key: "production" !== "production",
1268
+ debug: () => this.options.debug
1269
+ }
1270
+ );
1271
+ this.calculateRange = memo(
1272
+ () => [
1273
+ this.getMeasurements(),
1274
+ this.getSize(),
1275
+ this.getScrollOffset(),
1276
+ this.options.lanes,
1277
+ // scrollOffset is measured in the scroll element and the layout total
1278
+ // from the list start, so the list ends scrollMargin further down.
1279
+ this._getLayoutTotalSize() + this.options.scrollMargin
1280
+ ],
1281
+ (measurements, outerSize, scrollOffset, lanes, listEnd) => {
1282
+ if (measurements.length === 0 || outerSize === 0) {
1283
+ this.range = null;
1284
+ return null;
1285
+ }
1286
+ const maxScrollOffset = Math.max(listEnd - outerSize, 0);
1287
+ this.range = calculateRangeImpl(
1288
+ measurements,
1289
+ outerSize,
1290
+ Math.min(scrollOffset, maxScrollOffset),
1291
+ lanes,
1292
+ // Pass the typed array so binary search + forward-walk can read
1293
+ // start/end directly from Float64Array, skipping the Proxy traps.
1294
+ lanes === 1 && this._singleLaneMeasurements !== null ? this._singleLaneMeasurements.flat : null
1295
+ );
1296
+ return this.range;
1297
+ },
1298
+ {
1299
+ key: "production" !== "production",
1300
+ debug: () => this.options.debug
1301
+ }
1302
+ );
1303
+ this.getVirtualIndexes = memo(
1304
+ () => {
1305
+ let startIndex = null;
1306
+ let endIndex = null;
1307
+ const range = this.calculateRange();
1308
+ if (range) {
1309
+ startIndex = range.startIndex;
1310
+ endIndex = range.endIndex;
1311
+ }
1312
+ this.maybeNotify.updateDeps([this.isScrolling, startIndex, endIndex]);
1313
+ return [
1314
+ this.options.rangeExtractor,
1315
+ this.options.overscan,
1316
+ this.options.count,
1317
+ startIndex,
1318
+ endIndex,
1319
+ this.options.lanes
1320
+ ];
1321
+ },
1322
+ (rangeExtractor, overscan, count, startIndex, endIndex, lanes) => {
1323
+ return startIndex === null || endIndex === null ? [] : rangeExtractor({
1324
+ startIndex,
1325
+ endIndex,
1326
+ overscan,
1327
+ count,
1328
+ lanes
1329
+ });
1330
+ },
1331
+ {
1332
+ key: "production" !== "production",
1333
+ debug: () => this.options.debug
1334
+ }
1335
+ );
1336
+ this.indexFromElement = (node) => {
1337
+ const attributeName = this.options.indexAttribute;
1338
+ const indexStr = node.getAttribute(attributeName);
1339
+ if (!indexStr) {
1340
+ console.warn(
1341
+ `Missing attribute name '${attributeName}={index}' on measured element.`
1342
+ );
1343
+ return -1;
1344
+ }
1345
+ return parseInt(indexStr, 10);
1346
+ };
1347
+ this.shouldMeasureDuringScroll = (index) => {
1348
+ var _a;
1349
+ if (!isSmoothScroll(this.scrollState)) {
1350
+ return true;
1351
+ }
1352
+ const scrollIndex = this.scrollState.index ?? ((_a = this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)) == null ? void 0 : _a.index);
1353
+ if (scrollIndex !== void 0 && this.range) {
1354
+ const bufferSize = Math.max(
1355
+ this.options.overscan,
1356
+ Math.ceil((this.range.endIndex - this.range.startIndex) / 2)
1357
+ );
1358
+ const minIndex = Math.max(0, scrollIndex - bufferSize);
1359
+ const maxIndex = Math.min(
1360
+ this.options.count - 1,
1361
+ scrollIndex + bufferSize
1362
+ );
1363
+ return index >= minIndex && index <= maxIndex;
1364
+ }
1365
+ return true;
1366
+ };
1367
+ this.measureElement = (node) => {
1368
+ if (!node) {
1369
+ this.elementsCache.forEach((cached, key2) => {
1370
+ if (!cached.isConnected) {
1371
+ this.observer.unobserve(cached);
1372
+ this.elementsCache.delete(key2);
1373
+ }
1374
+ });
1375
+ return;
1376
+ }
1377
+ const index = this.indexFromElement(node);
1378
+ if (!this.isIndexInRange(index)) return;
1379
+ const key = this.options.getItemKey(index);
1380
+ const prevNode = this.elementsCache.get(key);
1381
+ if (prevNode !== node) {
1382
+ if (prevNode) {
1383
+ this.observer.unobserve(prevNode);
1384
+ }
1385
+ this.observer.observe(node);
1386
+ this.elementsCache.set(key, node);
1387
+ }
1388
+ if (node.isConnected && (!this.isScrolling || this.scrollState) && this.shouldMeasureDuringScroll(index)) {
1389
+ this.resizeItem(index, this.options.measureElement(node, void 0, this));
1390
+ }
1391
+ };
1392
+ this.resizeItem = (index, size) => {
1393
+ var _a, _b, _c;
1394
+ if (!this.isIndexInRange(index)) return;
1395
+ if ((_a = this._resizeBatch) == null ? void 0 : _a.sync) this.getMeasurements();
1396
+ let cachedSize;
1397
+ let itemStart;
1398
+ let key;
1399
+ const flat = (_b = this._singleLaneMeasurements) == null ? void 0 : _b.flat;
1400
+ if (this.options.lanes === 1 && flat != null) {
1401
+ key = this.options.getItemKey(index);
1402
+ itemStart = flat[index * 2];
1403
+ cachedSize = flat[index * 2 + 1];
1404
+ } else {
1405
+ const item = this.measurementsCache[index];
1406
+ if (!item) return;
1407
+ key = item.key;
1408
+ itemStart = item.start;
1409
+ cachedSize = item.size;
1410
+ }
1411
+ const itemSize = this.itemSizeCache.get(key) ?? cachedSize;
1412
+ const delta = size - itemSize;
1413
+ if (delta !== 0) {
1414
+ const wasAtEnd = this.options.anchorTo === "end" && !isSmoothScroll(this.scrollState) && this.getVirtualDistanceFromEnd() <= this.options.scrollEndThreshold;
1415
+ const prevTotalSize = wasAtEnd ? this._getLayoutTotalSize() : 0;
1416
+ const scrollOffset = this.getScrollOffset();
1417
+ const isFirstMeasure = !this.itemSizeCache.has(key);
1418
+ const defaultShouldAdjust = isFirstMeasure ? (
1419
+ // First measurement: compensate any item whose top sits above the
1420
+ // fold — the estimate→actual delta must be corrected regardless of
1421
+ // scroll direction, since the whole estimated block was above it.
1422
+ itemStart < scrollOffset
1423
+ ) : (
1424
+ // Re-measurement: only compensate an item that is ENTIRELY above the
1425
+ // fold. An item that merely *spans* the fold (top above, bottom
1426
+ // below — e.g. a streaming chat message growing at its bottom)
1427
+ // changes size *below* the anchor point, so shifting scrollTop by the
1428
+ // delta would drag the viewport downward on every growth (#1218).
1429
+ // Also skip during backward scroll to avoid the "items jump while
1430
+ // scrolling up" cascade.
1431
+ itemStart + itemSize <= scrollOffset && this.scrollDirection !== "backward"
1432
+ );
1433
+ const shouldAdjustScroll = !isSmoothScroll(this.scrollState) && (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(
1434
+ // The callback expects a VirtualItem; build one lazily only
1435
+ // when the consumer actually supplied a custom predicate.
1436
+ this.measurementsCache[index] ?? {
1437
+ index,
1438
+ key,
1439
+ start: itemStart,
1440
+ size: cachedSize,
1441
+ end: itemStart + cachedSize,
1442
+ lane: 0
1443
+ },
1444
+ delta,
1445
+ this
1446
+ ) : defaultShouldAdjust);
1447
+ if (this.pendingMin === null || index < this.pendingMin) {
1448
+ this.pendingMin = index;
1449
+ }
1450
+ this.itemSizeCache.set(key, size);
1451
+ this.itemSizeCacheVersion++;
1452
+ let adjustedSync = false;
1453
+ if (!this._awaitingCommandReadBack()) {
1454
+ if (wasAtEnd) {
1455
+ adjustedSync = this.applyScrollAdjustment(
1456
+ this._getLayoutTotalSize() - prevTotalSize
1457
+ );
1458
+ } else if (shouldAdjustScroll) {
1459
+ adjustedSync = this.applyScrollAdjustment(delta);
1460
+ }
1461
+ }
1462
+ if (this._resizeBatch) {
1463
+ this._resizeBatch.notify = true;
1464
+ (_c = this._resizeBatch).sync || (_c.sync = adjustedSync);
1465
+ return;
1466
+ }
1467
+ this.notify(adjustedSync);
1468
+ this._noteClampMax();
1469
+ this._flushHoldIfReady(true);
1470
+ this._retryClampedAdjustment();
1471
+ }
1472
+ };
1473
+ this.getVirtualItems = memo(
1474
+ () => [this.getVirtualIndexes(), this.getMeasurements(), this._holdOffset],
1475
+ (indexes, measurements, hold) => {
1476
+ const virtualItems = [];
1477
+ for (let k = 0, len = indexes.length; k < len; k++) {
1478
+ const i = indexes[k];
1479
+ const measurement = measurements[i];
1480
+ virtualItems.push(
1481
+ hold === 0 ? measurement : {
1482
+ ...measurement,
1483
+ start: measurement.start - hold,
1484
+ end: measurement.end - hold
1485
+ }
1486
+ );
1487
+ }
1488
+ return virtualItems;
1489
+ },
1490
+ {
1491
+ key: "production" !== "production",
1492
+ debug: () => this.options.debug
1493
+ }
1494
+ );
1495
+ this.getVirtualItemForOffset = (offset) => {
1496
+ var _a;
1497
+ const measurements = this.getMeasurements();
1498
+ if (measurements.length === 0) {
1499
+ return void 0;
1500
+ }
1501
+ const flat = (_a = this._singleLaneMeasurements) == null ? void 0 : _a.flat;
1502
+ const useFlat = this.options.lanes === 1 && flat != null;
1503
+ const idx = findNearestBinarySearch(
1504
+ 0,
1505
+ measurements.length - 1,
1506
+ useFlat ? (i) => flat[i * 2] : (i) => notUndefined(measurements[i]).start,
1507
+ offset
1508
+ );
1509
+ return notUndefined(measurements[idx]);
1510
+ };
1511
+ this._noteClampMax = () => {
1512
+ if (!this._awaitingCommandReadBack()) return;
1513
+ const elementMax = this._elementMaxScrollOffset();
1514
+ if (elementMax === null) return;
1515
+ const write = this.pendingWrite;
1516
+ const max = Math.max(elementMax, 0) + this._holdOffset;
1517
+ if (max >= write.target) return;
1518
+ const lowMaxes = write.lowMaxes ?? (write.lowMaxes = []);
1519
+ if (lowMaxes[lowMaxes.length - 1] !== max) lowMaxes.push(max);
1520
+ };
1521
+ this.getMaxScrollOffset = () => (this._elementMaxScrollOffset() ?? 0) + this._holdOffset;
1522
+ this._toLayoutOffset = (elementOffset) => {
1523
+ var _a;
1524
+ let offset = elementOffset + this._holdOffset;
1525
+ if (((_a = this.pendingScrollAnchor) == null ? void 0 : _a.kind) === "anchor") {
1526
+ offset += this.pendingScrollAnchor.delta;
1527
+ }
1528
+ return offset;
1529
+ };
1530
+ this._elementMaxScrollOffset = () => {
1531
+ const el = this.scrollElement;
1532
+ if (el === null) return null;
1533
+ if ("scrollHeight" in el) {
1534
+ return this.options.horizontal ? el.scrollWidth - el.clientWidth : el.scrollHeight - el.clientHeight;
1535
+ }
1536
+ if ("document" in el) {
1537
+ const doc = el.document.documentElement;
1538
+ return this.options.horizontal ? doc.scrollWidth - el.innerWidth : doc.scrollHeight - el.innerHeight;
1539
+ }
1540
+ return null;
1541
+ };
1542
+ this._momentumStop = null;
1543
+ this._stopMomentum = (done) => {
1544
+ const el = this.scrollElement;
1545
+ const win = this.targetWindow;
1546
+ if (el === null || win === null) return;
1547
+ const scroller = "document" in el ? el.document.scrollingElement : el;
1548
+ if (!(scroller == null ? void 0 : scroller.style)) return;
1549
+ if (this._momentumStop) {
1550
+ this._momentumStop.done = done;
1551
+ return;
1552
+ }
1553
+ const { style } = scroller;
1554
+ const property = this.options.horizontal ? "overflow-x" : "overflow-y";
1555
+ const value = style.getPropertyValue(property);
1556
+ const priority = style.getPropertyPriority(property);
1557
+ const crossSize = () => this.options.horizontal ? scroller.clientHeight : scroller.clientWidth;
1558
+ const crossSizeBefore = crossSize();
1559
+ style.setProperty(property, "hidden", "important");
1560
+ if (crossSize() !== crossSizeBefore) {
1561
+ style.setProperty(property, value, priority);
1562
+ return;
1563
+ }
1564
+ const stop = {
1565
+ // False when the app replaced the hidden value: the fling may not
1566
+ // have stopped.
1567
+ restore: () => {
1568
+ if (style.getPropertyValue(property) !== "hidden" || style.getPropertyPriority(property) !== "important") {
1569
+ return false;
1570
+ }
1571
+ style.setProperty(property, value, priority);
1572
+ return true;
1573
+ },
1574
+ done
1575
+ };
1576
+ this._momentumStop = stop;
1577
+ win.requestAnimationFrame(
1578
+ () => win.requestAnimationFrame(() => {
1579
+ if (this._momentumStop !== stop) return;
1580
+ this._momentumStop = null;
1581
+ if (stop.restore()) stop.done();
1582
+ })
1583
+ );
1584
+ };
1585
+ this._clampedBy = (target) => {
1586
+ const elementMax = this._elementMaxScrollOffset();
1587
+ if (elementMax === null) return null;
1588
+ const maxAtWrite = elementMax + this._holdOffset;
1589
+ return target > maxAtWrite + 0.5 ? { target, maxAtWrite } : null;
1590
+ };
1591
+ this.getVirtualDistanceFromEnd = () => {
1592
+ return Math.max(
1593
+ this._getLayoutTotalSize() + this.options.scrollMargin - this.getSize() - this.getScrollOffset(),
1594
+ 0
1595
+ );
1596
+ };
1597
+ this.getDistanceFromEnd = () => {
1598
+ return Math.max(this.getMaxScrollOffset() - this.getScrollOffset(), 0);
1599
+ };
1600
+ this.isAtEnd = (threshold = this.options.scrollEndThreshold) => {
1601
+ return this.getDistanceFromEnd() <= threshold;
1602
+ };
1603
+ this.getOffsetForAlignment = (toOffset, align, itemSize = 0) => {
1604
+ if (!this.scrollElement) return 0;
1605
+ const size = this.getSize();
1606
+ const scrollOffset = this.getScrollOffset();
1607
+ if (align === "auto") {
1608
+ align = toOffset >= scrollOffset + size ? "end" : "start";
1609
+ }
1610
+ if (align === "center") {
1611
+ toOffset += (itemSize - size) / 2;
1612
+ } else if (align === "end") {
1613
+ toOffset -= size;
1614
+ }
1615
+ const maxOffset = this.getMaxScrollOffset();
1616
+ return Math.max(Math.min(maxOffset, toOffset), 0);
1617
+ };
1618
+ this.getOffsetForIndex = (index, align = "auto") => {
1619
+ index = Math.max(0, Math.min(index, this.options.count - 1));
1620
+ const size = this.getSize();
1621
+ const scrollOffset = this.getScrollOffset();
1622
+ const item = this.measurementsCache[index];
1623
+ if (!item) return;
1624
+ if (align === "auto") {
1625
+ if (item.end >= scrollOffset + size - this.options.scrollPaddingEnd) {
1626
+ align = "end";
1627
+ } else if (item.start <= scrollOffset + this.options.scrollPaddingStart) {
1628
+ align = "start";
1629
+ } else {
1630
+ return [scrollOffset, align];
1631
+ }
1632
+ }
1633
+ if (align === "end" && index === this.options.count - 1) {
1634
+ const maxOffset = this.getMaxScrollOffset();
1635
+ const toOffset2 = maxOffset - this.options.paddingEnd + this.options.scrollPaddingEnd;
1636
+ return [Math.max(Math.min(toOffset2, maxOffset), 0), align];
1637
+ }
1638
+ const toOffset = align === "end" ? item.end + this.options.scrollPaddingEnd : item.start - this.options.scrollPaddingStart;
1639
+ return [
1640
+ this.getOffsetForAlignment(toOffset, align, item.size),
1641
+ align
1642
+ ];
1643
+ };
1644
+ this.scrollToOffset = (toOffset, { align = "start", behavior = "auto" } = {}) => {
1645
+ this._startScroll(
1646
+ { index: null, align },
1647
+ this.getOffsetForAlignment(toOffset, align),
1648
+ behavior,
1649
+ "absolute"
1650
+ );
1651
+ };
1652
+ this.scrollToIndex = (index, {
1653
+ align: initialAlign = "auto",
1654
+ behavior = "auto"
1655
+ } = {}) => {
1656
+ index = Math.max(0, Math.min(index, this.options.count - 1));
1657
+ const offsetInfo = this.getOffsetForIndex(index, initialAlign);
1658
+ if (!offsetInfo) return;
1659
+ const [offset, align] = offsetInfo;
1660
+ this._startScroll({ index, align }, offset, behavior, "absolute");
1661
+ };
1662
+ this.scrollBy = (delta, { behavior = "auto" } = {}) => {
1663
+ const offset = this.getOffsetForAlignment(
1664
+ (this.getCommandWrittenOffset() ?? this.getScrollOffset()) + delta,
1665
+ "start"
1666
+ );
1667
+ this._startScroll(
1668
+ { index: null, align: "start" },
1669
+ offset,
1670
+ behavior,
1671
+ "relative"
1672
+ );
1673
+ };
1674
+ this.scrollToEnd = ({ behavior = "auto" } = {}) => {
1675
+ if (this.options.count > 0) {
1676
+ this._startScroll(
1677
+ { index: this.options.count - 1, align: "end", toEnd: true },
1678
+ Math.max(this.getMaxScrollOffset(), 0),
1679
+ behavior,
1680
+ "absolute"
1681
+ );
1682
+ return;
1683
+ }
1684
+ this.scrollToOffset(Math.max(this.getTotalSize() - this.getSize(), 0), {
1685
+ behavior
1686
+ });
1687
+ };
1688
+ this.cancelScroll = () => {
1689
+ if (this.rafId != null && this.targetWindow) {
1690
+ this.targetWindow.cancelAnimationFrame(this.rafId);
1691
+ this.rafId = null;
1692
+ }
1693
+ this.scrollState = null;
1694
+ };
1695
+ this.getTotalSize = () => Math.max(this._getLayoutTotalSize() - this._holdOffset, 0);
1696
+ this._getLayoutTotalSize = () => {
1697
+ var _a, _b;
1698
+ const measurements = this.getMeasurements();
1699
+ let end;
1700
+ if (measurements.length === 0) {
1701
+ end = this.options.paddingStart;
1702
+ } else if (this.options.lanes === 1) {
1703
+ const lastIdx = measurements.length - 1;
1704
+ const flat = (_a = this._singleLaneMeasurements) == null ? void 0 : _a.flat;
1705
+ if (flat != null) {
1706
+ end = flat[lastIdx * 2] + flat[lastIdx * 2 + 1];
1707
+ } else {
1708
+ end = ((_b = measurements[lastIdx]) == null ? void 0 : _b.end) ?? 0;
1709
+ }
1710
+ } else {
1711
+ const endByLane = Array(this.options.lanes).fill(null);
1712
+ let endIndex = measurements.length - 1;
1713
+ while (endIndex >= 0 && endByLane.some((val) => val === null)) {
1714
+ const item = measurements[endIndex];
1715
+ if (endByLane[item.lane] === null) {
1716
+ endByLane[item.lane] = item.end;
1717
+ }
1718
+ endIndex--;
1719
+ }
1720
+ end = Math.max(...endByLane.filter((val) => val !== null));
1721
+ }
1722
+ return Math.max(
1723
+ end - this.options.scrollMargin + this.options.paddingEnd,
1724
+ 0
1725
+ );
1726
+ };
1727
+ this.takeSnapshot = () => {
1728
+ const snapshot = [];
1729
+ if (this.itemSizeCache.size === 0) return snapshot;
1730
+ const m = this.getMeasurements();
1731
+ for (const item of m) {
1732
+ if (item && this.itemSizeCache.has(item.key)) {
1733
+ snapshot.push({
1734
+ index: item.index,
1735
+ key: item.key,
1736
+ start: item.start,
1737
+ size: item.size,
1738
+ end: item.end,
1739
+ lane: item.lane
1740
+ });
1741
+ }
1742
+ }
1743
+ return snapshot;
1744
+ };
1745
+ this._scrollToOffset = (offset, {
1746
+ adjustments,
1747
+ behavior
1748
+ } = {}) => {
1749
+ const write = {
1750
+ target: offset + (adjustments ?? 0),
1751
+ smooth: behavior === "smooth"
1752
+ };
1753
+ this.pendingWrite = write;
1754
+ this.options.scrollToFn(
1755
+ offset - this._holdOffset,
1756
+ { behavior, adjustments },
1757
+ this
1758
+ );
1759
+ return write;
1760
+ };
1761
+ this.getCommandWrittenOffset = () => this.scrollState !== null && this.pendingWrite !== null && !this.pendingWrite.smooth ? this.pendingWrite.target : null;
1762
+ this._awaitingCommandReadBack = () => {
1763
+ const writtenOffset = this.getCommandWrittenOffset();
1764
+ return !(isIOSWebKit() && this._iosGesture.dragging()) && writtenOffset !== null && !approxEqual(writtenOffset, this.getScrollOffset());
1765
+ };
1766
+ this._followOffsetTarget = (delta) => {
1767
+ if (this.scrollState !== null && this.scrollState.index == null) {
1768
+ this.scrollState.lastTargetOffset += delta;
1769
+ }
1770
+ };
1771
+ this.measure = () => {
1772
+ this.pendingMin = null;
1773
+ this.itemSizeCache.clear();
1774
+ this.laneAssignments.clear();
1775
+ this.itemSizeCacheVersion++;
1776
+ this.notify(false);
1777
+ };
1778
+ this.setOptions(opts);
1779
+ }
1780
+ /**
1781
+ * @deprecated Always 0: a scroll correction is folded into `scrollOffset`
1782
+ * at once, so there is never an outstanding adjustment to add to it. Read
1783
+ * `scrollOffset` alone.
1784
+ */
1785
+ get scrollAdjustments() {
1786
+ return 0;
1787
+ }
1788
+ // Returns `true` when it performed a synchronous `scrollTop` write this
1789
+ // tick, `false` when the delta was zero or the write was deferred (iOS).
1790
+ // `resizeItem` uses that to decide whether the follow-up `notify` must be
1791
+ // synchronous so the grown transforms commit in the same paint (#1227).
1792
+ applyScrollAdjustment(delta, behavior) {
1793
+ if (delta === 0) return false;
1794
+ this._followOffsetTarget(delta);
1795
+ if (!this._canWriteScroll()) {
1796
+ this._holdOffset += delta;
1797
+ if (this.scrollOffset !== null) this.scrollOffset += delta;
1798
+ return true;
1799
+ } else {
1800
+ const offset = this.getScrollOffset();
1801
+ this._clampedAdjustment = this._clampedBy(offset + delta);
1802
+ const write = this._scrollToOffset(offset, {
1803
+ adjustments: delta,
1804
+ behavior
1805
+ });
1806
+ if (this.scrollOffset !== null) {
1807
+ if (this.pendingWrite === write) this.scrollOffset += delta;
1808
+ if (this.scrollOffset < 0) this.scrollOffset = 0;
1809
+ }
1810
+ return true;
1811
+ }
1812
+ }
1813
+ scheduleScrollReconcile() {
1814
+ if (!this.targetWindow) {
1815
+ this.scrollState = null;
1816
+ return;
1817
+ }
1818
+ if (this.rafId != null) return;
1819
+ this.rafId = this.targetWindow.requestAnimationFrame(() => {
1820
+ this.rafId = null;
1821
+ this.reconcileScroll();
1822
+ });
1823
+ }
1824
+ getScrollStateTarget(state) {
1825
+ const offsetInfo = state.toEnd ? [Math.max(this.getMaxScrollOffset(), 0)] : state.index != null ? this.getOffsetForIndex(state.index, state.align) : void 0;
1826
+ return offsetInfo ? offsetInfo[0] : state.lastTargetOffset;
1827
+ }
1828
+ reconcileScroll() {
1829
+ if (!this.scrollState) return;
1830
+ const el = this.scrollElement;
1831
+ if (!el) return;
1832
+ const MAX_RECONCILE_MS = 5e3;
1833
+ if (this.now() - this.scrollState.startedAt > MAX_RECONCILE_MS) {
1834
+ this.scrollState = null;
1835
+ return;
1836
+ }
1837
+ if (this.scrollState.phase === "queued") {
1838
+ this.scheduleScrollReconcile();
1839
+ return;
1840
+ }
1841
+ this.getMeasurements();
1842
+ const targetOffset = this.getScrollStateTarget(this.scrollState);
1843
+ const STABLE_FRAMES = this.scrollState.index == null ? 1 : this.options.useAnimationFrameWithResizeObserver ? 3 : 2;
1844
+ const targetChanged = targetOffset !== this.scrollState.lastTargetOffset;
1845
+ if (!targetChanged && approxEqual(targetOffset, this.getScrollOffset())) {
1846
+ if (this.scrollState.phase === "smooth") {
1847
+ this.scrollState.phase = "smoothLanded";
1848
+ } else if (this.scrollState.phase === "smoothFinishing") {
1849
+ this.scrollState.phase = "instant";
1850
+ }
1851
+ this.scrollState.stableFrames++;
1852
+ if (this.scrollState.stableFrames >= STABLE_FRAMES) {
1853
+ if (this.getScrollOffset() !== targetOffset) {
1854
+ this._scrollToOffset(targetOffset, { behavior: "auto" });
1855
+ }
1856
+ this.scrollState = null;
1857
+ return;
1858
+ }
1859
+ } else {
1860
+ this.scrollState.stableFrames = 0;
1861
+ if (targetChanged) {
1862
+ const viewport = this.getSize() || 600;
1863
+ const distance = Math.abs(targetOffset - this.getScrollOffset());
1864
+ const keepSmooth = isSmoothScroll(this.scrollState) && distance > viewport;
1865
+ this.scrollState.lastTargetOffset = targetOffset;
1866
+ if (keepSmooth) {
1867
+ this.scrollState.phase = "smooth";
1868
+ } else if (this.scrollState.phase === "smooth") {
1869
+ this.scrollState.phase = "smoothFinishing";
1870
+ } else if (this.scrollState.phase === "smoothLanded") {
1871
+ this.scrollState.phase = "instant";
1872
+ }
1873
+ this._scrollToOffset(targetOffset, {
1874
+ behavior: keepSmooth ? "smooth" : "auto"
1875
+ });
1876
+ }
1877
+ }
1878
+ this.scheduleScrollReconcile();
1879
+ }
1880
+ // Every scroll command starts here: it becomes the in-flight command,
1881
+ // writes its first target and leaves reconcile to retarget and retire it.
1882
+ //
1883
+ // Targets are layout offsets. A held correction is not dropped by a
1884
+ // command: the write lands the element `_holdOffset` short of the target,
1885
+ // under the rows exposed shifted by the same amount, and the flush moves
1886
+ // both together once a write is possible.
1887
+ //
1888
+ // An index or end target that is already at its offset starts a smooth
1889
+ // scroll as landed; an offset target never does, so its first scroll
1890
+ // event is read as the user's (see the scroll handler in `_willUpdate`).
1891
+ _startScroll(target, offset, behavior, kind) {
1892
+ this.pendingScrollAnchor = null;
1893
+ this._clampedAdjustment = null;
1894
+ const tail = this._iosGesture.tail();
1895
+ if (kind === "absolute" && tail !== null) {
1896
+ if (tail === "fling" && momentumOverridesWrites()) {
1897
+ this._stopMomentum(() => {
1898
+ const state = this.scrollState;
1899
+ if ((state == null ? void 0 : state.phase) !== "queued" || // A finger came down: it owns the scroll until it lifts.
1900
+ this._iosGesture.tail() !== "fling" || // In a bounce WebKit can drop the write (#1287): the tail
1901
+ // decides, as without the stop. (Not `flingCaught`: our stop
1902
+ // also ends the fling at speed, so a slow frame would read as
1903
+ // a catch and the tail would drop the command.)
1904
+ this._reportedOverscroll) {
1905
+ return;
1906
+ }
1907
+ this._iosGesture.end();
1908
+ this._flushHoldIfReady(true);
1909
+ this._writeAwaitingCommand();
1910
+ });
1911
+ this.scrollState = {
1912
+ ...target,
1913
+ startedAt: this.now(),
1914
+ lastTargetOffset: offset,
1915
+ stableFrames: 0,
1916
+ phase: "queued",
1917
+ behavior,
1918
+ samples: []
1919
+ };
1920
+ this.scheduleScrollReconcile();
1921
+ return;
1922
+ }
1923
+ this._iosGesture.end();
1924
+ }
1925
+ this.scrollState = {
1926
+ ...target,
1927
+ startedAt: this.now(),
1928
+ lastTargetOffset: offset,
1929
+ stableFrames: 0,
1930
+ behavior,
1931
+ phase: initialScrollPhase(
1932
+ behavior,
1933
+ target.index != null && approxEqual(offset, this.getScrollOffset())
1934
+ )
1935
+ };
1936
+ this._scrollToOffset(offset, { behavior });
1937
+ this.scheduleScrollReconcile();
1938
+ }
1939
+ }
1940
+ const findNearestBinarySearch = (low, high, getCurrentValue, value) => {
1941
+ while (low <= high) {
1942
+ const middle = (low + high) / 2 | 0;
1943
+ const currentValue = getCurrentValue(middle);
1944
+ if (currentValue < value) {
1945
+ low = middle + 1;
1946
+ } else if (currentValue > value) {
1947
+ high = middle - 1;
1948
+ } else {
1949
+ return middle;
1950
+ }
1951
+ }
1952
+ if (low > 0) {
1953
+ return low - 1;
1954
+ } else {
1955
+ return 0;
1956
+ }
1957
+ };
1958
+ function findNearestBinarySearchFlat(flat, high, value) {
1959
+ let low = 0;
1960
+ while (low <= high) {
1961
+ const middle = (low + high) / 2 | 0;
1962
+ const currentValue = flat[middle * 2];
1963
+ if (currentValue < value) {
1964
+ low = middle + 1;
1965
+ } else if (currentValue > value) {
1966
+ high = middle - 1;
1967
+ } else {
1968
+ return middle;
1969
+ }
1970
+ }
1971
+ return low > 0 ? low - 1 : 0;
1972
+ }
1973
+ function calculateRangeImpl(measurements, outerSize, scrollOffset, lanes, flat) {
1974
+ const lastIndex = measurements.length - 1;
1975
+ if (measurements.length <= lanes) {
1976
+ return { startIndex: 0, endIndex: lastIndex };
1977
+ }
1978
+ if (lanes === 1 && flat !== null) {
1979
+ const startIndex2 = findNearestBinarySearchFlat(
1980
+ flat,
1981
+ lastIndex,
1982
+ scrollOffset
1983
+ );
1984
+ let endIndex2 = startIndex2;
1985
+ const limit = scrollOffset + outerSize;
1986
+ while (endIndex2 < lastIndex && flat[endIndex2 * 2] + flat[endIndex2 * 2 + 1] < limit) {
1987
+ endIndex2++;
1988
+ }
1989
+ return { startIndex: startIndex2, endIndex: endIndex2 };
1990
+ }
1991
+ const getStart = (index) => measurements[index].start;
1992
+ let startIndex = findNearestBinarySearch(0, lastIndex, getStart, scrollOffset);
1993
+ let endIndex = startIndex;
1994
+ if (lanes === 1) {
1995
+ while (endIndex < lastIndex && measurements[endIndex].end < scrollOffset + outerSize) {
1996
+ endIndex++;
1997
+ }
1998
+ } else if (lanes > 1) {
1999
+ const endPerLane = Array(lanes).fill(0);
2000
+ while (endIndex < lastIndex && endPerLane.some((pos) => pos < scrollOffset + outerSize)) {
2001
+ const item = measurements[endIndex];
2002
+ endPerLane[item.lane] = item.end;
2003
+ endIndex++;
2004
+ }
2005
+ const startPerLane = Array(lanes).fill(scrollOffset + outerSize);
2006
+ while (startIndex >= 0 && startPerLane.some((pos) => pos >= scrollOffset)) {
2007
+ const item = measurements[startIndex];
2008
+ startPerLane[item.lane] = item.start;
2009
+ startIndex--;
2010
+ }
2011
+ startIndex = Math.max(0, startIndex - startIndex % lanes);
2012
+ endIndex = Math.min(lastIndex, endIndex + (lanes - 1 - endIndex % lanes));
2013
+ }
2014
+ return { startIndex, endIndex };
2015
+ }
2016
+
2017
+ /**
2018
+ * Decides which rows of a swirl-table to draw and positions them. The consumer
2019
+ * renders the rows, identified by `data-index`. Padding on the table body
2020
+ * stands in for the rows not drawn. A row's margin-top fills the gap before a
2021
+ * kept row far from the visible ones.
2022
+ */
2023
+ class SwirlTableVirtualizer {
2024
+ constructor(bodyEl, scrollElement, config, onIndexesChange) {
2025
+ this.bodyEl = bodyEl;
2026
+ this.scrollElement = scrollElement;
2027
+ this.config = config;
2028
+ this.onIndexesChange = onIndexesChange;
2029
+ // Index each row was last measured for. Rows can be reused for other indexes.
2030
+ this.measuredIndexes = new WeakMap();
2031
+ this.observedRows = new Set();
2032
+ /**
2033
+ * Own observer, because the virtualizer's `measureElement` caches elements
2034
+ * by index and stops observing reused ones.
2035
+ */
2036
+ this.resizeObserver = new ResizeObserver((entries) => this.resizeRows(entries.map(({ borderBoxSize, target }) => ({
2037
+ row: target,
2038
+ height: borderBoxSize[0].blockSize,
2039
+ }))));
2040
+ this.indexes = [];
2041
+ this.isResizingRows = false;
2042
+ this.hasChangeWhileResizing = false;
2043
+ this.bodyEl.style.overflowAnchor = "none";
2044
+ this.scrollMargin = this.measureScrollMargin();
2045
+ this.virtualizer = new Virtualizer(this.options());
2046
+ this.unmount = this.virtualizer._didMount();
2047
+ this.virtualizer._willUpdate();
2048
+ this.update();
2049
+ }
2050
+ setConfig(config) {
2051
+ this.config = config;
2052
+ this.applyOptions();
2053
+ }
2054
+ /**
2055
+ * Call after rows were added, removed or re-indexed. Measures new rows and
2056
+ * positions all rows.
2057
+ */
2058
+ sync() {
2059
+ this.updateScrollMargin();
2060
+ this.observedRows.forEach((row) => {
2061
+ if (!row.isConnected) {
2062
+ this.resizeObserver.unobserve(row);
2063
+ this.observedRows.delete(row);
2064
+ }
2065
+ });
2066
+ const rows = this.getRenderedRows();
2067
+ rows.forEach((row) => {
2068
+ if (!this.observedRows.has(row)) {
2069
+ this.observedRows.add(row);
2070
+ this.resizeObserver.observe(row);
2071
+ }
2072
+ });
2073
+ // Read all heights before resizeRows() writes styles, so the browser lays
2074
+ // out the table once instead of once per row.
2075
+ this.resizeRows(rows
2076
+ .filter((row) => this.measuredIndexes.get(row) !== getRowIndex(row))
2077
+ .map((row) => ({ row, height: row.getBoundingClientRect().height })));
2078
+ this.layout();
2079
+ }
2080
+ destroy() {
2081
+ this.unmount();
2082
+ this.resizeObserver.disconnect();
2083
+ this.observedRows.clear();
2084
+ this.bodyEl.style.overflowAnchor = "";
2085
+ this.bodyEl.style.paddingTop = "";
2086
+ this.bodyEl.style.paddingBottom = "";
2087
+ this.getRenderedRows().forEach((row) => (row.style.marginTop = ""));
2088
+ }
2089
+ applyOptions() {
2090
+ this.virtualizer.setOptions(this.options());
2091
+ this.virtualizer._willUpdate();
2092
+ this.update();
2093
+ }
2094
+ update() {
2095
+ // applyOptions() calls update() again with the new margin.
2096
+ if (this.updateScrollMargin()) {
2097
+ return;
2098
+ }
2099
+ const indexes = this.virtualizer
2100
+ .getVirtualItems()
2101
+ .map(({ index }) => index);
2102
+ if (!equalIndexes(indexes, this.indexes)) {
2103
+ this.indexes = indexes;
2104
+ this.onIndexesChange(indexes);
2105
+ }
2106
+ this.layout();
2107
+ }
2108
+ /**
2109
+ * Measures where the rows start again, as content above the table can
2110
+ * change height, e.g. a toolbar appears. Returns whether it changed.
2111
+ */
2112
+ updateScrollMargin() {
2113
+ const scrollMargin = this.measureScrollMargin();
2114
+ if (Math.abs(scrollMargin - this.scrollMargin) < 1) {
2115
+ return false;
2116
+ }
2117
+ this.scrollMargin = scrollMargin;
2118
+ this.applyOptions();
2119
+ return true;
2120
+ }
2121
+ /**
2122
+ * Reports each row's height for its current index. Every resize makes the
2123
+ * virtualizer call onChange, so the rows are positioned once at the end
2124
+ * instead of after each resize.
2125
+ */
2126
+ resizeRows(sizes) {
2127
+ this.isResizingRows = true;
2128
+ try {
2129
+ sizes.forEach(({ row, height }) => {
2130
+ const index = getRowIndex(row);
2131
+ // An unrendered row has no height yet. Counting it as 0 would draw
2132
+ // every row. The ResizeObserver measures it later.
2133
+ if (!row.isConnected || Number.isNaN(index) || height === 0) {
2134
+ return;
2135
+ }
2136
+ this.measuredIndexes.set(row, index);
2137
+ this.virtualizer.resizeItem(index, height);
2138
+ });
2139
+ }
2140
+ finally {
2141
+ this.isResizingRows = false;
2142
+ }
2143
+ if (this.hasChangeWhileResizing) {
2144
+ this.hasChangeWhileResizing = false;
2145
+ this.update();
2146
+ }
2147
+ }
2148
+ handleChange() {
2149
+ if (this.isResizingRows) {
2150
+ this.hasChangeWhileResizing = true;
2151
+ return;
2152
+ }
2153
+ this.update();
2154
+ }
2155
+ layout() {
2156
+ const items = new Map(this.virtualizer.getVirtualItems().map((item) => [item.index, item]));
2157
+ let cursor;
2158
+ this.getRenderedRows().forEach((row) => {
2159
+ const index = getRowIndex(row);
2160
+ const item = items.get(index);
2161
+ // The consumer hasn't removed this row yet.
2162
+ if (!item) {
2163
+ return;
2164
+ }
2165
+ // aria-rowindex starts at 1, which is the header row.
2166
+ if (row.index !== index + 2) {
2167
+ row.index = index + 2;
2168
+ }
2169
+ const start = item.start - this.scrollMargin;
2170
+ if (cursor === undefined) {
2171
+ setStyle(this.bodyEl, "paddingTop", start);
2172
+ setStyle(row, "marginTop", 0);
2173
+ }
2174
+ else {
2175
+ setStyle(row, "marginTop", start - cursor);
2176
+ }
2177
+ cursor = item.end - this.scrollMargin;
2178
+ });
2179
+ if (cursor === undefined) {
2180
+ setStyle(this.bodyEl, "paddingTop", 0);
2181
+ }
2182
+ setStyle(this.bodyEl, "paddingBottom", this.virtualizer.getTotalSize() - (cursor ?? 0));
2183
+ }
2184
+ getRenderedRows() {
2185
+ return Array.from(this.bodyEl.querySelectorAll("swirl-table-row[data-index]"));
2186
+ }
2187
+ options() {
2188
+ const { estimatedRowHeight, keptIndexes, overscan, rowCount } = this.config;
2189
+ const isWindow = this.scrollElement instanceof Window;
2190
+ return {
2191
+ count: rowCount,
2192
+ estimateSize: () => estimatedRowHeight,
2193
+ getScrollElement: () => this.scrollElement,
2194
+ // defaults to 0, which makes the virtualizer scroll to the top when it
2195
+ // subscribes to the scroll container.
2196
+ initialOffset: () => this.scrollElement instanceof Window
2197
+ ? this.scrollElement.scrollY
2198
+ : this.scrollElement.scrollTop,
2199
+ overscan,
2200
+ scrollMargin: this.scrollMargin,
2201
+ rangeExtractor: (range) => mergeIndexes(defaultRangeExtractor(range), keptIndexes.filter((index) => Number.isInteger(index) && index >= 0 && index < rowCount)),
2202
+ observeElementRect: (isWindow
2203
+ ? observeWindowRect
2204
+ : observeElementRect),
2205
+ observeElementOffset: (isWindow
2206
+ ? observeWindowOffset
2207
+ : observeElementOffset),
2208
+ scrollToFn: (isWindow
2209
+ ? windowScroll
2210
+ : elementScroll),
2211
+ onChange: () => this.handleChange(),
2212
+ };
2213
+ }
2214
+ /** Offset of the first row from the top of the scrolled content. */
2215
+ measureScrollMargin() {
2216
+ const bodyTop = this.bodyEl.getBoundingClientRect().top;
2217
+ if (this.scrollElement instanceof Window) {
2218
+ return bodyTop + this.scrollElement.scrollY;
2219
+ }
2220
+ return (bodyTop -
2221
+ this.scrollElement.getBoundingClientRect().top +
2222
+ this.scrollElement.scrollTop);
2223
+ }
2224
+ }
2225
+ function getRowIndex(row) {
2226
+ return Number(row.dataset.index);
2227
+ }
2228
+ function mergeIndexes(a, b) {
2229
+ return [...new Set([...a, ...b])].sort((x, y) => x - y);
2230
+ }
2231
+ function equalIndexes(a, b) {
2232
+ return a.length === b.length && a.every((index, i) => index === b[i]);
2233
+ }
2234
+ function setStyle(el, property, px) {
2235
+ const value = px > 0 ? `${px}px` : "";
2236
+ if (el.style[property] !== value) {
2237
+ el.style[property] = value;
2238
+ }
2239
+ }
2240
+
90
2241
  const swirlTableCss = () => `.sc-swirl-table-h{--swirl-table-shadow-rgba:rgba(23, 23, 23, 0.2);position:relative;display:block}.sc-swirl-table-h *.sc-swirl-table{box-sizing:border-box}html.theme-dark.sc-swirl-table-h,html.theme-dark .sc-swirl-table-h{--swirl-table-shadow-rgba:rgba(0, 0, 0, 0.2)}.table--keyboard-move.sc-swirl-table:focus-within{--swirl-table-moving-row-border:var(--s-border-width-default) solid var(--s-border-highlight)}.table--show-empty-state.sc-swirl-table .table__empty-row.sc-swirl-table{display:flex}.table__container.sc-swirl-table{position:relative;overflow:auto;width:100%}.table__container--scrolled.sc-swirl-table{--swirl-table-sticky-right-shadow:4px 0 16px -4px var(--swirl-table-shadow-rgba), 2px 0 4px -2px var(--swirl-table-shadow-rgba)}.table__container--scrollable.sc-swirl-table:not(.table__container--scrolled-to-end){--swirl-table-sticky-left-shadow:0px 4px 16px 0px var(--swirl-table-shadow-rgba), 0px 1px 4px 0px var(--swirl-table-shadow-rgba)}.table__table.sc-swirl-table{width:-moz-max-content;width:max-content;min-width:max(20rem, 100%)}.table__header.sc-swirl-table-s>*,.table__header .sc-swirl-table-s>*{display:flex}.table__empty-row.sc-swirl-table{display:none}.table__empty-row-cell.sc-swirl-table{display:flex;overflow:auto;padding-top:var(--s-space-8);padding-right:var(--s-space-16);padding-bottom:var(--s-space-8);padding-left:var(--s-space-16);flex-basis:0;flex-grow:1;flex-shrink:1;align-items:center;background-color:var(--s-surface-default)}.table__empty-row-cell.sc-swirl-table>*.sc-swirl-table{flex-grow:1}`;
91
2242
 
92
2243
  const defaultDragDropInstructions = {
@@ -99,10 +2250,20 @@ const SwirlTable = class {
99
2250
  constructor(hostRef) {
100
2251
  registerInstance(this, hostRef);
101
2252
  this.dropRow = createEvent(this, "dropRow", 7);
2253
+ this.virtualizationRowsChange = createEvent(this, "virtualizationRowsChange", 7);
102
2254
  this.dragDropInstructions = defaultDragDropInstructions;
103
2255
  this.emptyStateLabel = "No results found.";
2256
+ /** Height in px assumed for rows not drawn yet. */
2257
+ this.virtualizationEstimatedRowHeight = 56;
2258
+ /** Number of extra rows drawn above and below the visible ones. */
2259
+ this.virtualizationOverscan = 10;
2260
+ /**
2261
+ * Indexes of rows to keep drawn when out of view, e.g. a row with an open
2262
+ * menu. The focused row is always kept.
2263
+ */
2264
+ this.virtualizationKeepRowsRendered = [];
104
2265
  this.liveRegionText = "";
105
- this.triggerRerender = debounce(async () => {
2266
+ this.triggerRerender = debounce$1(async () => {
106
2267
  await this.updateLayout();
107
2268
  this.updateEmptyState();
108
2269
  }, 0, true);
@@ -120,6 +2281,7 @@ const SwirlTable = class {
120
2281
  this.updateScrolledState();
121
2282
  };
122
2283
  this.onFocus = (event) => {
2284
+ this.trackFocusedRow(event.target);
123
2285
  if (this.movingViaKeyboard) {
124
2286
  const movingRow = this.el.querySelector(".table-row--moving");
125
2287
  if (movingRow) {
@@ -133,6 +2295,9 @@ const SwirlTable = class {
133
2295
  };
134
2296
  this.onBlur = (event) => {
135
2297
  const newlyFocusedElement = event.relatedTarget;
2298
+ if (!this.el.contains(newlyFocusedElement)) {
2299
+ this.trackFocusedRow(null);
2300
+ }
136
2301
  const focusedDragHandle = !!newlyFocusedElement?.closest(this.dragDropHandle);
137
2302
  if (this.el.contains(newlyFocusedElement) && focusedDragHandle) {
138
2303
  return;
@@ -175,6 +2340,7 @@ const SwirlTable = class {
175
2340
  async componentDidLoad() {
176
2341
  this.setupIntersectionObserver();
177
2342
  this.setupMutationObservers();
2343
+ this.updateVirtualizer();
178
2344
  queueMicrotask(() => {
179
2345
  this.setupDragDrop();
180
2346
  });
@@ -184,6 +2350,60 @@ const SwirlTable = class {
184
2350
  this.columnMutationObserver?.disconnect();
185
2351
  this.rowMutationObserver?.disconnect();
186
2352
  this.sortable?.destroy();
2353
+ this.destroyVirtualizer();
2354
+ }
2355
+ handleVirtualizationChange() {
2356
+ this.updateVirtualizer();
2357
+ }
2358
+ get virtualizerConfig() {
2359
+ if (!this.enableVirtualization || !this.virtualizationRowCount) {
2360
+ return undefined;
2361
+ }
2362
+ return {
2363
+ estimatedRowHeight: this.virtualizationEstimatedRowHeight,
2364
+ keptIndexes: this.focusedRowIndex === undefined
2365
+ ? this.virtualizationKeepRowsRendered ?? []
2366
+ : [
2367
+ ...(this.virtualizationKeepRowsRendered ?? []),
2368
+ this.focusedRowIndex,
2369
+ ],
2370
+ overscan: this.virtualizationOverscan,
2371
+ rowCount: this.virtualizationRowCount,
2372
+ };
2373
+ }
2374
+ updateVirtualizer() {
2375
+ if (!this.bodyEl) {
2376
+ return;
2377
+ }
2378
+ const config = this.virtualizerConfig;
2379
+ if (!config) {
2380
+ const hadVirtualizer = Boolean(this.virtualizer);
2381
+ this.destroyVirtualizer();
2382
+ // tell the app to clear its rows when they drop to 0. checking for a
2383
+ // previous virtualizer emits only once, not on every focus change.
2384
+ if (this.enableVirtualization && hadVirtualizer) {
2385
+ queueMicrotask(() => this.virtualizationRowsChange.emit({ indexes: [] }));
2386
+ }
2387
+ return;
2388
+ }
2389
+ if (this.virtualizer) {
2390
+ this.virtualizer.setConfig(config);
2391
+ // find the scroll container when more rows make it overflow
2392
+ if (this.virtualizer.scrollElement === window) {
2393
+ this.updateScrollParent();
2394
+ }
2395
+ return;
2396
+ }
2397
+ // reserve the full height first, so the scroll container overflows and
2398
+ // can be found.
2399
+ this.bodyEl.style.paddingBottom = `${config.rowCount * config.estimatedRowHeight}px`;
2400
+ this.virtualizer = new SwirlTableVirtualizer(this.bodyEl, getScrollParent(this.el), config, (indexes) =>
2401
+ // emit async, so frameworks don't get it mid-render.
2402
+ queueMicrotask(() => this.virtualizationRowsChange.emit({ indexes })));
2403
+ }
2404
+ destroyVirtualizer() {
2405
+ this.virtualizer?.destroy();
2406
+ this.virtualizer = undefined;
187
2407
  }
188
2408
  handleEnableDragDropChange() {
189
2409
  queueMicrotask(() => {
@@ -219,15 +2439,21 @@ const SwirlTable = class {
219
2439
  });
220
2440
  this.rowMutationObserver = new MutationObserver((mutations) => {
221
2441
  const rowWasAddedOrRemoved = mutations.some((mutation) => mutation.addedNodes.length || mutation.removedNodes.length);
2442
+ // rows tracked by position are reused: only their data-index changes.
2443
+ const rowIndexChanged = mutations.some((mutation) => mutation.type === "attributes");
222
2444
  if (rowWasAddedOrRemoved) {
223
2445
  this.updateEmptyState();
224
2446
  this.setupDragDrop();
225
2447
  }
2448
+ if (rowWasAddedOrRemoved || rowIndexChanged) {
2449
+ this.syncVirtualizedRows();
2450
+ }
226
2451
  });
227
2452
  this.startRowMutationObserver();
228
2453
  }
229
2454
  startRowMutationObserver() {
230
2455
  this.rowMutationObserver?.observe(this.bodyEl, {
2456
+ attributeFilter: ["data-index"],
231
2457
  childList: true,
232
2458
  subtree: true,
233
2459
  });
@@ -289,10 +2515,23 @@ const SwirlTable = class {
289
2515
  // Delay layout update to ensure the container is fully visible,
290
2516
  // especially if it was initially rendered in a modal.
291
2517
  setTimeout(async () => {
2518
+ this.updateScrollParent();
292
2519
  await this.updateLayout();
293
2520
  }, 100);
294
2521
  }
295
2522
  }
2523
+ /**
2524
+ * A table hidden on load falls back to the window. Look for the scroll
2525
+ * container again once it is visible.
2526
+ */
2527
+ updateScrollParent() {
2528
+ if (!this.virtualizer ||
2529
+ getScrollParent(this.el) === this.virtualizer.scrollElement) {
2530
+ return;
2531
+ }
2532
+ this.destroyVirtualizer();
2533
+ this.updateVirtualizer();
2534
+ }
296
2535
  async componentDidRender() {
297
2536
  await this.updateLayout();
298
2537
  this.updateEmptyState();
@@ -477,6 +2716,10 @@ const SwirlTable = class {
477
2716
  .some((column) => column.sticky);
478
2717
  }
479
2718
  updateEmptyState() {
2719
+ if (this.enableVirtualization && this.virtualizationRowCount) {
2720
+ this.empty = false;
2721
+ return;
2722
+ }
480
2723
  const rowsContainer = this.el.querySelector('[slot="rows"]');
481
2724
  this.empty = !Boolean(rowsContainer) || rowsContainer.children.length === 0;
482
2725
  }
@@ -572,16 +2815,58 @@ const SwirlTable = class {
572
2815
  handle.querySelector("button")?.focus();
573
2816
  }
574
2817
  }
2818
+ /**
2819
+ * Measures and positions rows after they were added, removed or re-indexed.
2820
+ * The focused row's index is read again first, as it changes when e.g. a row
2821
+ * is inserted above it.
2822
+ */
2823
+ syncVirtualizedRows() {
2824
+ if (!this.virtualizer) {
2825
+ return;
2826
+ }
2827
+ this.trackFocusedRow(this.el.querySelector("swirl-table-row[data-index]:focus-within"));
2828
+ this.virtualizer.sync();
2829
+ }
2830
+ /** Keeps the focused row drawn, so it doesn't lose focus. */
2831
+ trackFocusedRow(target) {
2832
+ if (!this.enableVirtualization) {
2833
+ return;
2834
+ }
2835
+ const index = target?.closest("swirl-table-row[data-index]")
2836
+ ?.dataset.index;
2837
+ const focusedRowIndex = index === undefined ? undefined : Number(index);
2838
+ if (focusedRowIndex !== this.focusedRowIndex) {
2839
+ this.focusedRowIndex = focusedRowIndex;
2840
+ this.updateVirtualizer();
2841
+ }
2842
+ }
575
2843
  render() {
576
2844
  const hasEmptyStateSlotAssignment = Boolean(this.el.querySelector('[slot="empty"]'));
577
2845
  const className = classnames("table", {
578
2846
  "table--show-empty-state": this.empty && !this.loading,
579
2847
  "table--keyboard-move": this.movingViaKeyboard,
580
2848
  });
581
- return (h(Host, { key: '16d0611e24b24ee9f79cc38e0095a67672d74c2e' }, h("div", { key: 'aec12bf6d94bef63f68acfaf028658254d01f181', class: className }, this.enableDragDrop && (h("swirl-visually-hidden", { key: '0af23c204985e8578aee552beff188f5e599275f' }, h("span", { key: '0f4bcc195d7bd265c028b70604ba74b1531e3c25', "aria-live": "assertive" }, this.liveRegionText))), h("div", { key: '77e6c52ecbf5e81d268b9c49364cbe166e8ba45e', class: "table__container", onFocusin: this.onFocus, onFocusout: this.onBlur, onKeyDown: this.onKeyDown, onScroll: this.onScroll, ref: (el) => (this.container = el), tabIndex: -1 }, h("div", { key: '21156e4f5d0a98c1c11cdab2c8d812833d1af031', "aria-describedby": Boolean(this.caption) ? "caption" : undefined, "aria-label": this.label, role: "table", class: "table__table" }, this.caption && (h("swirl-visually-hidden", { key: 'deea452f4a44ffaf0f8472e0ba07446f555de0c2' }, h("div", { key: 'e0f7da4bf4009659451e3890827861a64045d740', id: "caption" }, this.caption))), h("div", { key: 'ce3b91d7709fb0b607cf3b4fa48f5d118d04ac4f', role: "rowgroup" }, h("div", { key: '15c9d000b9d69eedc6ca1285a9dcfa20ca2bec02', class: "table__header", ref: (el) => (this.headerEl = el), role: "row" }, h("slot", { key: '31f61474ba47292819e5fbaf655817ed28a03434', name: "columns" }))), h("div", { key: '2d5e8fab1af067c1eb59ad84db517113cc6935e3', class: "table__body", ref: (el) => (this.bodyEl = el) }, h("slot", { key: '47f0b034e0412de19194c87bf2dd1eea524af173', name: "rows" }), h("div", { key: '4b97574c5c5919c35fd5a9ce48a4b4dbb24d9518', class: "table__empty-row", role: "row" }, h("div", { key: 'e8d44d595d30450512ad57defb3c61fd77f2040a', "aria-colspan": this.getColumns().length, class: "table__empty-row-cell", role: "cell" }, h("slot", { key: '6551e8e625520b44e608a41e67d58e65a06c20d2', name: "empty" }), !hasEmptyStateSlotAssignment && (h("swirl-text", { key: '7689d667f7574ddd4dfa3ad54d05906e1822c035', align: "center", size: "sm" }, this.emptyStateLabel))))))))));
2849
+ return (h(Host, { key: '5fd51d538c87dce53702fa483657035e251d3507' }, h("div", { key: '7ec3b5830bcc7b0dfc5324f554b80b442b7bc290', class: className }, this.enableDragDrop && (h("swirl-visually-hidden", { key: '2928eb420bb8cad6477917a1883aeeffda3260eb' }, h("span", { key: 'fc615afed57d8dbfbf636f9e8feb9c6ef76ae72b', "aria-live": "assertive" }, this.liveRegionText))), h("div", { key: '4b7d5b9c4691d1828d0c24fc635d8e7c5dc48cf4', class: "table__container", onFocusin: this.onFocus, onFocusout: this.onBlur, onKeyDown: this.onKeyDown, onScroll: this.onScroll, ref: (el) => (this.container = el), tabIndex: -1 }, h("div", { key: '9669435927eb4944290b4fdcb4083ef1473c000e', "aria-describedby": Boolean(this.caption) ? "caption" : undefined, "aria-label": this.label, "aria-rowcount": this.enableVirtualization && this.virtualizationRowCount
2850
+ ? this.virtualizationRowCount + 1
2851
+ : undefined, role: "table", class: "table__table" }, this.caption && (h("swirl-visually-hidden", { key: '6806eedf8d1aa22b3ee8f51736032ead77a502cc' }, h("div", { key: 'bea8e3d31ba2e81461ff8e4d056ee3ea718707ea', id: "caption" }, this.caption))), h("div", { key: '386fa4a8c2d31471a43580b62ad1003cfbcf224d', role: "rowgroup" }, h("div", { key: 'aebae228fab2eb7d4a688bb50ee069e7138001c1', class: "table__header", "aria-rowindex": this.enableVirtualization ? 1 : undefined, ref: (el) => (this.headerEl = el), role: "row" }, h("slot", { key: '111dd938896772934ba589167ee254936c8bbe9d', name: "columns" }))), h("div", { key: '7a6b87e277bd50dfc8c5ff3e680aabe95384bb7f', class: "table__body", ref: (el) => (this.bodyEl = el) }, h("slot", { key: 'a766d1ff38bf321fac0b3c52a686d57d2b4551ea', name: "rows" }), h("div", { key: 'a26bec40f580546c85e3dd1007c913d53da4c18a', class: "table__empty-row", role: "row" }, h("div", { key: 'cd9793a4e353a88bfb04658354f247ddfd621e20', "aria-colspan": this.getColumns().length, class: "table__empty-row-cell", role: "cell" }, h("slot", { key: '3c79cf8327876b4be8e237e6d43c918d6f6dbda0', name: "empty" }), !hasEmptyStateSlotAssignment && (h("swirl-text", { key: '6f2d3365cd41f0242f8dc6720aed3c5bc1edf4fb', align: "center", size: "sm" }, this.emptyStateLabel))))))))));
582
2852
  }
583
2853
  get el() { return getElement(this); }
584
2854
  static get watchers() { return {
2855
+ "enableVirtualization": [{
2856
+ "handleVirtualizationChange": 0
2857
+ }],
2858
+ "virtualizationRowCount": [{
2859
+ "handleVirtualizationChange": 0
2860
+ }],
2861
+ "virtualizationEstimatedRowHeight": [{
2862
+ "handleVirtualizationChange": 0
2863
+ }],
2864
+ "virtualizationOverscan": [{
2865
+ "handleVirtualizationChange": 0
2866
+ }],
2867
+ "virtualizationKeepRowsRendered": [{
2868
+ "handleVirtualizationChange": 0
2869
+ }],
585
2870
  "enableDragDrop": [{
586
2871
  "handleEnableDragDropChange": 0
587
2872
  }]