tamagui 2.3.3 → 2.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.
package/dist/test.cjs CHANGED
@@ -12349,6 +12349,43 @@ function updateMediaListeners() {
12349
12349
  return cb(getMedia());
12350
12350
  });
12351
12351
  }
12352
+ function buildTouchTrackerProto() {
12353
+ var proto = {};
12354
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
12355
+ try {
12356
+ var _loop = function() {
12357
+ var fullKey = _step.value;
12358
+ var key = fullKey[0] === "$" ? fullKey.slice(1) : fullKey;
12359
+ proto[key] = {
12360
+ enumerable: true,
12361
+ configurable: true,
12362
+ get() {
12363
+ var slot = this[refSlot];
12364
+ if (!disableMediaTouch) slot.keys.add(key);
12365
+ return slot.proxyTarget[key];
12366
+ }
12367
+ };
12368
+ };
12369
+ for (var _iterator = mediaKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();
12370
+ } catch (err) {
12371
+ _didIteratorError = true;
12372
+ _iteratorError = err;
12373
+ } finally {
12374
+ try {
12375
+ if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
12376
+ } finally {
12377
+ if (_didIteratorError) throw _iteratorError;
12378
+ }
12379
+ }
12380
+ return Object.create(null, proto);
12381
+ }
12382
+ function getTouchTrackerProto() {
12383
+ if (!touchTrackerProto) touchTrackerProto = buildTouchTrackerProto();
12384
+ return touchTrackerProto;
12385
+ }
12386
+ function resetMediaTouchTracker() {
12387
+ touchTrackerProto = null;
12388
+ }
12352
12389
  function setMediaShouldUpdate(ref, enabled, keys) {
12353
12390
  var cur = States.get(ref);
12354
12391
  if (!cur || cur.enabled !== enabled || keys) States.set(ref, _objectSpread2(_objectSpread2({}, cur), {}, {
@@ -12364,53 +12401,99 @@ function subscribe$1(subscriber) {
12364
12401
  }
12365
12402
  function useMedia(componentContext, debug) {
12366
12403
  "use no memo";
12367
- var componentState = componentContext ? States.get(componentContext) : null;
12368
12404
  var internalRef = (0, react$1.useRef)(null);
12369
- if (!internalRef.current) internalRef.current = {
12370
- keys: /* @__PURE__ */ new Set(),
12371
- lastState: getMedia()
12372
- };
12373
- if (internalRef.current.pendingState) {
12374
- internalRef.current.lastState = internalRef.current.pendingState;
12375
- internalRef.current.pendingState = void 0;
12376
- }
12377
- var { keys } = internalRef.current;
12378
- if (keys.size) keys.clear();
12379
- var state = (0, react$1.useSyncExternalStore)(subscribe$1, function() {
12380
- var curKeys = (componentState === null || componentState === void 0 ? void 0 : componentState.keys) || keys;
12381
- var { lastState, pendingState } = internalRef.current;
12382
- if (!curKeys.size) return lastState;
12383
- var ms = getMedia();
12384
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
12385
- try {
12386
- for (var _iterator = curKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
12387
- var key = _step.value;
12388
- if (ms[key] !== (pendingState || lastState)[key]) {
12389
- if (componentContext === null || componentContext === void 0 ? void 0 : componentContext.mediaEmit) {
12390
- componentContext.mediaEmit(ms);
12391
- internalRef.current.pendingState = ms;
12392
- return lastState;
12405
+ if (!internalRef.current) {
12406
+ var initial = getMedia();
12407
+ var r = {
12408
+ keys: /* @__PURE__ */ new Set(),
12409
+ lastState: initial,
12410
+ renderVersion: 0,
12411
+ proxyTarget: initial,
12412
+ proxy: void 0,
12413
+ getSnapshot: void 0,
12414
+ componentContext,
12415
+ debug
12416
+ };
12417
+ var tracker = Object.create(getTouchTrackerProto());
12418
+ tracker[refSlot] = {
12419
+ proxyTarget: initial,
12420
+ keys: r.keys
12421
+ };
12422
+ r.proxy = tracker;
12423
+ r.getSnapshot = function() {
12424
+ var _States_get;
12425
+ var curKeys = r.componentContext ? ((_States_get = States.get(r.componentContext)) === null || _States_get === void 0 ? void 0 : _States_get.keys) || r.keys : r.keys;
12426
+ var { lastState, pendingState } = r;
12427
+ if (!curKeys.size) return lastState;
12428
+ var ms = getMedia();
12429
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
12430
+ try {
12431
+ for (var _iterator = curKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
12432
+ var key = _step.value;
12433
+ if (ms[key] !== (pendingState || lastState)[key]) {
12434
+ var _r_componentContext;
12435
+ if ((_r_componentContext = r.componentContext) === null || _r_componentContext === void 0 ? void 0 : _r_componentContext.mediaEmit) {
12436
+ r.componentContext.mediaEmit(ms);
12437
+ r.pendingState = ms;
12438
+ return lastState;
12439
+ }
12440
+ r.lastState = ms;
12441
+ return ms;
12393
12442
  }
12394
- internalRef.current.lastState = ms;
12395
- return ms;
12396
12443
  }
12397
- }
12398
- } catch (err) {
12399
- _didIteratorError = true;
12400
- _iteratorError = err;
12401
- } finally {
12402
- try {
12403
- if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
12444
+ } catch (err) {
12445
+ _didIteratorError = true;
12446
+ _iteratorError = err;
12404
12447
  } finally {
12405
- if (_didIteratorError) throw _iteratorError;
12448
+ try {
12449
+ if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
12450
+ } finally {
12451
+ if (_didIteratorError) throw _iteratorError;
12452
+ }
12406
12453
  }
12454
+ return lastState;
12455
+ };
12456
+ internalRef.current = r;
12457
+ } else {
12458
+ internalRef.current.componentContext = componentContext;
12459
+ internalRef.current.debug = debug;
12460
+ }
12461
+ var ref = internalRef.current;
12462
+ ref.renderVersion++;
12463
+ if (ref.pendingState) {
12464
+ ref.lastState = ref.pendingState;
12465
+ ref.pendingState = void 0;
12466
+ }
12467
+ if (ref.keys.size) ref.keys.clear();
12468
+ var [, forceUpdate] = (0, react$1.useReducer)(incReducer$1, 0);
12469
+ var state = ref.getSnapshot();
12470
+ ref.proxyTarget = state;
12471
+ ref.proxy[refSlot].proxyTarget = state;
12472
+ (0, react$1.useEffect)(function() {
12473
+ var _States_get;
12474
+ var renderVersion = ref.renderVersion;
12475
+ if (!ref.componentContext || !!((_States_get = States.get(ref.componentContext)) === null || _States_get === void 0 ? void 0 : _States_get.enabled)) {
12476
+ if (!ref.unsubscribe) ref.unsubscribe = subscribe$1(function() {
12477
+ var next = ref.getSnapshot();
12478
+ if (next !== ref.proxyTarget) {
12479
+ ref.proxyTarget = next;
12480
+ ref.proxy[refSlot].proxyTarget = next;
12481
+ forceUpdate();
12482
+ }
12483
+ });
12484
+ } else if (ref.unsubscribe) {
12485
+ ref.unsubscribe();
12486
+ ref.unsubscribe = void 0;
12407
12487
  }
12408
- return lastState;
12409
- }, getServerSnapshot);
12410
- return new Proxy(state, { get(_, key) {
12411
- if (!disableMediaTouch && typeof key === "string") keys.add(key);
12412
- return Reflect.get(state, key);
12413
- } });
12488
+ return function() {
12489
+ if (ref.renderVersion === renderVersion) {
12490
+ var _ref_unsubscribe;
12491
+ (_ref_unsubscribe = ref.unsubscribe) === null || _ref_unsubscribe === void 0 || _ref_unsubscribe.call(ref);
12492
+ ref.unsubscribe = void 0;
12493
+ }
12494
+ };
12495
+ });
12496
+ return ref.proxy;
12414
12497
  }
12415
12498
  function getMediaState(mediaGroups, layout) {
12416
12499
  disableMediaTouch = true;
@@ -12433,7 +12516,7 @@ function mediaKeyMatch(key, dimensions) {
12433
12516
  return isMax ? givenVal < expectedVal : givenVal > expectedVal;
12434
12517
  });
12435
12518
  }
12436
- var mediaKeyRegex, getMediaKey, initState, mediaKeysOrdered, getMediaKeyImportance, dispose, mediaVersion, configureMedia, setupVersion, listeners, States, getServerSnapshot, disableMediaTouch, getMediaImportanceIfMoreImportant;
12519
+ var mediaKeyRegex, getMediaKey, mediaKeysOrdered, getMediaKeyImportance, dispose, mediaVersion, configureMedia, setupVersion, listeners, States, touchTrackerProto, refSlot, incReducer$1, disableMediaTouch, getMediaImportanceIfMoreImportant;
12437
12520
  var init_useMedia_native = __esmMin((() => {
12438
12521
  init_index_native$7();
12439
12522
  init_config_native();
@@ -12462,20 +12545,23 @@ var init_useMedia_native = __esmMin((() => {
12462
12545
  if (!media) return;
12463
12546
  mediaVersion++;
12464
12547
  resetMediaStyleCache();
12548
+ resetMediaTouchTracker();
12465
12549
  for (var key in media) {
12466
12550
  getMedia()[key] = (mediaQueryDefaultActive === null || mediaQueryDefaultActive === void 0 ? void 0 : mediaQueryDefaultActive[key]) || false;
12467
12551
  mediaKeys.add(`$${key}`);
12468
12552
  }
12469
12553
  Object.assign(mediaQueryConfig, media);
12470
- initState = _objectSpread2({}, getMedia());
12554
+ _objectSpread2({}, getMedia());
12471
12555
  mediaKeysOrdered = Object.keys(media);
12472
12556
  setupMediaListeners();
12473
12557
  };
12474
12558
  setupVersion = -1;
12475
12559
  listeners = /* @__PURE__ */ new Set();
12476
12560
  States = /* @__PURE__ */ new WeakMap();
12477
- getServerSnapshot = function() {
12478
- return initState;
12561
+ touchTrackerProto = null;
12562
+ refSlot = /* @__PURE__ */ Symbol("mediaRefSlot");
12563
+ incReducer$1 = function(c) {
12564
+ return c + 1;
12479
12565
  };
12480
12566
  disableMediaTouch = false;
12481
12567
  getMediaImportanceIfMoreImportant = function(mediaKey, key, styleState, isSizeMedia) {
@@ -13100,6 +13186,18 @@ var init_getDynamicVal_native = __esmMin((() => {
13100
13186
  }));
13101
13187
  //#endregion
13102
13188
  //#region ../../core/web/dist/esm/hooks/useThemeState.native.js
13189
+ function cleanupThemeSubscription(r) {
13190
+ var _r_unsubscribe;
13191
+ (_r_unsubscribe = r.unsubscribe) === null || _r_unsubscribe === void 0 || _r_unsubscribe.call(r);
13192
+ }
13193
+ function cleanupThemeState(r) {
13194
+ if (r.unsubscribe) cleanupThemeSubscription(r);
13195
+ else {
13196
+ localStates.delete(r.id);
13197
+ states.delete(r.id);
13198
+ PendingUpdate.delete(r.id);
13199
+ }
13200
+ }
13103
13201
  function scheduleUpdate(id) {
13104
13202
  var queue = [id];
13105
13203
  var visited = /* @__PURE__ */ new Set();
@@ -13273,7 +13371,7 @@ function getNewThemeName() {
13273
13371
  themeNameCache.set(cacheKey, found);
13274
13372
  return found;
13275
13373
  }
13276
- var ThemeStateContext, allListeners, listenersByParent, HasRenderedOnce, HadTheme, PendingUpdate, states, localStates, shouldForce, forceUpdateThemes, getThemeState, cacheVersion, themeNameCache, themeNameCacheVer, themes, rootThemeState, getRootThemeState, getThemeBaseName, useThemeState, getNextState, validSchemes, getPropsKey, hasThemeUpdatingProps;
13374
+ var ThemeStateContext, allListeners, listenersByParent, HasRenderedOnce, HadTheme, PendingUpdate, states, localStates, shouldForce, forceUpdateThemes, getThemeState, cacheVersion, themeNameCache, themeNameCacheVer, themes, rootThemeState, getRootThemeState, getThemeBaseName, incReducer, useThemeState, shouldSubscribeToTheme, getSnapshotImpl, getNextState, validSchemes, getPropsKey, hasThemeUpdatingProps;
13277
13375
  var init_useThemeState_native = __esmMin((() => {
13278
13376
  init_index_native$7();
13279
13377
  init_config_native();
@@ -13310,9 +13408,12 @@ var init_useThemeState_native = __esmMin((() => {
13310
13408
  getThemeBaseName = function(name) {
13311
13409
  return name.replace(/^(light|dark)_/, "");
13312
13410
  };
13411
+ incReducer = function(c) {
13412
+ return c + 1;
13413
+ };
13313
13414
  useThemeState = function(props) {
13314
13415
  "use no memo";
13315
- var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, keys = arguments.length > 2 ? arguments[2] : void 0, schemeKeys = arguments.length > 3 ? arguments[3] : void 0;
13416
+ var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, keys = arguments.length > 2 ? arguments[2] : void 0, schemeKeys = arguments.length > 3 ? arguments[3] : void 0, cascadeOnChange = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false;
13316
13417
  var { disable } = props;
13317
13418
  var parentId = (0, react$1.useContext)(ThemeStateContext);
13318
13419
  if (!parentId && !isRoot) throw new Error(MISSING_THEME_MESSAGE);
@@ -13322,53 +13423,69 @@ var init_useThemeState_native = __esmMin((() => {
13322
13423
  theme: getConfig().themes.light
13323
13424
  };
13324
13425
  var id = (0, react$1.useId)();
13325
- var subscribe = (0, react$1.useCallback)(function(cb) {
13326
- listenersByParent[parentId] = listenersByParent[parentId] || /* @__PURE__ */ new Set();
13327
- listenersByParent[parentId].add(id);
13328
- allListeners.set(id, function() {
13329
- PendingUpdate.set(id, shouldForce ? "force" : true);
13330
- cb();
13331
- });
13332
- return function() {
13333
- allListeners.delete(id);
13334
- listenersByParent[parentId].delete(id);
13335
- localStates.delete(id);
13336
- states.delete(id);
13337
- PendingUpdate.delete(id);
13338
- };
13339
- }, [id, parentId]);
13340
13426
  var propsKey = getPropsKey(props);
13341
- var getSnapshot = function() {
13342
- var _keys_current, _schemeKeys_current, _keys_current1, _props_needsUpdate;
13343
- var local = localStates.get(id);
13344
- var parentState = states.get(parentId);
13345
- if (local && !PendingUpdate.has(id)) {
13346
- if (parentState && local._parentName === parentState.name && local._propsKey === propsKey) return local;
13347
- }
13348
- var isSchemeOnlyChange = supportsDynamicColorIOS && getSetting("fastSchemeChange") && local && parentState && local.scheme !== parentState.scheme && getThemeBaseName(local.name) === getThemeBaseName(parentState.name);
13349
- var _keys_current_size;
13350
- var keysSize = (_keys_current_size = keys === null || keys === void 0 ? void 0 : (_keys_current = keys.current) === null || _keys_current === void 0 ? void 0 : _keys_current.size) !== null && _keys_current_size !== void 0 ? _keys_current_size : 0;
13351
- var _schemeKeys_current_size;
13352
- var allKeysSchemeOptimized = ((_schemeKeys_current_size = schemeKeys === null || schemeKeys === void 0 ? void 0 : (_schemeKeys_current = schemeKeys.current) === null || _schemeKeys_current === void 0 ? void 0 : _schemeKeys_current.size) !== null && _schemeKeys_current_size !== void 0 ? _schemeKeys_current_size : 0) === keysSize && keysSize > 0;
13353
- var canSkipForSchemeChange = isSchemeOnlyChange && allKeysSchemeOptimized;
13354
- var needsUpdate = props.passThrough ? false : isRoot || props.name === "light" || props.name === "dark" || props.name === null ? true : !HasRenderedOnce.get(keys) ? true : canSkipForSchemeChange ? false : (keys === null || keys === void 0 ? void 0 : (_keys_current1 = keys.current) === null || _keys_current1 === void 0 ? void 0 : _keys_current1.size) ? true : (_props_needsUpdate = props.needsUpdate) === null || _props_needsUpdate === void 0 ? void 0 : _props_needsUpdate.call(props);
13355
- var [rerender, next] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, PendingUpdate.get(id));
13356
- PendingUpdate.delete(id);
13357
- if (!local || rerender) {
13358
- local = _objectSpread2({}, next);
13359
- localStates.set(id, local);
13360
- }
13361
- if (next !== local) {
13362
- Object.assign(local, next);
13363
- local.id = id;
13364
- }
13365
- local._parentName = parentState === null || parentState === void 0 ? void 0 : parentState.name;
13366
- local._propsKey = propsKey;
13367
- states.set(id, next);
13368
- return local;
13427
+ var ref = (0, react$1.useRef)(null);
13428
+ if (!ref.current) ref.current = {
13429
+ id,
13430
+ parentId,
13431
+ props,
13432
+ propsKey,
13433
+ isRoot,
13434
+ keys,
13435
+ schemeKeys,
13436
+ renderVersion: 0
13369
13437
  };
13370
- var state = (0, react$1.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
13371
- useIsomorphicLayoutEffect(function() {
13438
+ else {
13439
+ ref.current.props = props;
13440
+ ref.current.propsKey = propsKey;
13441
+ ref.current.isRoot = isRoot;
13442
+ ref.current.keys = keys;
13443
+ ref.current.schemeKeys = schemeKeys;
13444
+ ref.current.parentId = parentId;
13445
+ }
13446
+ ref.current.renderVersion++;
13447
+ var [, forceUpdate] = (0, react$1.useReducer)(incReducer, 0);
13448
+ var state = getSnapshotImpl(ref.current);
13449
+ ref.current.lastSnap = state;
13450
+ (0, react$1.useEffect)(function() {
13451
+ var r = ref.current;
13452
+ var renderVersion = r.renderVersion;
13453
+ if (r.unsubscribe && r.subscribedParentId !== r.parentId) cleanupThemeSubscription(r);
13454
+ if (shouldSubscribeToTheme(r, cascadeOnChange)) {
13455
+ if (!r.unsubscribe) {
13456
+ var pid = r.parentId;
13457
+ var sid = r.id;
13458
+ var cb = function() {
13459
+ var next = getSnapshotImpl(r);
13460
+ if (next !== r.lastSnap) {
13461
+ r.lastSnap = next;
13462
+ forceUpdate();
13463
+ }
13464
+ };
13465
+ listenersByParent[pid] = listenersByParent[pid] || /* @__PURE__ */ new Set();
13466
+ listenersByParent[pid].add(sid);
13467
+ allListeners.set(sid, function() {
13468
+ PendingUpdate.set(sid, shouldForce ? "force" : true);
13469
+ cb();
13470
+ });
13471
+ r.subscribedParentId = pid;
13472
+ r.unsubscribe = function() {
13473
+ var _listenersByParent_pid;
13474
+ allListeners.delete(sid);
13475
+ (_listenersByParent_pid = listenersByParent[pid]) === null || _listenersByParent_pid === void 0 || _listenersByParent_pid.delete(sid);
13476
+ localStates.delete(sid);
13477
+ states.delete(sid);
13478
+ PendingUpdate.delete(sid);
13479
+ r.unsubscribe = void 0;
13480
+ r.subscribedParentId = void 0;
13481
+ };
13482
+ }
13483
+ } else if (r.unsubscribe) cleanupThemeSubscription(r);
13484
+ return function() {
13485
+ if (r.renderVersion === renderVersion) cleanupThemeState(r);
13486
+ };
13487
+ });
13488
+ if (cascadeOnChange) useIsomorphicLayoutEffect(function() {
13372
13489
  if (!HasRenderedOnce.get(keys)) {
13373
13490
  HasRenderedOnce.set(keys, true);
13374
13491
  return;
@@ -13383,6 +13500,40 @@ var init_useThemeState_native = __esmMin((() => {
13383
13500
  }, [keys, propsKey]);
13384
13501
  return state;
13385
13502
  };
13503
+ shouldSubscribeToTheme = function(r, cascadeOnChange) {
13504
+ var _r_keys_current, _r_props_needsUpdate, _r_props;
13505
+ return r.isRoot || cascadeOnChange || hasThemeUpdatingProps(r.props) || !!((_r_keys_current = r.keys.current) === null || _r_keys_current === void 0 ? void 0 : _r_keys_current.size) || !!((_r_props_needsUpdate = (_r_props = r.props).needsUpdate) === null || _r_props_needsUpdate === void 0 ? void 0 : _r_props_needsUpdate.call(_r_props));
13506
+ };
13507
+ getSnapshotImpl = function(r) {
13508
+ var _keys_current, _schemeKeys_current, _keys_current1, _props_needsUpdate;
13509
+ var { id, parentId, props, propsKey, isRoot, keys, schemeKeys } = r;
13510
+ var local = localStates.get(id);
13511
+ var parentState = states.get(parentId);
13512
+ if (local && !PendingUpdate.has(id)) {
13513
+ if (parentState && local._parentName === parentState.name && local._propsKey === propsKey) return local;
13514
+ }
13515
+ var isSchemeOnlyChange = supportsDynamicColorIOS && getSetting("fastSchemeChange") && local && parentState && local.scheme !== parentState.scheme && getThemeBaseName(local.name) === getThemeBaseName(parentState.name);
13516
+ var _keys_current_size;
13517
+ var keysSize = (_keys_current_size = keys === null || keys === void 0 ? void 0 : (_keys_current = keys.current) === null || _keys_current === void 0 ? void 0 : _keys_current.size) !== null && _keys_current_size !== void 0 ? _keys_current_size : 0;
13518
+ var _schemeKeys_current_size;
13519
+ var allKeysSchemeOptimized = ((_schemeKeys_current_size = schemeKeys === null || schemeKeys === void 0 ? void 0 : (_schemeKeys_current = schemeKeys.current) === null || _schemeKeys_current === void 0 ? void 0 : _schemeKeys_current.size) !== null && _schemeKeys_current_size !== void 0 ? _schemeKeys_current_size : 0) === keysSize && keysSize > 0;
13520
+ var canSkipForSchemeChange = isSchemeOnlyChange && allKeysSchemeOptimized;
13521
+ var needsUpdate = props.passThrough ? false : isRoot || props.name === "light" || props.name === "dark" || props.name === null ? true : !HasRenderedOnce.get(keys) ? true : canSkipForSchemeChange ? false : (keys === null || keys === void 0 ? void 0 : (_keys_current1 = keys.current) === null || _keys_current1 === void 0 ? void 0 : _keys_current1.size) ? true : (_props_needsUpdate = props.needsUpdate) === null || _props_needsUpdate === void 0 ? void 0 : _props_needsUpdate.call(props);
13522
+ var [rerender, next] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, PendingUpdate.get(id));
13523
+ PendingUpdate.delete(id);
13524
+ if (!local || rerender) {
13525
+ local = _objectSpread2({}, next);
13526
+ localStates.set(id, local);
13527
+ }
13528
+ if (next !== local) {
13529
+ Object.assign(local, next);
13530
+ local.id = id;
13531
+ }
13532
+ local._parentName = parentState === null || parentState === void 0 ? void 0 : parentState.name;
13533
+ local._propsKey = propsKey;
13534
+ states.set(id, next);
13535
+ return local;
13536
+ };
13386
13537
  getNextState = function(lastState, props, propsKey) {
13387
13538
  var isRoot = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false, id = arguments.length > 4 ? arguments[4] : void 0, parentId = arguments.length > 5 ? arguments[5] : void 0, needsUpdate = arguments.length > 6 ? arguments[6] : void 0, pendingUpdate = arguments.length > 7 ? arguments[7] : void 0;
13388
13539
  var { debug } = props;
@@ -13397,9 +13548,13 @@ var init_useThemeState_native = __esmMin((() => {
13397
13548
  return [shouldRerender, _objectSpread2(_objectSpread2({}, parentState), {}, { isNew: false })];
13398
13549
  }
13399
13550
  if (!name) {
13400
- var next = lastState !== null && lastState !== void 0 ? lastState : parentState;
13401
- if (!next) throw new Error(MISSING_THEME_MESSAGE);
13402
- if (shouldRerender) return [true, _objectSpread2({}, parentState || lastState)];
13551
+ var _ref, _ref1;
13552
+ var next = (_ref1 = (_ref = lastState !== null && lastState !== void 0 ? lastState : parentState) !== null && _ref !== void 0 ? _ref : rootThemeState) !== null && _ref1 !== void 0 ? _ref1 : {
13553
+ id,
13554
+ name: "light",
13555
+ theme: getConfig().themes.light
13556
+ };
13557
+ if (shouldRerender) return [true, _objectSpread2({}, parentState || lastState || next)];
13403
13558
  return [false, next];
13404
13559
  }
13405
13560
  var scheme = getScheme(name);
@@ -13520,10 +13675,14 @@ var init_useTheme_native = __esmMin((() => {
13520
13675
  };
13521
13676
  useThemeWithState = function(props) {
13522
13677
  "use no memo";
13523
- var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
13524
- var keys = (0, react$1.useRef)(null);
13525
- var schemeKeys = (0, react$1.useRef)(null);
13526
- var themeState = useThemeState(props, isRoot, keys, schemeKeys);
13678
+ var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, forThemeView = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
13679
+ var bag = (0, react$1.useRef)(null);
13680
+ if (!bag.current) bag.current = {
13681
+ keys: { current: null },
13682
+ schemeKeys: { current: null }
13683
+ };
13684
+ var { keys, schemeKeys } = bag.current;
13685
+ var themeState = useThemeState(props, isRoot, keys, schemeKeys, forThemeView);
13527
13686
  return [props.passThrough ? {} : getThemeProxied(props, themeState, keys, schemeKeys), themeState];
13528
13687
  };
13529
13688
  }));
@@ -15602,6 +15761,11 @@ function normalizeGroupKey(key, groupContext) {
15602
15761
  function isValidStyleKey(key, validStyles, accept) {
15603
15762
  return key in validStyles ? true : accept && key in accept;
15604
15763
  }
15764
+ function shouldSkipNativeHoverProp(key, isMedia) {
15765
+ if (key === "hoverStyle") return true;
15766
+ if (isMedia === "group") return getGroupPropParts(key.slice(1)).pseudo === "hover";
15767
+ return false;
15768
+ }
15605
15769
  function mergeFlatTransforms(target, flatTransforms) {
15606
15770
  Object.entries(flatTransforms).sort(function(param, param1) {
15607
15771
  var [a] = param, [b] = param1;
@@ -15711,6 +15875,7 @@ var init_getSplitStyles_native = __esmMin((() => {
15711
15875
  viewProps[keyInit] = valInit;
15712
15876
  return "continue";
15713
15877
  }
15878
+ if (keyInit[0] === "d" && keyInit.startsWith("data-")) return "continue";
15714
15879
  if (keyInit === "jestAnimatedStyle") return "continue";
15715
15880
  if (accept) {
15716
15881
  var accepted = accept[keyInit];
@@ -15753,6 +15918,7 @@ var init_getSplitStyles_native = __esmMin((() => {
15753
15918
  var isMediaOrPseudo = Boolean(isMedia || isPseudo);
15754
15919
  if (isMediaOrPseudo && isMedia === "group") keyInit = normalizeGroupKey(keyInit, groupContext);
15755
15920
  var isStyleProp = isValidStyleKeyInit || isMediaOrPseudo || isVariant && !noExpand;
15921
+ if (shouldSkipNativeHoverProp(keyInit, isMedia)) return "continue";
15756
15922
  if (isStyleProp && (asChild === "except-style" || asChild === "except-style-web")) return "continue";
15757
15923
  var shouldPassProp = !isStyleProp && isHOC || isHOC && parentVariants && keyInit in parentVariants || (inlineProps === null || inlineProps === void 0 ? void 0 : inlineProps.has(keyInit));
15758
15924
  var parentVariant = parentVariants === null || parentVariants === void 0 ? void 0 : parentVariants[keyInit];
@@ -15790,6 +15956,7 @@ var init_getSplitStyles_native = __esmMin((() => {
15790
15956
  isMediaOrPseudo = Boolean(isMedia || isPseudo);
15791
15957
  isVariant = variants && key5 in variants;
15792
15958
  if (isMedia === "group") key5 = normalizeGroupKey(key5, groupContext);
15959
+ if (shouldSkipNativeHoverProp(key5, isMedia)) return;
15793
15960
  if ((inlineProps === null || inlineProps === void 0 ? void 0 : inlineProps.has(key5)) || process.env.IS_STATIC === "is_static" && (inlineWhenUnflattened === null || inlineWhenUnflattened === void 0 ? void 0 : inlineWhenUnflattened.has(key5))) {
15794
15961
  var _props_key;
15795
15962
  viewProps[key5] = (_props_key = props[key5]) !== null && _props_key !== void 0 ? _props_key : val2;
@@ -15954,6 +16121,7 @@ var init_getSplitStyles_native = __esmMin((() => {
15954
16121
  var groupState = groupContext === null || groupContext === void 0 ? void 0 : (_groupContext_groupName = groupContext[groupName]) === null || _groupContext_groupName === void 0 ? void 0 : _groupContext_groupName.state;
15955
16122
  var groupPseudoKey = groupInfo.pseudo;
15956
16123
  var groupMediaKey = groupInfo.media;
16124
+ if (groupPseudoKey === "hover") return;
15957
16125
  if (!groupState) {
15958
16126
  pseudoGroups || (pseudoGroups = /* @__PURE__ */ new Set());
15959
16127
  return;
@@ -16307,13 +16475,17 @@ var init_mergeRenderElementProps_native = __esmMin((() => {
16307
16475
  function usePointerEvents(props, viewProps) {
16308
16476
  var { onPointerDown, onPointerUp, onPointerMove, onPointerCancel, onPointerEnter, onPointerLeave } = props;
16309
16477
  var hasPointerEvents = onPointerDown || onPointerUp || onPointerMove || onPointerCancel || onPointerEnter || onPointerLeave;
16310
- var isInsideRef = (0, react$1.useRef)(false);
16311
- var layoutRef = (0, react$1.useRef)({
16312
- width: 0,
16313
- height: 0
16314
- });
16315
- var isCapturedRef = (0, react$1.useRef)(false);
16478
+ var ref = (0, react$1.useRef)(null);
16479
+ if (!ref.current) ref.current = {
16480
+ isInside: false,
16481
+ layout: {
16482
+ width: 0,
16483
+ height: 0
16484
+ },
16485
+ isCaptured: false
16486
+ };
16316
16487
  if (!hasPointerEvents) return;
16488
+ var bag = ref.current;
16317
16489
  var createNormalizedEvent = function(e) {
16318
16490
  var touch = e.nativeEvent;
16319
16491
  var _touch_identifier;
@@ -16329,10 +16501,10 @@ function usePointerEvents(props, viewProps) {
16329
16501
  nativeEvent: touch,
16330
16502
  target: {
16331
16503
  setPointerCapture: function(_pointerId) {
16332
- isCapturedRef.current = true;
16504
+ bag.isCaptured = true;
16333
16505
  },
16334
16506
  releasePointerCapture: function(_pointerId) {
16335
- isCapturedRef.current = false;
16507
+ bag.isCaptured = false;
16336
16508
  }
16337
16509
  }
16338
16510
  });
@@ -16341,46 +16513,46 @@ function usePointerEvents(props, viewProps) {
16341
16513
  onPointerDown(createNormalizedEvent(e));
16342
16514
  });
16343
16515
  if (onPointerUp) viewProps.onTouchEnd = composeEventHandlers(viewProps.onTouchEnd, function(e) {
16344
- isCapturedRef.current = false;
16516
+ bag.isCaptured = false;
16345
16517
  onPointerUp(createNormalizedEvent(e));
16346
16518
  });
16347
16519
  if (onPointerMove) viewProps.onTouchMove = composeEventHandlers(viewProps.onTouchMove, function(e) {
16348
16520
  var { locationX, locationY } = e.nativeEvent;
16349
- var { width, height } = layoutRef.current;
16521
+ var { width, height } = bag.layout;
16350
16522
  var isInBounds = locationX >= 0 && locationX <= width && locationY >= 0 && locationY <= height;
16351
- if (isCapturedRef.current || isInBounds) onPointerMove(createNormalizedEvent(e));
16523
+ if (bag.isCaptured || isInBounds) onPointerMove(createNormalizedEvent(e));
16352
16524
  });
16353
16525
  if (onPointerCancel) viewProps.onTouchCancel = composeEventHandlers(viewProps.onTouchCancel, function(e) {
16354
- isCapturedRef.current = false;
16526
+ bag.isCaptured = false;
16355
16527
  onPointerCancel(createNormalizedEvent(e));
16356
16528
  });
16357
16529
  if (onPointerEnter || onPointerLeave || onPointerMove) viewProps.onLayout = composeEventHandlers(viewProps.onLayout, function(e) {
16358
- layoutRef.current = {
16530
+ bag.layout = {
16359
16531
  width: e.nativeEvent.layout.width,
16360
16532
  height: e.nativeEvent.layout.height
16361
16533
  };
16362
16534
  });
16363
16535
  if (onPointerEnter) viewProps.onTouchStart = composeEventHandlers(viewProps.onTouchStart, function(e) {
16364
16536
  var { locationX, locationY } = e.nativeEvent;
16365
- var { width, height } = layoutRef.current;
16537
+ var { width, height } = bag.layout;
16366
16538
  if (locationX >= 0 && locationX <= width && locationY >= 0 && locationY <= height) {
16367
- isInsideRef.current = true;
16539
+ bag.isInside = true;
16368
16540
  onPointerEnter(createNormalizedEvent(e));
16369
16541
  }
16370
16542
  });
16371
16543
  if (onPointerLeave) {
16372
16544
  viewProps.onTouchMove = composeEventHandlers(viewProps.onTouchMove, function(e) {
16373
16545
  var { locationX, locationY } = e.nativeEvent;
16374
- var { width, height } = layoutRef.current;
16546
+ var { width, height } = bag.layout;
16375
16547
  var isInside = locationX >= 0 && locationX <= width && locationY >= 0 && locationY <= height;
16376
- if (isInsideRef.current && !isInside) {
16377
- isInsideRef.current = false;
16548
+ if (bag.isInside && !isInside) {
16549
+ bag.isInside = false;
16378
16550
  onPointerLeave(createNormalizedEvent(e));
16379
16551
  }
16380
16552
  });
16381
16553
  viewProps.onTouchEnd = composeEventHandlers(viewProps.onTouchEnd, function(e) {
16382
- if (isInsideRef.current) {
16383
- isInsideRef.current = false;
16554
+ if (bag.isInside) {
16555
+ bag.isInside = false;
16384
16556
  onPointerLeave(createNormalizedEvent(e));
16385
16557
  }
16386
16558
  });
@@ -16576,7 +16748,7 @@ var init_Theme_native = __esmMin((() => {
16576
16748
  if (props.disable) return props.children;
16577
16749
  var { passThrough } = props;
16578
16750
  var isRoot = !!props["_isRoot"];
16579
- var [_, themeState] = useThemeWithState(props, isRoot);
16751
+ var [_, themeState] = useThemeWithState(props, isRoot, true);
16580
16752
  var finalChildren = props["disable-child-theme"] ? react$1.Children.map(props.children, function(child) {
16581
16753
  return passThrough || !/* @__PURE__ */ (0, react$1.isValidElement)(child) ? child : /* @__PURE__ */ (0, react$1.cloneElement)(child, { ["data-disable-theme"]: true });
16582
16754
  }) : props.children;
@@ -16745,7 +16917,15 @@ var init_useComponentState_native = __esmMin((() => {
16745
16917
  });
16746
16918
  }
16747
16919
  var groupName = props.group;
16748
- var setStateShallow = useCreateShallowSetState(setState, props.debug);
16920
+ if (!stateRef.current.baseSetStateShallow) {
16921
+ var r = stateRef.current;
16922
+ r.baseSetStateShallow = function(stateOrGetState) {
16923
+ setState(function(prev) {
16924
+ return mergeIfNotShallowEqual(prev, typeof stateOrGetState === "function" ? stateOrGetState(prev) : stateOrGetState);
16925
+ });
16926
+ };
16927
+ }
16928
+ var setStateShallow = stateRef.current.baseSetStateShallow;
16749
16929
  if (presenceState && isAnimated && isHydrated && staticConfig.variants) {
16750
16930
  var { enterVariant, exitVariant, enterExitVariant, custom } = presenceState;
16751
16931
  if (isObj(custom)) Object.assign(props, custom);
@@ -16870,7 +17050,7 @@ function createComponent(staticConfig) {
16870
17050
  var overriddenContextProps = null;
16871
17051
  var componentContext = react$1.default.useContext(ComponentContext);
16872
17052
  var hasTextAncestor = false;
16873
- var isInsideNativeMenu = react$1.default.useContext(NativeMenuContext);
17053
+ var isInsideNativeMenu = isAndroid$1 ? react$1.default.useContext(NativeMenuContext) : false;
16874
17054
  var props = propsIn;
16875
17055
  var componentName = props.componentName || staticConfig.componentName;
16876
17056
  var [nextProps, overrides] = mergeComponentProps(getDefaultProps(staticConfig, props.componentName), styledContextValue, propsIn);
@@ -20625,6 +20805,7 @@ function PortalHostNonNative(props) {
20625
20805
  //#region ../portal/dist/esm/GorhomPortalItem.native.js
20626
20806
  init_index_native$7();
20627
20807
  init_index_native$3();
20808
+ init_index_native();
20628
20809
  var GorhomPortalItem = function(props) {
20629
20810
  var { name: _providedName, hostName = "root", handleOnMount: _providedHandleOnMount, handleOnUnmount: _providedHandleOnUnmount, handleOnUpdate: _providedHandleOnUpdate, children, passThrough } = props;
20630
20811
  if (getPortal().state.type === "teleport") {
@@ -20649,11 +20830,16 @@ var GorhomPortalItemFallback = function(props) {
20649
20830
  var { addPortal: addUpdatePortal, removePortal } = usePortal(hostName);
20650
20831
  var id = (0, react$1.useId)();
20651
20832
  var name = _providedName || id;
20833
+ var themeName = useThemeName();
20834
+ var themedChildren = passThrough ? children : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Theme, {
20835
+ name: themeName,
20836
+ children
20837
+ });
20652
20838
  var handleOnMount = useEvent(function() {
20653
20839
  if (_providedHandleOnMount) _providedHandleOnMount(function() {
20654
- return addUpdatePortal(name, children);
20840
+ return addUpdatePortal(name, themedChildren);
20655
20841
  });
20656
- else addUpdatePortal(name, children);
20842
+ else addUpdatePortal(name, themedChildren);
20657
20843
  });
20658
20844
  var handleOnUnmount = useEvent(function() {
20659
20845
  if (_providedHandleOnUnmount) _providedHandleOnUnmount(function() {
@@ -20663,9 +20849,9 @@ var GorhomPortalItemFallback = function(props) {
20663
20849
  });
20664
20850
  var handleOnUpdate = useEvent(function() {
20665
20851
  if (_providedHandleOnUpdate) _providedHandleOnUpdate(function() {
20666
- return addUpdatePortal(name, children);
20852
+ return addUpdatePortal(name, themedChildren);
20667
20853
  });
20668
- else addUpdatePortal(name, children);
20854
+ else addUpdatePortal(name, themedChildren);
20669
20855
  });
20670
20856
  useIsomorphicLayoutEffect(function() {
20671
20857
  if (passThrough) return;
@@ -20677,7 +20863,7 @@ var GorhomPortalItemFallback = function(props) {
20677
20863
  (0, react$1.useEffect)(function() {
20678
20864
  if (passThrough) return;
20679
20865
  handleOnUpdate();
20680
- }, [children]);
20866
+ }, [children, themeName]);
20681
20867
  return passThrough ? children : null;
20682
20868
  };
20683
20869
  //#endregion
@@ -28651,6 +28837,7 @@ function getKeyboardOccludedHeight(param) {
28651
28837
  //#region ../sheet/dist/esm/useGestureHandlerPan.native.js
28652
28838
  init_index_native$7();
28653
28839
  var AT_TOP_THRESHOLD = 5;
28840
+ var SCROLL_HANDOFF_THRESHOLD = 160;
28654
28841
  function useGestureHandlerPan(config) {
28655
28842
  var { positions, frameSize, setPosition, animateTo, stopSpring, scrollBridge, setIsDragging, getCurrentPosition, resisted, disableDrag, isShowingInnerSheet, setAnimatedPosition, scrollGestureRef } = config;
28656
28843
  var gestureHandlerEnabled = isGestureHandlerEnabled();
@@ -28676,16 +28863,45 @@ function useGestureHandlerPan(config) {
28676
28863
  frozenPositions: [],
28677
28864
  frozenMinY: 0,
28678
28865
  frozenIsKeyboardVisible: false,
28679
- panStarted: false
28866
+ panStarted: false,
28867
+ startedBelowTop: false,
28868
+ upwardDragAfterTop: 0,
28869
+ scrollUnlockedAfterTop: false,
28870
+ keepScrollLockedAfterEnd: false
28680
28871
  });
28872
+ var unlockScrollTimer = (0, react$1.useRef)(null);
28873
+ (0, react$1.useEffect)(function() {
28874
+ return function() {
28875
+ if (unlockScrollTimer.current) {
28876
+ clearTimeout(unlockScrollTimer.current);
28877
+ unlockScrollTimer.current = null;
28878
+ }
28879
+ };
28880
+ }, []);
28681
28881
  var onStart = (0, react$1.useCallback)(function() {
28682
28882
  stopSpring();
28683
28883
  }, [stopSpring]);
28684
28884
  var onEnd = (0, react$1.useCallback)(function(closestPoint, animationOverride) {
28685
- var _scrollBridge_setScrollEnabled;
28885
+ var keepScrollLocked = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
28886
+ if (unlockScrollTimer.current) {
28887
+ clearTimeout(unlockScrollTimer.current);
28888
+ unlockScrollTimer.current = null;
28889
+ }
28686
28890
  setIsDragging(false);
28687
28891
  scrollBridge.setParentDragging(false);
28688
- (_scrollBridge_setScrollEnabled = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled === void 0 || _scrollBridge_setScrollEnabled.call(scrollBridge, true);
28892
+ scrollBridge.lockScrollAtTop = false;
28893
+ if (keepScrollLocked) {
28894
+ var _scrollBridge_setScrollEnabled;
28895
+ (_scrollBridge_setScrollEnabled = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled === void 0 || _scrollBridge_setScrollEnabled.call(scrollBridge, false, 0);
28896
+ unlockScrollTimer.current = setTimeout(function() {
28897
+ var _scrollBridge_setScrollEnabled2;
28898
+ unlockScrollTimer.current = null;
28899
+ (_scrollBridge_setScrollEnabled2 = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled2 === void 0 || _scrollBridge_setScrollEnabled2.call(scrollBridge, true);
28900
+ }, 160);
28901
+ } else {
28902
+ var _scrollBridge_setScrollEnabled1;
28903
+ (_scrollBridge_setScrollEnabled1 = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled1 === void 0 || _scrollBridge_setScrollEnabled1.call(scrollBridge, true);
28904
+ }
28689
28905
  setPosition(closestPoint);
28690
28906
  animateTo(closestPoint, animationOverride);
28691
28907
  }, [
@@ -28715,6 +28931,15 @@ function useGestureHandlerPan(config) {
28715
28931
  gs.frozenPositions = [...positions];
28716
28932
  gs.frozenMinY = minY;
28717
28933
  gs.frozenIsKeyboardVisible = releaseConfigRef.current.isKeyboardVisible;
28934
+ gs.startedBelowTop = !atTop;
28935
+ gs.upwardDragAfterTop = 0;
28936
+ gs.scrollUnlockedAfterTop = false;
28937
+ gs.keepScrollLockedAfterEnd = false;
28938
+ scrollBridge.lockScrollAtTop = false;
28939
+ if (unlockScrollTimer.current) {
28940
+ clearTimeout(unlockScrollTimer.current);
28941
+ unlockScrollTimer.current = null;
28942
+ }
28718
28943
  if (!atTop) {
28719
28944
  var _scrollBridge_setScrollEnabled;
28720
28945
  (_scrollBridge_setScrollEnabled = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled === void 0 || _scrollBridge_setScrollEnabled.call(scrollBridge, false, 0);
@@ -28740,10 +28965,17 @@ function useGestureHandlerPan(config) {
28740
28965
  else if (isSwipingDown) if (nodeIsScrolling && hasScrollableContent) panHandles = false;
28741
28966
  else if (gs.scrollEngaged && hasScrollableContent) panHandles = true;
28742
28967
  else panHandles = true;
28743
- else if (hasScrollableContent) panHandles = false;
28968
+ else if (hasScrollableContent) if (gs.startedBelowTop && !gs.scrollUnlockedAfterTop) {
28969
+ gs.upwardDragAfterTop += Math.max(0, -deltaY);
28970
+ if (gs.upwardDragAfterTop >= SCROLL_HANDOFF_THRESHOLD) {
28971
+ gs.scrollUnlockedAfterTop = true;
28972
+ panHandles = false;
28973
+ } else panHandles = true;
28974
+ } else panHandles = false;
28744
28975
  else panHandles = true;
28745
28976
  if (panHandles) {
28746
28977
  var _scrollBridge_setScrollEnabled;
28978
+ scrollBridge.lockScrollAtTop = gs.startedBelowTop && !gs.scrollUnlockedAfterTop;
28747
28979
  var lockTo = isCurrentlyAtTop && isSwipingDown && gs.scrollEngaged ? void 0 : 0;
28748
28980
  (_scrollBridge_setScrollEnabled = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled === void 0 || _scrollBridge_setScrollEnabled.call(scrollBridge, false, lockTo);
28749
28981
  gs.accumulatedOffset += deltaY;
@@ -28753,15 +28985,20 @@ function useGestureHandlerPan(config) {
28753
28985
  scrollBridge.setParentDragging(newPosition > minY);
28754
28986
  } else {
28755
28987
  var _scrollBridge_setScrollEnabled1;
28988
+ scrollBridge.lockScrollAtTop = false;
28756
28989
  (_scrollBridge_setScrollEnabled1 = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled1 === void 0 || _scrollBridge_setScrollEnabled1.call(scrollBridge, true);
28990
+ scrollBridge.setParentDragging(false);
28757
28991
  }
28758
28992
  }).onEnd(function(event) {
28759
28993
  var { velocityY } = event;
28760
28994
  var currentPos = gs.startY + gs.accumulatedOffset;
28761
- scrollBridge.scrollLockY = void 0;
28995
+ var keepScrollLockedAfterEnd = gs.startedBelowTop && !gs.scrollUnlockedAfterTop;
28996
+ scrollBridge.lockScrollAtTop = false;
28997
+ scrollBridge.scrollLockY = keepScrollLockedAfterEnd ? 0 : void 0;
28998
+ gs.keepScrollLockedAfterEnd = keepScrollLockedAfterEnd;
28762
28999
  var snapPositions = gs.frozenPositions.length > 0 ? gs.frozenPositions : positions;
28763
29000
  if (currentPos <= (gs.frozenPositions.length > 0 ? gs.frozenMinY : minY) + AT_TOP_THRESHOLD && scrollBridge.y > 0) {
28764
- onEnd(0);
29001
+ onEnd(0, void 0, keepScrollLockedAfterEnd);
28765
29002
  return;
28766
29003
  }
28767
29004
  var projectedEnd = currentPos + frameSize * (velocityY / 1e3) * .2;
@@ -28775,9 +29012,10 @@ function useGestureHandlerPan(config) {
28775
29012
  snapPointsMode: releaseConfig.snapPointsMode,
28776
29013
  isKeyboardVisible: gs.frozenIsKeyboardVisible,
28777
29014
  isWeb: false
28778
- }));
29015
+ }), void 0, keepScrollLockedAfterEnd);
28779
29016
  }).onFinalize(function() {
28780
- scrollBridge.scrollLockY = void 0;
29017
+ scrollBridge.lockScrollAtTop = false;
29018
+ scrollBridge.scrollLockY = gs.keepScrollLockedAfterEnd ? 0 : void 0;
28781
29019
  if (gs.panStarted) setIsDragging(false);
28782
29020
  else if (config.pauseKeyboardHandler) config.pauseKeyboardHandler.current = false;
28783
29021
  }).runOnJS(true);
@@ -28930,8 +29168,7 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
28930
29168
  var { open, controller, isHidden } = state;
28931
29169
  var openRef = react$1.default.useRef(open);
28932
29170
  openRef.current = open;
28933
- var sheetRef = react$1.default.useRef(void 0);
28934
- var ref = useComposedRefs(forwardedRef, sheetRef, providerProps.contentRef);
29171
+ var ref = useComposedRefs(forwardedRef, react$1.default.useRef(void 0), providerProps.contentRef);
28935
29172
  var { animationDriver } = useConfiguration();
28936
29173
  if (!animationDriver) throw new Error(`Sheet requires an animation driver to be set`);
28937
29174
  var transitionConfig = function() {
@@ -28953,6 +29190,16 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
28953
29190
  if (open && frameSize) stableFrameSize.current = frameSize;
28954
29191
  }, [open, frameSize]);
28955
29192
  var isWebKbSheet = false;
29193
+ var isNativeKbFitSheet = hasFit && Boolean(moveOnKeyboardChange);
29194
+ var preKeyboardFrameSize = react$1.default.useRef(0);
29195
+ react$1.default.useEffect(function() {
29196
+ if (isNativeKbFitSheet && open && !isKeyboardVisible && frameSize > 0) preKeyboardFrameSize.current = frameSize;
29197
+ }, [
29198
+ isNativeKbFitSheet,
29199
+ open,
29200
+ isKeyboardVisible,
29201
+ frameSize
29202
+ ]);
28956
29203
  var effScreenSize = isWebKbSheet ? getStableViewportHeight() : screenSize;
28957
29204
  var effectiveFrameSize = open ? frameSize : stableFrameSize.current || frameSize;
28958
29205
  var positions = react$1.default.useMemo(function() {
@@ -29005,8 +29252,8 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
29005
29252
  screenSize: effScreenSize,
29006
29253
  sheetY: position >= 0 ? activePositions[position] : void 0
29007
29254
  });
29008
- var keyboardStableFrameHeight = isWebKbSheet && isKeyboardVisible && frameSize > 0 ? frameSize : 0;
29009
- var { useAnimatedNumber, useAnimatedNumberStyle, useAnimatedNumberReaction } = animationDriver;
29255
+ var keyboardStableFrameHeight = isWebKbSheet && isKeyboardVisible && frameSize > 0 ? frameSize : isNativeKbFitSheet && isKeyboardVisible && preKeyboardFrameSize.current > 0 ? preKeyboardFrameSize.current : 0;
29256
+ var { useAnimatedNumber, useAnimatedNumberStyle } = animationDriver;
29010
29257
  var _animationDriver_View;
29011
29258
  var AnimatedView = (_animationDriver_View = animationDriver.View) !== null && _animationDriver_View !== void 0 ? _animationDriver_View : View;
29012
29259
  useIsomorphicLayoutEffect(function() {
@@ -29028,33 +29275,49 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
29028
29275
  if (controller === null || controller === void 0 ? void 0 : controller.skipNextAnimation) skipAdaptAnimation.current = true;
29029
29276
  var hasScrollView = react$1.default.useRef(false);
29030
29277
  var opacityFallbackTimer = react$1.default.useRef(null);
29031
- useAnimatedNumberReaction({
29032
- value: animatedNumber,
29033
- hostRef: sheetRef
29034
- }, react$1.default.useCallback(function(value) {
29278
+ var syncAnimatedPosition = useEvent(function(value) {
29035
29279
  at.current = value;
29036
29280
  scrollBridge.paneY = value;
29037
29281
  var minY = activePositions[0];
29038
29282
  var wasAtTop = scrollBridge.isAtTop;
29039
29283
  var nowAtTop = value <= minY + 5;
29040
- if (wasAtTop !== nowAtTop) {
29041
- scrollBridge.isAtTop = nowAtTop;
29042
- if (nowAtTop) {
29043
- var _scrollBridge_setScrollEnabled;
29284
+ if (wasAtTop === nowAtTop) return;
29285
+ scrollBridge.isAtTop = nowAtTop;
29286
+ if (nowAtTop) {
29287
+ var _scrollBridge_setScrollEnabled;
29288
+ if (scrollBridge.lockScrollAtTop) {
29289
+ var _scrollBridge_setScrollEnabled1;
29044
29290
  if (scrollBridge.y > 0) {
29045
29291
  var _scrollBridge_forceScrollTo;
29046
29292
  (_scrollBridge_forceScrollTo = scrollBridge.forceScrollTo) === null || _scrollBridge_forceScrollTo === void 0 || _scrollBridge_forceScrollTo.call(scrollBridge, 0);
29047
29293
  scrollBridge.y = 0;
29048
29294
  }
29049
- scrollBridge.scrollLockY = void 0;
29050
- (_scrollBridge_setScrollEnabled = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled === void 0 || _scrollBridge_setScrollEnabled.call(scrollBridge, true);
29051
- } else {
29052
- var _scrollBridge_setScrollEnabled1;
29053
29295
  scrollBridge.scrollLockY = 0;
29054
- (_scrollBridge_setScrollEnabled1 = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled1 === void 0 || _scrollBridge_setScrollEnabled1.call(scrollBridge, false);
29296
+ (_scrollBridge_setScrollEnabled1 = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled1 === void 0 || _scrollBridge_setScrollEnabled1.call(scrollBridge, false, 0);
29297
+ return;
29055
29298
  }
29299
+ if (scrollBridge.y > 0) {
29300
+ var _scrollBridge_forceScrollTo1;
29301
+ (_scrollBridge_forceScrollTo1 = scrollBridge.forceScrollTo) === null || _scrollBridge_forceScrollTo1 === void 0 || _scrollBridge_forceScrollTo1.call(scrollBridge, 0);
29302
+ scrollBridge.y = 0;
29303
+ }
29304
+ scrollBridge.scrollLockY = void 0;
29305
+ (_scrollBridge_setScrollEnabled = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled === void 0 || _scrollBridge_setScrollEnabled.call(scrollBridge, true);
29306
+ } else {
29307
+ var _scrollBridge_setScrollEnabled2;
29308
+ scrollBridge.scrollLockY = 0;
29309
+ (_scrollBridge_setScrollEnabled2 = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled2 === void 0 || _scrollBridge_setScrollEnabled2.call(scrollBridge, false);
29056
29310
  }
29057
- }, [animationDriver, activePositions]));
29311
+ });
29312
+ var setAnimatedPositionDirect = useEvent(function(value) {
29313
+ syncAnimatedPosition(value);
29314
+ animatedNumber.setValue(value, { type: "direct" });
29315
+ });
29316
+ var getAnimatedPosition = useEvent(function() {
29317
+ var value = animatedNumber.getValue();
29318
+ syncAnimatedPosition(value);
29319
+ return value;
29320
+ });
29058
29321
  function stopSpring() {
29059
29322
  animatedNumber.stop();
29060
29323
  if (scrollBridge.onFinishAnimate) {
@@ -29075,6 +29338,7 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
29075
29338
  }
29076
29339
  var animationCompleteCallback = function() {
29077
29340
  var _controller_onAnimationComplete;
29341
+ syncAnimatedPosition(toValue);
29078
29342
  if (opacityFallbackTimer.current) {
29079
29343
  clearTimeout(opacityFallbackTimer.current);
29080
29344
  opacityFallbackTimer.current = null;
@@ -29104,6 +29368,7 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
29104
29368
  type: "timing",
29105
29369
  duration: 0
29106
29370
  }, function() {
29371
+ syncAnimatedPosition(screenSize);
29107
29372
  setTimeout(function() {
29108
29373
  setDisableAnimation(false);
29109
29374
  }, 10);
@@ -29206,7 +29471,7 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
29206
29471
  var grant = function() {
29207
29472
  setPanning(true);
29208
29473
  stopSpring();
29209
- startY = at.current;
29474
+ startY = getAnimatedPosition();
29210
29475
  };
29211
29476
  var isExternalDrag = false;
29212
29477
  scrollBridge.startPanDrag = function() {
@@ -29218,8 +29483,7 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
29218
29483
  isExternalDrag = true;
29219
29484
  grant();
29220
29485
  }
29221
- var to = dy + startY;
29222
- animatedNumber.setValue(resisted(to, minY), { type: "direct" });
29486
+ setAnimatedPositionDirect(resisted(dy + startY, minY));
29223
29487
  };
29224
29488
  scrollBridge.release = release;
29225
29489
  scrollBridge.snapToPosition = function(positionIndex) {
@@ -29239,7 +29503,7 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
29239
29503
  var to = resisted(dy + startY, minY);
29240
29504
  if (to <= minY) scrollBridge.setParentDragging(false);
29241
29505
  else scrollBridge.setParentDragging(true);
29242
- animatedNumber.setValue(to, { type: "direct" });
29506
+ setAnimatedPositionDirect(to);
29243
29507
  },
29244
29508
  onPanResponderEnd: finish,
29245
29509
  onPanResponderTerminate: finish,
@@ -29289,16 +29553,11 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
29289
29553
  stopSpring,
29290
29554
  scrollBridge,
29291
29555
  setIsDragging,
29292
- getCurrentPosition: function() {
29293
- return at.current;
29294
- },
29556
+ getCurrentPosition: getAnimatedPosition,
29295
29557
  resisted,
29296
29558
  disableDrag,
29297
29559
  isShowingInnerSheet,
29298
- setAnimatedPosition: function(val) {
29299
- at.current = val;
29300
- animatedNumber.setValue(val, { type: "direct" });
29301
- },
29560
+ setAnimatedPosition: setAnimatedPositionDirect,
29302
29561
  dismissOnSnapToBottom,
29303
29562
  snapPointsMode,
29304
29563
  isKeyboardVisible,
@@ -29599,6 +29858,7 @@ var SheetScrollView = /* @__PURE__ */ react$1.default.forwardRef(function(param,
29599
29858
  height: void 0,
29600
29859
  maxHeight: screenSize || void 0
29601
29860
  } : { flex: 1 };
29861
+ var contentContainerStyle = hasFit ? void 0 : { minHeight: "100%" };
29602
29862
  var keyboardFrozenOverride = hasFit && isKeyboardVisible && frozenFrameHeight > 0 ? {
29603
29863
  height: frozenFrameHeight,
29604
29864
  maxHeight: frozenFrameHeight
@@ -29607,20 +29867,29 @@ var SheetScrollView = /* @__PURE__ */ react$1.default.forwardRef(function(param,
29607
29867
  var { ScrollView: RNGHScrollView } = getGestureHandlerState();
29608
29868
  var useRNGHScrollView = isGestureHandlerEnabled() && RNGHScrollView && panGestureRef;
29609
29869
  var currentScrollOffset = (0, react$1.useRef)(0);
29870
+ var lastEmittedScrollOffset = (0, react$1.useRef)(0);
29610
29871
  var lockedScrollY = (0, react$1.useRef)(0);
29611
29872
  (0, react$1.useRef)(0);
29612
29873
  var setScrollEnabled = function(next, lockTo) {
29613
29874
  if (!next) {
29614
- var _scrollRef_current_scrollTo, _scrollRef_current;
29615
- var lockY = lockTo !== null && lockTo !== void 0 ? lockTo : currentScrollOffset.current;
29875
+ var _ref;
29876
+ var lockY = (_ref = lockTo !== null && lockTo !== void 0 ? lockTo : scrollBridge.scrollLockY) !== null && _ref !== void 0 ? _ref : currentScrollOffset.current;
29877
+ if (scrollBridge.enabled === false && scrollBridge.scrollLockY === lockY) return;
29878
+ scrollBridge.enabled = false;
29616
29879
  lockedScrollY.current = lockY;
29617
29880
  scrollBridge.scrollLockY = lockY;
29618
- (_scrollRef_current = scrollRef.current) === null || _scrollRef_current === void 0 || (_scrollRef_current_scrollTo = _scrollRef_current.scrollTo) == null || _scrollRef_current_scrollTo.call(_scrollRef_current, {
29619
- x: 0,
29620
- y: lockY,
29621
- animated: false
29622
- });
29881
+ if (currentScrollOffset.current !== lockY) {
29882
+ var _scrollRef_current_scrollTo, _scrollRef_current;
29883
+ (_scrollRef_current = scrollRef.current) === null || _scrollRef_current === void 0 || (_scrollRef_current_scrollTo = _scrollRef_current.scrollTo) == null || _scrollRef_current_scrollTo.call(_scrollRef_current, {
29884
+ x: 0,
29885
+ y: lockY,
29886
+ animated: false
29887
+ });
29888
+ currentScrollOffset.current = lockY;
29889
+ }
29623
29890
  } else {
29891
+ if (scrollBridge.enabled === true && scrollBridge.scrollLockY === void 0) return;
29892
+ scrollBridge.enabled = true;
29624
29893
  lockedScrollY.current = currentScrollOffset.current;
29625
29894
  scrollBridge.scrollLockY = void 0;
29626
29895
  }
@@ -29632,7 +29901,31 @@ var SheetScrollView = /* @__PURE__ */ react$1.default.forwardRef(function(param,
29632
29901
  y,
29633
29902
  animated: false
29634
29903
  });
29635
- };
29904
+ currentScrollOffset.current = y;
29905
+ };
29906
+ var emitManualScroll = react$1.default.useCallback(function(node, y) {
29907
+ currentScrollOffset.current = y;
29908
+ scrollBridge.y = y;
29909
+ if (y > 0) scrollBridge.scrollStartY = -1;
29910
+ lastEmittedScrollOffset.current = y;
29911
+ onScroll === null || onScroll === void 0 || onScroll({
29912
+ nativeEvent: {
29913
+ contentOffset: {
29914
+ x: node.scrollLeft,
29915
+ y
29916
+ },
29917
+ contentSize: {
29918
+ height: node.scrollHeight,
29919
+ width: node.scrollWidth
29920
+ },
29921
+ layoutMeasurement: {
29922
+ height: node.offsetHeight,
29923
+ width: node.offsetWidth
29924
+ }
29925
+ },
29926
+ timeStamp: Date.now()
29927
+ });
29928
+ }, [onScroll, scrollBridge]);
29636
29929
  var scrollFocusedInputClearOfKeyboard = react$1.default.useCallback(function() {}, [
29637
29930
  hasFit,
29638
29931
  isKeyboardVisible,
@@ -29667,7 +29960,8 @@ var SheetScrollView = /* @__PURE__ */ react$1.default.forwardRef(function(param,
29667
29960
  scrollBridge,
29668
29961
  hasScrollableContent,
29669
29962
  scrollEnabled,
29670
- setScrollEnabled
29963
+ setScrollEnabled,
29964
+ onManualScroll: emitManualScroll
29671
29965
  });
29672
29966
  var contentWrapper = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(View, {
29673
29967
  onLayout: function(e) {
@@ -29706,15 +30000,20 @@ var SheetScrollView = /* @__PURE__ */ react$1.default.forwardRef(function(param,
29706
30000
  animated: false
29707
30001
  });
29708
30002
  }
30003
+ currentScrollOffset.current = scrollBridge.scrollLockY;
29709
30004
  scrollBridge.y = scrollBridge.scrollLockY;
29710
- onScroll === null || onScroll === void 0 || onScroll(_objectSpread2(_objectSpread2({}, e), {}, { nativeEvent: _objectSpread2(_objectSpread2({}, e.nativeEvent), {}, { contentOffset: _objectSpread2(_objectSpread2({}, e.nativeEvent.contentOffset), {}, { y: scrollBridge.scrollLockY }) }) }));
30005
+ if (lastEmittedScrollOffset.current !== scrollBridge.scrollLockY) {
30006
+ lastEmittedScrollOffset.current = scrollBridge.scrollLockY;
30007
+ onScroll === null || onScroll === void 0 || onScroll(_objectSpread2(_objectSpread2({}, e), {}, { nativeEvent: _objectSpread2(_objectSpread2({}, e.nativeEvent), {}, { contentOffset: _objectSpread2(_objectSpread2({}, e.nativeEvent.contentOffset), {}, { y: scrollBridge.scrollLockY }) }) }));
30008
+ }
29711
30009
  return;
29712
30010
  }
29713
30011
  scrollBridge.y = y;
29714
30012
  if (y > 0) scrollBridge.scrollStartY = -1;
30013
+ lastEmittedScrollOffset.current = y;
29715
30014
  onScroll === null || onScroll === void 0 || onScroll(e);
29716
30015
  },
29717
- contentContainerStyle: { minHeight: "100%" },
30016
+ contentContainerStyle,
29718
30017
  bounces: false,
29719
30018
  keyboardShouldPersistTaps: "always",
29720
30019
  keyboardDismissMode: "none"
@@ -29734,9 +30033,10 @@ var SheetScrollView = /* @__PURE__ */ react$1.default.forwardRef(function(param,
29734
30033
  currentScrollOffset.current = y;
29735
30034
  scrollBridge.y = y;
29736
30035
  if (y > 0) scrollBridge.scrollStartY = -1;
30036
+ lastEmittedScrollOffset.current = y;
29737
30037
  onScroll === null || onScroll === void 0 || onScroll(e);
29738
30038
  },
29739
- contentContainerStyle: { minHeight: "100%" }
30039
+ contentContainerStyle
29740
30040
  }, gestureProps), props), keyboardFrozenOverride), {}, { children: contentWrapper }));
29741
30041
  });
29742
30042
  //#endregion
@@ -32276,13 +32576,19 @@ function getWindowSize() {
32276
32576
  return Dimensions.get("window");
32277
32577
  }
32278
32578
  var cbs = /* @__PURE__ */ new Set();
32279
- Dimensions.addEventListener("change", function(param) {
32280
- var { window } = param;
32281
- cbs.forEach(function(cb) {
32282
- return cb(window);
32579
+ var isListening = false;
32580
+ var ensureListening = function() {
32581
+ if (isListening) return;
32582
+ isListening = true;
32583
+ Dimensions.addEventListener("change", function(param) {
32584
+ var { window } = param;
32585
+ cbs.forEach(function(cb) {
32586
+ return cb(window);
32587
+ });
32283
32588
  });
32284
- });
32589
+ };
32285
32590
  function subscribe(cb) {
32591
+ ensureListening();
32286
32592
  cbs.add(cb);
32287
32593
  return function() {
32288
32594
  return cbs.delete(cb);