@rific/scroll-view 0.2.0 → 0.4.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 (35) hide show
  1. package/README.md +2 -0
  2. package/dist/index.d.mts +23 -17
  3. package/dist/index.d.ts +23 -17
  4. package/dist/index.js +720 -1960
  5. package/dist/index.mjs +697 -1939
  6. package/package.json +10 -10
  7. package/src/CustomList.tsx +32 -8
  8. package/src/FlatList.tsx +102 -20
  9. package/src/PullSearch.tsx +4 -3
  10. package/src/ScrollView.tsx +28 -8
  11. package/src/ScrollViewContext.ts +17 -4
  12. package/src/ScrollViewHeader.tsx +34 -31
  13. package/src/ScrollViewProvider.tsx +22 -6
  14. package/src/SectionList.tsx +31 -10
  15. package/src/internal/useScrollHandler.ts +19 -21
  16. package/src/internal/useScrollHandlerJS.ts +141 -0
  17. package/src/internal/useScrollList.ts +16 -11
  18. package/src/redux/scrollViewSlice.ts +19 -11
  19. package/src/useScrollInit.ts +200 -19
  20. package/src/__mocks__/auto-paper.ts +0 -9
  21. package/src/__mocks__/flash-list.ts +0 -20
  22. package/src/__mocks__/react-native-gesture-handler.ts +0 -13
  23. package/src/__mocks__/react-native-keyboard-controller.ts +0 -11
  24. package/src/__mocks__/react-native-paper.ts +0 -22
  25. package/src/__mocks__/react-native-reanimated.ts +0 -30
  26. package/src/__mocks__/react-native-safe-area-context.ts +0 -2
  27. package/src/__mocks__/react-native.ts +0 -30
  28. package/src/__tests__/CustomList.test.tsx +0 -61
  29. package/src/__tests__/FlatList.test.tsx +0 -52
  30. package/src/__tests__/PullSearch.test.tsx +0 -38
  31. package/src/__tests__/ScrollView.test.tsx +0 -23
  32. package/src/__tests__/ScrollViewHeader.test.tsx +0 -28
  33. package/src/__tests__/ScrollViewProvider.test.tsx +0 -65
  34. package/src/__tests__/SectionList.test.tsx +0 -88
  35. package/src/out.txt +0 -61
package/dist/index.js CHANGED
@@ -5,7 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
8
  var __export = (target, all) => {
10
9
  for (var name in all)
11
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,7 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
26
  mod
28
27
  ));
29
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
31
29
 
32
30
  // src/index.ts
33
31
  var index_exports = {};
@@ -56,6 +54,7 @@ module.exports = __toCommonJS(index_exports);
56
54
  var import_react6 = require("react");
57
55
  var import_react_native4 = require("react-native");
58
56
  var import_react_native_gesture_handler = require("react-native-gesture-handler");
57
+ var import_react_native_reanimated6 = require("react-native-reanimated");
59
58
 
60
59
  // src/internal/RefreshControl.tsx
61
60
  var import_react_native = require("react-native");
@@ -81,8 +80,8 @@ var styles = import_react_native2.StyleSheet.create({
81
80
  });
82
81
 
83
82
  // src/internal/useScrollHandler.ts
84
- var import_react2 = require("react");
85
- var import_react_native_reanimated2 = require("react-native-reanimated");
83
+ var import_react3 = require("react");
84
+ var import_react_native_reanimated3 = require("react-native-reanimated");
86
85
 
87
86
  // src/ScrollViewContext.ts
88
87
  var import_react = require("react");
@@ -92,10 +91,16 @@ var ScrollViewContext = (0, import_react.createContext)({
92
91
  footerHeightShared: null,
93
92
  footerFixed: false,
94
93
  footerOffset: null,
95
- headerHeight: 0,
94
+ headerHeight: null,
96
95
  headerHeightShared: null,
97
96
  headerFixed: false,
98
97
  headerOffset: null,
98
+ jsListGeneration: { current: 0 },
99
+ listGeneration: null,
100
+ onJsListUnmount: () => {
101
+ },
102
+ onListUnmount: () => {
103
+ },
99
104
  progress: null,
100
105
  progressing: false,
101
106
  pullSearchHeightShared: null,
@@ -114,17 +119,207 @@ var ScrollViewContext = (0, import_react.createContext)({
114
119
  tabBarHeight: 60
115
120
  });
116
121
 
122
+ // src/useScrollInit.ts
123
+ var import_react2 = require("react");
124
+ var import_react_native_reanimated2 = require("react-native-reanimated");
125
+ var REMOUNT_SYNC_MAX_ATTEMPTS = 8;
126
+ var REMOUNT_SYNC_TOLERANCE = 1;
127
+ var REMOUNT_SYNC_FALLBACK_MS = 500;
128
+ var REMOUNT_PRIME_FRAMES = 40;
129
+ var SNAP_VERIFY_TOLERANCE = 1;
130
+ var SNAP_VERIFY_MAX_ATTEMPTS = 5;
131
+ var SNAP_VERIFY_INITIAL_DELAY_MS = 400;
132
+ var SNAP_VERIFY_RETRY_DELAY_MS = 150;
133
+ function useScrollInit({ listHeaderComponent, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pullSearchHeight, scrollTo }) {
134
+ const { headerHeight, scrollPosition, setProgressing } = (0, import_react2.useContext)(ScrollViewContext);
135
+ const hasPullSearch = pullSearchHeight !== void 0;
136
+ const [phase, setPhase] = (0, import_react2.useState)(hasPullSearch && !headerHeight ? "measuring" : "ready");
137
+ const [refreshing, setRefreshing] = (0, import_react2.useState)(false);
138
+ const refreshingRef = (0, import_react2.useRef)(refreshing);
139
+ (0, import_react2.useEffect)(() => {
140
+ refreshingRef.current = refreshing;
141
+ }, [refreshing]);
142
+ const dragStartY = (0, import_react2.useRef)(null);
143
+ const pendingSnapTarget = (0, import_react2.useRef)(null);
144
+ const snapVerifyTimeout = (0, import_react2.useRef)(null);
145
+ const snapVerifyAttempts = (0, import_react2.useRef)(0);
146
+ const scheduleSnapVerification = (0, import_react2.useCallback)(
147
+ (target, delay) => {
148
+ if (snapVerifyTimeout.current !== null) clearTimeout(snapVerifyTimeout.current);
149
+ pendingSnapTarget.current = target;
150
+ snapVerifyAttempts.current = 0;
151
+ const check = () => {
152
+ snapVerifyTimeout.current = null;
153
+ if (pendingSnapTarget.current !== target) return;
154
+ if (Math.abs(scrollPosition.value - target) <= SNAP_VERIFY_TOLERANCE) {
155
+ pendingSnapTarget.current = null;
156
+ return;
157
+ }
158
+ snapVerifyAttempts.current += 1;
159
+ if (snapVerifyAttempts.current > SNAP_VERIFY_MAX_ATTEMPTS || refreshingRef.current) {
160
+ pendingSnapTarget.current = null;
161
+ return;
162
+ }
163
+ scrollTo(target, false);
164
+ snapVerifyTimeout.current = setTimeout(check, SNAP_VERIFY_RETRY_DELAY_MS);
165
+ };
166
+ snapVerifyTimeout.current = setTimeout(check, delay);
167
+ },
168
+ [scrollPosition, scrollTo]
169
+ );
170
+ (0, import_react2.useEffect)(
171
+ () => () => {
172
+ if (snapVerifyTimeout.current !== null) clearTimeout(snapVerifyTimeout.current);
173
+ },
174
+ []
175
+ );
176
+ const [remountTarget] = (0, import_react2.useState)(() => headerHeight !== null ? -headerHeight + (pullSearchHeight ?? 0) : null);
177
+ const remountSyncTarget = (0, import_react_native_reanimated2.useSharedValue)(remountTarget);
178
+ const [scrollReady, setScrollReady] = (0, import_react2.useState)(remountTarget === null);
179
+ const remountAttempts = (0, import_react2.useRef)(0);
180
+ const onRemountSynced = (0, import_react2.useCallback)(
181
+ (y) => {
182
+ scrollPosition.value = y;
183
+ setScrollReady(true);
184
+ },
185
+ [scrollPosition]
186
+ );
187
+ const onRemountSyncRetry = (0, import_react2.useCallback)(
188
+ (currentY) => {
189
+ if (remountTarget === null) return;
190
+ remountAttempts.current += 1;
191
+ if (remountAttempts.current > REMOUNT_SYNC_MAX_ATTEMPTS) {
192
+ remountSyncTarget.value = null;
193
+ onRemountSynced(currentY);
194
+ return;
195
+ }
196
+ scrollTo(remountTarget, false);
197
+ },
198
+ [onRemountSynced, remountSyncTarget, remountTarget, scrollTo]
199
+ );
200
+ (0, import_react2.useEffect)(() => {
201
+ if (remountTarget === null) return;
202
+ scrollTo(remountTarget, false);
203
+ const fallback = setTimeout(() => {
204
+ if (remountSyncTarget.value === null) return;
205
+ remountSyncTarget.value = null;
206
+ onRemountSynced(remountTarget);
207
+ }, REMOUNT_SYNC_FALLBACK_MS);
208
+ return () => clearTimeout(fallback);
209
+ }, []);
210
+ (0, import_react2.useEffect)(() => {
211
+ if (phase === "ready" || !headerHeight || !pullSearchHeight) return;
212
+ scrollPosition.value = -headerHeight + pullSearchHeight;
213
+ setPhase("ready");
214
+ }, [phase, headerHeight, pullSearchHeight, scrollPosition]);
215
+ const headerInitialized = (0, import_react2.useRef)(false);
216
+ (0, import_react2.useLayoutEffect)(() => {
217
+ if (!headerHeight || headerInitialized.current) return;
218
+ headerInitialized.current = true;
219
+ const target = remountTarget ?? -headerHeight;
220
+ scrollPosition.value = target;
221
+ scrollTo(target, false);
222
+ if (remountTarget === null) return;
223
+ let framesLeft = REMOUNT_PRIME_FRAMES;
224
+ let handle = null;
225
+ const tick = () => {
226
+ const offset = framesLeft === 1 ? target : framesLeft % 2 === 0 ? target + 30 : target - 30;
227
+ scrollTo(offset, false);
228
+ framesLeft -= 1;
229
+ if (framesLeft > 0) handle = requestAnimationFrame(tick);
230
+ };
231
+ handle = requestAnimationFrame(tick);
232
+ return () => {
233
+ if (handle !== null) cancelAnimationFrame(handle);
234
+ };
235
+ }, [remountTarget, headerHeight, scrollPosition, scrollTo]);
236
+ const pullSearchInitialized = (0, import_react2.useRef)(false);
237
+ (0, import_react2.useLayoutEffect)(() => {
238
+ if (remountTarget !== null || !hasPullSearch || phase !== "ready" || pullSearchInitialized.current || !headerHeight || !pullSearchHeight || !scrollReady) return;
239
+ pullSearchInitialized.current = true;
240
+ scrollPosition.value = -headerHeight + pullSearchHeight;
241
+ scrollTo(-headerHeight + pullSearchHeight, false);
242
+ }, [remountTarget, hasPullSearch, phase, headerHeight, pullSearchHeight, scrollPosition, scrollReady, scrollTo]);
243
+ (0, import_react2.useEffect)(() => {
244
+ if (pullSearchHeight) setProgressing(refreshing);
245
+ }, [pullSearchHeight, refreshing, setProgressing]);
246
+ const handleScrollBeginDrag = (0, import_react2.useCallback)(
247
+ (e) => {
248
+ if (snapVerifyTimeout.current !== null) {
249
+ clearTimeout(snapVerifyTimeout.current);
250
+ snapVerifyTimeout.current = null;
251
+ }
252
+ pendingSnapTarget.current = null;
253
+ if (pullSearchHeight) dragStartY.current = e.nativeEvent.contentOffset.y;
254
+ externalScrollBeginDrag?.(e);
255
+ },
256
+ [externalScrollBeginDrag, pullSearchHeight]
257
+ );
258
+ const handleScrollEndDrag = (0, import_react2.useCallback)(
259
+ (e) => {
260
+ if (pullSearchHeight && headerHeight) {
261
+ const y = e.nativeEvent.contentOffset.y;
262
+ const showY = -headerHeight;
263
+ const hideY = -headerHeight + pullSearchHeight;
264
+ const startY = dragStartY.current;
265
+ dragStartY.current = null;
266
+ const pulledDown = (startY ?? hideY) <= hideY;
267
+ const dragDistance = startY !== null ? startY - y : 0;
268
+ if (pulledDown && dragDistance >= pullSearchHeight * 0.5) {
269
+ if (y <= showY && !refreshing && onRefresh) {
270
+ setRefreshing(true);
271
+ Promise.resolve(onRefresh()).finally(() => setRefreshing(false));
272
+ }
273
+ scrollTo(showY, true);
274
+ scheduleSnapVerification(showY, SNAP_VERIFY_INITIAL_DELAY_MS);
275
+ } else if (y < hideY) {
276
+ scrollTo(hideY, true);
277
+ scheduleSnapVerification(hideY, SNAP_VERIFY_INITIAL_DELAY_MS);
278
+ }
279
+ }
280
+ externalScrollEndDrag?.(e);
281
+ },
282
+ [externalScrollEndDrag, headerHeight, onRefresh, pullSearchHeight, refreshing, scheduleSnapVerification, scrollTo]
283
+ );
284
+ const handleMomentumScrollEnd = (0, import_react2.useCallback)(
285
+ (e) => {
286
+ if (pullSearchHeight && headerHeight && !refreshing && pendingSnapTarget.current === null) {
287
+ const y = e.nativeEvent.contentOffset.y;
288
+ const hideY = -headerHeight + pullSearchHeight;
289
+ if (y < hideY - 1) {
290
+ scrollTo(hideY, true);
291
+ scheduleSnapVerification(hideY, SNAP_VERIFY_INITIAL_DELAY_MS);
292
+ }
293
+ }
294
+ externalMomentumScrollEnd?.(e);
295
+ },
296
+ [externalMomentumScrollEnd, headerHeight, pullSearchHeight, refreshing, scheduleSnapVerification, scrollTo]
297
+ );
298
+ const activeListHeader = hasPullSearch && phase === "measuring" ? null : listHeaderComponent;
299
+ const hiddenHeader = phase === "measuring" && listHeaderComponent != null ? typeof listHeaderComponent === "function" ? (0, import_react2.createElement)(listHeaderComponent) : listHeaderComponent : null;
300
+ return { activeListHeader, handleMomentumScrollEnd, handleScrollBeginDrag, handleScrollEndDrag, hiddenHeader, onRemountSyncRetry, onRemountSynced, pullSearchMinHeight: pullSearchHeight ?? 0, remountSyncTarget, remountTarget, scrollReady };
301
+ }
302
+
117
303
  // src/internal/useScrollHandler.ts
118
- function useScrollHandler({ chipHidden, chipThreshold = 100, footerFixed, headerFixed, isHorizontal, onPullSearchZoneEnter }) {
119
- const { footerHeightShared, footerOffset, headerHeightShared, headerOffset, pullSearchHeightShared, scrollPosition, snapBackFooterShared, snapBackHeaderShared } = (0, import_react2.useContext)(ScrollViewContext);
120
- const snapUpAccum = (0, import_react_native_reanimated2.useSharedValue)(0);
121
- const fromBottomBounce = (0, import_react_native_reanimated2.useSharedValue)(false);
122
- const isMomentum = (0, import_react_native_reanimated2.useSharedValue)(false);
123
- const momentumPullSearchFired = (0, import_react_native_reanimated2.useSharedValue)(false);
124
- return (0, import_react_native_reanimated2.useAnimatedScrollHandler)(
304
+ function useScrollHandler({ capturedGeneration, chipHidden, chipThreshold = 100, footerFixed, headerFixed, isHorizontal, listGeneration, onRemountSyncRetry, onRemountSynced, remountSyncTarget }) {
305
+ const { footerHeightShared, footerOffset, headerHeightShared, headerOffset, pullSearchHeightShared, scrollPosition, snapBackFooterShared, snapBackHeaderShared } = (0, import_react3.useContext)(ScrollViewContext);
306
+ const snapUpAccum = (0, import_react_native_reanimated3.useSharedValue)(0);
307
+ const fromBottomBounce = (0, import_react_native_reanimated3.useSharedValue)(false);
308
+ return (0, import_react_native_reanimated3.useAnimatedScrollHandler)(
125
309
  {
126
310
  onScroll: ({ contentOffset: { x, y }, contentSize: { height: contentHeight }, layoutMeasurement: { height: layoutHeight } }) => {
127
311
  "worklet";
312
+ if (remountSyncTarget && remountSyncTarget.value !== null) {
313
+ const target = remountSyncTarget.value;
314
+ if (Math.abs(y - target) < REMOUNT_SYNC_TOLERANCE) {
315
+ remountSyncTarget.value = null;
316
+ if (onRemountSynced) (0, import_react_native_reanimated3.runOnJS)(onRemountSynced)(y);
317
+ } else if (onRemountSyncRetry) {
318
+ (0, import_react_native_reanimated3.runOnJS)(onRemountSyncRetry)(y);
319
+ }
320
+ return;
321
+ }
322
+ if (listGeneration.value !== capturedGeneration.value) return;
128
323
  if (isHorizontal) {
129
324
  scrollPosition.value = x;
130
325
  chipHidden.value = x < chipThreshold ? 1 : 0;
@@ -140,13 +335,6 @@ function useScrollHandler({ chipHidden, chipThreshold = 100, footerFixed, header
140
335
  } else if (fromBottomBounce.value) {
141
336
  fromBottomBounce.value = false;
142
337
  }
143
- if (isMomentum.value && pullSearchHeightShared.value > 0 && !momentumPullSearchFired.value) {
144
- const hideY = -headerHeightShared.value + pullSearchHeightShared.value;
145
- if (y < hideY) {
146
- momentumPullSearchFired.value = true;
147
- if (onPullSearchZoneEnter) (0, import_react_native_reanimated2.runOnJS)(onPullSearchZoneEnter)();
148
- }
149
- }
150
338
  const snapHeader = snapBackHeaderShared.value && !headerFixed;
151
339
  const snapFooter = snapBackFooterShared.value && !footerFixed;
152
340
  if (snapHeader || snapFooter) {
@@ -164,24 +352,17 @@ function useScrollHandler({ chipHidden, chipThreshold = 100, footerFixed, header
164
352
  if (y >= -headerHeightShared.value + pullSearchHeightShared.value) snapUpAccum.value -= delta;
165
353
  if (snapUpAccum.value >= 10) {
166
354
  snapUpAccum.value = 999;
167
- if (snapHeader) headerOffset.value = (0, import_react_native_reanimated2.withTiming)(0, { duration: 200 });
168
- if (snapFooter) footerOffset.value = (0, import_react_native_reanimated2.withTiming)(0, { duration: 200 });
355
+ if (snapHeader) headerOffset.value = (0, import_react_native_reanimated3.withTiming)(0, { duration: 200 });
356
+ if (snapFooter) footerOffset.value = (0, import_react_native_reanimated3.withTiming)(0, { duration: 200 });
169
357
  }
170
358
  }
171
359
  }
172
360
  },
173
361
  onBeginDrag: () => {
174
362
  "worklet";
175
- isMomentum.value = false;
176
- momentumPullSearchFired.value = false;
177
363
  fromBottomBounce.value = false;
178
364
  snapUpAccum.value = 0;
179
365
  },
180
- onMomentumBegin: () => {
181
- "worklet";
182
- isMomentum.value = true;
183
- momentumPullSearchFired.value = false;
184
- },
185
366
  onEndDrag: ({ contentOffset: { y }, contentSize: { height: contentHeight }, layoutMeasurement: { height: layoutHeight } }) => {
186
367
  "worklet";
187
368
  if (isHorizontal) return;
@@ -192,37 +373,35 @@ function useScrollHandler({ chipHidden, chipThreshold = 100, footerFixed, header
192
373
  },
193
374
  onMomentumEnd: () => {
194
375
  "worklet";
195
- isMomentum.value = false;
196
- momentumPullSearchFired.value = false;
197
376
  fromBottomBounce.value = false;
198
377
  snapUpAccum.value = 0;
199
378
  }
200
379
  },
201
- [headerFixed, footerFixed, isHorizontal, chipThreshold, onPullSearchZoneEnter]
380
+ [capturedGeneration, headerFixed, footerFixed, isHorizontal, chipThreshold, listGeneration, onRemountSyncRetry, onRemountSynced, remountSyncTarget]
202
381
  );
203
382
  }
204
383
 
205
384
  // src/internal/useScrollList.ts
206
- var import_react4 = require("react");
385
+ var import_react5 = require("react");
207
386
  var import_react_native3 = require("react-native");
208
- var import_react_native_reanimated4 = require("react-native-reanimated");
387
+ var import_react_native_reanimated5 = require("react-native-reanimated");
209
388
  var import_react_native_safe_area_context = require("react-native-safe-area-context");
210
389
 
211
390
  // src/useKeyboardInset.ts
212
- var import_react3 = require("react");
391
+ var import_react4 = require("react");
213
392
  var import_react_native_keyboard_controller = require("react-native-keyboard-controller");
214
- var import_react_native_reanimated3 = require("react-native-reanimated");
393
+ var import_react_native_reanimated4 = require("react-native-reanimated");
215
394
  var useKeyboardInset = () => {
216
- const [keyboardHeight, setKeyboardHeight] = (0, import_react3.useState)(0);
395
+ const [keyboardHeight, setKeyboardHeight] = (0, import_react4.useState)(0);
217
396
  (0, import_react_native_keyboard_controller.useKeyboardHandler)(
218
397
  {
219
398
  onMove: (e) => {
220
399
  "worklet";
221
- (0, import_react_native_reanimated3.runOnJS)(setKeyboardHeight)(e.height);
400
+ (0, import_react_native_reanimated4.runOnJS)(setKeyboardHeight)(e.height);
222
401
  },
223
402
  onEnd: (e) => {
224
403
  "worklet";
225
- (0, import_react_native_reanimated3.runOnJS)(setKeyboardHeight)(e.height);
404
+ (0, import_react_native_reanimated4.runOnJS)(setKeyboardHeight)(e.height);
226
405
  }
227
406
  },
228
407
  []
@@ -235,122 +414,55 @@ var CHIP_SLIDE = 48;
235
414
  function useScrollList({ footerFixed: footerFixedProp, headerFixed: headerFixedProp, isHorizontal, keyboardAware, pullSearchHeight, style } = {}) {
236
415
  const insets = (0, import_react_native_safe_area_context.useSafeAreaInsets)();
237
416
  const keyboardHeight = useKeyboardInset();
238
- const { footerHeight, footerFixed: contextFooterFixed, headerHeight, headerFixed: contextHeaderFixed, headerOffset, pullSearchHeightShared, scrollPosition, snapBackHeaderShared } = (0, import_react4.useContext)(ScrollViewContext);
417
+ const { footerHeight, footerFixed: contextFooterFixed, headerHeight, headerFixed: contextHeaderFixed, headerOffset, pullSearchHeightShared, scrollPosition, snapBackHeaderShared } = (0, import_react5.useContext)(ScrollViewContext);
239
418
  const headerFixed = isHorizontal ? true : headerFixedProp ?? contextHeaderFixed;
240
419
  const footerFixed = isHorizontal ? true : footerFixedProp ?? contextFooterFixed;
241
- (0, import_react4.useEffect)(() => {
420
+ (0, import_react5.useEffect)(() => {
242
421
  pullSearchHeightShared.value = pullSearchHeight ?? 0;
243
422
  }, [pullSearchHeight, pullSearchHeightShared]);
244
- const containerStyle = (0, import_react4.useMemo)(() => headerHeight === 0 ? [{ flex: 1 }, style] : [import_react_native3.StyleSheet.absoluteFill, style], [headerHeight, style]);
245
- const contentInset = (0, import_react4.useMemo)(() => ({ bottom: (footerFixed ? footerHeight || insets.bottom : insets.bottom) + (keyboardAware ? keyboardHeight : 0), top: headerHeight }), [footerFixed, footerHeight, insets.bottom, headerHeight, keyboardAware, keyboardHeight]);
246
- const contentOffset = (0, import_react4.useMemo)(() => ({ x: 0, y: -contentInset.top }), [contentInset.top]);
247
- const chipHidden = (0, import_react_native_reanimated4.useSharedValue)(1);
248
- const chipStyle = (0, import_react_native_reanimated4.useAnimatedStyle)(() => {
423
+ const containerStyle = (0, import_react5.useMemo)(() => headerHeight === null ? [{ flex: 1, opacity: 0 }, style] : [import_react_native3.StyleSheet.absoluteFill, style], [headerHeight, style]);
424
+ const contentInset = (0, import_react5.useMemo)(() => ({ bottom: (footerFixed ? footerHeight || insets.bottom : insets.bottom) + (keyboardAware ? keyboardHeight : 0), top: headerHeight ?? 0 }), [footerFixed, footerHeight, insets.bottom, headerHeight, keyboardAware, keyboardHeight]);
425
+ const [startedWithHeader] = (0, import_react5.useState)(headerHeight !== null);
426
+ const contentOffset = (0, import_react5.useMemo)(() => ({ x: 0, y: headerHeight !== null ? -headerHeight + (startedWithHeader && !isHorizontal && pullSearchHeight ? pullSearchHeight : 0) : 0 }), [headerHeight, isHorizontal, pullSearchHeight, startedWithHeader]);
427
+ const chipHidden = (0, import_react_native_reanimated5.useSharedValue)(1);
428
+ const chipStyle = (0, import_react_native_reanimated5.useAnimatedStyle)(() => {
249
429
  const pointerEvents = chipHidden.value ? "none" : "box-none";
250
430
  if (isHorizontal) {
251
431
  return {
252
- opacity: chipHidden.value ? (0, import_react_native_reanimated4.withTiming)(0) : (0, import_react_native_reanimated4.withTiming)(1),
432
+ opacity: chipHidden.value ? (0, import_react_native_reanimated5.withTiming)(0) : (0, import_react_native_reanimated5.withTiming)(1),
253
433
  pointerEvents,
254
- top: Math.max(headerHeight, insets.top) + 4,
255
- transform: [{ translateX: chipHidden.value ? (0, import_react_native_reanimated4.withTiming)(-CHIP_SLIDE) : (0, import_react_native_reanimated4.withTiming)(0) }]
434
+ top: Math.max(headerHeight ?? 0, insets.top) + 4,
435
+ transform: [{ translateX: chipHidden.value ? (0, import_react_native_reanimated5.withTiming)(-CHIP_SLIDE) : (0, import_react_native_reanimated5.withTiming)(0) }]
256
436
  };
257
437
  }
258
- const slide = headerFixed ? 0 : snapBackHeaderShared.value ? -headerOffset.value : Math.max(0, scrollPosition.value + headerHeight - pullSearchHeightShared.value);
259
- const top = Math.max(headerHeight - slide, insets.top) + 4;
438
+ const h = headerHeight ?? 0;
439
+ const slide = headerFixed ? 0 : snapBackHeaderShared.value ? -headerOffset.value : Math.max(0, scrollPosition.value + h - pullSearchHeightShared.value);
440
+ const top = Math.max(h - slide, insets.top) + 4;
260
441
  return {
261
- opacity: chipHidden.value ? (0, import_react_native_reanimated4.withTiming)(0) : (0, import_react_native_reanimated4.withTiming)(1),
442
+ opacity: chipHidden.value ? (0, import_react_native_reanimated5.withTiming)(0) : (0, import_react_native_reanimated5.withTiming)(1),
262
443
  pointerEvents,
263
444
  top,
264
- transform: [{ translateY: chipHidden.value ? (0, import_react_native_reanimated4.withTiming)(-CHIP_SLIDE) : (0, import_react_native_reanimated4.withTiming)(0) }]
445
+ transform: [{ translateY: chipHidden.value ? (0, import_react_native_reanimated5.withTiming)(-CHIP_SLIDE) : (0, import_react_native_reanimated5.withTiming)(0) }]
265
446
  };
266
447
  }, [isHorizontal, headerFixed, headerHeight, insets.top]);
267
448
  return { chipHidden, chipStyle, containerStyle, contentInset, contentOffset, footerFixed, headerFixed, headerHeight, insets, isHorizontal: isHorizontal ?? false };
268
449
  }
269
450
 
270
- // src/useScrollInit.ts
271
- var import_react5 = require("react");
272
- function useScrollInit({ listHeaderComponent, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pullSearchHeight, scrollTo }) {
273
- const { headerHeight, scrollPosition, setProgressing } = (0, import_react5.useContext)(ScrollViewContext);
274
- const hasPullSearch = pullSearchHeight !== void 0;
275
- const [phase, setPhase] = (0, import_react5.useState)(hasPullSearch ? "measuring" : "ready");
276
- const [refreshing, setRefreshing] = (0, import_react5.useState)(false);
277
- const dragStartY = (0, import_react5.useRef)(null);
278
- const deliberatelyOpened = (0, import_react5.useRef)(false);
279
- (0, import_react5.useEffect)(() => {
280
- if (phase === "ready" || !headerHeight || !pullSearchHeight) return;
281
- scrollPosition.value = -headerHeight + pullSearchHeight;
282
- setPhase("ready");
283
- }, [phase, headerHeight, pullSearchHeight, scrollPosition]);
284
- const headerInitialized = (0, import_react5.useRef)(false);
285
- (0, import_react5.useLayoutEffect)(() => {
286
- if (!headerHeight || headerInitialized.current) return;
287
- headerInitialized.current = true;
288
- scrollPosition.value = -headerHeight;
289
- scrollTo(-headerHeight, false);
290
- }, [headerHeight, scrollPosition, scrollTo]);
291
- const pullSearchInitialized = (0, import_react5.useRef)(false);
292
- (0, import_react5.useLayoutEffect)(() => {
293
- if (!hasPullSearch || phase !== "ready" || pullSearchInitialized.current || !headerHeight || !pullSearchHeight) return;
294
- pullSearchInitialized.current = true;
295
- scrollPosition.value = -headerHeight + pullSearchHeight;
296
- scrollTo(-headerHeight + pullSearchHeight, false);
297
- }, [hasPullSearch, phase, headerHeight, pullSearchHeight, scrollPosition, scrollTo]);
298
- (0, import_react5.useEffect)(() => {
299
- if (pullSearchHeight) setProgressing(refreshing);
300
- }, [pullSearchHeight, refreshing, setProgressing]);
301
- const handleScrollBeginDrag = (0, import_react5.useCallback)(
302
- (e) => {
303
- deliberatelyOpened.current = false;
304
- if (pullSearchHeight) dragStartY.current = e.nativeEvent.contentOffset.y;
305
- externalScrollBeginDrag?.(e);
306
- },
307
- [externalScrollBeginDrag, pullSearchHeight]
308
- );
309
- const handleScrollEndDrag = (0, import_react5.useCallback)(
310
- (e) => {
311
- if (pullSearchHeight && headerHeight) {
312
- const y = e.nativeEvent.contentOffset.y;
313
- const showY = -headerHeight;
314
- const hideY = -headerHeight + pullSearchHeight;
315
- const pulledDown = (dragStartY.current ?? hideY) <= hideY;
316
- dragStartY.current = null;
317
- if (pulledDown && y <= showY + pullSearchHeight * 0.5) {
318
- deliberatelyOpened.current = true;
319
- if (y <= showY && !refreshing && onRefresh) {
320
- setRefreshing(true);
321
- Promise.resolve(onRefresh()).finally(() => setRefreshing(false));
322
- }
323
- scrollTo(showY, true);
324
- } else if (y < hideY) {
325
- scrollTo(hideY, true);
326
- }
327
- }
328
- externalScrollEndDrag?.(e);
329
- },
330
- [externalScrollEndDrag, headerHeight, onRefresh, pullSearchHeight, refreshing, scrollTo]
331
- );
332
- const handleMomentumScrollEnd = (0, import_react5.useCallback)(
333
- (e) => {
334
- if (pullSearchHeight && headerHeight && !deliberatelyOpened.current && !refreshing) {
335
- const y = e.nativeEvent.contentOffset.y;
336
- const hideY = -headerHeight + pullSearchHeight;
337
- if (y < hideY - 1) scrollTo(hideY, true);
338
- }
339
- deliberatelyOpened.current = false;
340
- externalMomentumScrollEnd?.(e);
341
- },
342
- [externalMomentumScrollEnd, headerHeight, pullSearchHeight, refreshing, scrollTo]
343
- );
344
- const activeListHeader = hasPullSearch && phase === "measuring" ? null : listHeaderComponent;
345
- const hiddenHeader = phase === "measuring" && listHeaderComponent != null ? typeof listHeaderComponent === "function" ? (0, import_react5.createElement)(listHeaderComponent) : listHeaderComponent : null;
346
- return { activeListHeader, handleMomentumScrollEnd, handleScrollBeginDrag, handleScrollEndDrag, hiddenHeader, pullSearchMinHeight: pullSearchHeight ?? 0 };
347
- }
348
-
349
451
  // src/CustomList.tsx
350
452
  var import_jsx_runtime3 = require("react/jsx-runtime");
351
453
  var CustomListInner = ({ chipProps, chipThreshold, component: List, renderFilters, footerFixed: footerFixedProp, gesture, headerFixed: headerFixedProp, keyboardAware, onChipPress, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pullSearchHeight, scrollRef, style, ...props }) => {
352
454
  const { ListHeaderComponent: listHeaderComponent, contentContainerStyle: externalContentContainerStyle, ...restProps } = props;
353
455
  const { chipHidden, chipStyle, containerStyle, contentInset, contentOffset, footerFixed, headerFixed } = useScrollList({ footerFixed: footerFixedProp, headerFixed: headerFixedProp, keyboardAware, pullSearchHeight, style });
456
+ const { listGeneration, onListUnmount } = (0, import_react6.useContext)(ScrollViewContext);
457
+ const capturedGeneration = (0, import_react_native_reanimated6.useSharedValue)(-1);
458
+ (0, import_react6.useLayoutEffect)(() => {
459
+ const generation = listGeneration.value;
460
+ (0, import_react_native_reanimated6.runOnUI)((gen) => {
461
+ "worklet";
462
+ capturedGeneration.value = gen;
463
+ })(generation);
464
+ }, [capturedGeneration, listGeneration]);
465
+ (0, import_react6.useLayoutEffect)(() => () => onListUnmount(), [onListUnmount]);
354
466
  const scrollViewInternal = (0, import_react6.useRef)(null);
355
467
  const handleRef = (0, import_react6.useCallback)(
356
468
  (el) => {
@@ -368,7 +480,10 @@ var CustomListInner = ({ chipProps, chipThreshold, component: List, renderFilter
368
480
  handleScrollBeginDrag,
369
481
  handleScrollEndDrag,
370
482
  hiddenHeader,
371
- pullSearchMinHeight
483
+ onRemountSyncRetry,
484
+ onRemountSynced,
485
+ pullSearchMinHeight,
486
+ remountSyncTarget
372
487
  } = useScrollInit({
373
488
  listHeaderComponent,
374
489
  onMomentumScrollEnd: externalMomentumScrollEnd,
@@ -387,11 +502,7 @@ var CustomListInner = ({ chipProps, chipThreshold, component: List, renderFilter
387
502
  ] });
388
503
  }, [pullSearchHeader, renderFilters]);
389
504
  const contentContainerStyle = (0, import_react6.useMemo)(() => [{ minHeight: import_react_native4.Dimensions.get("window").height - contentInset.top - contentInset.bottom + pullSearchMinHeight }, externalContentContainerStyle], [contentInset.bottom, contentInset.top, externalContentContainerStyle, pullSearchMinHeight]);
390
- const onPullSearchZoneEnter = (0, import_react6.useCallback)(() => {
391
- if (!pullSearchHeight) return;
392
- scrollViewInternal.current?.scrollToOffset({ offset: -contentInset.top + pullSearchHeight, animated: true });
393
- }, [contentInset.top, pullSearchHeight]);
394
- const onScroll = useScrollHandler({ chipHidden, chipThreshold, footerFixed, headerFixed, onPullSearchZoneEnter: pullSearchHeight ? onPullSearchZoneEnter : void 0 });
505
+ const onScroll = useScrollHandler({ capturedGeneration, chipHidden, chipThreshold, footerFixed, headerFixed, listGeneration, onRemountSyncRetry, onRemountSynced, remountSyncTarget });
395
506
  const handleScrollToTop = (0, import_react6.useCallback)(() => {
396
507
  const offset = pullSearchHeight ? -contentInset.top + pullSearchHeight : -contentInset.top;
397
508
  scrollViewInternal.current?.scrollToOffset({ offset, animated: true });
@@ -412,17 +523,16 @@ var styles2 = { measureContainer: { left: 0, opacity: 0, position: "absolute", r
412
523
  var CustomList = (0, import_react6.memo)(CustomListInner);
413
524
 
414
525
  // src/FlatList.tsx
415
- var import_react8 = require("react");
526
+ var import_react9 = require("react");
416
527
  var import_react_native6 = require("react-native");
417
528
  var import_react_native_gesture_handler2 = require("react-native-gesture-handler");
418
- var import_react_native_reanimated6 = __toESM(require("react-native-reanimated"));
419
529
 
420
530
  // src/internal/HorizontalDots.tsx
421
531
  var import_auto_paper2 = require("@rific/auto-paper");
422
532
  var import_react7 = require("react");
423
533
  var import_react_native5 = require("react-native");
424
534
  var import_react_native_paper = require("react-native-paper");
425
- var import_react_native_reanimated5 = __toESM(require("react-native-reanimated"));
535
+ var import_react_native_reanimated7 = __toESM(require("react-native-reanimated"));
426
536
  var import_react_native_safe_area_context2 = require("react-native-safe-area-context");
427
537
  var import_jsx_runtime4 = require("react/jsx-runtime");
428
538
  var DOT_FULL = 8;
@@ -437,15 +547,15 @@ var PILL_HEIGHT = DOT_FULL + PILL_PAD_V * 2;
437
547
  var PILL_RADIUS = PILL_HEIGHT / 2;
438
548
  var PILL_WIDTH = CLIP_WIDTH + PILL_PAD_H * 2;
439
549
  var Dot = ({ activeColor, index, inactiveColor, pageWidth, scrollPosition }) => {
440
- const circleStyle = (0, import_react_native_reanimated5.useAnimatedStyle)(() => {
550
+ const circleStyle = (0, import_react_native_reanimated7.useAnimatedStyle)(() => {
441
551
  const page = scrollPosition.value / pageWidth;
442
552
  const distance = Math.abs(index - page);
443
553
  const t = Math.max(0, Math.min((distance - 0.5) / 2, 1));
444
554
  const size = DOT_FULL + (DOT_SMALL - DOT_FULL) * t;
445
- const backgroundColor = (0, import_react_native_reanimated5.interpolateColor)(t, [0, 1], [activeColor, inactiveColor]);
555
+ const backgroundColor = (0, import_react_native_reanimated7.interpolateColor)(t, [0, 1], [activeColor, inactiveColor]);
446
556
  return { backgroundColor, borderRadius: size / 2, height: size, width: size };
447
557
  });
448
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native5.View, { style: styles3.dotContainer, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_reanimated5.default.View, { style: circleStyle }) });
558
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native5.View, { style: styles3.dotContainer, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_reanimated7.default.View, { style: circleStyle }) });
449
559
  };
450
560
  var HorizontalDots = ({ total }) => {
451
561
  const { blur, footerHeightShared, scrollPosition } = (0, import_react7.useContext)(ScrollViewContext);
@@ -455,18 +565,18 @@ var HorizontalDots = ({ total }) => {
455
565
  const insetsBottom = insets.bottom;
456
566
  const activeColor = theme.colors.primary;
457
567
  const inactiveColor = theme.colors.outlineVariant;
458
- const pillContainerStyle = (0, import_react_native_reanimated5.useAnimatedStyle)(() => ({
568
+ const pillContainerStyle = (0, import_react_native_reanimated7.useAnimatedStyle)(() => ({
459
569
  bottom: Math.max(footerHeightShared.value, insetsBottom) + 8
460
570
  }));
461
- const rowStyle = (0, import_react_native_reanimated5.useAnimatedStyle)(() => {
571
+ const rowStyle = (0, import_react_native_reanimated7.useAnimatedStyle)(() => {
462
572
  const page = scrollPosition.value / width;
463
573
  const maxOffset = Math.max(0, (total - CLIP_COUNT) * DOT_STEP);
464
574
  const offset = Math.max(0, Math.min((page - (CLIP_COUNT - 1) / 2) * DOT_STEP, maxOffset));
465
575
  return { transform: [{ translateX: -offset }] };
466
576
  });
467
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_reanimated5.default.View, { pointerEvents: "none", style: [styles3.pillContainer, pillContainerStyle], children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native5.View, { style: styles3.pill, children: [
577
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_reanimated7.default.View, { pointerEvents: "none", style: [styles3.pillContainer, pillContainerStyle], children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_native5.View, { style: styles3.pill, children: [
468
578
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_auto_paper2.BlurView, { blur, style: import_react_native5.StyleSheet.absoluteFill }),
469
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native5.View, { style: styles3.dotsClip, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_reanimated5.default.View, { style: [styles3.dotsRow, rowStyle], children: Array.from({ length: total }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Dot, { activeColor, index: i, inactiveColor, pageWidth: width, scrollPosition }, i)) }) })
579
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native5.View, { style: styles3.dotsClip, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_reanimated7.default.View, { style: [styles3.dotsRow, rowStyle], children: Array.from({ length: total }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Dot, { activeColor, index: i, inactiveColor, pageWidth: width, scrollPosition }, i)) }) })
470
580
  ] }) });
471
581
  };
472
582
  var styles3 = import_react_native5.StyleSheet.create({
@@ -481,1750 +591,382 @@ var styles3 = import_react_native5.StyleSheet.create({
481
591
  overflow: "hidden",
482
592
  width: PILL_WIDTH
483
593
  },
484
- pillContainer: { alignItems: "center", left: 0, position: "absolute", right: 0, zIndex: 3 }
485
- });
486
-
487
- // src/FlatList.tsx
488
- var import_jsx_runtime5 = require("react/jsx-runtime");
489
- var FlatListInner = ({ chipProps, chipThreshold, contentContainerStyle: externalContentContainerStyle, data, initialNumToRender = 20, maxToRenderPerBatch = 50, renderFilters, footerFixed: footerFixedProp, gesture, headerFixed: headerFixedProp, horizontal, keyboardAware, ListHeaderComponent: externalListHeaderComponent, onChipPress, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pagingEnabled, pullSearchHeight, removeClippedSubviews = false, showsHorizontalScrollIndicator, showsVerticalScrollIndicator, style, onContentSizeChange, ref: externalRef, windowSize = 100, ...props }) => {
490
- const scrollView = (0, import_react8.useRef)(null);
491
- const isHorizontal = horizontal === true;
492
- const showDots = isHorizontal && pagingEnabled === true && (data?.length ?? 0) > 1;
493
- const { chipHidden, chipStyle, containerStyle, contentInset, contentOffset, footerFixed, headerFixed } = useScrollList({ footerFixed: footerFixedProp, headerFixed: headerFixedProp, isHorizontal, keyboardAware, pullSearchHeight, style });
494
- const scrollTo = (0, import_react8.useCallback)((offset, animated) => {
495
- scrollView.current?.scrollToOffset({ offset, animated });
496
- }, []);
497
- const {
498
- activeListHeader: pullSearchHeader,
499
- handleMomentumScrollEnd,
500
- handleScrollBeginDrag,
501
- handleScrollEndDrag,
502
- hiddenHeader,
503
- pullSearchMinHeight
504
- } = useScrollInit({
505
- listHeaderComponent: externalListHeaderComponent,
506
- onMomentumScrollEnd: externalMomentumScrollEnd,
507
- onRefresh: pullSearchHeight ? onRefresh : void 0,
508
- onScrollBeginDrag: externalScrollBeginDrag,
509
- onScrollEndDrag: externalScrollEndDrag,
510
- pullSearchHeight,
511
- scrollTo
512
- });
513
- const activeListHeader = (0, import_react8.useMemo)(() => {
514
- if (!renderFilters) return pullSearchHeader;
515
- const Inner = pullSearchHeader;
516
- return () => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
517
- Inner ? typeof Inner === "function" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Inner, {}) : Inner : null,
518
- renderFilters
519
- ] });
520
- }, [pullSearchHeader, renderFilters]);
521
- const contentContainerStyle = (0, import_react8.useMemo)(() => isHorizontal ? externalContentContainerStyle : [{ minHeight: import_react_native6.Dimensions.get("window").height - contentInset.top - contentInset.bottom + pullSearchMinHeight }, externalContentContainerStyle], [isHorizontal, contentInset.bottom, contentInset.top, externalContentContainerStyle, pullSearchMinHeight]);
522
- const onPullSearchZoneEnter = (0, import_react8.useCallback)(() => {
523
- if (!pullSearchHeight) return;
524
- scrollView.current?.scrollToOffset({ offset: -contentInset.top + pullSearchHeight, animated: true });
525
- }, [contentInset.top, pullSearchHeight]);
526
- const handleScroll = useScrollHandler({ chipHidden, chipThreshold, footerFixed, headerFixed, isHorizontal, onPullSearchZoneEnter: pullSearchHeight ? onPullSearchZoneEnter : void 0 });
527
- const handleScrollToTop = (0, import_react8.useCallback)(() => {
528
- if (isHorizontal) {
529
- scrollView.current?.scrollToOffset({ offset: 0, animated: true });
530
- return;
531
- }
532
- const offset = pullSearchHeight ? -contentInset.top + pullSearchHeight : -contentInset.top;
533
- scrollView.current?.scrollToOffset({ offset, animated: true });
534
- }, [isHorizontal, contentInset.top, pullSearchHeight]);
535
- const handleContentSizeChange = (0, import_react8.useCallback)(
536
- (w, h) => {
537
- if (onContentSizeChange) onContentSizeChange(w, h);
538
- },
539
- [onContentSizeChange]
540
- );
541
- const refreshControl = (0, import_react8.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RefreshControl, {}), []);
542
- const nativeGesture = (0, import_react8.useMemo)(() => import_react_native_gesture_handler2.Gesture.Native(), []);
543
- const combinedGesture = (0, import_react8.useMemo)(() => gesture !== void 0 ? import_react_native_gesture_handler2.Gesture.Simultaneous(gesture, nativeGesture) : nativeGesture, [gesture, nativeGesture]);
544
- const detectorGesture = gesture !== void 0 ? combinedGesture : void 0;
545
- const content = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react_native6.View, { style: containerStyle, children: [
546
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
547
- import_react_native_reanimated6.default.FlatList,
548
- {
549
- ...props,
550
- contentContainerStyle,
551
- contentInset,
552
- contentOffset,
553
- data,
554
- horizontal: isHorizontal,
555
- initialNumToRender,
556
- ListHeaderComponent: activeListHeader,
557
- maxToRenderPerBatch,
558
- onContentSizeChange: handleContentSizeChange,
559
- onMomentumScrollEnd: handleMomentumScrollEnd,
560
- onScroll: handleScroll,
561
- onScrollBeginDrag: handleScrollBeginDrag,
562
- onScrollEndDrag: handleScrollEndDrag,
563
- pagingEnabled,
564
- ref: (el) => {
565
- if (externalRef) externalRef.current = el;
566
- scrollView.current = el;
567
- },
568
- refreshControl,
569
- removeClippedSubviews,
570
- scrollEventThrottle: 16,
571
- showsHorizontalScrollIndicator: showsHorizontalScrollIndicator ?? isHorizontal,
572
- showsVerticalScrollIndicator: showsVerticalScrollIndicator ?? !isHorizontal,
573
- windowSize
574
- }
575
- ),
576
- hiddenHeader && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native6.View, { pointerEvents: "none", style: styles4.measureContainer, children: hiddenHeader }),
577
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ScrollViewChip, { chipProps, isHorizontal, onChipPress, onPress: handleScrollToTop, style: chipStyle }),
578
- showDots && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(HorizontalDots, { total: data?.length ?? 0 })
579
- ] });
580
- return detectorGesture ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native_gesture_handler2.GestureDetector, { gesture: detectorGesture, children: content }) : content;
581
- };
582
- var styles4 = { measureContainer: { left: 0, opacity: 0, position: "absolute", right: 0, top: -9999 } };
583
- var FlatList = (0, import_react8.memo)(FlatListInner);
584
-
585
- // src/PullSearch.tsx
586
- var import_react9 = require("react");
587
- var import_react_native7 = require("react-native");
588
- var import_react_native_paper2 = require("react-native-paper");
589
- var import_react_native_reanimated7 = __toESM(require("react-native-reanimated"));
590
- var import_jsx_runtime6 = require("react/jsx-runtime");
591
- var PullSearch = (0, import_react9.forwardRef)(function PullSearch2({ debounce, onChangeText, onHeightChange, placeholder, value: propValue }, ref) {
592
- const { headerHeight, scrollPosition } = (0, import_react9.useContext)(ScrollViewContext);
593
- const theme = (0, import_react_native_paper2.useTheme)();
594
- const inputRef = (0, import_react9.useRef)(null);
595
- const [barHeight, setBarHeight] = (0, import_react9.useState)(0);
596
- const [value, setValue] = (0, import_react9.useState)(propValue ?? "");
597
- const prevPropValueRef = (0, import_react9.useRef)(propValue);
598
- (0, import_react9.useEffect)(() => {
599
- if (prevPropValueRef.current === propValue) return;
600
- prevPropValueRef.current = propValue;
601
- setValue(propValue ?? "");
602
- }, [propValue]);
603
- (0, import_react9.useImperativeHandle)(ref, () => ({
604
- blur: () => inputRef.current?.blur(),
605
- focus: () => inputRef.current?.focus()
606
- }));
607
- const blurInput = (0, import_react9.useCallback)(() => inputRef.current?.blur(), []);
608
- (0, import_react_native_reanimated7.useAnimatedReaction)(
609
- () => {
610
- if (barHeight === 0) return false;
611
- return scrollPosition.value >= -headerHeight + barHeight;
612
- },
613
- (isHidden, wasHidden) => {
614
- if (isHidden && !wasHidden) (0, import_react_native_reanimated7.runOnJS)(blurInput)();
615
- },
616
- [barHeight, headerHeight, blurInput]
617
- );
618
- const handleClear = (0, import_react9.useCallback)(() => {
619
- setValue("");
620
- onChangeText("");
621
- }, [onChangeText]);
622
- const handleLayout = (0, import_react9.useCallback)(
623
- ({
624
- nativeEvent: {
625
- layout: { height }
626
- }
627
- }) => {
628
- setBarHeight(height);
629
- onHeightChange(height);
630
- },
631
- [onHeightChange]
632
- );
633
- (0, import_react9.useEffect)(() => {
634
- const normalizedValue = value.trim();
635
- if (debounce) {
636
- const timeout = setTimeout(() => onChangeText(normalizedValue), 500);
637
- return () => clearTimeout(timeout);
638
- }
639
- onChangeText(normalizedValue);
640
- }, [debounce, onChangeText, value]);
641
- const animatedStyle = (0, import_react_native_reanimated7.useAnimatedStyle)(() => {
642
- if (barHeight === 0) return { opacity: 0 };
643
- const showY = -headerHeight;
644
- const hideY = -headerHeight + barHeight;
645
- return { opacity: (0, import_react_native_reanimated7.interpolate)(scrollPosition.value, [showY, hideY], [1, 0], import_react_native_reanimated7.Extrapolation.CLAMP) };
646
- }, [barHeight, headerHeight]);
647
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native_reanimated7.default.View, { onLayout: handleLayout, style: [styles5.container, animatedStyle], children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native_paper2.Searchbar, { autoCorrect: false, onChangeText: (text) => setValue((text || "").trimStart()), onClearIconPress: handleClear, placeholder, placeholderTextColor: theme.colors.onSurfaceVariant, ref: inputRef, spellCheck: false, style: styles5.input, value }) });
648
- });
649
- var styles5 = import_react_native7.StyleSheet.create({
650
- container: { paddingVertical: 8 },
651
- input: { margin: 0 }
652
- });
653
-
654
- // node_modules/redux/dist/redux.mjs
655
- var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
656
- var ActionTypes = {
657
- INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
658
- REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
659
- PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
660
- };
661
- function isPlainObject(obj) {
662
- if (typeof obj !== "object" || obj === null)
663
- return false;
664
- let proto = obj;
665
- while (Object.getPrototypeOf(proto) !== null) {
666
- proto = Object.getPrototypeOf(proto);
667
- }
668
- return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
669
- }
670
- function compose(...funcs) {
671
- if (funcs.length === 0) {
672
- return (arg) => arg;
673
- }
674
- if (funcs.length === 1) {
675
- return funcs[0];
676
- }
677
- return funcs.reduce((a, b) => (...args) => a(b(...args)));
678
- }
679
- function isAction(action) {
680
- return isPlainObject(action) && "type" in action && typeof action.type === "string";
681
- }
682
-
683
- // node_modules/immer/dist/immer.mjs
684
- var NOTHING = /* @__PURE__ */ Symbol.for("immer-nothing");
685
- var DRAFTABLE = /* @__PURE__ */ Symbol.for("immer-draftable");
686
- var DRAFT_STATE = /* @__PURE__ */ Symbol.for("immer-state");
687
- var errors = process.env.NODE_ENV !== "production" ? [
688
- // All error codes, starting by 0:
689
- function(plugin) {
690
- return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`;
691
- },
692
- function(thing) {
693
- return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`;
694
- },
695
- "This object has been frozen and should not be mutated",
696
- function(data) {
697
- return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + data;
698
- },
699
- "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
700
- "Immer forbids circular references",
701
- "The first or second argument to `produce` must be a function",
702
- "The third argument to `produce` must be a function or undefined",
703
- "First argument to `createDraft` must be a plain object, an array, or an immerable object",
704
- "First argument to `finishDraft` must be a draft returned by `createDraft`",
705
- function(thing) {
706
- return `'current' expects a draft, got: ${thing}`;
707
- },
708
- "Object.defineProperty() cannot be used on an Immer draft",
709
- "Object.setPrototypeOf() cannot be used on an Immer draft",
710
- "Immer only supports deleting array indices",
711
- "Immer only supports setting array indices and the 'length' property",
712
- function(thing) {
713
- return `'original' expects a draft, got: ${thing}`;
714
- }
715
- // Note: if more errors are added, the errorOffset in Patches.ts should be increased
716
- // See Patches.ts for additional errors
717
- ] : [];
718
- function die(error, ...args) {
719
- if (process.env.NODE_ENV !== "production") {
720
- const e = errors[error];
721
- const msg = isFunction(e) ? e.apply(null, args) : e;
722
- throw new Error(`[Immer] ${msg}`);
723
- }
724
- throw new Error(
725
- `[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`
726
- );
727
- }
728
- var O = Object;
729
- var getPrototypeOf = O.getPrototypeOf;
730
- var CONSTRUCTOR = "constructor";
731
- var PROTOTYPE = "prototype";
732
- var CONFIGURABLE = "configurable";
733
- var ENUMERABLE = "enumerable";
734
- var WRITABLE = "writable";
735
- var VALUE = "value";
736
- var isDraft = (value) => !!value && !!value[DRAFT_STATE];
737
- function isDraftable(value) {
738
- if (!value)
739
- return false;
740
- return isPlainObject2(value) || isArray(value) || !!value[DRAFTABLE] || !!value[CONSTRUCTOR]?.[DRAFTABLE] || isMap(value) || isSet(value);
741
- }
742
- var objectCtorString = O[PROTOTYPE][CONSTRUCTOR].toString();
743
- var cachedCtorStrings = /* @__PURE__ */ new WeakMap();
744
- function isPlainObject2(value) {
745
- if (!value || !isObjectish(value))
746
- return false;
747
- const proto = getPrototypeOf(value);
748
- if (proto === null || proto === O[PROTOTYPE])
749
- return true;
750
- const Ctor = O.hasOwnProperty.call(proto, CONSTRUCTOR) && proto[CONSTRUCTOR];
751
- if (Ctor === Object)
752
- return true;
753
- if (!isFunction(Ctor))
754
- return false;
755
- let ctorString = cachedCtorStrings.get(Ctor);
756
- if (ctorString === void 0) {
757
- ctorString = Function.toString.call(Ctor);
758
- cachedCtorStrings.set(Ctor, ctorString);
759
- }
760
- return ctorString === objectCtorString;
761
- }
762
- function each(obj, iter, strict = true) {
763
- if (getArchtype(obj) === 0) {
764
- const keys = strict ? Reflect.ownKeys(obj) : O.keys(obj);
765
- keys.forEach((key) => {
766
- iter(key, obj[key], obj);
767
- });
768
- } else {
769
- obj.forEach((entry, index) => iter(index, entry, obj));
770
- }
771
- }
772
- function getArchtype(thing) {
773
- const state = thing[DRAFT_STATE];
774
- return state ? state.type_ : isArray(thing) ? 1 : isMap(thing) ? 2 : isSet(thing) ? 3 : 0;
775
- }
776
- var has = (thing, prop, type = getArchtype(thing)) => type === 2 ? thing.has(prop) : O[PROTOTYPE].hasOwnProperty.call(thing, prop);
777
- var get = (thing, prop, type = getArchtype(thing)) => (
778
- // @ts-ignore
779
- type === 2 ? thing.get(prop) : thing[prop]
780
- );
781
- var set = (thing, propOrOldValue, value, type = getArchtype(thing)) => {
782
- if (type === 2)
783
- thing.set(propOrOldValue, value);
784
- else if (type === 3) {
785
- thing.add(value);
786
- } else
787
- thing[propOrOldValue] = value;
788
- };
789
- function is(x, y) {
790
- if (x === y) {
791
- return x !== 0 || 1 / x === 1 / y;
792
- } else {
793
- return x !== x && y !== y;
794
- }
795
- }
796
- var isArray = Array.isArray;
797
- var isMap = (target) => target instanceof Map;
798
- var isSet = (target) => target instanceof Set;
799
- var isObjectish = (target) => typeof target === "object";
800
- var isFunction = (target) => typeof target === "function";
801
- var isBoolean = (target) => typeof target === "boolean";
802
- function isArrayIndex(value) {
803
- const n = +value;
804
- return Number.isInteger(n) && String(n) === value;
805
- }
806
- var latest = (state) => state.copy_ || state.base_;
807
- var getFinalValue = (state) => state.modified_ ? state.copy_ : state.base_;
808
- function shallowCopy(base, strict) {
809
- if (isMap(base)) {
810
- return new Map(base);
811
- }
812
- if (isSet(base)) {
813
- return new Set(base);
814
- }
815
- if (isArray(base))
816
- return Array[PROTOTYPE].slice.call(base);
817
- const isPlain = isPlainObject2(base);
818
- if (strict === true || strict === "class_only" && !isPlain) {
819
- const descriptors = O.getOwnPropertyDescriptors(base);
820
- delete descriptors[DRAFT_STATE];
821
- let keys = Reflect.ownKeys(descriptors);
822
- for (let i = 0; i < keys.length; i++) {
823
- const key = keys[i];
824
- const desc = descriptors[key];
825
- if (desc[WRITABLE] === false) {
826
- desc[WRITABLE] = true;
827
- desc[CONFIGURABLE] = true;
828
- }
829
- if (desc.get || desc.set)
830
- descriptors[key] = {
831
- [CONFIGURABLE]: true,
832
- [WRITABLE]: true,
833
- // could live with !!desc.set as well here...
834
- [ENUMERABLE]: desc[ENUMERABLE],
835
- [VALUE]: base[key]
836
- };
837
- }
838
- return O.create(getPrototypeOf(base), descriptors);
839
- } else {
840
- const proto = getPrototypeOf(base);
841
- if (proto !== null && isPlain) {
842
- return { ...base };
843
- }
844
- const obj = O.create(proto);
845
- return O.assign(obj, base);
846
- }
847
- }
848
- function freeze(obj, deep = false) {
849
- if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj))
850
- return obj;
851
- if (getArchtype(obj) > 1) {
852
- O.defineProperties(obj, {
853
- set: dontMutateMethodOverride,
854
- add: dontMutateMethodOverride,
855
- clear: dontMutateMethodOverride,
856
- delete: dontMutateMethodOverride
857
- });
858
- }
859
- O.freeze(obj);
860
- if (deep)
861
- each(
862
- obj,
863
- (_key, value) => {
864
- freeze(value, true);
865
- },
866
- false
867
- );
868
- return obj;
869
- }
870
- function dontMutateFrozenCollections() {
871
- die(2);
872
- }
873
- var dontMutateMethodOverride = {
874
- [VALUE]: dontMutateFrozenCollections
875
- };
876
- function isFrozen(obj) {
877
- if (obj === null || !isObjectish(obj))
878
- return true;
879
- return O.isFrozen(obj);
880
- }
881
- var PluginMapSet = "MapSet";
882
- var PluginPatches = "Patches";
883
- var PluginArrayMethods = "ArrayMethods";
884
- var plugins = {};
885
- function getPlugin(pluginKey) {
886
- const plugin = plugins[pluginKey];
887
- if (!plugin) {
888
- die(0, pluginKey);
889
- }
890
- return plugin;
891
- }
892
- var isPluginLoaded = (pluginKey) => !!plugins[pluginKey];
893
- var currentScope;
894
- var getCurrentScope = () => currentScope;
895
- var createScope = (parent_, immer_) => ({
896
- drafts_: [],
897
- parent_,
898
- immer_,
899
- // Whenever the modified draft contains a draft from another scope, we
900
- // need to prevent auto-freezing so the unowned draft can be finalized.
901
- canAutoFreeze_: true,
902
- unfinalizedDrafts_: 0,
903
- handledSet_: /* @__PURE__ */ new Set(),
904
- processedForPatches_: /* @__PURE__ */ new Set(),
905
- mapSetPlugin_: isPluginLoaded(PluginMapSet) ? getPlugin(PluginMapSet) : void 0,
906
- arrayMethodsPlugin_: isPluginLoaded(PluginArrayMethods) ? getPlugin(PluginArrayMethods) : void 0
907
- });
908
- function usePatchesInScope(scope, patchListener) {
909
- if (patchListener) {
910
- scope.patchPlugin_ = getPlugin(PluginPatches);
911
- scope.patches_ = [];
912
- scope.inversePatches_ = [];
913
- scope.patchListener_ = patchListener;
914
- }
915
- }
916
- function revokeScope(scope) {
917
- leaveScope(scope);
918
- scope.drafts_.forEach(revokeDraft);
919
- scope.drafts_ = null;
920
- }
921
- function leaveScope(scope) {
922
- if (scope === currentScope) {
923
- currentScope = scope.parent_;
924
- }
925
- }
926
- var enterScope = (immer2) => currentScope = createScope(currentScope, immer2);
927
- function revokeDraft(draft) {
928
- const state = draft[DRAFT_STATE];
929
- if (state.type_ === 0 || state.type_ === 1)
930
- state.revoke_();
931
- else
932
- state.revoked_ = true;
933
- }
934
- function processResult(result, scope) {
935
- scope.unfinalizedDrafts_ = scope.drafts_.length;
936
- const baseDraft = scope.drafts_[0];
937
- const isReplaced = result !== void 0 && result !== baseDraft;
938
- if (isReplaced) {
939
- if (baseDraft[DRAFT_STATE].modified_) {
940
- revokeScope(scope);
941
- die(4);
942
- }
943
- if (isDraftable(result)) {
944
- result = finalize(scope, result);
945
- }
946
- const { patchPlugin_ } = scope;
947
- if (patchPlugin_) {
948
- patchPlugin_.generateReplacementPatches_(
949
- baseDraft[DRAFT_STATE].base_,
950
- result,
951
- scope
952
- );
953
- }
954
- } else {
955
- result = finalize(scope, baseDraft);
956
- }
957
- maybeFreeze(scope, result, true);
958
- revokeScope(scope);
959
- if (scope.patches_) {
960
- scope.patchListener_(scope.patches_, scope.inversePatches_);
961
- }
962
- return result !== NOTHING ? result : void 0;
963
- }
964
- function finalize(rootScope, value) {
965
- if (isFrozen(value))
966
- return value;
967
- const state = value[DRAFT_STATE];
968
- if (!state) {
969
- const finalValue = handleValue(value, rootScope.handledSet_, rootScope);
970
- return finalValue;
971
- }
972
- if (!isSameScope(state, rootScope)) {
973
- return value;
974
- }
975
- if (!state.modified_) {
976
- return state.base_;
977
- }
978
- if (!state.finalized_) {
979
- const { callbacks_ } = state;
980
- if (callbacks_) {
981
- while (callbacks_.length > 0) {
982
- const callback = callbacks_.pop();
983
- callback(rootScope);
984
- }
985
- }
986
- generatePatchesAndFinalize(state, rootScope);
987
- }
988
- return state.copy_;
989
- }
990
- function maybeFreeze(scope, value, deep = false) {
991
- if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {
992
- freeze(value, deep);
993
- }
994
- }
995
- function markStateFinalized(state) {
996
- state.finalized_ = true;
997
- state.scope_.unfinalizedDrafts_--;
998
- }
999
- var isSameScope = (state, rootScope) => state.scope_ === rootScope;
1000
- var EMPTY_LOCATIONS_RESULT = [];
1001
- function updateDraftInParent(parent, draftValue, finalizedValue, originalKey) {
1002
- const parentCopy = latest(parent);
1003
- const parentType = parent.type_;
1004
- if (originalKey !== void 0) {
1005
- const currentValue = get(parentCopy, originalKey, parentType);
1006
- if (currentValue === draftValue) {
1007
- set(parentCopy, originalKey, finalizedValue, parentType);
1008
- return;
1009
- }
1010
- }
1011
- if (!parent.draftLocations_) {
1012
- const draftLocations = parent.draftLocations_ = /* @__PURE__ */ new Map();
1013
- each(parentCopy, (key, value) => {
1014
- if (isDraft(value)) {
1015
- const keys = draftLocations.get(value) || [];
1016
- keys.push(key);
1017
- draftLocations.set(value, keys);
1018
- }
1019
- });
1020
- }
1021
- const locations = parent.draftLocations_.get(draftValue) ?? EMPTY_LOCATIONS_RESULT;
1022
- for (const location of locations) {
1023
- set(parentCopy, location, finalizedValue, parentType);
1024
- }
1025
- }
1026
- function registerChildFinalizationCallback(parent, child, key) {
1027
- parent.callbacks_.push(function childCleanup(rootScope) {
1028
- const state = child;
1029
- if (!state || !isSameScope(state, rootScope)) {
1030
- return;
1031
- }
1032
- rootScope.mapSetPlugin_?.fixSetContents(state);
1033
- const finalizedValue = getFinalValue(state);
1034
- updateDraftInParent(parent, state.draft_ ?? state, finalizedValue, key);
1035
- generatePatchesAndFinalize(state, rootScope);
1036
- });
1037
- }
1038
- function generatePatchesAndFinalize(state, rootScope) {
1039
- const shouldFinalize = state.modified_ && !state.finalized_ && (state.type_ === 3 || state.type_ === 1 && state.allIndicesReassigned_ || (state.assigned_?.size ?? 0) > 0);
1040
- if (shouldFinalize) {
1041
- const { patchPlugin_ } = rootScope;
1042
- if (patchPlugin_) {
1043
- const basePath = patchPlugin_.getPath(state);
1044
- if (basePath) {
1045
- patchPlugin_.generatePatches_(state, basePath, rootScope);
1046
- }
1047
- }
1048
- markStateFinalized(state);
1049
- }
1050
- }
1051
- function handleCrossReference(target, key, value) {
1052
- const { scope_ } = target;
1053
- if (isDraft(value)) {
1054
- const state = value[DRAFT_STATE];
1055
- if (isSameScope(state, scope_)) {
1056
- state.callbacks_.push(function crossReferenceCleanup() {
1057
- prepareCopy(target);
1058
- const finalizedValue = getFinalValue(state);
1059
- updateDraftInParent(target, value, finalizedValue, key);
1060
- });
1061
- }
1062
- } else if (isDraftable(value)) {
1063
- target.callbacks_.push(function nestedDraftCleanup() {
1064
- const targetCopy = latest(target);
1065
- if (target.type_ === 3) {
1066
- if (targetCopy.has(value)) {
1067
- handleValue(value, scope_.handledSet_, scope_);
1068
- }
1069
- } else {
1070
- if (get(targetCopy, key, target.type_) === value) {
1071
- if (scope_.drafts_.length > 1 && (target.assigned_.get(key) ?? false) === true && target.copy_) {
1072
- handleValue(
1073
- get(target.copy_, key, target.type_),
1074
- scope_.handledSet_,
1075
- scope_
1076
- );
1077
- }
1078
- }
1079
- }
1080
- });
1081
- }
1082
- }
1083
- function handleValue(target, handledSet, rootScope) {
1084
- if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
1085
- return target;
1086
- }
1087
- if (isDraft(target) || handledSet.has(target) || !isDraftable(target) || isFrozen(target)) {
1088
- return target;
1089
- }
1090
- handledSet.add(target);
1091
- each(target, (key, value) => {
1092
- if (isDraft(value)) {
1093
- const state = value[DRAFT_STATE];
1094
- if (isSameScope(state, rootScope)) {
1095
- const updatedValue = getFinalValue(state);
1096
- set(target, key, updatedValue, target.type_);
1097
- markStateFinalized(state);
1098
- }
1099
- } else if (isDraftable(value)) {
1100
- handleValue(value, handledSet, rootScope);
1101
- }
1102
- });
1103
- return target;
1104
- }
1105
- function createProxyProxy(base, parent) {
1106
- const baseIsArray = isArray(base);
1107
- const state = {
1108
- type_: baseIsArray ? 1 : 0,
1109
- // Track which produce call this is associated with.
1110
- scope_: parent ? parent.scope_ : getCurrentScope(),
1111
- // True for both shallow and deep changes.
1112
- modified_: false,
1113
- // Used during finalization.
1114
- finalized_: false,
1115
- // Track which properties have been assigned (true) or deleted (false).
1116
- // actually instantiated in `prepareCopy()`
1117
- assigned_: void 0,
1118
- // The parent draft state.
1119
- parent_: parent,
1120
- // The base state.
1121
- base_: base,
1122
- // The base proxy.
1123
- draft_: null,
1124
- // set below
1125
- // The base copy with any updated values.
1126
- copy_: null,
1127
- // Called by the `produce` function.
1128
- revoke_: null,
1129
- isManual_: false,
1130
- // `callbacks` actually gets assigned in `createProxy`
1131
- callbacks_: void 0
1132
- };
1133
- let target = state;
1134
- let traps = objectTraps;
1135
- if (baseIsArray) {
1136
- target = [state];
1137
- traps = arrayTraps;
1138
- }
1139
- const { revoke, proxy } = Proxy.revocable(target, traps);
1140
- state.draft_ = proxy;
1141
- state.revoke_ = revoke;
1142
- return [proxy, state];
1143
- }
1144
- var objectTraps = {
1145
- get(state, prop) {
1146
- if (prop === DRAFT_STATE)
1147
- return state;
1148
- let arrayPlugin = state.scope_.arrayMethodsPlugin_;
1149
- const isArrayWithStringProp = state.type_ === 1 && typeof prop === "string";
1150
- if (isArrayWithStringProp) {
1151
- if (arrayPlugin?.isArrayOperationMethod(prop)) {
1152
- return arrayPlugin.createMethodInterceptor(state, prop);
1153
- }
1154
- }
1155
- const source = latest(state);
1156
- if (!has(source, prop, state.type_)) {
1157
- return readPropFromProto(state, source, prop);
1158
- }
1159
- const value = source[prop];
1160
- if (state.finalized_ || !isDraftable(value)) {
1161
- return value;
1162
- }
1163
- if (isArrayWithStringProp && state.operationMethod && arrayPlugin?.isMutatingArrayMethod(
1164
- state.operationMethod
1165
- ) && isArrayIndex(prop)) {
1166
- return value;
1167
- }
1168
- if (value === peek(state.base_, prop)) {
1169
- prepareCopy(state);
1170
- const childKey = state.type_ === 1 ? +prop : prop;
1171
- const childDraft = createProxy(state.scope_, value, state, childKey);
1172
- return state.copy_[childKey] = childDraft;
1173
- }
1174
- return value;
1175
- },
1176
- has(state, prop) {
1177
- return prop in latest(state);
1178
- },
1179
- ownKeys(state) {
1180
- return Reflect.ownKeys(latest(state));
1181
- },
1182
- set(state, prop, value) {
1183
- const desc = getDescriptorFromProto(latest(state), prop);
1184
- if (desc?.set) {
1185
- desc.set.call(state.draft_, value);
1186
- return true;
1187
- }
1188
- if (!state.modified_) {
1189
- const current2 = peek(latest(state), prop);
1190
- const currentState = current2?.[DRAFT_STATE];
1191
- if (currentState && currentState.base_ === value) {
1192
- state.copy_[prop] = value;
1193
- state.assigned_.set(prop, false);
1194
- return true;
1195
- }
1196
- if (is(value, current2) && (value !== void 0 || has(state.base_, prop, state.type_)))
1197
- return true;
1198
- prepareCopy(state);
1199
- markChanged(state);
1200
- }
1201
- if (state.copy_[prop] === value && // special case: handle new props with value 'undefined'
1202
- (value !== void 0 || prop in state.copy_) || // special case: NaN
1203
- Number.isNaN(value) && Number.isNaN(state.copy_[prop]))
1204
- return true;
1205
- state.copy_[prop] = value;
1206
- state.assigned_.set(prop, true);
1207
- handleCrossReference(state, prop, value);
1208
- return true;
1209
- },
1210
- deleteProperty(state, prop) {
1211
- prepareCopy(state);
1212
- if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
1213
- state.assigned_.set(prop, false);
1214
- markChanged(state);
1215
- } else {
1216
- state.assigned_.delete(prop);
1217
- }
1218
- if (state.copy_) {
1219
- delete state.copy_[prop];
1220
- }
1221
- return true;
1222
- },
1223
- // Note: We never coerce `desc.value` into an Immer draft, because we can't make
1224
- // the same guarantee in ES5 mode.
1225
- getOwnPropertyDescriptor(state, prop) {
1226
- const owner = latest(state);
1227
- const desc = Reflect.getOwnPropertyDescriptor(owner, prop);
1228
- if (!desc)
1229
- return desc;
1230
- return {
1231
- [WRITABLE]: true,
1232
- [CONFIGURABLE]: state.type_ !== 1 || prop !== "length",
1233
- [ENUMERABLE]: desc[ENUMERABLE],
1234
- [VALUE]: owner[prop]
1235
- };
1236
- },
1237
- defineProperty() {
1238
- die(11);
1239
- },
1240
- getPrototypeOf(state) {
1241
- return getPrototypeOf(state.base_);
1242
- },
1243
- setPrototypeOf() {
1244
- die(12);
1245
- }
1246
- };
1247
- var arrayTraps = {};
1248
- for (let key in objectTraps) {
1249
- let fn = objectTraps[key];
1250
- arrayTraps[key] = function() {
1251
- const args = arguments;
1252
- args[0] = args[0][0];
1253
- return fn.apply(this, args);
1254
- };
1255
- }
1256
- arrayTraps.deleteProperty = function(state, prop) {
1257
- if (process.env.NODE_ENV !== "production" && isNaN(parseInt(prop)))
1258
- die(13);
1259
- return arrayTraps.set.call(this, state, prop, void 0);
1260
- };
1261
- arrayTraps.set = function(state, prop, value) {
1262
- if (process.env.NODE_ENV !== "production" && prop !== "length" && isNaN(parseInt(prop)))
1263
- die(14);
1264
- return objectTraps.set.call(this, state[0], prop, value, state[0]);
1265
- };
1266
- function peek(draft, prop) {
1267
- const state = draft[DRAFT_STATE];
1268
- const source = state ? latest(state) : draft;
1269
- return source[prop];
1270
- }
1271
- function readPropFromProto(state, source, prop) {
1272
- const desc = getDescriptorFromProto(source, prop);
1273
- return desc ? VALUE in desc ? desc[VALUE] : (
1274
- // This is a very special case, if the prop is a getter defined by the
1275
- // prototype, we should invoke it with the draft as context!
1276
- desc.get?.call(state.draft_)
1277
- ) : void 0;
1278
- }
1279
- function getDescriptorFromProto(source, prop) {
1280
- if (!(prop in source))
1281
- return void 0;
1282
- let proto = getPrototypeOf(source);
1283
- while (proto) {
1284
- const desc = Object.getOwnPropertyDescriptor(proto, prop);
1285
- if (desc)
1286
- return desc;
1287
- proto = getPrototypeOf(proto);
1288
- }
1289
- return void 0;
1290
- }
1291
- function markChanged(state) {
1292
- if (!state.modified_) {
1293
- state.modified_ = true;
1294
- if (state.parent_) {
1295
- markChanged(state.parent_);
1296
- }
1297
- }
1298
- }
1299
- function prepareCopy(state) {
1300
- if (!state.copy_) {
1301
- state.assigned_ = /* @__PURE__ */ new Map();
1302
- state.copy_ = shallowCopy(
1303
- state.base_,
1304
- state.scope_.immer_.useStrictShallowCopy_
1305
- );
1306
- }
1307
- }
1308
- var Immer2 = class {
1309
- constructor(config) {
1310
- this.autoFreeze_ = true;
1311
- this.useStrictShallowCopy_ = false;
1312
- this.useStrictIteration_ = false;
1313
- this.produce = (base, recipe, patchListener) => {
1314
- if (isFunction(base) && !isFunction(recipe)) {
1315
- const defaultBase = recipe;
1316
- recipe = base;
1317
- const self = this;
1318
- return function curriedProduce(base2 = defaultBase, ...args) {
1319
- return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
1320
- };
1321
- }
1322
- if (!isFunction(recipe))
1323
- die(6);
1324
- if (patchListener !== void 0 && !isFunction(patchListener))
1325
- die(7);
1326
- let result;
1327
- if (isDraftable(base)) {
1328
- const scope = enterScope(this);
1329
- const proxy = createProxy(scope, base, void 0);
1330
- let hasError = true;
1331
- try {
1332
- result = recipe(proxy);
1333
- hasError = false;
1334
- } finally {
1335
- if (hasError)
1336
- revokeScope(scope);
1337
- else
1338
- leaveScope(scope);
1339
- }
1340
- usePatchesInScope(scope, patchListener);
1341
- return processResult(result, scope);
1342
- } else if (!base || !isObjectish(base)) {
1343
- result = recipe(base);
1344
- if (result === void 0)
1345
- result = base;
1346
- if (result === NOTHING)
1347
- result = void 0;
1348
- if (this.autoFreeze_)
1349
- freeze(result, true);
1350
- if (patchListener) {
1351
- const p = [];
1352
- const ip = [];
1353
- getPlugin(PluginPatches).generateReplacementPatches_(base, result, {
1354
- patches_: p,
1355
- inversePatches_: ip
1356
- });
1357
- patchListener(p, ip);
1358
- }
1359
- return result;
1360
- } else
1361
- die(1, base);
1362
- };
1363
- this.produceWithPatches = (base, recipe) => {
1364
- if (isFunction(base)) {
1365
- return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
1366
- }
1367
- let patches, inversePatches;
1368
- const result = this.produce(base, recipe, (p, ip) => {
1369
- patches = p;
1370
- inversePatches = ip;
1371
- });
1372
- return [result, patches, inversePatches];
1373
- };
1374
- if (isBoolean(config?.autoFreeze))
1375
- this.setAutoFreeze(config.autoFreeze);
1376
- if (isBoolean(config?.useStrictShallowCopy))
1377
- this.setUseStrictShallowCopy(config.useStrictShallowCopy);
1378
- if (isBoolean(config?.useStrictIteration))
1379
- this.setUseStrictIteration(config.useStrictIteration);
1380
- }
1381
- createDraft(base) {
1382
- if (!isDraftable(base))
1383
- die(8);
1384
- if (isDraft(base))
1385
- base = current(base);
1386
- const scope = enterScope(this);
1387
- const proxy = createProxy(scope, base, void 0);
1388
- proxy[DRAFT_STATE].isManual_ = true;
1389
- leaveScope(scope);
1390
- return proxy;
1391
- }
1392
- finishDraft(draft, patchListener) {
1393
- const state = draft && draft[DRAFT_STATE];
1394
- if (!state || !state.isManual_)
1395
- die(9);
1396
- const { scope_: scope } = state;
1397
- usePatchesInScope(scope, patchListener);
1398
- return processResult(void 0, scope);
1399
- }
1400
- /**
1401
- * Pass true to automatically freeze all copies created by Immer.
1402
- *
1403
- * By default, auto-freezing is enabled.
1404
- */
1405
- setAutoFreeze(value) {
1406
- this.autoFreeze_ = value;
1407
- }
1408
- /**
1409
- * Pass true to enable strict shallow copy.
1410
- *
1411
- * By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
1412
- */
1413
- setUseStrictShallowCopy(value) {
1414
- this.useStrictShallowCopy_ = value;
1415
- }
1416
- /**
1417
- * Pass false to use faster iteration that skips non-enumerable properties
1418
- * but still handles symbols for compatibility.
1419
- *
1420
- * By default, strict iteration is enabled (includes all own properties).
1421
- */
1422
- setUseStrictIteration(value) {
1423
- this.useStrictIteration_ = value;
1424
- }
1425
- shouldUseStrictIteration() {
1426
- return this.useStrictIteration_;
1427
- }
1428
- applyPatches(base, patches) {
1429
- let i;
1430
- for (i = patches.length - 1; i >= 0; i--) {
1431
- const patch = patches[i];
1432
- if (patch.path.length === 0 && patch.op === "replace") {
1433
- base = patch.value;
1434
- break;
1435
- }
1436
- }
1437
- if (i > -1) {
1438
- patches = patches.slice(i + 1);
1439
- }
1440
- const applyPatchesImpl = getPlugin(PluginPatches).applyPatches_;
1441
- if (isDraft(base)) {
1442
- return applyPatchesImpl(base, patches);
1443
- }
1444
- return this.produce(
1445
- base,
1446
- (draft) => applyPatchesImpl(draft, patches)
1447
- );
1448
- }
1449
- };
1450
- function createProxy(rootScope, value, parent, key) {
1451
- const [draft, state] = isMap(value) ? getPlugin(PluginMapSet).proxyMap_(value, parent) : isSet(value) ? getPlugin(PluginMapSet).proxySet_(value, parent) : createProxyProxy(value, parent);
1452
- const scope = parent?.scope_ ?? getCurrentScope();
1453
- scope.drafts_.push(draft);
1454
- state.callbacks_ = parent?.callbacks_ ?? [];
1455
- state.key_ = key;
1456
- if (parent && key !== void 0) {
1457
- registerChildFinalizationCallback(parent, state, key);
1458
- } else {
1459
- state.callbacks_.push(function rootDraftCleanup(rootScope2) {
1460
- rootScope2.mapSetPlugin_?.fixSetContents(state);
1461
- const { patchPlugin_ } = rootScope2;
1462
- if (state.modified_ && patchPlugin_) {
1463
- patchPlugin_.generatePatches_(state, [], rootScope2);
1464
- }
1465
- });
1466
- }
1467
- return draft;
1468
- }
1469
- function current(value) {
1470
- if (!isDraft(value))
1471
- die(10, value);
1472
- return currentImpl(value);
1473
- }
1474
- function currentImpl(value) {
1475
- if (!isDraftable(value) || isFrozen(value))
1476
- return value;
1477
- const state = value[DRAFT_STATE];
1478
- let copy;
1479
- let strict = true;
1480
- if (state) {
1481
- if (!state.modified_)
1482
- return state.base_;
1483
- state.finalized_ = true;
1484
- copy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
1485
- strict = state.scope_.immer_.shouldUseStrictIteration();
1486
- } else {
1487
- copy = shallowCopy(value, true);
1488
- }
1489
- each(
1490
- copy,
1491
- (key, childValue) => {
1492
- set(copy, key, currentImpl(childValue));
1493
- },
1494
- strict
1495
- );
1496
- if (state) {
1497
- state.finalized_ = false;
1498
- }
1499
- return copy;
1500
- }
1501
- var immer = new Immer2();
1502
- var produce = immer.produce;
1503
-
1504
- // node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.mjs
1505
- var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function() {
1506
- if (arguments.length === 0) return void 0;
1507
- if (typeof arguments[0] === "object") return compose;
1508
- return compose.apply(null, arguments);
1509
- };
1510
- var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function() {
1511
- return function(noop3) {
1512
- return noop3;
1513
- };
1514
- };
1515
- var hasMatchFunction = (v) => {
1516
- return v && typeof v.match === "function";
1517
- };
1518
- function createAction(type, prepareAction) {
1519
- function actionCreator(...args) {
1520
- if (prepareAction) {
1521
- let prepared = prepareAction(...args);
1522
- if (!prepared) {
1523
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : "prepareAction did not return an object");
1524
- }
1525
- return {
1526
- type,
1527
- payload: prepared.payload,
1528
- ..."meta" in prepared && {
1529
- meta: prepared.meta
1530
- },
1531
- ..."error" in prepared && {
1532
- error: prepared.error
1533
- }
1534
- };
1535
- }
1536
- return {
1537
- type,
1538
- payload: args[0]
1539
- };
1540
- }
1541
- actionCreator.toString = () => `${type}`;
1542
- actionCreator.type = type;
1543
- actionCreator.match = (action) => isAction(action) && action.type === type;
1544
- return actionCreator;
1545
- }
1546
- function freezeDraftable(val) {
1547
- return isDraftable(val) ? produce(val, () => {
1548
- }) : val;
1549
- }
1550
- function getOrInsertComputed(map, key, compute) {
1551
- if (map.has(key)) return map.get(key);
1552
- return map.set(key, compute(key)).get(key);
1553
- }
1554
- function executeReducerBuilderCallback(builderCallback) {
1555
- const actionsMap = {};
1556
- const actionMatchers = [];
1557
- let defaultCaseReducer;
1558
- const builder = {
1559
- addCase(typeOrActionCreator, reducer) {
1560
- if (process.env.NODE_ENV !== "production") {
1561
- if (actionMatchers.length > 0) {
1562
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(26) : "`builder.addCase` should only be called before calling `builder.addMatcher`");
1563
- }
1564
- if (defaultCaseReducer) {
1565
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(27) : "`builder.addCase` should only be called before calling `builder.addDefaultCase`");
1566
- }
1567
- }
1568
- const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
1569
- if (!type) {
1570
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(28) : "`builder.addCase` cannot be called with an empty action type");
1571
- }
1572
- if (type in actionsMap) {
1573
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(29) : `\`builder.addCase\` cannot be called with two reducers for the same action type '${type}'`);
1574
- }
1575
- actionsMap[type] = reducer;
1576
- return builder;
1577
- },
1578
- addAsyncThunk(asyncThunk, reducers) {
1579
- if (process.env.NODE_ENV !== "production") {
1580
- if (defaultCaseReducer) {
1581
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(43) : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
1582
- }
1583
- }
1584
- if (reducers.pending) actionsMap[asyncThunk.pending.type] = reducers.pending;
1585
- if (reducers.rejected) actionsMap[asyncThunk.rejected.type] = reducers.rejected;
1586
- if (reducers.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers.fulfilled;
1587
- if (reducers.settled) actionMatchers.push({
1588
- matcher: asyncThunk.settled,
1589
- reducer: reducers.settled
1590
- });
1591
- return builder;
1592
- },
1593
- addMatcher(matcher, reducer) {
1594
- if (process.env.NODE_ENV !== "production") {
1595
- if (defaultCaseReducer) {
1596
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(30) : "`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
1597
- }
1598
- }
1599
- actionMatchers.push({
1600
- matcher,
1601
- reducer
1602
- });
1603
- return builder;
1604
- },
1605
- addDefaultCase(reducer) {
1606
- if (process.env.NODE_ENV !== "production") {
1607
- if (defaultCaseReducer) {
1608
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(31) : "`builder.addDefaultCase` can only be called once");
1609
- }
1610
- }
1611
- defaultCaseReducer = reducer;
1612
- return builder;
1613
- }
1614
- };
1615
- builderCallback(builder);
1616
- return [actionsMap, actionMatchers, defaultCaseReducer];
1617
- }
1618
- function isStateFunction(x) {
1619
- return typeof x === "function";
1620
- }
1621
- function createReducer(initialState, mapOrBuilderCallback) {
1622
- if (process.env.NODE_ENV !== "production") {
1623
- if (typeof mapOrBuilderCallback === "object") {
1624
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(8) : "The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");
1625
- }
1626
- }
1627
- let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] = executeReducerBuilderCallback(mapOrBuilderCallback);
1628
- let getInitialState;
1629
- if (isStateFunction(initialState)) {
1630
- getInitialState = () => freezeDraftable(initialState());
1631
- } else {
1632
- const frozenInitialState = freezeDraftable(initialState);
1633
- getInitialState = () => frozenInitialState;
1634
- }
1635
- function reducer(state = getInitialState(), action) {
1636
- let caseReducers = [actionsMap[action.type], ...finalActionMatchers.filter(({
1637
- matcher
1638
- }) => matcher(action)).map(({
1639
- reducer: reducer2
1640
- }) => reducer2)];
1641
- if (caseReducers.filter((cr) => !!cr).length === 0) {
1642
- caseReducers = [finalDefaultCaseReducer];
1643
- }
1644
- return caseReducers.reduce((previousState, caseReducer) => {
1645
- if (caseReducer) {
1646
- if (isDraft(previousState)) {
1647
- const draft = previousState;
1648
- const result = caseReducer(draft, action);
1649
- if (result === void 0) {
1650
- return previousState;
1651
- }
1652
- return result;
1653
- } else if (!isDraftable(previousState)) {
1654
- const result = caseReducer(previousState, action);
1655
- if (result === void 0) {
1656
- if (previousState === null) {
1657
- return previousState;
1658
- }
1659
- throw Error("A case reducer on a non-draftable value must not return undefined");
1660
- }
1661
- return result;
1662
- } else {
1663
- return produce(previousState, (draft) => {
1664
- return caseReducer(draft, action);
1665
- });
1666
- }
1667
- }
1668
- return previousState;
1669
- }, state);
1670
- }
1671
- reducer.getInitialState = getInitialState;
1672
- return reducer;
1673
- }
1674
- var matches = (matcher, action) => {
1675
- if (hasMatchFunction(matcher)) {
1676
- return matcher.match(action);
1677
- } else {
1678
- return matcher(action);
1679
- }
1680
- };
1681
- function isAnyOf(...matchers) {
1682
- return (action) => {
1683
- return matchers.some((matcher) => matches(matcher, action));
1684
- };
1685
- }
1686
- var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
1687
- var nanoid = (size = 21) => {
1688
- let id = "";
1689
- let i = size;
1690
- while (i--) {
1691
- id += urlAlphabet[Math.random() * 64 | 0];
1692
- }
1693
- return id;
1694
- };
1695
- var commonProperties = ["name", "message", "stack", "code"];
1696
- var RejectWithValue = class {
1697
- constructor(payload, meta) {
1698
- __publicField(this, "payload");
1699
- __publicField(this, "meta");
1700
- /*
1701
- type-only property to distinguish between RejectWithValue and FulfillWithMeta
1702
- does not exist at runtime
1703
- */
1704
- __publicField(this, "_type");
1705
- this.payload = payload;
1706
- this.meta = meta;
1707
- }
1708
- };
1709
- var FulfillWithMeta = class {
1710
- constructor(payload, meta) {
1711
- __publicField(this, "payload");
1712
- __publicField(this, "meta");
1713
- /*
1714
- type-only property to distinguish between RejectWithValue and FulfillWithMeta
1715
- does not exist at runtime
1716
- */
1717
- __publicField(this, "_type");
1718
- this.payload = payload;
1719
- this.meta = meta;
1720
- }
1721
- };
1722
- var miniSerializeError = (value) => {
1723
- if (typeof value === "object" && value !== null) {
1724
- const simpleError = {};
1725
- for (const property of commonProperties) {
1726
- if (typeof value[property] === "string") {
1727
- simpleError[property] = value[property];
1728
- }
1729
- }
1730
- return simpleError;
1731
- }
1732
- return {
1733
- message: String(value)
1734
- };
1735
- };
1736
- var externalAbortMessage = "External signal was aborted";
1737
- var createAsyncThunk = /* @__PURE__ */ (() => {
1738
- function createAsyncThunk2(typePrefix, payloadCreator, options) {
1739
- const fulfilled = createAction(typePrefix + "/fulfilled", (payload, requestId, arg, meta) => ({
1740
- payload,
1741
- meta: {
1742
- ...meta || {},
1743
- arg,
1744
- requestId,
1745
- requestStatus: "fulfilled"
1746
- }
1747
- }));
1748
- const pending = createAction(typePrefix + "/pending", (requestId, arg, meta) => ({
1749
- payload: void 0,
1750
- meta: {
1751
- ...meta || {},
1752
- arg,
1753
- requestId,
1754
- requestStatus: "pending"
1755
- }
1756
- }));
1757
- const rejected = createAction(typePrefix + "/rejected", (error, requestId, arg, payload, meta) => ({
1758
- payload,
1759
- error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
1760
- meta: {
1761
- ...meta || {},
1762
- arg,
1763
- requestId,
1764
- rejectedWithValue: !!payload,
1765
- requestStatus: "rejected",
1766
- aborted: error?.name === "AbortError",
1767
- condition: error?.name === "ConditionError"
1768
- }
1769
- }));
1770
- function actionCreator(arg, {
1771
- signal
1772
- } = {}) {
1773
- return (dispatch, getState, extra) => {
1774
- const requestId = options?.idGenerator ? options.idGenerator(arg) : nanoid();
1775
- const abortController = new AbortController();
1776
- let abortHandler;
1777
- let abortReason;
1778
- function abort(reason) {
1779
- abortReason = reason;
1780
- abortController.abort();
1781
- }
1782
- if (signal) {
1783
- if (signal.aborted) {
1784
- abort(externalAbortMessage);
594
+ pillContainer: { alignItems: "center", left: 0, position: "absolute", right: 0, zIndex: 3 }
595
+ });
596
+
597
+ // src/internal/useScrollHandlerJS.ts
598
+ var import_react8 = require("react");
599
+ var import_react_native_reanimated8 = require("react-native-reanimated");
600
+ var REMOUNT_RETRY_TOLERANCE = 1;
601
+ var REMOUNT_RETRY_MAX_ATTEMPTS = 8;
602
+ function useScrollHandlerJS({ capturedGeneration, chipHidden, chipThreshold = 100, footerFixed, headerFixed, isHorizontal, jsListGeneration, remountTarget = null, scrollTo }) {
603
+ const { footerHeightShared, footerOffset, headerHeightShared, headerOffset, pullSearchHeightShared, scrollPosition, snapBackFooterShared, snapBackHeaderShared } = (0, import_react8.useContext)(ScrollViewContext);
604
+ const snapUpAccum = (0, import_react8.useRef)(0);
605
+ const fromBottomBounce = (0, import_react8.useRef)(false);
606
+ const pendingRemountTarget = (0, import_react8.useRef)(remountTarget);
607
+ const remountAttempts = (0, import_react8.useRef)(0);
608
+ const onScroll = (0, import_react8.useCallback)(
609
+ (event) => {
610
+ if (jsListGeneration.current !== capturedGeneration.current) return;
611
+ const {
612
+ contentOffset: { x, y },
613
+ contentSize: { height: contentHeight },
614
+ layoutMeasurement: { height: layoutHeight }
615
+ } = event.nativeEvent;
616
+ if (pendingRemountTarget.current !== null) {
617
+ const target = pendingRemountTarget.current;
618
+ if (Math.abs(y - target) < REMOUNT_RETRY_TOLERANCE) {
619
+ pendingRemountTarget.current = null;
620
+ } else {
621
+ remountAttempts.current += 1;
622
+ if (remountAttempts.current > REMOUNT_RETRY_MAX_ATTEMPTS) {
623
+ pendingRemountTarget.current = null;
1785
624
  } else {
1786
- signal.addEventListener("abort", () => abort(externalAbortMessage), {
1787
- once: true
1788
- });
1789
- }
1790
- }
1791
- const promise = (async function() {
1792
- let finalAction;
1793
- try {
1794
- let conditionResult = options?.condition?.(arg, {
1795
- getState,
1796
- extra
1797
- });
1798
- if (isThenable(conditionResult)) {
1799
- conditionResult = await conditionResult;
1800
- }
1801
- if (conditionResult === false || abortController.signal.aborted) {
1802
- throw {
1803
- name: "ConditionError",
1804
- message: "Aborted due to condition callback returning false."
1805
- };
1806
- }
1807
- const abortedPromise = new Promise((_, reject) => {
1808
- abortHandler = () => {
1809
- reject({
1810
- name: "AbortError",
1811
- message: abortReason || "Aborted"
1812
- });
1813
- };
1814
- abortController.signal.addEventListener("abort", abortHandler, {
1815
- once: true
1816
- });
1817
- });
1818
- dispatch(pending(requestId, arg, options?.getPendingMeta?.({
1819
- requestId,
1820
- arg
1821
- }, {
1822
- getState,
1823
- extra
1824
- })));
1825
- finalAction = await Promise.race([abortedPromise, Promise.resolve(payloadCreator(arg, {
1826
- dispatch,
1827
- getState,
1828
- extra,
1829
- requestId,
1830
- signal: abortController.signal,
1831
- abort,
1832
- rejectWithValue: ((value, meta) => {
1833
- return new RejectWithValue(value, meta);
1834
- }),
1835
- fulfillWithValue: ((value, meta) => {
1836
- return new FulfillWithMeta(value, meta);
1837
- })
1838
- })).then((result) => {
1839
- if (result instanceof RejectWithValue) {
1840
- throw result;
1841
- }
1842
- if (result instanceof FulfillWithMeta) {
1843
- return fulfilled(result.payload, requestId, arg, result.meta);
1844
- }
1845
- return fulfilled(result, requestId, arg);
1846
- })]);
1847
- } catch (err) {
1848
- finalAction = err instanceof RejectWithValue ? rejected(null, requestId, arg, err.payload, err.meta) : rejected(err, requestId, arg);
1849
- } finally {
1850
- if (abortHandler) {
1851
- abortController.signal.removeEventListener("abort", abortHandler);
1852
- }
1853
- }
1854
- const skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
1855
- if (!skipDispatch) {
1856
- dispatch(finalAction);
625
+ scrollTo?.(target, false);
626
+ return;
1857
627
  }
1858
- return finalAction;
1859
- })();
1860
- return Object.assign(promise, {
1861
- abort,
1862
- requestId,
1863
- arg,
1864
- unwrap() {
1865
- return promise.then(unwrapResult);
1866
- }
1867
- });
1868
- };
1869
- }
1870
- return Object.assign(actionCreator, {
1871
- pending,
1872
- rejected,
1873
- fulfilled,
1874
- settled: isAnyOf(rejected, fulfilled),
1875
- typePrefix
1876
- });
1877
- }
1878
- createAsyncThunk2.withTypes = () => createAsyncThunk2;
1879
- return createAsyncThunk2;
1880
- })();
1881
- function unwrapResult(action) {
1882
- if (action.meta && action.meta.rejectedWithValue) {
1883
- throw action.payload;
1884
- }
1885
- if (action.error) {
1886
- throw action.error;
1887
- }
1888
- return action.payload;
1889
- }
1890
- function isThenable(value) {
1891
- return value !== null && typeof value === "object" && typeof value.then === "function";
1892
- }
1893
- var asyncThunkSymbol = /* @__PURE__ */ Symbol.for("rtk-slice-createasyncthunk");
1894
- var asyncThunkCreator = {
1895
- [asyncThunkSymbol]: createAsyncThunk
1896
- };
1897
- function getType(slice2, actionKey) {
1898
- return `${slice2}/${actionKey}`;
1899
- }
1900
- function buildCreateSlice({
1901
- creators
1902
- } = {}) {
1903
- const cAT = creators?.asyncThunk?.[asyncThunkSymbol];
1904
- return function createSlice2(options) {
1905
- const {
1906
- name,
1907
- reducerPath = name
1908
- } = options;
1909
- if (!name) {
1910
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "`name` is a required option for createSlice");
1911
- }
1912
- if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
1913
- if (options.initialState === void 0) {
1914
- console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
1915
- }
1916
- }
1917
- const reducers = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {};
1918
- const reducerNames = Object.keys(reducers);
1919
- const context = {
1920
- sliceCaseReducersByName: {},
1921
- sliceCaseReducersByType: {},
1922
- actionCreators: {},
1923
- sliceMatchers: []
1924
- };
1925
- const contextMethods = {
1926
- addCase(typeOrActionCreator, reducer2) {
1927
- const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
1928
- if (!type) {
1929
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : "`context.addCase` cannot be called with an empty action type");
1930
628
  }
1931
- if (type in context.sliceCaseReducersByType) {
1932
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "`context.addCase` cannot be called with two reducers for the same action type: " + type);
1933
- }
1934
- context.sliceCaseReducersByType[type] = reducer2;
1935
- return contextMethods;
1936
- },
1937
- addMatcher(matcher, reducer2) {
1938
- context.sliceMatchers.push({
1939
- matcher,
1940
- reducer: reducer2
1941
- });
1942
- return contextMethods;
1943
- },
1944
- exposeAction(name2, actionCreator) {
1945
- context.actionCreators[name2] = actionCreator;
1946
- return contextMethods;
1947
- },
1948
- exposeCaseReducer(name2, reducer2) {
1949
- context.sliceCaseReducersByName[name2] = reducer2;
1950
- return contextMethods;
1951
629
  }
1952
- };
1953
- reducerNames.forEach((reducerName) => {
1954
- const reducerDefinition = reducers[reducerName];
1955
- const reducerDetails = {
1956
- reducerName,
1957
- type: getType(name, reducerName),
1958
- createNotation: typeof options.reducers === "function"
1959
- };
1960
- if (isAsyncThunkSliceReducerDefinition(reducerDefinition)) {
1961
- handleThunkCaseReducerDefinition(reducerDetails, reducerDefinition, contextMethods, cAT);
1962
- } else {
1963
- handleNormalReducerDefinition(reducerDetails, reducerDefinition, contextMethods);
630
+ if (isHorizontal) {
631
+ scrollPosition.value = x;
632
+ chipHidden.value = x < chipThreshold ? 1 : 0;
633
+ return;
1964
634
  }
1965
- });
1966
- function buildReducer() {
1967
- if (process.env.NODE_ENV !== "production") {
1968
- if (typeof options.extraReducers === "object") {
1969
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : "The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");
1970
- }
635
+ const delta = y - scrollPosition.value;
636
+ scrollPosition.value = y;
637
+ chipHidden.value = y < chipThreshold ? 1 : 0;
638
+ const maxScroll = contentHeight - layoutHeight;
639
+ if (maxScroll > 0 && y >= maxScroll) {
640
+ fromBottomBounce.current = true;
641
+ snapUpAccum.current = 0;
642
+ } else if (fromBottomBounce.current) {
643
+ fromBottomBounce.current = false;
1971
644
  }
1972
- const [extraReducers = {}, actionMatchers = [], defaultCaseReducer = void 0] = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers];
1973
- const finalCaseReducers = {
1974
- ...extraReducers,
1975
- ...context.sliceCaseReducersByType
1976
- };
1977
- return createReducer(options.initialState, (builder) => {
1978
- for (let key in finalCaseReducers) {
1979
- builder.addCase(key, finalCaseReducers[key]);
1980
- }
1981
- for (let sM of context.sliceMatchers) {
1982
- builder.addMatcher(sM.matcher, sM.reducer);
1983
- }
1984
- for (let m of actionMatchers) {
1985
- builder.addMatcher(m.matcher, m.reducer);
1986
- }
1987
- if (defaultCaseReducer) {
1988
- builder.addDefaultCase(defaultCaseReducer);
1989
- }
1990
- });
1991
- }
1992
- const selectSelf = (state) => state;
1993
- const injectedSelectorCache = /* @__PURE__ */ new Map();
1994
- const injectedStateCache = /* @__PURE__ */ new WeakMap();
1995
- let _reducer;
1996
- function reducer(state, action) {
1997
- if (!_reducer) _reducer = buildReducer();
1998
- return _reducer(state, action);
1999
- }
2000
- function getInitialState() {
2001
- if (!_reducer) _reducer = buildReducer();
2002
- return _reducer.getInitialState();
2003
- }
2004
- function makeSelectorProps(reducerPath2, injected = false) {
2005
- function selectSlice(state) {
2006
- let sliceState = state[reducerPath2];
2007
- if (typeof sliceState === "undefined") {
2008
- if (injected) {
2009
- sliceState = getOrInsertComputed(injectedStateCache, selectSlice, getInitialState);
2010
- } else if (process.env.NODE_ENV !== "production") {
2011
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : "selectSlice returned undefined for an uninjected slice reducer");
645
+ const snapHeader = snapBackHeaderShared.value && !headerFixed;
646
+ const snapFooter = snapBackFooterShared.value && !footerFixed;
647
+ if (snapHeader || snapFooter) {
648
+ if (y <= -headerHeightShared.value) {
649
+ snapUpAccum.current = 0;
650
+ if (snapHeader) headerOffset.value = 0;
651
+ if (snapFooter) footerOffset.value = 0;
652
+ } else if (delta > 0) {
653
+ snapUpAccum.current = 0;
654
+ if (y >= -headerHeightShared.value + pullSearchHeightShared.value) {
655
+ if (snapHeader) headerOffset.value = Math.max(-headerHeightShared.value, Math.min(0, headerOffset.value - delta));
656
+ if (snapFooter) footerOffset.value = Math.max(0, Math.min(footerHeightShared.value, footerOffset.value + delta));
2012
657
  }
2013
- }
2014
- return sliceState;
2015
- }
2016
- function getSelectors(selectState = selectSelf) {
2017
- const selectorCache = getOrInsertComputed(injectedSelectorCache, injected, () => /* @__PURE__ */ new WeakMap());
2018
- return getOrInsertComputed(selectorCache, selectState, () => {
2019
- const map = {};
2020
- for (const [name2, selector] of Object.entries(options.selectors ?? {})) {
2021
- map[name2] = wrapSelector(selector, selectState, () => getOrInsertComputed(injectedStateCache, selectState, getInitialState), injected);
658
+ } else if (delta < 0 && !fromBottomBounce.current) {
659
+ if (y >= -headerHeightShared.value + pullSearchHeightShared.value) snapUpAccum.current -= delta;
660
+ if (snapUpAccum.current >= 10) {
661
+ snapUpAccum.current = 999;
662
+ if (snapHeader) headerOffset.value = (0, import_react_native_reanimated8.withTiming)(0, { duration: 200 });
663
+ if (snapFooter) footerOffset.value = (0, import_react_native_reanimated8.withTiming)(0, { duration: 200 });
2022
664
  }
2023
- return map;
2024
- });
2025
- }
2026
- return {
2027
- reducerPath: reducerPath2,
2028
- getSelectors,
2029
- get selectors() {
2030
- return getSelectors(selectSlice);
2031
- },
2032
- selectSlice
2033
- };
2034
- }
2035
- const slice2 = {
2036
- name,
2037
- reducer,
2038
- actions: context.actionCreators,
2039
- caseReducers: context.sliceCaseReducersByName,
2040
- getInitialState,
2041
- ...makeSelectorProps(reducerPath),
2042
- injectInto(injectable, {
2043
- reducerPath: pathOpt,
2044
- ...config
2045
- } = {}) {
2046
- const newReducerPath = pathOpt ?? reducerPath;
2047
- injectable.inject({
2048
- reducerPath: newReducerPath,
2049
- reducer
2050
- }, config);
2051
- return {
2052
- ...slice2,
2053
- ...makeSelectorProps(newReducerPath, true)
2054
- };
665
+ }
2055
666
  }
2056
- };
2057
- return slice2;
2058
- };
2059
- }
2060
- function wrapSelector(selector, selectState, getInitialState, injected) {
2061
- function wrapper(rootState, ...args) {
2062
- let sliceState = selectState(rootState);
2063
- if (typeof sliceState === "undefined") {
2064
- if (injected) {
2065
- sliceState = getInitialState();
2066
- } else if (process.env.NODE_ENV !== "production") {
2067
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(16) : "selectState returned undefined for an uninjected slice reducer");
667
+ },
668
+ [capturedGeneration, chipHidden, chipThreshold, footerFixed, footerHeightShared, footerOffset, headerFixed, headerHeightShared, headerOffset, isHorizontal, jsListGeneration, pullSearchHeightShared, scrollPosition, scrollTo, snapBackFooterShared, snapBackHeaderShared]
669
+ );
670
+ const onScrollBeginDrag = (0, import_react8.useCallback)(() => {
671
+ fromBottomBounce.current = false;
672
+ snapUpAccum.current = 0;
673
+ }, []);
674
+ const onMomentumScrollBegin = (0, import_react8.useCallback)(() => {
675
+ }, []);
676
+ const onScrollEndDrag = (0, import_react8.useCallback)(
677
+ (event) => {
678
+ if (isHorizontal) return;
679
+ const {
680
+ contentOffset: { y },
681
+ contentSize: { height: contentHeight },
682
+ layoutMeasurement: { height: layoutHeight }
683
+ } = event.nativeEvent;
684
+ if (y >= contentHeight - layoutHeight - 10) {
685
+ fromBottomBounce.current = true;
686
+ snapUpAccum.current = 0;
2068
687
  }
2069
- }
2070
- return selector(sliceState, ...args);
2071
- }
2072
- wrapper.unwrapped = selector;
2073
- return wrapper;
688
+ },
689
+ [isHorizontal]
690
+ );
691
+ const onMomentumScrollEnd = (0, import_react8.useCallback)(() => {
692
+ fromBottomBounce.current = false;
693
+ snapUpAccum.current = 0;
694
+ }, []);
695
+ return { onMomentumScrollBegin, onMomentumScrollEnd, onScroll, onScrollBeginDrag, onScrollEndDrag };
2074
696
  }
2075
- var createSlice = /* @__PURE__ */ buildCreateSlice();
2076
- function buildReducerCreators() {
2077
- function asyncThunk(payloadCreator, config) {
2078
- return {
2079
- _reducerDefinitionType: "asyncThunk",
2080
- payloadCreator,
2081
- ...config
2082
- };
2083
- }
2084
- asyncThunk.withTypes = () => asyncThunk;
2085
- return {
2086
- reducer(caseReducer) {
2087
- return Object.assign({
2088
- // hack so the wrapping function has the same name as the original
2089
- // we need to create a wrapper so the `reducerDefinitionType` is not assigned to the original
2090
- [caseReducer.name](...args) {
2091
- return caseReducer(...args);
2092
- }
2093
- }[caseReducer.name], {
2094
- _reducerDefinitionType: "reducer"
2095
- /* reducer */
2096
- });
697
+
698
+ // src/FlatList.tsx
699
+ var import_jsx_runtime5 = require("react/jsx-runtime");
700
+ var FlatListInner = ({ chipProps, chipThreshold, columnWrapperStyle, contentContainerStyle: externalContentContainerStyle, data, initialNumToRender = 20, keyExtractor, maxToRenderPerBatch = 50, numColumns, renderFilters, renderItem, footerFixed: footerFixedProp, gesture, headerFixed: headerFixedProp, horizontal, keyboardAware, ListHeaderComponent: externalListHeaderComponent, onChipPress, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pagingEnabled, pullSearchHeight, removeClippedSubviews = false, showsHorizontalScrollIndicator, showsVerticalScrollIndicator, style, onContentSizeChange, ref: externalRef, windowSize = 100, ...props }) => {
701
+ const scrollView = (0, import_react9.useRef)(null);
702
+ const isHorizontal = horizontal === true;
703
+ const showDots = isHorizontal && pagingEnabled === true && (data?.length ?? 0) > 1;
704
+ const cols = numColumns && numColumns > 1 ? numColumns : 1;
705
+ const rowData = (0, import_react9.useMemo)(() => {
706
+ if (cols <= 1 || !data) return data;
707
+ const items = Array.from(data);
708
+ const rows = [];
709
+ for (let i = 0; i < items.length; i += cols) rows.push(items.slice(i, i + cols));
710
+ return rows;
711
+ }, [cols, data]);
712
+ const rowKeyExtractor = (0, import_react9.useCallback)(
713
+ (row, rowIndex) => {
714
+ if (cols <= 1) return keyExtractor ? keyExtractor(row, rowIndex) : defaultKeyExtractor(row, rowIndex);
715
+ return row.map((item, kk) => keyExtractor ? keyExtractor(item, rowIndex * cols + kk) : defaultKeyExtractor(item, rowIndex * cols + kk)).join(":");
2097
716
  },
2098
- preparedReducer(prepare, reducer) {
2099
- return {
2100
- _reducerDefinitionType: "reducerWithPrepare",
2101
- prepare,
2102
- reducer
2103
- };
717
+ [cols, keyExtractor]
718
+ );
719
+ const rowRenderItem = (0, import_react9.useCallback)(
720
+ (info) => {
721
+ if (cols <= 1) return renderItem ? renderItem(info) : null;
722
+ const row = info.item;
723
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native6.View, { style: [styles4.row, columnWrapperStyle], children: row.map((item, kk) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react9.Fragment, { children: renderItem ? renderItem({ index: info.index * cols + kk, item, separators: info.separators }) : null }, kk)) });
2104
724
  },
2105
- asyncThunk
2106
- };
2107
- }
2108
- function handleNormalReducerDefinition({
2109
- type,
2110
- reducerName,
2111
- createNotation
2112
- }, maybeReducerWithPrepare, context) {
2113
- let caseReducer;
2114
- let prepareCallback;
2115
- if ("reducer" in maybeReducerWithPrepare) {
2116
- if (createNotation && !isCaseReducerWithPrepareDefinition(maybeReducerWithPrepare)) {
2117
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(17) : "Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");
2118
- }
2119
- caseReducer = maybeReducerWithPrepare.reducer;
2120
- prepareCallback = maybeReducerWithPrepare.prepare;
2121
- } else {
2122
- caseReducer = maybeReducerWithPrepare;
2123
- }
2124
- context.addCase(type, caseReducer).exposeCaseReducer(reducerName, caseReducer).exposeAction(reducerName, prepareCallback ? createAction(type, prepareCallback) : createAction(type));
2125
- }
2126
- function isAsyncThunkSliceReducerDefinition(reducerDefinition) {
2127
- return reducerDefinition._reducerDefinitionType === "asyncThunk";
2128
- }
2129
- function isCaseReducerWithPrepareDefinition(reducerDefinition) {
2130
- return reducerDefinition._reducerDefinitionType === "reducerWithPrepare";
2131
- }
2132
- function handleThunkCaseReducerDefinition({
2133
- type,
2134
- reducerName
2135
- }, reducerDefinition, context, cAT) {
2136
- if (!cAT) {
2137
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(18) : "Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");
2138
- }
725
+ [cols, columnWrapperStyle, renderItem]
726
+ );
727
+ const { chipHidden, chipStyle, containerStyle, contentInset, contentOffset, footerFixed, headerFixed } = useScrollList({ footerFixed: footerFixedProp, headerFixed: headerFixedProp, isHorizontal, keyboardAware, pullSearchHeight, style });
728
+ const { jsListGeneration, onJsListUnmount } = (0, import_react9.useContext)(ScrollViewContext);
729
+ const capturedGeneration = (0, import_react9.useRef)(jsListGeneration.current);
730
+ (0, import_react9.useLayoutEffect)(() => {
731
+ capturedGeneration.current = jsListGeneration.current;
732
+ }, [jsListGeneration]);
733
+ (0, import_react9.useLayoutEffect)(() => () => onJsListUnmount(), [onJsListUnmount]);
734
+ const scrollTo = (0, import_react9.useCallback)((offset, animated) => {
735
+ scrollView.current?.scrollToOffset({ offset, animated });
736
+ }, []);
2139
737
  const {
2140
- payloadCreator,
2141
- fulfilled,
2142
- pending,
2143
- rejected,
2144
- settled,
2145
- options
2146
- } = reducerDefinition;
2147
- const thunk = cAT(type, payloadCreator, options);
2148
- context.exposeAction(reducerName, thunk);
2149
- if (fulfilled) {
2150
- context.addCase(thunk.fulfilled, fulfilled);
2151
- }
2152
- if (pending) {
2153
- context.addCase(thunk.pending, pending);
2154
- }
2155
- if (rejected) {
2156
- context.addCase(thunk.rejected, rejected);
2157
- }
2158
- if (settled) {
2159
- context.addMatcher(thunk.settled, settled);
2160
- }
2161
- context.exposeCaseReducer(reducerName, {
2162
- fulfilled: fulfilled || noop,
2163
- pending: pending || noop,
2164
- rejected: rejected || noop,
2165
- settled: settled || noop
738
+ activeListHeader: pullSearchHeader,
739
+ handleMomentumScrollEnd,
740
+ handleScrollBeginDrag,
741
+ handleScrollEndDrag,
742
+ hiddenHeader,
743
+ pullSearchMinHeight,
744
+ remountTarget
745
+ } = useScrollInit({
746
+ listHeaderComponent: externalListHeaderComponent,
747
+ onMomentumScrollEnd: externalMomentumScrollEnd,
748
+ onRefresh: pullSearchHeight ? onRefresh : void 0,
749
+ onScrollBeginDrag: externalScrollBeginDrag,
750
+ onScrollEndDrag: externalScrollEndDrag,
751
+ pullSearchHeight,
752
+ scrollTo
2166
753
  });
2167
- }
2168
- function noop() {
2169
- }
2170
- var listener = "listener";
2171
- var completed = "completed";
2172
- var cancelled = "cancelled";
2173
- var taskCancelled = `task-${cancelled}`;
2174
- var taskCompleted = `task-${completed}`;
2175
- var listenerCancelled = `${listener}-${cancelled}`;
2176
- var listenerCompleted = `${listener}-${completed}`;
2177
- var {
2178
- assign
2179
- } = Object;
2180
- var alm = "listenerMiddleware";
2181
- var addListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/add`), {
2182
- withTypes: () => addListener
754
+ const activeListHeader = (0, import_react9.useMemo)(() => {
755
+ if (!renderFilters) return pullSearchHeader;
756
+ const Inner = pullSearchHeader;
757
+ return () => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
758
+ Inner ? typeof Inner === "function" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Inner, {}) : Inner : null,
759
+ renderFilters
760
+ ] });
761
+ }, [pullSearchHeader, renderFilters]);
762
+ const contentContainerStyle = (0, import_react9.useMemo)(() => isHorizontal ? externalContentContainerStyle : [{ minHeight: import_react_native6.Dimensions.get("window").height - contentInset.top - contentInset.bottom + pullSearchMinHeight }, externalContentContainerStyle], [isHorizontal, contentInset.bottom, contentInset.top, externalContentContainerStyle, pullSearchMinHeight]);
763
+ const scrollHandler = useScrollHandlerJS({ capturedGeneration, chipHidden, chipThreshold, footerFixed, headerFixed, isHorizontal, jsListGeneration, remountTarget, scrollTo });
764
+ const onScrollBeginDrag = (0, import_react9.useCallback)(
765
+ (e) => {
766
+ scrollHandler.onScrollBeginDrag(e);
767
+ handleScrollBeginDrag(e);
768
+ },
769
+ [scrollHandler, handleScrollBeginDrag]
770
+ );
771
+ const onScrollEndDrag = (0, import_react9.useCallback)(
772
+ (e) => {
773
+ scrollHandler.onScrollEndDrag(e);
774
+ handleScrollEndDrag(e);
775
+ },
776
+ [scrollHandler, handleScrollEndDrag]
777
+ );
778
+ const onMomentumScrollEnd = (0, import_react9.useCallback)(
779
+ (e) => {
780
+ scrollHandler.onMomentumScrollEnd(e);
781
+ handleMomentumScrollEnd(e);
782
+ },
783
+ [scrollHandler, handleMomentumScrollEnd]
784
+ );
785
+ const handleScrollToTop = (0, import_react9.useCallback)(() => {
786
+ if (isHorizontal) {
787
+ scrollView.current?.scrollToOffset({ offset: 0, animated: true });
788
+ return;
789
+ }
790
+ const offset = pullSearchHeight ? -contentInset.top + pullSearchHeight : -contentInset.top;
791
+ scrollView.current?.scrollToOffset({ offset, animated: true });
792
+ }, [isHorizontal, contentInset.top, pullSearchHeight]);
793
+ const handleContentSizeChange = (0, import_react9.useCallback)(
794
+ (w, h) => {
795
+ if (onContentSizeChange) onContentSizeChange(w, h);
796
+ },
797
+ [onContentSizeChange]
798
+ );
799
+ const refreshControl = (0, import_react9.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RefreshControl, {}), []);
800
+ const nativeGesture = (0, import_react9.useMemo)(() => import_react_native_gesture_handler2.Gesture.Native(), []);
801
+ const combinedGesture = (0, import_react9.useMemo)(() => gesture !== void 0 ? import_react_native_gesture_handler2.Gesture.Simultaneous(gesture, nativeGesture) : nativeGesture, [gesture, nativeGesture]);
802
+ const detectorGesture = gesture !== void 0 ? combinedGesture : void 0;
803
+ const content = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react_native6.View, { style: containerStyle, children: [
804
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
805
+ import_react_native6.FlatList,
806
+ {
807
+ ...props,
808
+ contentContainerStyle,
809
+ contentInset,
810
+ contentInsetAdjustmentBehavior: "never",
811
+ contentOffset,
812
+ data: cols > 1 ? rowData : data,
813
+ horizontal: isHorizontal,
814
+ initialNumToRender,
815
+ keyExtractor: cols > 1 ? rowKeyExtractor : keyExtractor,
816
+ ListHeaderComponent: activeListHeader,
817
+ maxToRenderPerBatch,
818
+ onContentSizeChange: handleContentSizeChange,
819
+ onMomentumScrollBegin: scrollHandler.onMomentumScrollBegin,
820
+ onMomentumScrollEnd,
821
+ onScroll: scrollHandler.onScroll,
822
+ onScrollBeginDrag,
823
+ onScrollEndDrag,
824
+ pagingEnabled,
825
+ renderItem: cols > 1 ? rowRenderItem : renderItem,
826
+ ref: (el) => {
827
+ if (externalRef) externalRef.current = el;
828
+ scrollView.current = el;
829
+ },
830
+ refreshControl,
831
+ removeClippedSubviews,
832
+ scrollEventThrottle: 16,
833
+ showsHorizontalScrollIndicator: showsHorizontalScrollIndicator ?? isHorizontal,
834
+ showsVerticalScrollIndicator: showsVerticalScrollIndicator ?? !isHorizontal,
835
+ windowSize
836
+ }
837
+ ),
838
+ hiddenHeader && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native6.View, { pointerEvents: "none", style: styles4.measureContainer, children: hiddenHeader }),
839
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ScrollViewChip, { chipProps, isHorizontal, onChipPress, onPress: handleScrollToTop, style: chipStyle }),
840
+ showDots && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(HorizontalDots, { total: data?.length ?? 0 })
841
+ ] });
842
+ return detectorGesture ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native_gesture_handler2.GestureDetector, { gesture: detectorGesture, children: content }) : content;
843
+ };
844
+ var defaultKeyExtractor = (item, index) => {
845
+ const key = item?.key ?? item?.id;
846
+ return key != null ? String(key) : String(index);
847
+ };
848
+ var styles4 = { measureContainer: { left: 0, opacity: 0, position: "absolute", right: 0, top: -9999 }, row: { flexDirection: "row" } };
849
+ var FlatList = (0, import_react9.memo)(FlatListInner);
850
+
851
+ // src/PullSearch.tsx
852
+ var import_react10 = require("react");
853
+ var import_react_native7 = require("react-native");
854
+ var import_react_native_paper2 = require("react-native-paper");
855
+ var import_react_native_reanimated9 = __toESM(require("react-native-reanimated"));
856
+ var import_jsx_runtime6 = require("react/jsx-runtime");
857
+ var PullSearch = (0, import_react10.forwardRef)(function PullSearch2({ debounce, onChangeText, onHeightChange, placeholder, value: propValue }, ref) {
858
+ const { headerHeight, scrollPosition } = (0, import_react10.useContext)(ScrollViewContext);
859
+ const theme = (0, import_react_native_paper2.useTheme)();
860
+ const inputRef = (0, import_react10.useRef)(null);
861
+ const [barHeight, setBarHeight] = (0, import_react10.useState)(0);
862
+ const [value, setValue] = (0, import_react10.useState)(propValue ?? "");
863
+ const prevPropValueRef = (0, import_react10.useRef)(propValue);
864
+ (0, import_react10.useEffect)(() => {
865
+ if (prevPropValueRef.current === propValue) return;
866
+ prevPropValueRef.current = propValue;
867
+ setValue(propValue ?? "");
868
+ }, [propValue]);
869
+ (0, import_react10.useImperativeHandle)(ref, () => ({
870
+ blur: () => inputRef.current?.blur(),
871
+ focus: () => inputRef.current?.focus()
872
+ }));
873
+ const blurInput = (0, import_react10.useCallback)(() => inputRef.current?.blur(), []);
874
+ (0, import_react_native_reanimated9.useAnimatedReaction)(
875
+ () => {
876
+ if (barHeight === 0) return false;
877
+ return scrollPosition.value >= -(headerHeight ?? 0) + barHeight;
878
+ },
879
+ (isHidden, wasHidden) => {
880
+ if (isHidden && !wasHidden) (0, import_react_native_reanimated9.runOnJS)(blurInput)();
881
+ },
882
+ [barHeight, headerHeight, blurInput]
883
+ );
884
+ const handleClear = (0, import_react10.useCallback)(() => {
885
+ setValue("");
886
+ onChangeText("");
887
+ }, [onChangeText]);
888
+ const handleLayout = (0, import_react10.useCallback)(
889
+ ({
890
+ nativeEvent: {
891
+ layout: { height }
892
+ }
893
+ }) => {
894
+ setBarHeight(height);
895
+ onHeightChange(height);
896
+ },
897
+ [onHeightChange]
898
+ );
899
+ (0, import_react10.useEffect)(() => {
900
+ const normalizedValue = value.trim();
901
+ if (debounce) {
902
+ const timeout = setTimeout(() => onChangeText(normalizedValue), 500);
903
+ return () => clearTimeout(timeout);
904
+ }
905
+ onChangeText(normalizedValue);
906
+ }, [debounce, onChangeText, value]);
907
+ const animatedStyle = (0, import_react_native_reanimated9.useAnimatedStyle)(() => {
908
+ if (barHeight === 0) return { opacity: 0 };
909
+ const h = headerHeight ?? 0;
910
+ const showY = -h;
911
+ const hideY = -h + barHeight;
912
+ return { opacity: (0, import_react_native_reanimated9.interpolate)(scrollPosition.value, [showY, hideY], [1, 0], import_react_native_reanimated9.Extrapolation.CLAMP) };
913
+ }, [barHeight, headerHeight]);
914
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native_reanimated9.default.View, { onLayout: handleLayout, style: [styles5.container, animatedStyle], children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native_paper2.Searchbar, { autoCorrect: false, onChangeText: (text) => setValue((text || "").trimStart()), onClearIconPress: handleClear, placeholder, placeholderTextColor: theme.colors.onSurfaceVariant, ref: inputRef, spellCheck: false, style: styles5.input, value }) });
2183
915
  });
2184
- var clearAllListeners = /* @__PURE__ */ createAction(`${alm}/removeAll`);
2185
- var removeListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/remove`), {
2186
- withTypes: () => removeListener
916
+ var styles5 = import_react_native7.StyleSheet.create({
917
+ container: { paddingVertical: 8 },
918
+ input: { margin: 0 }
2187
919
  });
2188
- function formatProdErrorMessage(code) {
2189
- return `Minified Redux Toolkit error #${code}; visit https://redux-toolkit.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
2190
- }
2191
920
 
2192
921
  // src/ScrollViewSettingsContext.ts
2193
- var import_react10 = require("react");
922
+ var import_react11 = require("react");
2194
923
  var defaultScrollViewSettings = {
2195
924
  backActionFixed: true,
2196
925
  footerFixed: false,
2197
926
  headerFixed: false,
2198
927
  snapBack: false
2199
928
  };
2200
- var ScrollViewSettingsContext = (0, import_react10.createContext)({
929
+ var ScrollViewSettingsContext = (0, import_react11.createContext)({
2201
930
  settings: defaultScrollViewSettings,
2202
931
  set: () => {
2203
932
  }
2204
933
  });
2205
934
 
2206
935
  // src/redux/scrollViewSlice.ts
2207
- var slice = createSlice({
2208
- name: "scrollView",
2209
- initialState: defaultScrollViewSettings,
2210
- reducers: {
2211
- initialize: (_state, action) => action.payload
2212
- }
2213
- });
2214
- var scrollViewActions = slice.actions;
2215
- var scrollViewReducer = slice.reducer;
936
+ var createAction = (type) => {
937
+ const actionCreator = (payload) => ({ payload, type });
938
+ actionCreator.type = type;
939
+ actionCreator.match = (action) => action.type === type;
940
+ return actionCreator;
941
+ };
942
+ var initialize = createAction("scrollView/initialize");
943
+ var scrollViewActions = { initialize };
944
+ var scrollViewReducer = (state = defaultScrollViewSettings, action) => {
945
+ if (initialize.match(action)) return action.payload;
946
+ return state;
947
+ };
2216
948
 
2217
949
  // src/ScrollView.tsx
2218
- var import_react11 = require("react");
950
+ var import_react12 = require("react");
2219
951
  var import_react_native8 = require("react-native");
2220
952
  var import_react_native_gesture_handler3 = require("react-native-gesture-handler");
2221
- var import_react_native_reanimated8 = __toESM(require("react-native-reanimated"));
953
+ var import_react_native_reanimated10 = __toESM(require("react-native-reanimated"));
2222
954
  var import_jsx_runtime7 = require("react/jsx-runtime");
2223
955
  var ScrollViewInner = ({ chipProps, chipThreshold, children, footerFixed: footerFixedProp, gesture, headerFixed: headerFixedProp, horizontal, keyboardAware, onChipPress, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pullSearchHeight, refreshing, style, ...props }) => {
2224
- const scrollView = (0, import_react11.useRef)(null);
956
+ const scrollView = (0, import_react12.useRef)(null);
2225
957
  const isHorizontal = horizontal === true;
2226
958
  const { chipHidden, chipStyle, containerStyle, contentInset, contentOffset, footerFixed, headerFixed } = useScrollList({ footerFixed: footerFixedProp, headerFixed: headerFixedProp, isHorizontal, keyboardAware, pullSearchHeight, style });
2227
- const scrollTo = (0, import_react11.useCallback)((offset, animated) => {
959
+ const { listGeneration, onListUnmount } = (0, import_react12.useContext)(ScrollViewContext);
960
+ const capturedGeneration = (0, import_react_native_reanimated10.useSharedValue)(-1);
961
+ (0, import_react12.useLayoutEffect)(() => {
962
+ const generation = listGeneration.value;
963
+ (0, import_react_native_reanimated10.runOnUI)((gen) => {
964
+ "worklet";
965
+ capturedGeneration.value = gen;
966
+ })(generation);
967
+ }, [capturedGeneration, listGeneration]);
968
+ (0, import_react12.useLayoutEffect)(() => () => onListUnmount(), [onListUnmount]);
969
+ const scrollTo = (0, import_react12.useCallback)((offset, animated) => {
2228
970
  scrollView.current?.scrollTo({ y: offset, animated });
2229
971
  }, []);
2230
972
  const { handleMomentumScrollEnd, handleScrollBeginDrag, handleScrollEndDrag } = useScrollInit({
@@ -2234,12 +976,8 @@ var ScrollViewInner = ({ chipProps, chipThreshold, children, footerFixed: footer
2234
976
  pullSearchHeight,
2235
977
  scrollTo
2236
978
  });
2237
- const onPullSearchZoneEnter = (0, import_react11.useCallback)(() => {
2238
- if (!pullSearchHeight) return;
2239
- scrollTo(-contentInset.top + pullSearchHeight, true);
2240
- }, [contentInset.top, pullSearchHeight, scrollTo]);
2241
- const handleScroll = useScrollHandler({ chipHidden, chipThreshold, footerFixed, headerFixed, isHorizontal, onPullSearchZoneEnter: pullSearchHeight ? onPullSearchZoneEnter : void 0 });
2242
- const handleScrollToTop = (0, import_react11.useCallback)(() => {
979
+ const handleScroll = useScrollHandler({ capturedGeneration, chipHidden, chipThreshold, footerFixed, headerFixed, isHorizontal, listGeneration });
980
+ const handleScrollToTop = (0, import_react12.useCallback)(() => {
2243
981
  if (isHorizontal) {
2244
982
  scrollView.current?.scrollTo({ x: 0, animated: true });
2245
983
  return;
@@ -2247,13 +985,13 @@ var ScrollViewInner = ({ chipProps, chipThreshold, children, footerFixed: footer
2247
985
  const offset = pullSearchHeight ? -contentInset.top + pullSearchHeight : -contentInset.top;
2248
986
  scrollView.current?.scrollTo({ y: offset, animated: true });
2249
987
  }, [isHorizontal, contentInset.top, pullSearchHeight]);
2250
- const refreshControl = (0, import_react11.useMemo)(() => onRefresh ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(RefreshControl, { onRefresh, refreshing: refreshing ?? false }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(RefreshControl, {}), [onRefresh, refreshing]);
2251
- const nativeGesture = (0, import_react11.useMemo)(() => import_react_native_gesture_handler3.Gesture.Native(), []);
2252
- const combinedGesture = (0, import_react11.useMemo)(() => gesture !== void 0 ? import_react_native_gesture_handler3.Gesture.Simultaneous(gesture, nativeGesture) : nativeGesture, [gesture, nativeGesture]);
988
+ const refreshControl = (0, import_react12.useMemo)(() => onRefresh ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(RefreshControl, { onRefresh, refreshing: refreshing ?? false }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(RefreshControl, {}), [onRefresh, refreshing]);
989
+ const nativeGesture = (0, import_react12.useMemo)(() => import_react_native_gesture_handler3.Gesture.Native(), []);
990
+ const combinedGesture = (0, import_react12.useMemo)(() => gesture !== void 0 ? import_react_native_gesture_handler3.Gesture.Simultaneous(gesture, nativeGesture) : nativeGesture, [gesture, nativeGesture]);
2253
991
  const detectorGesture = gesture !== void 0 ? combinedGesture : void 0;
2254
992
  const content = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native8.View, { style: containerStyle, children: [
2255
993
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2256
- import_react_native_reanimated8.default.ScrollView,
994
+ import_react_native_reanimated10.default.ScrollView,
2257
995
  {
2258
996
  ...props,
2259
997
  contentInset,
@@ -2275,19 +1013,19 @@ var ScrollViewInner = ({ chipProps, chipThreshold, children, footerFixed: footer
2275
1013
  ] });
2276
1014
  return detectorGesture ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native_gesture_handler3.GestureDetector, { gesture: detectorGesture, children: content }) : content;
2277
1015
  };
2278
- var ScrollView = (0, import_react11.memo)(ScrollViewInner);
1016
+ var ScrollView = (0, import_react12.memo)(ScrollViewInner);
2279
1017
 
2280
1018
  // src/ScrollViewFooter.tsx
2281
1019
  var import_auto_paper3 = require("@rific/auto-paper");
2282
- var import_react12 = require("react");
1020
+ var import_react13 = require("react");
2283
1021
  var import_react_native9 = require("react-native");
2284
- var import_react_native_reanimated9 = __toESM(require("react-native-reanimated"));
1022
+ var import_react_native_reanimated11 = __toESM(require("react-native-reanimated"));
2285
1023
  var import_react_native_safe_area_context3 = require("react-native-safe-area-context");
2286
1024
  var import_jsx_runtime8 = require("react/jsx-runtime");
2287
1025
  var ScrollViewFooter = ({ children, style }) => {
2288
- const { blur, footerHeight, footerFixed, footerOffset, headerHeightShared, pullSearchHeightShared, scrollPosition, setFooterHeight, snapBackFooterShared } = (0, import_react12.useContext)(ScrollViewContext);
1026
+ const { blur, footerHeight, footerFixed, footerOffset, headerHeightShared, pullSearchHeightShared, scrollPosition, setFooterHeight, snapBackFooterShared } = (0, import_react13.useContext)(ScrollViewContext);
2289
1027
  const insets = (0, import_react_native_safe_area_context3.useSafeAreaInsets)();
2290
- (0, import_react12.useEffect)(
1028
+ (0, import_react13.useEffect)(
2291
1029
  () => () => {
2292
1030
  setFooterHeight(0);
2293
1031
  },
@@ -2300,14 +1038,14 @@ var ScrollViewFooter = ({ children, style }) => {
2300
1038
  }) => {
2301
1039
  if (footerHeight !== height) setFooterHeight(height);
2302
1040
  };
2303
- const footerStyle = (0, import_react_native_reanimated9.useAnimatedStyle)(() => {
1041
+ const footerStyle = (0, import_react_native_reanimated11.useAnimatedStyle)(() => {
2304
1042
  if (footerFixed) return { transform: [{ translateY: 0 }] };
2305
1043
  if (snapBackFooterShared.value) return { transform: [{ translateY: footerOffset.value }] };
2306
1044
  const effective = scrollPosition.value + headerHeightShared.value - pullSearchHeightShared.value;
2307
1045
  if (effective <= 0) return { transform: [{ translateY: 0 }] };
2308
1046
  return { transform: [{ translateY: Math.min(effective, footerHeight) }] };
2309
1047
  }, [footerHeight, footerFixed]);
2310
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_native_reanimated9.default.View, { onLayout: handleLayout, pointerEvents: "box-none", style: [styles6.footer, footerStyle], children: [
1048
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_native_reanimated11.default.View, { onLayout: handleLayout, pointerEvents: "box-none", style: [styles6.footer, footerStyle], children: [
2311
1049
  footerHeight > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_auto_paper3.BlurView, { blur, style: import_react_native9.StyleSheet.absoluteFill }),
2312
1050
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native9.View, { style: [styles6.row, { paddingBottom: insets.bottom }, style], children })
2313
1051
  ] });
@@ -2319,16 +1057,16 @@ var styles6 = import_react_native9.StyleSheet.create({
2319
1057
 
2320
1058
  // src/ScrollViewHeader.tsx
2321
1059
  var import_auto_paper4 = require("@rific/auto-paper");
2322
- var import_react13 = require("react");
1060
+ var import_react14 = require("react");
2323
1061
  var import_react_native10 = require("react-native");
2324
1062
  var import_react_native_paper3 = require("react-native-paper");
2325
- var import_react_native_reanimated10 = __toESM(require("react-native-reanimated"));
1063
+ var import_react_native_reanimated12 = __toESM(require("react-native-reanimated"));
2326
1064
  var import_react_native_safe_area_context4 = require("react-native-safe-area-context");
2327
1065
  var import_jsx_runtime9 = require("react/jsx-runtime");
2328
1066
  var ActionBg = ({ blur, style }) => blur ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: [import_react_native10.StyleSheet.absoluteFill, styles7.actionBg, style], children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_auto_paper4.BlurView, { blur: true, style: import_react_native10.StyleSheet.absoluteFill }) }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: [import_react_native10.StyleSheet.absoluteFill, styles7.actionBg, style], pointerEvents: "none", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_paper3.Surface, { style: import_react_native10.StyleSheet.absoluteFill, elevation: 1, children: null }) });
2329
1067
  var ScrollViewHeader = ({ actionSize = 48, actionStyle, backAction, backActionFixed, caption, centerContent, children, iconSize, style, title, topInset = true, trailingAction, trailingActionFixed = true }) => {
2330
- const { blur, headerHeight, headerFixed, headerOffset, progress, progressing, pullSearchHeightShared, scrollPosition, setHeaderHeight, snapBackHeaderShared } = (0, import_react13.useContext)(ScrollViewContext);
2331
- const { settings } = (0, import_react13.useContext)(ScrollViewSettingsContext);
1068
+ const { blur, headerHeight, headerFixed, headerOffset, progress, progressing, pullSearchHeightShared, scrollPosition, setHeaderHeight, snapBackHeaderShared } = (0, import_react14.useContext)(ScrollViewContext);
1069
+ const { settings } = (0, import_react14.useContext)(ScrollViewSettingsContext);
2332
1070
  const effectiveBackActionFixed = backActionFixed ?? settings.backActionFixed;
2333
1071
  const insets = (0, import_react_native_safe_area_context4.useSafeAreaInsets)();
2334
1072
  const theme = (0, import_react_native_paper3.useTheme)();
@@ -2340,23 +1078,25 @@ var ScrollViewHeader = ({ actionSize = 48, actionStyle, backAction, backActionFi
2340
1078
  }) => {
2341
1079
  if (headerHeight !== height) setHeaderHeight(height);
2342
1080
  };
2343
- const translateStyle = (0, import_react_native_reanimated10.useAnimatedStyle)(() => {
1081
+ const translateStyle = (0, import_react_native_reanimated12.useAnimatedStyle)(() => {
2344
1082
  if (headerFixed) return { transform: [{ translateY: 0 }] };
2345
1083
  if (snapBackHeaderShared.value) return { transform: [{ translateY: headerOffset.value }] };
2346
- const effective = scrollPosition.value + headerHeight - pullSearchHeightShared.value;
1084
+ const effective = scrollPosition.value + (headerHeight ?? 0) - pullSearchHeightShared.value;
2347
1085
  if (effective <= 0) return { transform: [{ translateY: 0 }] };
2348
1086
  return { transform: [{ translateY: -effective }] };
2349
1087
  }, [headerFixed, headerHeight]);
2350
- const blurStyle = (0, import_react_native_reanimated10.useAnimatedStyle)(() => {
1088
+ const blurStyle = (0, import_react_native_reanimated12.useAnimatedStyle)(() => {
2351
1089
  if (!headerHeight) return { height: 0 };
2352
1090
  if (headerFixed) return { height: headerHeight };
2353
- const translateY = snapBackHeaderShared.value ? headerOffset.value : -Math.max(0, scrollPosition.value + headerHeight - pullSearchHeightShared.value);
2354
- return { height: Math.max(headerHeight + translateY, top) };
1091
+ const h = headerHeight ?? 0;
1092
+ const translateY = snapBackHeaderShared.value ? headerOffset.value : -Math.max(0, scrollPosition.value + h - pullSearchHeightShared.value);
1093
+ return { height: Math.max(h + translateY, top) };
2355
1094
  }, [headerFixed, headerHeight, top]);
2356
- const progressStyle = (0, import_react_native_reanimated10.useAnimatedStyle)(() => {
2357
- if (headerFixed) return { top: headerHeight };
2358
- const slide = snapBackHeaderShared.value ? -headerOffset.value : Math.max(0, scrollPosition.value + headerHeight - pullSearchHeightShared.value);
2359
- return { top: Math.max(headerHeight - slide, top) };
1095
+ const progressStyle = (0, import_react_native_reanimated12.useAnimatedStyle)(() => {
1096
+ const h = headerHeight ?? 0;
1097
+ if (headerFixed) return { top: h };
1098
+ const slide = snapBackHeaderShared.value ? -headerOffset.value : Math.max(0, scrollPosition.value + h - pullSearchHeightShared.value);
1099
+ return { top: Math.max(h - slide, top) };
2360
1100
  }, [headerFixed, headerHeight, top]);
2361
1101
  const actionMargin = 4;
2362
1102
  const contentMinHeight = actionSize + 2 * actionMargin;
@@ -2366,12 +1106,11 @@ var ScrollViewHeader = ({ actionSize = 48, actionStyle, backAction, backActionFi
2366
1106
  const leadingStyle = { alignItems: "center", height: actionSize, justifyContent: "center", left: actionMargin, position: "absolute", top: actionTop, width: actionSize, zIndex: 3, ...actionShadow };
2367
1107
  const trailingStyle = { alignItems: "center", height: actionSize, justifyContent: "center", position: "absolute", right: actionMargin, top: actionTop, width: actionSize, zIndex: 3, ...actionShadow };
2368
1108
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2369
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_reanimated10.default.View, { pointerEvents: "none", style: [styles7.blur, blurStyle], children: headerHeight > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_auto_paper4.BlurView, { blur, style: [styles7.blurInner, { height: headerHeight }] }) }),
2370
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native_reanimated10.default.View, { onLayout: handleLayout, pointerEvents: "box-none", style: [headerHeight === 0 ? styles7.headerInit : styles7.header, translateStyle], children: [
2371
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: [{ paddingTop: top }, style], children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native10.View, { style: [styles7.content, { minHeight: contentMinHeight }], children: [
1109
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_reanimated12.default.View, { pointerEvents: "none", style: [styles7.blur, blurStyle], children: headerHeight !== null && headerHeight > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_auto_paper4.BlurView, { blur, style: [styles7.blurInner, { height: headerHeight }] }) }),
1110
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native_reanimated12.default.View, { onLayout: handleLayout, pointerEvents: "box-none", style: [headerHeight === null ? styles7.headerInit : styles7.header, translateStyle], children: [
1111
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: [{ paddingTop: top }, style], children: children ?? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native10.View, { style: [styles7.content, { minHeight: contentMinHeight }], children: [
2372
1112
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: styles7.side }),
2373
1113
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: styles7.spacer }),
2374
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: styles7.side, children }),
2375
1114
  (centerContent || title || caption) && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: [import_react_native10.StyleSheet.absoluteFill, styles7.titleContainer], pointerEvents: centerContent ? "box-none" : "none", children: centerContent ?? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2376
1115
  title && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.Text, { numberOfLines: 1, style: [styles7.title, { color: theme.colors.onSurface }], children: title }),
2377
1116
  caption && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.Text, { numberOfLines: 1, style: [styles7.caption, { color: theme.colors.onSurfaceVariant }], children: caption })
@@ -2379,18 +1118,18 @@ var ScrollViewHeader = ({ actionSize = 48, actionStyle, backAction, backActionFi
2379
1118
  ] }) }),
2380
1119
  !blur && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native10.View, { style: [styles7.divider, { backgroundColor: theme.colors.outlineVariant }] })
2381
1120
  ] }),
2382
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_reanimated10.default.View, { pointerEvents: "none", style: [styles7.progress, progressStyle], children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_paper3.ProgressBar, { indeterminate: progress === null, visible: progressing, progress: progress ?? void 0 }) }),
2383
- backAction && (effectiveBackActionFixed ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native_reanimated10.default.View, { style: leadingStyle, children: [
1121
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_reanimated12.default.View, { pointerEvents: "none", style: [styles7.progress, progressStyle], children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_paper3.ProgressBar, { indeterminate: progress === null, visible: progressing, progress: progress ?? void 0 }) }),
1122
+ backAction && (effectiveBackActionFixed ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native_reanimated12.default.View, { style: leadingStyle, children: [
2384
1123
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ActionBg, { blur, style: actionStyle }),
2385
1124
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_paper3.Appbar.BackAction, { onPress: backAction, size: iconSize ?? actionSize / 2, style: buttonStyle })
2386
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native_reanimated10.default.View, { style: [leadingStyle, translateStyle], children: [
1125
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native_reanimated12.default.View, { style: [leadingStyle, translateStyle], children: [
2387
1126
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ActionBg, { blur, style: actionStyle }),
2388
1127
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_paper3.Appbar.BackAction, { onPress: backAction, size: iconSize ?? actionSize / 2, style: buttonStyle })
2389
1128
  ] })),
2390
1129
  trailingAction && (trailingActionFixed ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native10.View, { style: trailingStyle, children: [
2391
1130
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ActionBg, { blur, style: actionStyle }),
2392
1131
  trailingAction
2393
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native_reanimated10.default.View, { style: [trailingStyle, translateStyle], children: [
1132
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react_native_reanimated12.default.View, { style: [trailingStyle, translateStyle], children: [
2394
1133
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ActionBg, { blur, style: actionStyle }),
2395
1134
  trailingAction
2396
1135
  ] }))
@@ -2414,62 +1153,77 @@ var styles7 = import_react_native10.StyleSheet.create({
2414
1153
 
2415
1154
  // src/ScrollViewProvider.tsx
2416
1155
  var import_auto_paper5 = require("@rific/auto-paper");
2417
- var import_react14 = require("react");
1156
+ var import_react15 = require("react");
2418
1157
  var import_react_native11 = require("react-native");
2419
- var import_react_native_reanimated11 = require("react-native-reanimated");
1158
+ var import_react_native_reanimated13 = require("react-native-reanimated");
2420
1159
  var import_jsx_runtime10 = require("react/jsx-runtime");
2421
1160
  var ScrollViewProvider = ({ blur, children, fixed = false, footerFixed, headerFixed, snapBack, snapBackFooter, snapBackHeader, tabBarHeight = 60 }) => {
2422
- const { settings } = (0, import_react14.useContext)(ScrollViewSettingsContext);
1161
+ const { settings } = (0, import_react15.useContext)(ScrollViewSettingsContext);
2423
1162
  const effectiveBlur = (0, import_auto_paper5.useBlur)(blur);
2424
1163
  const effectiveSnapBack = snapBack ?? settings.snapBack;
2425
1164
  const effectiveSnapBackHeader = snapBackHeader ?? settings.snapBackHeader;
2426
1165
  const effectiveSnapBackFooter = snapBackFooter ?? settings.snapBackFooter;
2427
- const [headerHeight, setHeaderHeightState] = (0, import_react14.useState)(0);
2428
- const [footerHeight, setFooterHeightState] = (0, import_react14.useState)(0);
2429
- const [progress, setProgress] = (0, import_react14.useState)(null);
2430
- const [progressing, setProgressing] = (0, import_react14.useState)(false);
2431
- const scrollPosition = (0, import_react_native_reanimated11.useSharedValue)(0);
2432
- const headerHeightShared = (0, import_react_native_reanimated11.useSharedValue)(0);
2433
- const footerHeightShared = (0, import_react_native_reanimated11.useSharedValue)(0);
2434
- const headerOffset = (0, import_react_native_reanimated11.useSharedValue)(0);
2435
- const footerOffset = (0, import_react_native_reanimated11.useSharedValue)(0);
2436
- const pullSearchHeightShared = (0, import_react_native_reanimated11.useSharedValue)(0);
2437
- const snapBackHeaderShared = (0, import_react_native_reanimated11.useSharedValue)(false);
2438
- const snapBackFooterShared = (0, import_react_native_reanimated11.useSharedValue)(false);
2439
- (0, import_react14.useEffect)(() => {
1166
+ const [headerHeight, setHeaderHeightState] = (0, import_react15.useState)(null);
1167
+ const [footerHeight, setFooterHeightState] = (0, import_react15.useState)(0);
1168
+ const [progress, setProgress] = (0, import_react15.useState)(null);
1169
+ const [progressing, setProgressing] = (0, import_react15.useState)(false);
1170
+ const scrollPosition = (0, import_react_native_reanimated13.useSharedValue)(0);
1171
+ const listGeneration = (0, import_react_native_reanimated13.useSharedValue)(0);
1172
+ const jsListGeneration = (0, import_react15.useRef)(0);
1173
+ const headerHeightShared = (0, import_react_native_reanimated13.useSharedValue)(0);
1174
+ const footerHeightShared = (0, import_react_native_reanimated13.useSharedValue)(0);
1175
+ const headerOffset = (0, import_react_native_reanimated13.useSharedValue)(0);
1176
+ const footerOffset = (0, import_react_native_reanimated13.useSharedValue)(0);
1177
+ const pullSearchHeightShared = (0, import_react_native_reanimated13.useSharedValue)(0);
1178
+ const snapBackHeaderShared = (0, import_react_native_reanimated13.useSharedValue)(false);
1179
+ const snapBackFooterShared = (0, import_react_native_reanimated13.useSharedValue)(false);
1180
+ (0, import_react15.useEffect)(() => {
2440
1181
  snapBackHeaderShared.value = effectiveSnapBackHeader ?? effectiveSnapBack;
2441
1182
  snapBackFooterShared.value = effectiveSnapBackFooter ?? effectiveSnapBack;
2442
1183
  }, [effectiveSnapBack, effectiveSnapBackFooter, effectiveSnapBackHeader, snapBackFooterShared, snapBackHeaderShared]);
2443
- const setHeaderHeight = (0, import_react14.useCallback)(
1184
+ const setHeaderHeight = (0, import_react15.useCallback)(
2444
1185
  (h) => {
2445
1186
  setHeaderHeightState(h);
2446
- headerHeightShared.value = h;
1187
+ headerHeightShared.value = h ?? 0;
2447
1188
  },
2448
1189
  [headerHeightShared]
2449
1190
  );
2450
- const setFooterHeight = (0, import_react14.useCallback)(
1191
+ const onListUnmount = (0, import_react15.useCallback)(() => {
1192
+ listGeneration.value += 1;
1193
+ }, [listGeneration]);
1194
+ const onJsListUnmount = (0, import_react15.useCallback)(() => {
1195
+ jsListGeneration.current += 1;
1196
+ }, []);
1197
+ (0, import_react15.useEffect)(() => {
1198
+ if (!__DEV__ || headerHeight !== null) return;
1199
+ const timeout = setTimeout(() => {
1200
+ console.warn("[scroll-view] No ScrollViewHeader ever measured inside this ScrollViewProvider \u2014 scroll content stays hidden (opacity: 0) until one does. Render a <ScrollViewHeader> (it can be empty / zero height) inside this provider.");
1201
+ }, 3e3);
1202
+ return () => clearTimeout(timeout);
1203
+ }, [headerHeight]);
1204
+ const setFooterHeight = (0, import_react15.useCallback)(
2451
1205
  (h) => {
2452
1206
  setFooterHeightState(h);
2453
1207
  footerHeightShared.value = h;
2454
1208
  },
2455
1209
  [footerHeightShared]
2456
1210
  );
2457
- const scrollHeight = (0, import_react14.useMemo)(() => import_react_native11.Dimensions.get("window").height - headerHeight - footerHeight, [headerHeight, footerHeight]);
1211
+ const scrollHeight = (0, import_react15.useMemo)(() => import_react_native11.Dimensions.get("window").height - (headerHeight ?? 0) - footerHeight, [headerHeight, footerHeight]);
2458
1212
  const effectiveHeaderFixed = fixed || (headerFixed ?? settings.headerFixed);
2459
1213
  const effectiveFooterFixed = fixed || (footerFixed ?? settings.footerFixed);
2460
- const value = (0, import_react14.useMemo)(() => ({ blur: effectiveBlur, footerHeight, footerHeightShared, footerFixed: effectiveFooterFixed, footerOffset, headerHeight, headerHeightShared, headerFixed: effectiveHeaderFixed, headerOffset, progress, pullSearchHeightShared, progressing, scrollHeight, scrollPosition, setFooterHeight, setHeaderHeight, setProgress, setProgressing, snapBackFooterShared, snapBackHeaderShared, tabBarHeight }), [effectiveBlur, effectiveFooterFixed, effectiveHeaderFixed, footerHeight, footerHeightShared, footerOffset, headerHeight, headerHeightShared, headerOffset, progress, pullSearchHeightShared, progressing, scrollHeight, scrollPosition, setFooterHeight, setHeaderHeight, snapBackFooterShared, snapBackHeaderShared, tabBarHeight]);
1214
+ const value = (0, import_react15.useMemo)(() => ({ blur: effectiveBlur, footerHeight, footerHeightShared, footerFixed: effectiveFooterFixed, footerOffset, headerHeight, headerHeightShared, headerFixed: effectiveHeaderFixed, headerOffset, jsListGeneration, listGeneration, onJsListUnmount, onListUnmount, progress, pullSearchHeightShared, progressing, scrollHeight, scrollPosition, setFooterHeight, setHeaderHeight, setProgress, setProgressing, snapBackFooterShared, snapBackHeaderShared, tabBarHeight }), [effectiveBlur, effectiveFooterFixed, effectiveHeaderFixed, footerHeight, footerHeightShared, footerOffset, headerHeight, headerHeightShared, headerOffset, jsListGeneration, listGeneration, onJsListUnmount, onListUnmount, progress, pullSearchHeightShared, progressing, scrollHeight, scrollPosition, setFooterHeight, setHeaderHeight, snapBackFooterShared, snapBackHeaderShared, tabBarHeight]);
2461
1215
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ScrollViewContext.Provider, { value, children });
2462
1216
  };
2463
1217
 
2464
1218
  // src/ScrollViewSettingsProvider.tsx
2465
- var import_react15 = require("react");
1219
+ var import_react16 = require("react");
2466
1220
  var import_jsx_runtime11 = require("react/jsx-runtime");
2467
1221
  var ScrollViewSettingsProvider = ({ children, onChange, initialValue }) => {
2468
- const [settings, setSettings] = (0, import_react15.useState)(() => ({
1222
+ const [settings, setSettings] = (0, import_react16.useState)(() => ({
2469
1223
  ...defaultScrollViewSettings,
2470
1224
  ...initialValue
2471
1225
  }));
2472
- const set2 = (0, import_react15.useCallback)(
1226
+ const set = (0, import_react16.useCallback)(
2473
1227
  (patch) => {
2474
1228
  setSettings((prev) => {
2475
1229
  const next = { ...prev, ...patch };
@@ -2479,33 +1233,33 @@ var ScrollViewSettingsProvider = ({ children, onChange, initialValue }) => {
2479
1233
  },
2480
1234
  [onChange]
2481
1235
  );
2482
- const ctx = (0, import_react15.useMemo)(() => ({ settings, set: set2 }), [settings, set2]);
1236
+ const ctx = (0, import_react16.useMemo)(() => ({ settings, set }), [settings, set]);
2483
1237
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ScrollViewSettingsContext.Provider, { value: ctx, children });
2484
1238
  };
2485
1239
 
2486
1240
  // src/SectionList.tsx
2487
- var import_react17 = require("react");
1241
+ var import_react18 = require("react");
2488
1242
  var import_react_native12 = require("react-native");
2489
1243
  var import_react_native_gesture_handler4 = require("react-native-gesture-handler");
2490
- var import_react_native_reanimated13 = __toESM(require("react-native-reanimated"));
1244
+ var import_react_native_reanimated15 = __toESM(require("react-native-reanimated"));
2491
1245
 
2492
1246
  // src/internal/useStickyHeaders.ts
2493
- var import_react16 = require("react");
2494
- var import_react_native_reanimated12 = require("react-native-reanimated");
1247
+ var import_react17 = require("react");
1248
+ var import_react_native_reanimated14 = require("react-native-reanimated");
2495
1249
  var import_react_native_safe_area_context5 = require("react-native-safe-area-context");
2496
1250
  function useStickyHeaders(headerFixed, enabled) {
2497
- const { headerHeightShared, headerOffset, pullSearchHeightShared, scrollPosition, snapBackHeaderShared } = (0, import_react16.useContext)(ScrollViewContext);
1251
+ const { headerHeightShared, headerOffset, pullSearchHeightShared, scrollPosition, snapBackHeaderShared } = (0, import_react17.useContext)(ScrollViewContext);
2498
1252
  const insetsTop = (0, import_react_native_safe_area_context5.useSafeAreaInsets)().top;
2499
- const sectionYPositions = (0, import_react_native_reanimated12.useSharedValue)([]);
2500
- const sectionHeights = (0, import_react_native_reanimated12.useSharedValue)([]);
2501
- const [activeIndex, setActiveIndex] = (0, import_react16.useState)(-1);
2502
- const contentIndexShared = (0, import_react_native_reanimated12.useSharedValue)(-1);
2503
- (0, import_react16.useLayoutEffect)(() => {
1253
+ const sectionYPositions = (0, import_react_native_reanimated14.useSharedValue)([]);
1254
+ const sectionHeights = (0, import_react_native_reanimated14.useSharedValue)([]);
1255
+ const [activeIndex, setActiveIndex] = (0, import_react17.useState)(-1);
1256
+ const contentIndexShared = (0, import_react_native_reanimated14.useSharedValue)(-1);
1257
+ (0, import_react17.useLayoutEffect)(() => {
2504
1258
  contentIndexShared.value = activeIndex;
2505
1259
  }, [activeIndex, contentIndexShared]);
2506
- const positionsCache = (0, import_react16.useRef)([]);
2507
- const heightsCache = (0, import_react16.useRef)([]);
2508
- (0, import_react_native_reanimated12.useAnimatedReaction)(
1260
+ const positionsCache = (0, import_react17.useRef)([]);
1261
+ const heightsCache = (0, import_react17.useRef)([]);
1262
+ (0, import_react_native_reanimated14.useAnimatedReaction)(
2509
1263
  () => {
2510
1264
  if (!enabled) return -1;
2511
1265
  const positions = sectionYPositions.value;
@@ -2530,11 +1284,11 @@ function useStickyHeaders(headerFixed, enabled) {
2530
1284
  return active;
2531
1285
  },
2532
1286
  (curr, prev) => {
2533
- if (curr !== prev) (0, import_react_native_reanimated12.runOnJS)(setActiveIndex)(curr);
1287
+ if (curr !== prev) (0, import_react_native_reanimated14.runOnJS)(setActiveIndex)(curr);
2534
1288
  },
2535
1289
  [enabled, headerFixed, insetsTop]
2536
1290
  );
2537
- const clipStyle = (0, import_react_native_reanimated12.useAnimatedStyle)(() => {
1291
+ const clipStyle = (0, import_react_native_reanimated14.useAnimatedStyle)(() => {
2538
1292
  const hHeight = headerHeightShared.value;
2539
1293
  const scrollPos = scrollPosition.value;
2540
1294
  let stickyTop;
@@ -2548,7 +1302,7 @@ function useStickyHeaders(headerFixed, enabled) {
2548
1302
  }
2549
1303
  return { top: stickyTop };
2550
1304
  }, [enabled, headerFixed, insetsTop]);
2551
- const overlayStyle = (0, import_react_native_reanimated12.useAnimatedStyle)(() => {
1305
+ const overlayStyle = (0, import_react_native_reanimated14.useAnimatedStyle)(() => {
2552
1306
  const hidden = { opacity: 0, top: 0, transform: [{ translateY: 0 }] };
2553
1307
  if (!enabled) return hidden;
2554
1308
  const index = contentIndexShared.value;
@@ -2576,7 +1330,7 @@ function useStickyHeaders(headerFixed, enabled) {
2576
1330
  }
2577
1331
  return { opacity: 1, top: 0, transform: [{ translateY }] };
2578
1332
  }, [enabled, headerFixed, insetsTop]);
2579
- const measureHeader = (0, import_react16.useCallback)(
1333
+ const measureHeader = (0, import_react17.useCallback)(
2580
1334
  (index, pageY, height) => {
2581
1335
  const contentY = pageY + scrollPosition.value;
2582
1336
  positionsCache.current[index] = contentY;
@@ -2586,7 +1340,7 @@ function useStickyHeaders(headerFixed, enabled) {
2586
1340
  },
2587
1341
  [scrollPosition, sectionHeights, sectionYPositions]
2588
1342
  );
2589
- const resetPositions = (0, import_react16.useCallback)(
1343
+ const resetPositions = (0, import_react17.useCallback)(
2590
1344
  (count) => {
2591
1345
  positionsCache.current = Array.from({ length: count }, () => -1);
2592
1346
  sectionYPositions.value = positionsCache.current.slice();
@@ -2600,18 +1354,27 @@ function useStickyHeaders(headerFixed, enabled) {
2600
1354
 
2601
1355
  // src/SectionList.tsx
2602
1356
  var import_jsx_runtime12 = require("react/jsx-runtime");
2603
- var AnimatedSectionList = (0, import_react_native_reanimated13.createAnimatedComponent)(import_react_native12.SectionList);
1357
+ var AnimatedSectionList = import_react_native_reanimated15.default.createAnimatedComponent(import_react_native12.SectionList);
2604
1358
  var SectionListInner = ({ chipProps, chipThreshold, contentContainerStyle: externalContentContainerStyle, initialNumToRender = 20, maxToRenderPerBatch = 50, renderFilters, footerFixed: footerFixedProp, gesture, headerFixed: headerFixedProp, keyboardAware, ListHeaderComponent: externalListHeaderComponent, onChipPress, onMomentumScrollEnd: externalMomentumScrollEnd, onRefresh, onContentSizeChange, onScrollBeginDrag: externalScrollBeginDrag, onScrollEndDrag: externalScrollEndDrag, pullSearchHeight, refreshing, removeClippedSubviews = false, sections, showsVerticalScrollIndicator, style, ref: externalRef, windowSize = 100, ...props }) => {
2605
- const scrollView = (0, import_react17.useRef)(null);
1359
+ const scrollView = (0, import_react18.useRef)(null);
2606
1360
  const { stickySectionHeadersEnabled = true, renderSectionHeader, ...passThroughProps } = props;
2607
1361
  const { chipHidden, chipStyle, containerStyle, contentInset, contentOffset, footerFixed, headerFixed, headerHeight } = useScrollList({ footerFixed: footerFixedProp, headerFixed: headerFixedProp, keyboardAware, pullSearchHeight, style });
1362
+ const { listGeneration, onListUnmount } = (0, import_react18.useContext)(ScrollViewContext);
1363
+ const capturedGeneration = (0, import_react_native_reanimated15.useSharedValue)(-1);
1364
+ (0, import_react18.useLayoutEffect)(() => {
1365
+ const generation = listGeneration.value;
1366
+ (0, import_react_native_reanimated15.runOnUI)((gen) => {
1367
+ "worklet";
1368
+ capturedGeneration.value = gen;
1369
+ })(generation);
1370
+ }, [capturedGeneration, listGeneration]);
2608
1371
  const usesCustomSticky = stickySectionHeadersEnabled && renderSectionHeader != null;
2609
1372
  const { activeIndex, clipStyle, measureHeader, overlayStyle, resetPositions } = useStickyHeaders(headerFixed, usesCustomSticky);
2610
- (0, import_react17.useLayoutEffect)(() => {
1373
+ (0, import_react18.useLayoutEffect)(() => {
2611
1374
  if (usesCustomSticky) resetPositions(sections.length);
2612
1375
  }, [sections, usesCustomSticky, resetPositions, headerHeight]);
2613
- const sectionViewRefs = (0, import_react17.useRef)(/* @__PURE__ */ new Map());
2614
- const wrappedRenderSectionHeader = (0, import_react17.useMemo)(() => {
1376
+ const sectionViewRefs = (0, import_react18.useRef)(/* @__PURE__ */ new Map());
1377
+ const wrappedRenderSectionHeader = (0, import_react18.useMemo)(() => {
2615
1378
  if (!usesCustomSticky) return renderSectionHeader ?? void 0;
2616
1379
  return (info) => {
2617
1380
  const idx = sections.findIndex((s) => s === info.section);
@@ -2632,7 +1395,8 @@ var SectionListInner = ({ chipProps, chipThreshold, contentContainerStyle: exter
2632
1395
  );
2633
1396
  };
2634
1397
  }, [usesCustomSticky, renderSectionHeader, sections, measureHeader]);
2635
- const scrollTo = (0, import_react17.useCallback)((offset, animated) => {
1398
+ (0, import_react18.useLayoutEffect)(() => () => onListUnmount(), [onListUnmount]);
1399
+ const scrollTo = (0, import_react18.useCallback)((offset, animated) => {
2636
1400
  scrollView.current?.getScrollResponder()?.scrollTo({ y: offset, animated });
2637
1401
  }, []);
2638
1402
  const {
@@ -2650,7 +1414,7 @@ var SectionListInner = ({ chipProps, chipThreshold, contentContainerStyle: exter
2650
1414
  pullSearchHeight,
2651
1415
  scrollTo
2652
1416
  });
2653
- const activeListHeader = (0, import_react17.useMemo)(() => {
1417
+ const activeListHeader = (0, import_react18.useMemo)(() => {
2654
1418
  if (!renderFilters) return pullSearchHeader;
2655
1419
  const Inner = pullSearchHeader;
2656
1420
  return () => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
@@ -2658,8 +1422,8 @@ var SectionListInner = ({ chipProps, chipThreshold, contentContainerStyle: exter
2658
1422
  renderFilters
2659
1423
  ] });
2660
1424
  }, [pullSearchHeader, renderFilters]);
2661
- const pullSearchSettled = (0, import_react17.useRef)(false);
2662
- (0, import_react17.useEffect)(() => {
1425
+ const pullSearchSettled = (0, import_react18.useRef)(false);
1426
+ (0, import_react18.useEffect)(() => {
2663
1427
  if (!usesCustomSticky || activeListHeader == null || pullSearchSettled.current) return;
2664
1428
  pullSearchSettled.current = true;
2665
1429
  const handle = requestAnimationFrame(() => {
@@ -2671,25 +1435,21 @@ var SectionListInner = ({ chipProps, chipThreshold, contentContainerStyle: exter
2671
1435
  });
2672
1436
  return () => cancelAnimationFrame(handle);
2673
1437
  }, [activeListHeader, usesCustomSticky, measureHeader]);
2674
- const contentContainerStyle = (0, import_react17.useMemo)(() => [{ minHeight: import_react_native12.Dimensions.get("window").height - contentInset.top - contentInset.bottom + pullSearchMinHeight }, externalContentContainerStyle], [contentInset.bottom, contentInset.top, externalContentContainerStyle, pullSearchMinHeight]);
2675
- const onPullSearchZoneEnter = (0, import_react17.useCallback)(() => {
2676
- if (!pullSearchHeight) return;
2677
- scrollTo(-contentInset.top + pullSearchHeight, true);
2678
- }, [contentInset.top, pullSearchHeight, scrollTo]);
2679
- const handleScroll = useScrollHandler({ chipHidden, chipThreshold, footerFixed, headerFixed, onPullSearchZoneEnter: pullSearchHeight ? onPullSearchZoneEnter : void 0 });
2680
- const handleScrollToTop = (0, import_react17.useCallback)(() => {
1438
+ const contentContainerStyle = (0, import_react18.useMemo)(() => [{ minHeight: import_react_native12.Dimensions.get("window").height - contentInset.top - contentInset.bottom + pullSearchMinHeight }, externalContentContainerStyle], [contentInset.bottom, contentInset.top, externalContentContainerStyle, pullSearchMinHeight]);
1439
+ const handleScroll = useScrollHandler({ capturedGeneration, chipHidden, chipThreshold, footerFixed, headerFixed, listGeneration });
1440
+ const handleScrollToTop = (0, import_react18.useCallback)(() => {
2681
1441
  const offset = pullSearchHeight ? -contentInset.top + pullSearchHeight : -contentInset.top;
2682
1442
  scrollView.current?.getScrollResponder()?.scrollTo({ y: offset, animated: true });
2683
1443
  }, [contentInset.top, pullSearchHeight]);
2684
- const handleContentSizeChange = (0, import_react17.useCallback)(
1444
+ const handleContentSizeChange = (0, import_react18.useCallback)(
2685
1445
  (w, h) => {
2686
1446
  if (onContentSizeChange) onContentSizeChange(w, h);
2687
1447
  },
2688
1448
  [onContentSizeChange]
2689
1449
  );
2690
- const refreshControl = (0, import_react17.useMemo)(() => onRefresh ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RefreshControl, { onRefresh, refreshing: refreshing ?? false }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RefreshControl, {}), [onRefresh, refreshing]);
2691
- const nativeGesture = (0, import_react17.useMemo)(() => import_react_native_gesture_handler4.Gesture.Native(), []);
2692
- const combinedGesture = (0, import_react17.useMemo)(() => gesture !== void 0 ? import_react_native_gesture_handler4.Gesture.Simultaneous(gesture, nativeGesture) : nativeGesture, [gesture, nativeGesture]);
1450
+ const refreshControl = (0, import_react18.useMemo)(() => onRefresh ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RefreshControl, { onRefresh, refreshing: refreshing ?? false }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RefreshControl, {}), [onRefresh, refreshing]);
1451
+ const nativeGesture = (0, import_react18.useMemo)(() => import_react_native_gesture_handler4.Gesture.Native(), []);
1452
+ const combinedGesture = (0, import_react18.useMemo)(() => gesture !== void 0 ? import_react_native_gesture_handler4.Gesture.Simultaneous(gesture, nativeGesture) : nativeGesture, [gesture, nativeGesture]);
2693
1453
  const detectorGesture = gesture !== void 0 ? combinedGesture : void 0;
2694
1454
  const content = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_native12.View, { style: containerStyle, children: [
2695
1455
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
@@ -2720,11 +1480,11 @@ var SectionListInner = ({ chipProps, chipThreshold, contentContainerStyle: exter
2720
1480
  stickySectionHeadersEnabled: false,
2721
1481
  windowSize
2722
1482
  },
2723
- headerHeight > 0 ? 1 : 0
1483
+ headerHeight !== null && headerHeight > 0 ? 1 : 0
2724
1484
  ),
2725
1485
  hiddenHeader && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native12.View, { pointerEvents: "none", style: styles8.measureContainer, children: hiddenHeader }),
2726
1486
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ScrollViewChip, { chipProps, onChipPress, onPress: handleScrollToTop, style: chipStyle }),
2727
- usesCustomSticky && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native_reanimated13.default.View, { pointerEvents: "none", style: [styles8.stickyClip, clipStyle], children: activeIndex >= 0 && activeIndex < sections.length && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native_reanimated13.default.View, { style: [styles8.stickyOverlay, overlayStyle], children: renderSectionHeader({ section: sections[activeIndex] }) }) })
1487
+ usesCustomSticky && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native_reanimated15.default.View, { pointerEvents: "none", style: [styles8.stickyClip, clipStyle], children: activeIndex >= 0 && activeIndex < sections.length && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native_reanimated15.default.View, { style: [styles8.stickyOverlay, overlayStyle], children: renderSectionHeader({ section: sections[activeIndex] }) }) })
2728
1488
  ] });
2729
1489
  return detectorGesture ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native_gesture_handler4.GestureDetector, { gesture: detectorGesture, children: content }) : content;
2730
1490
  };
@@ -2733,18 +1493,18 @@ var styles8 = {
2733
1493
  stickyClip: { bottom: 0, left: 0, overflow: "hidden", position: "absolute", right: 0, zIndex: 2 },
2734
1494
  stickyOverlay: { left: 0, position: "absolute", right: 0 }
2735
1495
  };
2736
- var SectionList = (0, import_react17.memo)(SectionListInner);
1496
+ var SectionList = (0, import_react18.memo)(SectionListInner);
2737
1497
 
2738
1498
  // src/useScrollView.ts
2739
- var import_react18 = require("react");
1499
+ var import_react19 = require("react");
2740
1500
  var useScrollView = () => {
2741
- const { progress, progressing, scrollHeight, scrollPosition, setProgress, setProgressing } = (0, import_react18.useContext)(ScrollViewContext);
1501
+ const { progress, progressing, scrollHeight, scrollPosition, setProgress, setProgressing } = (0, import_react19.useContext)(ScrollViewContext);
2742
1502
  return { progress, progressing, scrollHeight, scrollPosition, setProgress, setProgressing };
2743
1503
  };
2744
1504
 
2745
1505
  // src/useScrollViewSettings.ts
2746
- var import_react19 = require("react");
2747
- var useScrollViewSettings = () => (0, import_react19.useContext)(ScrollViewSettingsContext);
1506
+ var import_react20 = require("react");
1507
+ var useScrollViewSettings = () => (0, import_react20.useContext)(ScrollViewSettingsContext);
2748
1508
  // Annotate the CommonJS export names for ESM import in node:
2749
1509
  0 && (module.exports = {
2750
1510
  CustomList,