motion 12.6.3-alpha.0 → 12.6.3

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 (74) hide show
  1. package/dist/cjs/debug.js +12 -12
  2. package/dist/cjs/index.js +402 -352
  3. package/dist/cjs/mini.js +339 -352
  4. package/dist/cjs/react-client.js +169 -181
  5. package/dist/cjs/react-m.js +18 -22
  6. package/dist/cjs/react-mini.js +275 -336
  7. package/dist/es/framer-motion/dist/es/animation/animate/index.mjs +2 -2
  8. package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +7 -4
  9. package/dist/es/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +8 -6
  10. package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +10 -8
  11. package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-sequence.mjs +2 -2
  12. package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +2 -2
  13. package/dist/es/framer-motion/dist/es/animation/generators/spring/index.mjs +11 -1
  14. package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +3 -3
  15. package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +1 -2
  16. package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-variant.mjs +1 -2
  17. package/dist/es/framer-motion/dist/es/animation/optimized-appear/handoff.mjs +2 -4
  18. package/dist/es/framer-motion/dist/es/animation/optimized-appear/start.mjs +4 -6
  19. package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +3 -3
  20. package/dist/es/framer-motion/dist/es/animation/sequence/utils/calc-time.mjs +1 -2
  21. package/dist/es/framer-motion/dist/es/components/AnimatePresence/index.mjs +2 -2
  22. package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +5 -10
  23. package/dist/es/framer-motion/dist/es/motion/features/animation/index.mjs +1 -2
  24. package/dist/es/framer-motion/dist/es/motion/index.mjs +2 -3
  25. package/dist/es/framer-motion/dist/es/motion/utils/use-visual-element.mjs +3 -5
  26. package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +19 -27
  27. package/dist/es/framer-motion/dist/es/projection/styles/transform.mjs +1 -1
  28. package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +3 -4
  29. package/dist/es/framer-motion/dist/es/render/dom/DOMKeyframesResolver.mjs +1 -2
  30. package/dist/es/framer-motion/dist/es/render/dom/resize/handle-element.mjs +5 -6
  31. package/dist/es/framer-motion/dist/es/render/dom/scroll/track.mjs +1 -2
  32. package/dist/es/framer-motion/dist/es/render/dom/utils/css-variables-conversion.mjs +1 -1
  33. package/dist/es/framer-motion/dist/es/render/dom/utils/filter-props.mjs +1 -1
  34. package/dist/es/framer-motion/dist/es/render/html/utils/scrape-motion-values.mjs +1 -2
  35. package/dist/es/framer-motion/dist/es/render/utils/KeyframesResolver.mjs +2 -3
  36. package/dist/es/framer-motion/dist/es/render/utils/animation-state.mjs +3 -5
  37. package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
  38. package/dist/es/framer-motion/dist/es/render/utils/resolve-variants.mjs +1 -1
  39. package/dist/es/framer-motion/dist/es/utils/mix/complex.mjs +1 -2
  40. package/dist/es/framer-motion/dist/es/value/types/complex/index.mjs +2 -3
  41. package/dist/es/framer-motion/dist/es/value/use-scroll.mjs +2 -2
  42. package/dist/es/framer-motion/dist/es/value/use-will-change/add-will-change.mjs +0 -7
  43. package/dist/es/motion/lib/react.mjs +0 -1
  44. package/dist/es/motion-dom/dist/es/animation/{controls/BaseGroup.mjs → GroupAnimation.mjs} +4 -5
  45. package/dist/es/motion-dom/dist/es/animation/GroupAnimationWithThen.mjs +9 -0
  46. package/dist/es/motion-dom/dist/es/animation/NativeAnimation.mjs +161 -0
  47. package/dist/es/motion-dom/dist/es/animation/generators/utils/is-generator.mjs +1 -1
  48. package/dist/es/motion-dom/dist/es/animation/keyframes/get-final.mjs +12 -0
  49. package/dist/es/motion-dom/dist/es/animation/keyframes/hydrate.mjs +26 -0
  50. package/dist/es/motion-dom/dist/es/animation/utils/get-value-transition.mjs +3 -5
  51. package/dist/es/motion-dom/dist/es/animation/waapi/easing/cubic-bezier.mjs +3 -0
  52. package/dist/es/motion-dom/dist/es/animation/waapi/easing/is-supported.mjs +14 -0
  53. package/dist/es/motion-dom/dist/es/animation/waapi/easing/map-easing.mjs +26 -0
  54. package/dist/es/motion-dom/dist/es/animation/waapi/easing/supported.mjs +15 -0
  55. package/dist/es/{framer-motion/dist/es/animation/animators/waapi/index.mjs → motion-dom/dist/es/animation/waapi/start-waapi-animation.mjs} +8 -6
  56. package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs → motion-dom/dist/es/animation/waapi/supports/partial-keyframes.mjs} +2 -2
  57. package/dist/es/motion-dom/dist/es/animation/waapi/utils/apply-generator.mjs +14 -0
  58. package/dist/es/motion-dom/dist/es/animation/waapi/utils/linear.mjs +1 -4
  59. package/dist/es/motion-dom/dist/es/animation/waapi/utils/px-values.mjs +39 -0
  60. package/dist/es/motion-dom/dist/es/gestures/press/index.mjs +1 -1
  61. package/dist/es/motion-dom/dist/es/render/dom/style.mjs +15 -0
  62. package/dist/es/motion-dom/dist/es/utils/resolve-elements.mjs +2 -7
  63. package/dist/es/motion-dom/dist/es/utils/supports/flags.mjs +1 -3
  64. package/dist/es/motion-dom/dist/es/utils/supports/memo.mjs +1 -1
  65. package/dist/es/motion-dom/dist/es/value/index.mjs +1 -1
  66. package/dist/es/motion-utils/dist/es/errors.mjs +2 -4
  67. package/dist/motion.dev.js +402 -352
  68. package/dist/motion.js +1 -1
  69. package/package.json +3 -3
  70. package/dist/es/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +0 -116
  71. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/style.mjs +0 -8
  72. package/dist/es/motion-dom/dist/es/animation/controls/Group.mjs +0 -13
  73. package/dist/es/motion-dom/dist/es/animation/waapi/NativeAnimationControls.mjs +0 -85
  74. package/dist/es/motion-dom/dist/es/animation/waapi/utils/easing.mjs +0 -44
@@ -13,7 +13,7 @@ function isAnimationControls(v) {
13
13
 
14
14
  function getValueState(visualElement) {
15
15
  const state = [{}, {}];
16
- visualElement === null || visualElement === void 0 ? void 0 : visualElement.values.forEach((value, key) => {
16
+ visualElement?.values.forEach((value, key) => {
17
17
  state[0][key] = value.get();
18
18
  state[1][key] = value.getVelocity();
19
19
  });
@@ -61,11 +61,8 @@ function removeItem(arr, item) {
61
61
  arr.splice(index, 1);
62
62
  }
63
63
 
64
- /*#__NO_SIDE_EFFECTS__*/
65
- const noop = (any) => any;
66
-
67
- let warning = noop;
68
- let invariant = noop;
64
+ let warning = () => { };
65
+ let invariant = () => { };
69
66
  if (process.env.NODE_ENV !== "production") {
70
67
  warning = (check, message) => {
71
68
  if (!check && typeof console !== "undefined") {
@@ -94,6 +91,9 @@ function memo(callback) {
94
91
  };
95
92
  }
96
93
 
94
+ /*#__NO_SIDE_EFFECTS__*/
95
+ const noop = (any) => any;
96
+
97
97
  /*
98
98
  Progress within given range
99
99
 
@@ -182,15 +182,14 @@ function warnOnce(condition, message, element) {
182
182
 
183
183
  const supportsScrollTimeline = /* @__PURE__ */ memo(() => window.ScrollTimeline !== undefined);
184
184
 
185
- class BaseGroupPlaybackControls {
185
+ class GroupAnimation {
186
186
  constructor(animations) {
187
187
  // Bound to accomodate common `return animation.stop` pattern
188
188
  this.stop = () => this.runAll("stop");
189
189
  this.animations = animations.filter(Boolean);
190
190
  }
191
191
  get finished() {
192
- // Support for new finished Promise and legacy thennable API
193
- return Promise.all(this.animations.map((animation) => "finished" in animation ? animation.finished : animation));
192
+ return Promise.all(this.animations.map((animation) => animation.finished));
194
193
  }
195
194
  /**
196
195
  * TODO: Filter out cancelled or stopped animations before returning
@@ -261,48 +260,16 @@ class BaseGroupPlaybackControls {
261
260
  }
262
261
  }
263
262
 
264
- /**
265
- * TODO: This is a temporary class to support the legacy
266
- * thennable API
267
- */
268
- class GroupPlaybackControls extends BaseGroupPlaybackControls {
269
- then(onResolve, onReject) {
270
- return Promise.all(this.animations).then(onResolve).catch(onReject);
271
- }
272
- }
273
-
274
- function getValueTransition(transition, key) {
275
- return transition
276
- ? transition[key] ||
277
- transition["default"] ||
278
- transition
279
- : undefined;
280
- }
281
-
282
- /**
283
- * Implement a practical max duration for keyframe generation
284
- * to prevent infinite loops
285
- */
286
- const maxGeneratorDuration = 20000;
287
- function calcGeneratorDuration(generator) {
288
- let duration = 0;
289
- const timeStep = 50;
290
- let state = generator.next(duration);
291
- while (!state.done && duration < maxGeneratorDuration) {
292
- duration += timeStep;
293
- state = generator.next(duration);
263
+ class GroupAnimationWithThen extends GroupAnimation {
264
+ then(onResolve, _onReject) {
265
+ return this.finished.finally(onResolve).then(() => { });
294
266
  }
295
- return duration >= maxGeneratorDuration ? Infinity : duration;
296
267
  }
297
268
 
298
- function isGenerator(type) {
299
- return typeof type === "function";
300
- }
301
-
302
- function attachTimeline(animation, timeline) {
303
- animation.timeline = timeline;
304
- animation.onfinish = null;
305
- }
269
+ const statsBuffer = {
270
+ value: null,
271
+ addProjectionMetrics: null,
272
+ };
306
273
 
307
274
  const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0] === "number";
308
275
 
@@ -310,13 +277,11 @@ const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0]
310
277
  * Add the ability for test suites to manually set support flags
311
278
  * to better test more environments.
312
279
  */
313
- const supportsFlags = {
314
- linearEasing: undefined,
315
- };
280
+ const supportsFlags = {};
316
281
 
317
282
  function memoSupports(callback, supportsFlag) {
318
283
  const memoized = memo(callback);
319
- return () => { var _a; return (_a = supportsFlags[supportsFlag]) !== null && _a !== void 0 ? _a : memoized(); };
284
+ return () => supportsFlags[supportsFlag] ?? memoized();
320
285
  }
321
286
 
322
287
  const supportsLinearEasing = /*@__PURE__*/ memoSupports(() => {
@@ -337,20 +302,13 @@ resolution = 10 // as milliseconds
337
302
  let points = "";
338
303
  const numPoints = Math.max(Math.round(duration / resolution), 2);
339
304
  for (let i = 0; i < numPoints; i++) {
340
- points += easing(progress(0, numPoints - 1, i)) + ", ";
305
+ points += easing(i / (numPoints - 1)) + ", ";
341
306
  }
342
307
  return `linear(${points.substring(0, points.length - 2)})`;
343
308
  };
344
309
 
345
- function isWaapiSupportedEasing(easing) {
346
- return Boolean((typeof easing === "function" && supportsLinearEasing()) ||
347
- !easing ||
348
- (typeof easing === "string" &&
349
- (easing in supportedWaapiEasing || supportsLinearEasing())) ||
350
- isBezierDefinition(easing) ||
351
- (Array.isArray(easing) && easing.every(isWaapiSupportedEasing)));
352
- }
353
310
  const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
311
+
354
312
  const supportedWaapiEasing = {
355
313
  linear: "linear",
356
314
  ease: "ease",
@@ -362,6 +320,7 @@ const supportedWaapiEasing = {
362
320
  backIn: /*@__PURE__*/ cubicBezierAsString([0.31, 0.01, 0.66, -0.59]),
363
321
  backOut: /*@__PURE__*/ cubicBezierAsString([0.33, 1.53, 0.69, 0.99]),
364
322
  };
323
+
365
324
  function mapEasingToNativeEasing(easing, duration) {
366
325
  if (!easing) {
367
326
  return undefined;
@@ -381,6 +340,85 @@ function mapEasingToNativeEasing(easing, duration) {
381
340
  }
382
341
  }
383
342
 
343
+ function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}, pseudoElement = undefined) {
344
+ const keyframeOptions = {
345
+ [valueName]: keyframes,
346
+ };
347
+ if (times)
348
+ keyframeOptions.offset = times;
349
+ const easing = mapEasingToNativeEasing(ease, duration);
350
+ /**
351
+ * If this is an easing array, apply to keyframes, not animation as a whole
352
+ */
353
+ if (Array.isArray(easing))
354
+ keyframeOptions.easing = easing;
355
+ const animation = element.animate(keyframeOptions, {
356
+ delay,
357
+ duration,
358
+ easing: !Array.isArray(easing) ? easing : "linear",
359
+ fill: "both",
360
+ iterations: repeat + 1,
361
+ direction: repeatType === "reverse" ? "alternate" : "normal",
362
+ pseudoElement,
363
+ });
364
+ return animation;
365
+ }
366
+
367
+ function isGenerator(type) {
368
+ return typeof type === "function" && "applyToOptions" in type;
369
+ }
370
+
371
+ function getValueTransition(transition, key) {
372
+ return (transition?.[key] ??
373
+ transition?.["default"] ??
374
+ transition);
375
+ }
376
+
377
+ /**
378
+ * Implement a practical max duration for keyframe generation
379
+ * to prevent infinite loops
380
+ */
381
+ const maxGeneratorDuration = 20000;
382
+ function calcGeneratorDuration(generator) {
383
+ let duration = 0;
384
+ const timeStep = 50;
385
+ let state = generator.next(duration);
386
+ while (!state.done && duration < maxGeneratorDuration) {
387
+ duration += timeStep;
388
+ state = generator.next(duration);
389
+ }
390
+ return duration >= maxGeneratorDuration ? Infinity : duration;
391
+ }
392
+
393
+ /**
394
+ * Create a progress => progress easing function from a generator.
395
+ */
396
+ function createGeneratorEasing(options, scale = 100, createGenerator) {
397
+ const generator = createGenerator({ ...options, keyframes: [0, scale] });
398
+ const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
399
+ return {
400
+ type: "keyframes",
401
+ ease: (progress) => {
402
+ return generator.next(duration * progress).value / scale;
403
+ },
404
+ duration: millisecondsToSeconds(duration),
405
+ };
406
+ }
407
+
408
+ function isWaapiSupportedEasing(easing) {
409
+ return Boolean((typeof easing === "function" && supportsLinearEasing()) ||
410
+ !easing ||
411
+ (typeof easing === "string" &&
412
+ (easing in supportedWaapiEasing || supportsLinearEasing())) ||
413
+ isBezierDefinition(easing) ||
414
+ (Array.isArray(easing) && easing.every(isWaapiSupportedEasing)));
415
+ }
416
+
417
+ function attachTimeline(animation, timeline) {
418
+ animation.timeline = timeline;
419
+ animation.onfinish = null;
420
+ }
421
+
384
422
  const stepsOrder = [
385
423
  "read", // Read
386
424
  "resolveKeyframes", // Write/Read/Write/Read
@@ -390,11 +428,6 @@ const stepsOrder = [
390
428
  "postRender", // Compute
391
429
  ];
392
430
 
393
- const statsBuffer = {
394
- value: null,
395
- addProjectionMetrics: null,
396
- };
397
-
398
431
  function createRenderStep(runNextFrame, stepName) {
399
432
  /**
400
433
  * We create and reuse two queues, one to queue jobs for the current frame
@@ -612,21 +645,16 @@ function setDragLock(axis) {
612
645
  }
613
646
 
614
647
  function resolveElements(elementOrSelector, scope, selectorCache) {
615
- var _a;
616
648
  if (elementOrSelector instanceof EventTarget) {
617
649
  return [elementOrSelector];
618
650
  }
619
651
  else if (typeof elementOrSelector === "string") {
620
652
  let root = document;
621
653
  if (scope) {
622
- // TODO: Refactor to utils package
623
- // invariant(
624
- // Boolean(scope.current),
625
- // "Scope provided, but no element detected."
626
- // )
627
654
  root = scope.current;
628
655
  }
629
- const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
656
+ const elements = selectorCache?.[elementOrSelector] ??
657
+ root.querySelectorAll(elementOrSelector);
630
658
  return elements ? Array.from(elements) : [];
631
659
  }
632
660
  return Array.from(elementOrSelector);
@@ -825,7 +853,7 @@ function press(targetOrSelector, onPressStart, options = {}) {
825
853
  if (target instanceof HTMLElement) {
826
854
  target.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions));
827
855
  if (!isElementKeyboardAccessible(target) &&
828
- target.tabIndex === null) {
856
+ !target.hasAttribute("tabindex")) {
829
857
  target.tabIndex = 0;
830
858
  }
831
859
  }
@@ -858,7 +886,7 @@ class MotionValue {
858
886
  * This will be replaced by the build step with the latest version number.
859
887
  * When MotionValues are provided to motion components, warn if versions are mixed.
860
888
  */
861
- this.version = "12.6.3-alpha.0";
889
+ this.version = "12.6.3";
862
890
  /**
863
891
  * Tracks whether this value can output a velocity. Currently this is only true
864
892
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -1219,11 +1247,6 @@ function addValueToWillChange(visualElement, key) {
1219
1247
  if (isWillChangeMotionValue(willChange)) {
1220
1248
  return willChange.add(key);
1221
1249
  }
1222
- else if (!willChange && MotionGlobalConfig.WillChange) {
1223
- const newWillChange = new MotionGlobalConfig.WillChange("auto");
1224
- visualElement.addValue("willChange", newWillChange);
1225
- newWillChange.add(key);
1226
- }
1227
1250
  }
1228
1251
 
1229
1252
  /**
@@ -1491,11 +1514,10 @@ const color = {
1491
1514
  const colorRegex = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
1492
1515
 
1493
1516
  function test(v) {
1494
- var _a, _b;
1495
1517
  return (isNaN(v) &&
1496
1518
  typeof v === "string" &&
1497
- (((_a = v.match(floatRegex)) === null || _a === void 0 ? void 0 : _a.length) || 0) +
1498
- (((_b = v.match(colorRegex)) === null || _b === void 0 ? void 0 : _b.length) || 0) >
1519
+ (v.match(floatRegex)?.length || 0) +
1520
+ (v.match(colorRegex)?.length || 0) >
1499
1521
  0);
1500
1522
  }
1501
1523
  const NUMBER_TOKEN = "number";
@@ -1883,8 +1905,7 @@ function measureAllKeyframes() {
1883
1905
  const restore = transformsToRestore.get(element);
1884
1906
  if (restore) {
1885
1907
  restore.forEach(([key, value]) => {
1886
- var _a;
1887
- (_a = element.getValue(key)) === null || _a === void 0 ? void 0 : _a.set(value);
1908
+ element.getValue(key)?.set(value);
1888
1909
  });
1889
1910
  }
1890
1911
  });
@@ -1971,7 +1992,7 @@ class KeyframeResolver {
1971
1992
  * If the first keyframe is null, we need to find its value by sampling the element
1972
1993
  */
1973
1994
  if (i === 0) {
1974
- const currentValue = motionValue === null || motionValue === void 0 ? void 0 : motionValue.get();
1995
+ const currentValue = motionValue?.get();
1975
1996
  const finalKeyframe = unresolvedKeyframes[unresolvedKeyframes.length - 1];
1976
1997
  if (currentValue !== undefined) {
1977
1998
  unresolvedKeyframes[0] = currentValue;
@@ -2052,7 +2073,7 @@ function parseCSSVariable(current) {
2052
2073
  if (!match)
2053
2074
  return [,];
2054
2075
  const [, token1, token2, fallback] = match;
2055
- return [`--${token1 !== null && token1 !== void 0 ? token1 : token2}`, fallback];
2076
+ return [`--${token1 ?? token2}`, fallback];
2056
2077
  }
2057
2078
  const maxDepth = 4;
2058
2079
  function getVariableValue(current, element, depth = 1) {
@@ -2191,7 +2212,6 @@ class DOMKeyframesResolver extends KeyframeResolver {
2191
2212
  }
2192
2213
  }
2193
2214
  measureEndState() {
2194
- var _a;
2195
2215
  const { element, name, unresolvedKeyframes } = this;
2196
2216
  if (!element || !element.current)
2197
2217
  return;
@@ -2204,7 +2224,7 @@ class DOMKeyframesResolver extends KeyframeResolver {
2204
2224
  this.finalKeyframe = finalKeyframe;
2205
2225
  }
2206
2226
  // If we removed transform values, reapply them before the next render
2207
- if ((_a = this.removedTransforms) === null || _a === void 0 ? void 0 : _a.length) {
2227
+ if (this.removedTransforms?.length) {
2208
2228
  this.removedTransforms.forEach(([unsetTransformName, unsetTransformValue]) => {
2209
2229
  element
2210
2230
  .getValue(unsetTransformName)
@@ -2585,13 +2605,12 @@ function mixObject(a, b) {
2585
2605
  };
2586
2606
  }
2587
2607
  function matchOrder(origin, target) {
2588
- var _a;
2589
2608
  const orderedOrigin = [];
2590
2609
  const pointers = { color: 0, var: 0, number: 0 };
2591
2610
  for (let i = 0; i < target.values.length; i++) {
2592
2611
  const type = target.types[i];
2593
2612
  const originIndex = origin.indexes[type][pointers[type]];
2594
- const originValue = (_a = origin.values[originIndex]) !== null && _a !== void 0 ? _a : 0;
2613
+ const originValue = origin.values[originIndex] ?? 0;
2595
2614
  orderedOrigin[i] = originValue;
2596
2615
  pointers[type]++;
2597
2616
  }
@@ -2895,9 +2914,17 @@ function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce
2895
2914
  const easing = generateLinearEasing((progress) => generator.next(calculatedDuration * progress).value, calculatedDuration, 30);
2896
2915
  return calculatedDuration + "ms " + easing;
2897
2916
  },
2917
+ toTransition: () => { },
2898
2918
  };
2899
2919
  return generator;
2900
2920
  }
2921
+ spring.applyToOptions = (options) => {
2922
+ const generatorOptions = createGeneratorEasing(options, 100, spring);
2923
+ options.ease = supportsLinearEasing() ? generatorOptions.ease : "easeOut";
2924
+ options.duration = secondsToMilliseconds(generatorOptions.duration);
2925
+ options.type = "keyframes";
2926
+ return options;
2927
+ };
2901
2928
 
2902
2929
  function inertia({ keyframes, velocity = 0.0, power = 0.8, timeConstant = 325, bounceDamping = 10, bounceStiffness = 500, modifyTarget, min, max, restDelta = 0.5, restSpeed, }) {
2903
2930
  const origin = keyframes[0];
@@ -3219,7 +3246,7 @@ class MainThreadAnimation extends BaseAnimation {
3219
3246
  onStop && onStop();
3220
3247
  };
3221
3248
  const { name, motionValue, element, keyframes } = this.options;
3222
- const KeyframeResolver$1 = (element === null || element === void 0 ? void 0 : element.KeyframeResolver) || KeyframeResolver;
3249
+ const KeyframeResolver$1 = element?.KeyframeResolver || KeyframeResolver;
3223
3250
  const onResolved = (resolvedKeyframes, finalKeyframe) => this.onKeyframesResolved(resolvedKeyframes, finalKeyframe);
3224
3251
  this.resolver = new KeyframeResolver$1(keyframes, onResolved, name, motionValue, element);
3225
3252
  this.resolver.scheduleResolve();
@@ -3468,7 +3495,7 @@ class MainThreadAnimation extends BaseAnimation {
3468
3495
  this.startTime = now - this.holdTime;
3469
3496
  }
3470
3497
  else if (!this.startTime) {
3471
- this.startTime = startTime !== null && startTime !== void 0 ? startTime : this.calcStartTime();
3498
+ this.startTime = startTime ?? this.calcStartTime();
3472
3499
  }
3473
3500
  else if (this.state === "finished") {
3474
3501
  this.startTime = now;
@@ -3486,13 +3513,12 @@ class MainThreadAnimation extends BaseAnimation {
3486
3513
  this.driver.start();
3487
3514
  }
3488
3515
  pause() {
3489
- var _a;
3490
3516
  if (!this._resolved) {
3491
3517
  this.pendingPlayState = "paused";
3492
3518
  return;
3493
3519
  }
3494
3520
  this.state = "paused";
3495
- this.holdTime = (_a = this.currentTime) !== null && _a !== void 0 ? _a : 0;
3521
+ this.holdTime = this.currentTime ?? 0;
3496
3522
  }
3497
3523
  complete() {
3498
3524
  if (this.state !== "running") {
@@ -3532,6 +3558,9 @@ class MainThreadAnimation extends BaseAnimation {
3532
3558
  this.startTime = 0;
3533
3559
  return this.tick(time, true);
3534
3560
  }
3561
+ get finished() {
3562
+ return this.currentFinishedPromise;
3563
+ }
3535
3564
  }
3536
3565
 
3537
3566
  /**
@@ -3547,27 +3576,6 @@ const acceleratedValues = new Set([
3547
3576
  // "background-color"
3548
3577
  ]);
3549
3578
 
3550
- function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}) {
3551
- const keyframeOptions = { [valueName]: keyframes };
3552
- if (times)
3553
- keyframeOptions.offset = times;
3554
- const easing = mapEasingToNativeEasing(ease, duration);
3555
- /**
3556
- * If this is an easing array, apply to keyframes, not animation as a whole
3557
- */
3558
- if (Array.isArray(easing))
3559
- keyframeOptions.easing = easing;
3560
- const animation = element.animate(keyframeOptions, {
3561
- delay,
3562
- duration,
3563
- easing: !Array.isArray(easing) ? easing : "linear",
3564
- fill: "both",
3565
- iterations: repeat + 1,
3566
- direction: repeatType === "reverse" ? "alternate" : "normal",
3567
- });
3568
- return animation;
3569
- }
3570
-
3571
3579
  const supportsWaapi = /*@__PURE__*/ memo(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
3572
3580
 
3573
3581
  /**
@@ -3678,7 +3686,7 @@ class AcceleratedAnimation extends BaseAnimation {
3678
3686
  const animation = startWaapiAnimation(motionValue.owner.current, name, keyframes, { ...this.options, duration, times, ease });
3679
3687
  // Override the browser calculated startTime with one synchronised to other JS
3680
3688
  // and WAAPI animations starting this event loop.
3681
- animation.startTime = startTime !== null && startTime !== void 0 ? startTime : this.calcStartTime();
3689
+ animation.startTime = startTime ?? this.calcStartTime();
3682
3690
  if (this.pendingTimeline) {
3683
3691
  attachTimeline(animation, this.pendingTimeline);
3684
3692
  this.pendingTimeline = undefined;
@@ -3737,6 +3745,9 @@ class AcceleratedAnimation extends BaseAnimation {
3737
3745
  const { animation } = resolved;
3738
3746
  return animation.playbackRate;
3739
3747
  }
3748
+ get finished() {
3749
+ return this.resolved.animation.finished;
3750
+ }
3740
3751
  set speed(newSpeed) {
3741
3752
  const { resolved } = this;
3742
3753
  if (!resolved)
@@ -4002,7 +4013,7 @@ const animateMotionValue = (name, value, target, transition = {}, element, isHan
4002
4013
  });
4003
4014
  // We still want to return some animation controls here rather
4004
4015
  // than returning undefined
4005
- return new GroupPlaybackControls([]);
4016
+ return new GroupAnimationWithThen([]);
4006
4017
  }
4007
4018
  }
4008
4019
  /**
@@ -4030,7 +4041,6 @@ function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
4030
4041
  return shouldBlock;
4031
4042
  }
4032
4043
  function animateTarget(visualElement, targetAndTransition, { delay = 0, transitionOverride, type } = {}) {
4033
- var _a;
4034
4044
  let { transition = visualElement.getDefaultTransition(), transitionEnd, ...target } = targetAndTransition;
4035
4045
  if (transitionOverride)
4036
4046
  transition = transitionOverride;
@@ -4039,7 +4049,7 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
4039
4049
  visualElement.animationState &&
4040
4050
  visualElement.animationState.getState()[type];
4041
4051
  for (const key in target) {
4042
- const value = visualElement.getValue(key, (_a = visualElement.latestValues[key]) !== null && _a !== void 0 ? _a : null);
4052
+ const value = visualElement.getValue(key, visualElement.latestValues[key] ?? null);
4043
4053
  const valueTarget = target[key];
4044
4054
  if (valueTarget === undefined ||
4045
4055
  (animationTypeState &&
@@ -4085,9 +4095,8 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
4085
4095
  }
4086
4096
 
4087
4097
  function animateVariant(visualElement, variant, options = {}) {
4088
- var _a;
4089
4098
  const resolved = resolveVariant(visualElement, variant, options.type === "exit"
4090
- ? (_a = visualElement.presenceContext) === null || _a === void 0 ? void 0 : _a.custom
4099
+ ? visualElement.presenceContext?.custom
4091
4100
  : undefined);
4092
4101
  let { transition = visualElement.getDefaultTransition() || {} } = resolved || {};
4093
4102
  if (options.transitionOverride) {
@@ -4236,9 +4245,8 @@ function createAnimationState(visualElement) {
4236
4245
  * each active animation type into an object of resolved values for it.
4237
4246
  */
4238
4247
  const buildResolvedTypeValues = (type) => (acc, definition) => {
4239
- var _a;
4240
4248
  const resolved = resolveVariant(visualElement, definition, type === "exit"
4241
- ? (_a = visualElement.presenceContext) === null || _a === void 0 ? void 0 : _a.custom
4249
+ ? visualElement.presenceContext?.custom
4242
4250
  : undefined);
4243
4251
  if (resolved) {
4244
4252
  const { transition, transitionEnd, ...target } = resolved;
@@ -4486,7 +4494,7 @@ function createAnimationState(visualElement) {
4486
4494
  if (motionValue)
4487
4495
  motionValue.liveStyle = true;
4488
4496
  // @ts-expect-error - @mattgperry to figure if we should do something here
4489
- fallbackAnimation[key] = fallbackTarget !== null && fallbackTarget !== void 0 ? fallbackTarget : null;
4497
+ fallbackAnimation[key] = fallbackTarget ?? null;
4490
4498
  });
4491
4499
  animations.push({ animation: fallbackAnimation });
4492
4500
  }
@@ -4503,12 +4511,11 @@ function createAnimationState(visualElement) {
4503
4511
  * Change whether a certain animation type is active.
4504
4512
  */
4505
4513
  function setActive(type, isActive) {
4506
- var _a;
4507
4514
  // If the active state hasn't changed, we can safely do nothing here
4508
4515
  if (state[type].isActive === isActive)
4509
4516
  return Promise.resolve();
4510
4517
  // Propagate active change to children
4511
- (_a = visualElement.variantChildren) === null || _a === void 0 ? void 0 : _a.forEach((child) => { var _a; return (_a = child.animationState) === null || _a === void 0 ? void 0 : _a.setActive(type, isActive); });
4518
+ visualElement.variantChildren?.forEach((child) => child.animationState?.setActive(type, isActive));
4512
4519
  state[type].isActive = isActive;
4513
4520
  const animations = animateChanges(type);
4514
4521
  for (const key in state) {
@@ -4594,9 +4601,8 @@ class AnimationFeature extends Feature {
4594
4601
  }
4595
4602
  }
4596
4603
  unmount() {
4597
- var _a;
4598
4604
  this.node.animationState.reset();
4599
- (_a = this.unmountControls) === null || _a === void 0 ? void 0 : _a.call(this);
4605
+ this.unmountControls?.();
4600
4606
  }
4601
4607
  }
4602
4608
 
@@ -5323,11 +5329,8 @@ class VisualElementDragControls {
5323
5329
  onDrag && onDrag(event, info);
5324
5330
  };
5325
5331
  const onSessionEnd = (event, info) => this.stop(event, info);
5326
- const resumeAnimation = () => eachAxis((axis) => {
5327
- var _a;
5328
- return this.getAnimationState(axis) === "paused" &&
5329
- ((_a = this.getAxisMotionValue(axis).animation) === null || _a === void 0 ? void 0 : _a.play());
5330
- });
5332
+ const resumeAnimation = () => eachAxis((axis) => this.getAnimationState(axis) === "paused" &&
5333
+ this.getAxisMotionValue(axis).animation?.play());
5331
5334
  const { dragSnapToOrigin } = this.getProps();
5332
5335
  this.panSession = new PanSession(originEvent, {
5333
5336
  onSessionStart,
@@ -5382,12 +5385,11 @@ class VisualElementDragControls {
5382
5385
  axisValue.set(next);
5383
5386
  }
5384
5387
  resolveConstraints() {
5385
- var _a;
5386
5388
  const { dragConstraints, dragElastic } = this.getProps();
5387
5389
  const layout = this.visualElement.projection &&
5388
5390
  !this.visualElement.projection.layout
5389
5391
  ? this.visualElement.projection.measure(false)
5390
- : (_a = this.visualElement.projection) === null || _a === void 0 ? void 0 : _a.layout;
5392
+ : this.visualElement.projection?.layout;
5391
5393
  const prevConstraints = this.constraints;
5392
5394
  if (dragConstraints && isRefObject(dragConstraints)) {
5393
5395
  if (!this.constraints) {
@@ -5490,11 +5492,10 @@ class VisualElementDragControls {
5490
5492
  eachAxis((axis) => this.getAxisMotionValue(axis).stop());
5491
5493
  }
5492
5494
  pauseAnimation() {
5493
- eachAxis((axis) => { var _a; return (_a = this.getAxisMotionValue(axis).animation) === null || _a === void 0 ? void 0 : _a.pause(); });
5495
+ eachAxis((axis) => this.getAxisMotionValue(axis).animation?.pause());
5494
5496
  }
5495
5497
  getAnimationState(axis) {
5496
- var _a;
5497
- return (_a = this.getAxisMotionValue(axis).animation) === null || _a === void 0 ? void 0 : _a.state;
5498
+ return this.getAxisMotionValue(axis).animation?.state;
5498
5499
  }
5499
5500
  /**
5500
5501
  * Drag works differently depending on which props are provided.
@@ -6376,7 +6377,7 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
6376
6377
  */
6377
6378
  const xTranslate = delta.x.translate / treeScale.x;
6378
6379
  const yTranslate = delta.y.translate / treeScale.y;
6379
- const zTranslate = (latestTransform === null || latestTransform === void 0 ? void 0 : latestTransform.z) || 0;
6380
+ const zTranslate = latestTransform?.z || 0;
6380
6381
  if (xTranslate || yTranslate || zTranslate) {
6381
6382
  transform = `translate3d(${xTranslate}px, ${yTranslate}px, ${zTranslate}px) `;
6382
6383
  }
@@ -6452,7 +6453,7 @@ function cancelTreeOptimisedTransformAnimations(projectionNode) {
6452
6453
  }
6453
6454
  function createProjectionNode$1({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
6454
6455
  return class ProjectionNode {
6455
- constructor(latestValues = {}, parent = defaultParent === null || defaultParent === void 0 ? void 0 : defaultParent()) {
6456
+ constructor(latestValues = {}, parent = defaultParent?.()) {
6456
6457
  /**
6457
6458
  * A unique ID generated for every projection node.
6458
6459
  */
@@ -6970,12 +6971,11 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
6970
6971
  };
6971
6972
  }
6972
6973
  measurePageBox() {
6973
- var _a;
6974
6974
  const { visualElement } = this.options;
6975
6975
  if (!visualElement)
6976
6976
  return createBox();
6977
6977
  const box = visualElement.measureViewportBox();
6978
- const wasInScrollRoot = ((_a = this.scroll) === null || _a === void 0 ? void 0 : _a.wasRoot) || this.path.some(checkNodeWasScrollRoot);
6978
+ const wasInScrollRoot = this.scroll?.wasRoot || this.path.some(checkNodeWasScrollRoot);
6979
6979
  if (!wasInScrollRoot) {
6980
6980
  // Remove viewport scroll to give page-relative coordinates
6981
6981
  const { scroll } = this.root;
@@ -6987,10 +6987,9 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
6987
6987
  return box;
6988
6988
  }
6989
6989
  removeElementScroll(box) {
6990
- var _a;
6991
6990
  const boxWithoutScroll = createBox();
6992
6991
  copyBoxInto(boxWithoutScroll, box);
6993
- if ((_a = this.scroll) === null || _a === void 0 ? void 0 : _a.wasRoot) {
6992
+ if (this.scroll?.wasRoot) {
6994
6993
  return boxWithoutScroll;
6995
6994
  }
6996
6995
  /**
@@ -7093,7 +7092,6 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
7093
7092
  }
7094
7093
  }
7095
7094
  resolveTargetDelta(forceRecalculation = false) {
7096
- var _a;
7097
7095
  /**
7098
7096
  * Once the dirty status of nodes has been spread through the tree, we also
7099
7097
  * need to check if we have a shared node of a different depth that has itself
@@ -7111,7 +7109,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
7111
7109
  const canSkip = !(forceRecalculation ||
7112
7110
  (isShared && this.isSharedProjectionDirty) ||
7113
7111
  this.isProjectionDirty ||
7114
- ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.isProjectionDirty) ||
7112
+ this.parent?.isProjectionDirty ||
7115
7113
  this.attemptToResolveRelativeTarget ||
7116
7114
  this.root.updateBlockedByResize);
7117
7115
  if (canSkip)
@@ -7230,7 +7228,6 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
7230
7228
  this.layout);
7231
7229
  }
7232
7230
  calcProjection() {
7233
- var _a;
7234
7231
  const lead = this.getLead();
7235
7232
  const isShared = Boolean(this.resumingFrom) || this !== lead;
7236
7233
  let canSkip = true;
@@ -7238,7 +7235,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
7238
7235
  * If this is a normal layout animation and neither this node nor its nearest projecting
7239
7236
  * is dirty then we can't skip.
7240
7237
  */
7241
- if (this.isProjectionDirty || ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.isProjectionDirty)) {
7238
+ if (this.isProjectionDirty || this.parent?.isProjectionDirty) {
7242
7239
  canSkip = false;
7243
7240
  }
7244
7241
  /**
@@ -7344,8 +7341,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
7344
7341
  // TODO: Schedule render
7345
7342
  }
7346
7343
  scheduleRender(notifyAll = true) {
7347
- var _a;
7348
- (_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.scheduleRender();
7344
+ this.options.visualElement?.scheduleRender();
7349
7345
  if (notifyAll) {
7350
7346
  const stack = this.getStack();
7351
7347
  stack && stack.scheduleRender();
@@ -7529,14 +7525,12 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
7529
7525
  return stack ? stack.lead === this : true;
7530
7526
  }
7531
7527
  getLead() {
7532
- var _a;
7533
7528
  const { layoutId } = this.options;
7534
- return layoutId ? ((_a = this.getStack()) === null || _a === void 0 ? void 0 : _a.lead) || this : this;
7529
+ return layoutId ? this.getStack()?.lead || this : this;
7535
7530
  }
7536
7531
  getPrevLead() {
7537
- var _a;
7538
7532
  const { layoutId } = this.options;
7539
- return layoutId ? (_a = this.getStack()) === null || _a === void 0 ? void 0 : _a.prevLead : undefined;
7533
+ return layoutId ? this.getStack()?.prevLead : undefined;
7540
7534
  }
7541
7535
  getStack() {
7542
7536
  const { layoutId } = this.options;
@@ -7610,7 +7604,6 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
7610
7604
  visualElement.scheduleRender();
7611
7605
  }
7612
7606
  getProjectionStyles(styleProp) {
7613
- var _a, _b;
7614
7607
  if (!this.instance || this.isSVG)
7615
7608
  return undefined;
7616
7609
  if (!this.isVisible) {
@@ -7624,7 +7617,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
7624
7617
  this.needsReset = false;
7625
7618
  styles.opacity = "";
7626
7619
  styles.pointerEvents =
7627
- resolveMotionValue(styleProp === null || styleProp === void 0 ? void 0 : styleProp.pointerEvents) || "";
7620
+ resolveMotionValue(styleProp?.pointerEvents) || "";
7628
7621
  styles.transform = transformTemplate
7629
7622
  ? transformTemplate(this.latestValues, "")
7630
7623
  : "none";
@@ -7639,7 +7632,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
7639
7632
  ? this.latestValues.opacity
7640
7633
  : 1;
7641
7634
  emptyStyles.pointerEvents =
7642
- resolveMotionValue(styleProp === null || styleProp === void 0 ? void 0 : styleProp.pointerEvents) || "";
7635
+ resolveMotionValue(styleProp?.pointerEvents) || "";
7643
7636
  }
7644
7637
  if (this.hasProjected && !hasTransform(this.latestValues)) {
7645
7638
  emptyStyles.transform = transformTemplate
@@ -7664,7 +7657,9 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
7664
7657
  */
7665
7658
  styles.opacity =
7666
7659
  lead === this
7667
- ? (_b = (_a = valuesToRender.opacity) !== null && _a !== void 0 ? _a : this.latestValues.opacity) !== null && _b !== void 0 ? _b : 1
7660
+ ? valuesToRender.opacity ??
7661
+ this.latestValues.opacity ??
7662
+ 1
7668
7663
  : this.preserveOpacity
7669
7664
  ? this.latestValues.opacity
7670
7665
  : valuesToRender.opacityExit;
@@ -7725,7 +7720,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
7725
7720
  if (this.options.layoutId) {
7726
7721
  styles.pointerEvents =
7727
7722
  lead === this
7728
- ? resolveMotionValue(styleProp === null || styleProp === void 0 ? void 0 : styleProp.pointerEvents) || ""
7723
+ ? resolveMotionValue(styleProp?.pointerEvents) || ""
7729
7724
  : "none";
7730
7725
  }
7731
7726
  return styles;
@@ -7735,7 +7730,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
7735
7730
  }
7736
7731
  // Only run on root
7737
7732
  resetTree() {
7738
- this.root.nodes.forEach((node) => { var _a; return (_a = node.currentAnimation) === null || _a === void 0 ? void 0 : _a.stop(); });
7733
+ this.root.nodes.forEach((node) => node.currentAnimation?.stop());
7739
7734
  this.root.nodes.forEach(clearMeasurements);
7740
7735
  this.root.sharedNodes.clear();
7741
7736
  }
@@ -7745,8 +7740,7 @@ function updateLayout(node) {
7745
7740
  node.updateLayout();
7746
7741
  }
7747
7742
  function notifyLayoutUpdate(node) {
7748
- var _a;
7749
- const snapshot = ((_a = node.resumeFrom) === null || _a === void 0 ? void 0 : _a.snapshot) || node.snapshot;
7743
+ const snapshot = node.resumeFrom?.snapshot || node.snapshot;
7750
7744
  if (node.isLead() &&
7751
7745
  node.layout &&
7752
7746
  snapshot &&
@@ -7946,8 +7940,7 @@ function shouldAnimatePositionOnly(animationType, snapshot, layout) {
7946
7940
  !isNear(aspectRatio(snapshot), aspectRatio(layout), 0.2)));
7947
7941
  }
7948
7942
  function checkNodeWasScrollRoot(node) {
7949
- var _a;
7950
- return node !== node.root && ((_a = node.scroll) === null || _a === void 0 ? void 0 : _a.wasRoot);
7943
+ return node !== node.root && node.scroll?.wasRoot;
7951
7944
  }
7952
7945
 
7953
7946
  const DocumentProjectionNode = createProjectionNode$1({
@@ -8337,7 +8330,6 @@ function useMotionRef(visualState, visualElement, externalRef) {
8337
8330
  const useIsomorphicLayoutEffect = isBrowser ? react.useLayoutEffect : react.useEffect;
8338
8331
 
8339
8332
  function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor) {
8340
- var _a, _b;
8341
8333
  const { visualElement: parent } = react.useContext(MotionContext);
8342
8334
  const lazyContext = react.useContext(LazyContext);
8343
8335
  const presenceContext = react.useContext(PresenceContext);
@@ -8387,8 +8379,8 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
8387
8379
  */
8388
8380
  const optimisedAppearId = props[optimizedAppearDataAttribute];
8389
8381
  const wantsHandoff = react.useRef(Boolean(optimisedAppearId) &&
8390
- !((_a = window.MotionHandoffIsComplete) === null || _a === void 0 ? void 0 : _a.call(window, optimisedAppearId)) &&
8391
- ((_b = window.MotionHasOptimisedAnimation) === null || _b === void 0 ? void 0 : _b.call(window, optimisedAppearId)));
8382
+ !window.MotionHandoffIsComplete?.(optimisedAppearId) &&
8383
+ window.MotionHasOptimisedAnimation?.(optimisedAppearId));
8392
8384
  useIsomorphicLayoutEffect(() => {
8393
8385
  if (!visualElement)
8394
8386
  return;
@@ -8419,8 +8411,7 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
8419
8411
  if (wantsHandoff.current) {
8420
8412
  // This ensures all future calls to animateChanges() in this component will run in useEffect
8421
8413
  queueMicrotask(() => {
8422
- var _a;
8423
- (_a = window.MotionHandoffMarkAsComplete) === null || _a === void 0 ? void 0 : _a.call(window, optimisedAppearId);
8414
+ window.MotionHandoffMarkAsComplete?.(optimisedAppearId);
8424
8415
  });
8425
8416
  wantsHandoff.current = false;
8426
8417
  }
@@ -8468,7 +8459,6 @@ function getClosestProjectingNode(visualElement) {
8468
8459
  * component "offline", or outside the React render cycle.
8469
8460
  */
8470
8461
  function createRendererMotionComponent({ preloadedFeatures, createVisualElement, useRender, useVisualState, Component, }) {
8471
- var _a, _b;
8472
8462
  preloadedFeatures && loadFeatures(preloadedFeatures);
8473
8463
  function MotionComponent(props, externalRef) {
8474
8464
  /**
@@ -8504,7 +8494,7 @@ function createRendererMotionComponent({ preloadedFeatures, createVisualElement,
8504
8494
  }
8505
8495
  MotionComponent.displayName = `motion.${typeof Component === "string"
8506
8496
  ? Component
8507
- : `create(${(_b = (_a = Component.displayName) !== null && _a !== void 0 ? _a : Component.name) !== null && _b !== void 0 ? _b : ""})`}`;
8497
+ : `create(${Component.displayName ?? Component.name ?? ""})`}`;
8508
8498
  const ForwardRefMotionComponent = react.forwardRef(MotionComponent);
8509
8499
  ForwardRefMotionComponent[motionComponentSymbol] = Component;
8510
8500
  return ForwardRefMotionComponent;
@@ -8536,7 +8526,7 @@ function getProjectionFunctionality(props) {
8536
8526
  return {};
8537
8527
  const combined = { ...drag, ...layout };
8538
8528
  return {
8539
- MeasureLayout: (drag === null || drag === void 0 ? void 0 : drag.isEnabled(props)) || (layout === null || layout === void 0 ? void 0 : layout.isEnabled(props))
8529
+ MeasureLayout: drag?.isEnabled(props) || layout?.isEnabled(props)
8540
8530
  ? combined.MeasureLayout
8541
8531
  : undefined,
8542
8532
  ProjectionNode: combined.ProjectionNode,
@@ -8815,7 +8805,7 @@ try {
8815
8805
  */
8816
8806
  loadExternalIsValidProp(require("@emotion/is-prop-valid").default);
8817
8807
  }
8818
- catch (_a) {
8808
+ catch {
8819
8809
  // We don't need to actually do anything here - the fallback is the existing `isPropValid`.
8820
8810
  }
8821
8811
  function filterProps(props, isDom, forwardMotionProps) {
@@ -9136,7 +9126,6 @@ function makeLatestValues(props, context, presenceContext, scrapeMotionValues) {
9136
9126
  }
9137
9127
 
9138
9128
  function scrapeMotionValuesFromProps$1(props, prevProps, visualElement) {
9139
- var _a;
9140
9129
  const { style } = props;
9141
9130
  const newValues = {};
9142
9131
  for (const key in style) {
@@ -9144,7 +9133,7 @@ function scrapeMotionValuesFromProps$1(props, prevProps, visualElement) {
9144
9133
  (prevProps.style &&
9145
9134
  isMotionValue(prevProps.style[key])) ||
9146
9135
  isForcedMotionValue(key, props) ||
9147
- ((_a = visualElement === null || visualElement === void 0 ? void 0 : visualElement.getValue(key)) === null || _a === void 0 ? void 0 : _a.liveStyle) !== undefined) {
9136
+ visualElement?.getValue(key)?.liveStyle !== undefined) {
9148
9137
  newValues[key] = style[key];
9149
9138
  }
9150
9139
  }
@@ -9341,7 +9330,7 @@ function updateMotionValuesFromProps(element, next, prev) {
9341
9330
  * and warn against mismatches.
9342
9331
  */
9343
9332
  if (process.env.NODE_ENV === "development") {
9344
- warnOnce(nextValue.version === "12.6.3-alpha.0", `Attempting to mix Motion versions ${nextValue.version} with 12.6.3-alpha.0 may not work as expected.`);
9333
+ warnOnce(nextValue.version === "12.6.3", `Attempting to mix Motion versions ${nextValue.version} with 12.6.3 may not work as expected.`);
9345
9334
  }
9346
9335
  }
9347
9336
  else if (isMotionValue(prevValue)) {
@@ -9765,10 +9754,10 @@ class VisualElement {
9765
9754
  * directly from the instance (which might have performance implications).
9766
9755
  */
9767
9756
  readValue(key, target) {
9768
- var _a;
9769
9757
  let value = this.latestValues[key] !== undefined || !this.current
9770
9758
  ? this.latestValues[key]
9771
- : (_a = this.getBaseTargetFromProps(this.props, key)) !== null && _a !== void 0 ? _a : this.readValueFromInstance(this.current, key, this.options);
9759
+ : this.getBaseTargetFromProps(this.props, key) ??
9760
+ this.readValueFromInstance(this.current, key, this.options);
9772
9761
  if (value !== undefined && value !== null) {
9773
9762
  if (typeof value === "string" &&
9774
9763
  (isNumericalString(value) || isZeroValueString(value))) {
@@ -9794,11 +9783,10 @@ class VisualElement {
9794
9783
  * props.
9795
9784
  */
9796
9785
  getBaseTarget(key) {
9797
- var _a;
9798
9786
  const { initial } = this.props;
9799
9787
  let valueFromInitial;
9800
9788
  if (typeof initial === "string" || typeof initial === "object") {
9801
- const variant = resolveVariantFromProps(this.props, initial, (_a = this.presenceContext) === null || _a === void 0 ? void 0 : _a.custom);
9789
+ const variant = resolveVariantFromProps(this.props, initial, this.presenceContext?.custom);
9802
9790
  if (variant) {
9803
9791
  valueFromInitial = variant[key];
9804
9792
  }