framer-motion 12.6.2 → 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 (66) hide show
  1. package/dist/cjs/client.js +1 -1
  2. package/dist/cjs/{create-BLp_edji.js → create-B2InJs4e.js} +68 -115
  3. package/dist/cjs/dom-mini.js +14 -219
  4. package/dist/cjs/dom.js +56 -199
  5. package/dist/cjs/index.js +32 -156
  6. package/dist/cjs/m.js +8 -12
  7. package/dist/cjs/mini.js +10 -214
  8. package/dist/dom-mini.d.ts +3 -3
  9. package/dist/dom-mini.js +1 -1
  10. package/dist/dom.d.ts +17 -14
  11. package/dist/dom.js +1 -1
  12. package/dist/es/animation/animate/index.mjs +2 -2
  13. package/dist/es/animation/animators/AcceleratedAnimation.mjs +5 -3
  14. package/dist/es/animation/animators/MainThreadAnimation.mjs +6 -4
  15. package/dist/es/animation/animators/waapi/animate-elements.mjs +10 -9
  16. package/dist/es/animation/animators/waapi/animate-sequence.mjs +2 -2
  17. package/dist/es/animation/animators/waapi/animate-style.mjs +2 -2
  18. package/dist/es/animation/generators/spring/index.mjs +9 -1
  19. package/dist/es/animation/interfaces/motion-value.mjs +2 -2
  20. package/dist/es/animation/interfaces/visual-element-target.mjs +1 -2
  21. package/dist/es/animation/interfaces/visual-element-variant.mjs +1 -2
  22. package/dist/es/animation/optimized-appear/handoff.mjs +2 -4
  23. package/dist/es/animation/optimized-appear/start.mjs +4 -6
  24. package/dist/es/animation/sequence/create.mjs +2 -2
  25. package/dist/es/animation/sequence/utils/calc-time.mjs +1 -2
  26. package/dist/es/components/AnimatePresence/index.mjs +2 -2
  27. package/dist/es/gestures/drag/VisualElementDragControls.mjs +5 -10
  28. package/dist/es/motion/features/animation/index.mjs +1 -2
  29. package/dist/es/motion/index.mjs +2 -3
  30. package/dist/es/motion/utils/use-visual-element.mjs +3 -5
  31. package/dist/es/projection/node/create-projection-node.mjs +17 -25
  32. package/dist/es/projection/styles/transform.mjs +1 -1
  33. package/dist/es/render/VisualElement.mjs +3 -4
  34. package/dist/es/render/dom/DOMKeyframesResolver.mjs +1 -2
  35. package/dist/es/render/dom/resize/handle-element.mjs +5 -6
  36. package/dist/es/render/dom/scroll/track.mjs +1 -2
  37. package/dist/es/render/dom/utils/css-variables-conversion.mjs +1 -1
  38. package/dist/es/render/dom/utils/filter-props.mjs +1 -1
  39. package/dist/es/render/html/utils/scrape-motion-values.mjs +1 -2
  40. package/dist/es/render/utils/KeyframesResolver.mjs +2 -3
  41. package/dist/es/render/utils/animation-state.mjs +3 -5
  42. package/dist/es/render/utils/motion-values.mjs +1 -1
  43. package/dist/es/render/utils/resolve-variants.mjs +1 -1
  44. package/dist/es/utils/mix/complex.mjs +1 -2
  45. package/dist/es/value/types/complex/index.mjs +2 -3
  46. package/dist/es/value/use-scroll.mjs +2 -2
  47. package/dist/framer-motion.dev.js +445 -414
  48. package/dist/framer-motion.js +1 -1
  49. package/dist/mini.d.ts +1 -1
  50. package/dist/mini.js +1 -1
  51. package/dist/size-rollup-animate.js +1 -1
  52. package/dist/size-rollup-dom-animation-assets.js +1 -1
  53. package/dist/size-rollup-dom-animation-m.js +1 -1
  54. package/dist/size-rollup-dom-animation.js +1 -1
  55. package/dist/size-rollup-dom-max-assets.js +1 -1
  56. package/dist/size-rollup-dom-max.js +1 -1
  57. package/dist/size-rollup-m.js +1 -1
  58. package/dist/size-rollup-motion.js +1 -1
  59. package/dist/size-rollup-scroll.js +1 -1
  60. package/dist/size-rollup-waapi-animate.js +1 -1
  61. package/dist/types/index.d.ts +28 -31
  62. package/package.json +4 -4
  63. package/dist/es/animation/animators/waapi/NativeAnimation.mjs +0 -112
  64. package/dist/es/animation/animators/waapi/index.mjs +0 -32
  65. package/dist/es/animation/animators/waapi/utils/style.mjs +0 -8
  66. package/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs +0 -13
@@ -438,9 +438,9 @@
438
438
  isEveryExitComplete = false;
439
439
  });
440
440
  if (isEveryExitComplete) {
441
- forceRender === null || forceRender === void 0 ? void 0 : forceRender();
441
+ forceRender?.();
442
442
  setRenderedChildren(pendingPresentChildren.current);
443
- propagate && (safeToRemove === null || safeToRemove === void 0 ? void 0 : safeToRemove());
443
+ propagate && safeToRemove?.();
444
444
  onExitComplete && onExitComplete();
445
445
  }
446
446
  };
@@ -477,11 +477,8 @@
477
477
  return arr;
478
478
  }
479
479
 
480
- /*#__NO_SIDE_EFFECTS__*/
481
- const noop = (any) => any;
482
-
483
- let warning = noop;
484
- exports.invariant = noop;
480
+ let warning = () => { };
481
+ exports.invariant = () => { };
485
482
  {
486
483
  warning = (check, message) => {
487
484
  if (!check && typeof console !== "undefined") {
@@ -510,6 +507,9 @@
510
507
  };
511
508
  }
512
509
 
510
+ /*#__NO_SIDE_EFFECTS__*/
511
+ const noop = (any) => any;
512
+
513
513
  /*
514
514
  Progress within given range
515
515
 
@@ -598,15 +598,14 @@
598
598
 
599
599
  const supportsScrollTimeline = /* @__PURE__ */ memo(() => window.ScrollTimeline !== undefined);
600
600
 
601
- class BaseGroupPlaybackControls {
601
+ class GroupAnimation {
602
602
  constructor(animations) {
603
603
  // Bound to accomodate common `return animation.stop` pattern
604
604
  this.stop = () => this.runAll("stop");
605
605
  this.animations = animations.filter(Boolean);
606
606
  }
607
607
  get finished() {
608
- // Support for new finished Promise and legacy thennable API
609
- return Promise.all(this.animations.map((animation) => "finished" in animation ? animation.finished : animation));
608
+ return Promise.all(this.animations.map((animation) => animation.finished));
610
609
  }
611
610
  /**
612
611
  * TODO: Filter out cancelled or stopped animations before returning
@@ -677,156 +676,122 @@
677
676
  }
678
677
  }
679
678
 
680
- /**
681
- * TODO: This is a temporary class to support the legacy
682
- * thennable API
683
- */
684
- class GroupPlaybackControls extends BaseGroupPlaybackControls {
685
- then(onResolve, onReject) {
686
- return Promise.all(this.animations).then(onResolve).catch(onReject);
679
+ class GroupAnimationWithThen extends GroupAnimation {
680
+ then(onResolve, _onReject) {
681
+ return this.finished.finally(onResolve).then(() => { });
687
682
  }
688
683
  }
689
684
 
690
- function getValueTransition$1(transition, key) {
691
- return transition
692
- ? transition[key] ||
693
- transition["default"] ||
694
- transition
695
- : undefined;
696
- }
697
-
698
- /**
699
- * Implement a practical max duration for keyframe generation
700
- * to prevent infinite loops
701
- */
702
- const maxGeneratorDuration = 20000;
703
- function calcGeneratorDuration(generator) {
704
- let duration = 0;
705
- const timeStep = 50;
706
- let state = generator.next(duration);
707
- while (!state.done && duration < maxGeneratorDuration) {
708
- duration += timeStep;
709
- state = generator.next(duration);
710
- }
711
- return duration >= maxGeneratorDuration ? Infinity : duration;
712
- }
713
-
714
- /**
715
- * Create a progress => progress easing function from a generator.
716
- */
717
- function createGeneratorEasing(options, scale = 100, createGenerator) {
718
- const generator = createGenerator({ ...options, keyframes: [0, scale] });
719
- const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
720
- return {
721
- type: "keyframes",
722
- ease: (progress) => {
723
- return generator.next(duration * progress).value / scale;
724
- },
725
- duration: millisecondsToSeconds(duration),
726
- };
727
- }
728
-
729
- function isGenerator(type) {
730
- return typeof type === "function";
731
- }
685
+ const isCSSVar = (name) => name.startsWith("--");
686
+ const style = {
687
+ set: (element, name, value) => {
688
+ isCSSVar(name)
689
+ ? element.style.setProperty(name, value)
690
+ : (element.style[name] = value);
691
+ },
692
+ get: (element, name) => {
693
+ return isCSSVar(name)
694
+ ? element.style.getPropertyValue(name)
695
+ : element.style[name];
696
+ },
697
+ };
732
698
 
733
- function attachTimeline(animation, timeline) {
734
- animation.timeline = timeline;
735
- animation.onfinish = null;
699
+ const isNotNull$1 = (value) => value !== null;
700
+ function getFinalKeyframe$1(keyframes, { repeat, repeatType = "loop" }, finalKeyframe) {
701
+ const resolvedKeyframes = keyframes.filter(isNotNull$1);
702
+ const index = repeat && repeatType !== "loop" && repeat % 2 === 1
703
+ ? 0
704
+ : resolvedKeyframes.length - 1;
705
+ return !index || finalKeyframe === undefined
706
+ ? resolvedKeyframes[index]
707
+ : finalKeyframe;
736
708
  }
737
709
 
738
- class NativeAnimationControls {
739
- constructor(animation) {
740
- this.animation = animation;
741
- }
742
- get duration() {
743
- var _a, _b, _c;
744
- const durationInMs = ((_b = (_a = this.animation) === null || _a === void 0 ? void 0 : _a.effect) === null || _b === void 0 ? void 0 : _b.getComputedTiming().duration) ||
745
- ((_c = this.options) === null || _c === void 0 ? void 0 : _c.duration) ||
746
- 300;
747
- return millisecondsToSeconds(Number(durationInMs));
748
- }
749
- get time() {
750
- var _a;
751
- if (this.animation) {
752
- return millisecondsToSeconds(((_a = this.animation) === null || _a === void 0 ? void 0 : _a.currentTime) || 0);
753
- }
754
- return 0;
755
- }
756
- set time(newTime) {
757
- if (this.animation) {
758
- this.animation.currentTime = secondsToMilliseconds(newTime);
759
- }
760
- }
761
- get speed() {
762
- return this.animation ? this.animation.playbackRate : 1;
763
- }
764
- set speed(newSpeed) {
765
- if (this.animation) {
766
- this.animation.playbackRate = newSpeed;
767
- }
768
- }
769
- get state() {
770
- return this.animation ? this.animation.playState : "finished";
771
- }
772
- get startTime() {
773
- return this.animation ? this.animation.startTime : null;
774
- }
775
- get finished() {
776
- return this.animation ? this.animation.finished : Promise.resolve();
710
+ const supportsPartialKeyframes = /*@__PURE__*/ memo(() => {
711
+ try {
712
+ document.createElement("div").animate({ opacity: [1] });
777
713
  }
778
- play() {
779
- this.animation && this.animation.play();
714
+ catch (e) {
715
+ return false;
780
716
  }
781
- pause() {
782
- this.animation && this.animation.pause();
717
+ return true;
718
+ });
719
+
720
+ const pxValues = new Set([
721
+ // Border props
722
+ "borderWidth",
723
+ "borderTopWidth",
724
+ "borderRightWidth",
725
+ "borderBottomWidth",
726
+ "borderLeftWidth",
727
+ "borderRadius",
728
+ "radius",
729
+ "borderTopLeftRadius",
730
+ "borderTopRightRadius",
731
+ "borderBottomRightRadius",
732
+ "borderBottomLeftRadius",
733
+ // Positioning props
734
+ "width",
735
+ "maxWidth",
736
+ "height",
737
+ "maxHeight",
738
+ "top",
739
+ "right",
740
+ "bottom",
741
+ "left",
742
+ // Spacing props
743
+ "padding",
744
+ "paddingTop",
745
+ "paddingRight",
746
+ "paddingBottom",
747
+ "paddingLeft",
748
+ "margin",
749
+ "marginTop",
750
+ "marginRight",
751
+ "marginBottom",
752
+ "marginLeft",
753
+ // Misc
754
+ "backgroundPositionX",
755
+ "backgroundPositionY",
756
+ ]);
757
+
758
+ function hydrateKeyframes(element, name, keyframes, pseudoElement) {
759
+ if (!Array.isArray(keyframes)) {
760
+ keyframes = [keyframes];
783
761
  }
784
- stop() {
785
- if (!this.animation ||
786
- this.state === "idle" ||
787
- this.state === "finished") {
788
- return;
762
+ for (let i = 0; i < keyframes.length; i++) {
763
+ if (keyframes[i] === null) {
764
+ keyframes[i] =
765
+ i === 0 && !pseudoElement
766
+ ? style.get(element, name)
767
+ : keyframes[i - 1];
789
768
  }
790
- if (this.animation.commitStyles) {
791
- this.animation.commitStyles();
769
+ if (typeof keyframes[i] === "number" && pxValues.has(name)) {
770
+ keyframes[i] = keyframes[i] + "px";
792
771
  }
793
- this.cancel();
794
- }
795
- flatten() {
796
- var _a, _b;
797
- if (!this.animation || !((_a = this.options) === null || _a === void 0 ? void 0 : _a.allowFlatten))
798
- return;
799
- (_b = this.animation.effect) === null || _b === void 0 ? void 0 : _b.updateTiming({ easing: "linear" });
800
- }
801
- attachTimeline(timeline) {
802
- if (this.animation)
803
- attachTimeline(this.animation, timeline);
804
- return noop;
805
772
  }
806
- complete() {
807
- this.animation && this.animation.finish();
808
- }
809
- cancel() {
810
- try {
811
- this.animation && this.animation.cancel();
812
- }
813
- catch (e) { }
773
+ if (!pseudoElement && !supportsPartialKeyframes() && keyframes.length < 2) {
774
+ keyframes.unshift(style.get(element, name));
814
775
  }
776
+ return keyframes;
815
777
  }
816
778
 
779
+ const statsBuffer = {
780
+ value: null,
781
+ addProjectionMetrics: null,
782
+ };
783
+
817
784
  const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0] === "number";
818
785
 
819
786
  /**
820
787
  * Add the ability for test suites to manually set support flags
821
788
  * to better test more environments.
822
789
  */
823
- const supportsFlags = {
824
- linearEasing: undefined,
825
- };
790
+ const supportsFlags = {};
826
791
 
827
792
  function memoSupports(callback, supportsFlag) {
828
793
  const memoized = memo(callback);
829
- return () => { var _a; return (_a = supportsFlags[supportsFlag]) !== null && _a !== void 0 ? _a : memoized(); };
794
+ return () => supportsFlags[supportsFlag] ?? memoized();
830
795
  }
831
796
 
832
797
  const supportsLinearEasing = /*@__PURE__*/ memoSupports(() => {
@@ -847,20 +812,13 @@
847
812
  let points = "";
848
813
  const numPoints = Math.max(Math.round(duration / resolution), 2);
849
814
  for (let i = 0; i < numPoints; i++) {
850
- points += easing(progress(0, numPoints - 1, i)) + ", ";
815
+ points += easing(i / (numPoints - 1)) + ", ";
851
816
  }
852
817
  return `linear(${points.substring(0, points.length - 2)})`;
853
818
  };
854
819
 
855
- function isWaapiSupportedEasing(easing) {
856
- return Boolean((typeof easing === "function" && supportsLinearEasing()) ||
857
- !easing ||
858
- (typeof easing === "string" &&
859
- (easing in supportedWaapiEasing || supportsLinearEasing())) ||
860
- isBezierDefinition(easing) ||
861
- (Array.isArray(easing) && easing.every(isWaapiSupportedEasing)));
862
- }
863
820
  const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
821
+
864
822
  const supportedWaapiEasing = {
865
823
  linear: "linear",
866
824
  ease: "ease",
@@ -872,6 +830,7 @@
872
830
  backIn: /*@__PURE__*/ cubicBezierAsString([0.31, 0.01, 0.66, -0.59]),
873
831
  backOut: /*@__PURE__*/ cubicBezierAsString([0.33, 1.53, 0.69, 0.99]),
874
832
  };
833
+
875
834
  function mapEasingToNativeEasing(easing, duration) {
876
835
  if (!easing) {
877
836
  return undefined;
@@ -891,6 +850,247 @@
891
850
  }
892
851
  }
893
852
 
853
+ function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}, pseudoElement = undefined) {
854
+ const keyframeOptions = {
855
+ [valueName]: keyframes,
856
+ };
857
+ if (times)
858
+ keyframeOptions.offset = times;
859
+ const easing = mapEasingToNativeEasing(ease, duration);
860
+ /**
861
+ * If this is an easing array, apply to keyframes, not animation as a whole
862
+ */
863
+ if (Array.isArray(easing))
864
+ keyframeOptions.easing = easing;
865
+ const animation = element.animate(keyframeOptions, {
866
+ delay,
867
+ duration,
868
+ easing: !Array.isArray(easing) ? easing : "linear",
869
+ fill: "both",
870
+ iterations: repeat + 1,
871
+ direction: repeatType === "reverse" ? "alternate" : "normal",
872
+ pseudoElement,
873
+ });
874
+ return animation;
875
+ }
876
+
877
+ function isGenerator(type) {
878
+ return typeof type === "function" && "applyToOptions" in type;
879
+ }
880
+
881
+ function applyGeneratorOptions({ type, ...options }) {
882
+ if (isGenerator(type)) {
883
+ return type.applyToOptions(options);
884
+ }
885
+ else {
886
+ options.duration ?? (options.duration = 300);
887
+ options.ease ?? (options.ease = "easeOut");
888
+ }
889
+ return options;
890
+ }
891
+
892
+ const animationMaps = new WeakMap();
893
+ const animationMapKey = (name, pseudoElement) => `${name}:${pseudoElement}`;
894
+ function getAnimationMap(element) {
895
+ const map = animationMaps.get(element) || new Map();
896
+ animationMaps.set(element, map);
897
+ return map;
898
+ }
899
+ /**
900
+ * NativeAnimation implements AnimationPlaybackControls for the browser's Web Animations API.
901
+ */
902
+ class NativeAnimation {
903
+ constructor(options) {
904
+ /**
905
+ * If we already have an animation, we don't need to instantiate one
906
+ * and can just use this as a controls interface.
907
+ */
908
+ if ("animation" in options) {
909
+ this.animation = options.animation;
910
+ return;
911
+ }
912
+ const { element, name, keyframes: unresolvedKeyframes, pseudoElement, allowFlatten = false, } = options;
913
+ let { transition } = options;
914
+ this.allowFlatten = allowFlatten;
915
+ /**
916
+ * Stop any existing animations on the element before reading existing keyframes.
917
+ *
918
+ * TODO: Check for VisualElement before using animation state. This is a fallback
919
+ * for mini animate(). Do this when implementing NativeAnimationExtended.
920
+ */
921
+ const animationMap = getAnimationMap(element);
922
+ const key = animationMapKey(name, pseudoElement || "");
923
+ const currentAnimation = animationMap.get(key);
924
+ currentAnimation && currentAnimation.stop();
925
+ /**
926
+ * TODO: If these keyframes aren't correctly hydrated then we want to throw
927
+ * run an instant animation.
928
+ */
929
+ const keyframes = hydrateKeyframes(element, name, unresolvedKeyframes, pseudoElement);
930
+ exports.invariant(typeof transition.type !== "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "motion"?`);
931
+ transition = applyGeneratorOptions(transition);
932
+ this.animation = startWaapiAnimation(element, name, keyframes, transition, pseudoElement);
933
+ if (transition.autoplay === false) {
934
+ this.animation.pause();
935
+ }
936
+ this.removeAnimation = () => animationMap.delete(key);
937
+ this.animation.onfinish = () => {
938
+ if (!pseudoElement) {
939
+ style.set(element, name, getFinalKeyframe$1(keyframes, transition));
940
+ }
941
+ else {
942
+ this.commitStyles();
943
+ }
944
+ this.cancel();
945
+ };
946
+ /**
947
+ * TODO: Check for VisualElement before using animation state.
948
+ */
949
+ animationMap.set(key, this);
950
+ }
951
+ play() {
952
+ this.animation.play();
953
+ }
954
+ pause() {
955
+ this.animation.pause();
956
+ }
957
+ complete() {
958
+ this.animation.finish();
959
+ }
960
+ cancel() {
961
+ try {
962
+ this.animation.cancel();
963
+ }
964
+ catch (e) { }
965
+ this.removeAnimation();
966
+ }
967
+ stop() {
968
+ const { state } = this;
969
+ if (state === "idle" || state === "finished") {
970
+ return;
971
+ }
972
+ this.commitStyles();
973
+ this.cancel();
974
+ }
975
+ /**
976
+ * WAAPI doesn't natively have any interruption capabilities.
977
+ *
978
+ * In this method, we commit styles back to the DOM before cancelling
979
+ * the animation.
980
+ *
981
+ * This is designed to be overridden by NativeAnimationExtended, which
982
+ * will create a renderless JS animation and sample it twice to calculate
983
+ * its current value, "previous" value, and therefore allow
984
+ * Motion to also correctly calculate velocity for any subsequent animation
985
+ * while deferring the commit until the next animation frame.
986
+ */
987
+ commitStyles() {
988
+ this.animation.commitStyles?.();
989
+ }
990
+ get duration() {
991
+ console.log(this.animation.effect?.getComputedTiming());
992
+ const duration = this.animation.effect?.getComputedTiming().duration || 0;
993
+ return millisecondsToSeconds(Number(duration));
994
+ }
995
+ get time() {
996
+ return millisecondsToSeconds(Number(this.animation.currentTime) || 0);
997
+ }
998
+ set time(newTime) {
999
+ this.animation.currentTime = secondsToMilliseconds(newTime);
1000
+ }
1001
+ /**
1002
+ * The playback speed of the animation.
1003
+ * 1 = normal speed, 2 = double speed, 0.5 = half speed.
1004
+ */
1005
+ get speed() {
1006
+ return this.animation.playbackRate;
1007
+ }
1008
+ set speed(newSpeed) {
1009
+ this.animation.playbackRate = newSpeed;
1010
+ }
1011
+ get state() {
1012
+ return this.animation.playState;
1013
+ }
1014
+ get startTime() {
1015
+ return Number(this.animation.startTime);
1016
+ }
1017
+ get finished() {
1018
+ return this.animation.finished;
1019
+ }
1020
+ flatten() {
1021
+ if (this.allowFlatten) {
1022
+ this.animation.effect?.updateTiming({ easing: "linear" });
1023
+ }
1024
+ }
1025
+ /**
1026
+ * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
1027
+ */
1028
+ attachTimeline(timeline) {
1029
+ this.animation.timeline = timeline;
1030
+ this.animation.onfinish = null;
1031
+ return noop;
1032
+ }
1033
+ /**
1034
+ * Allows the animation to be awaited.
1035
+ *
1036
+ * @deprecated Use `finished` instead.
1037
+ */
1038
+ then(onResolve, onReject) {
1039
+ return this.finished.then(onResolve).catch(onReject);
1040
+ }
1041
+ }
1042
+
1043
+ function getValueTransition$1(transition, key) {
1044
+ return (transition?.[key] ??
1045
+ transition?.["default"] ??
1046
+ transition);
1047
+ }
1048
+
1049
+ /**
1050
+ * Implement a practical max duration for keyframe generation
1051
+ * to prevent infinite loops
1052
+ */
1053
+ const maxGeneratorDuration = 20000;
1054
+ function calcGeneratorDuration(generator) {
1055
+ let duration = 0;
1056
+ const timeStep = 50;
1057
+ let state = generator.next(duration);
1058
+ while (!state.done && duration < maxGeneratorDuration) {
1059
+ duration += timeStep;
1060
+ state = generator.next(duration);
1061
+ }
1062
+ return duration >= maxGeneratorDuration ? Infinity : duration;
1063
+ }
1064
+
1065
+ /**
1066
+ * Create a progress => progress easing function from a generator.
1067
+ */
1068
+ function createGeneratorEasing(options, scale = 100, createGenerator) {
1069
+ const generator = createGenerator({ ...options, keyframes: [0, scale] });
1070
+ const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
1071
+ return {
1072
+ type: "keyframes",
1073
+ ease: (progress) => {
1074
+ return generator.next(duration * progress).value / scale;
1075
+ },
1076
+ duration: millisecondsToSeconds(duration),
1077
+ };
1078
+ }
1079
+
1080
+ function isWaapiSupportedEasing(easing) {
1081
+ return Boolean((typeof easing === "function" && supportsLinearEasing()) ||
1082
+ !easing ||
1083
+ (typeof easing === "string" &&
1084
+ (easing in supportedWaapiEasing || supportsLinearEasing())) ||
1085
+ isBezierDefinition(easing) ||
1086
+ (Array.isArray(easing) && easing.every(isWaapiSupportedEasing)));
1087
+ }
1088
+
1089
+ function attachTimeline(animation, timeline) {
1090
+ animation.timeline = timeline;
1091
+ animation.onfinish = null;
1092
+ }
1093
+
894
1094
  const stepsOrder = [
895
1095
  "read", // Read
896
1096
  "resolveKeyframes", // Write/Read/Write/Read
@@ -900,11 +1100,6 @@
900
1100
  "postRender", // Compute
901
1101
  ];
902
1102
 
903
- const statsBuffer = {
904
- value: null,
905
- addProjectionMetrics: null,
906
- };
907
-
908
1103
  function createRenderStep(runNextFrame, stepName) {
909
1104
  /**
910
1105
  * We create and reuse two queues, one to queue jobs for the current frame
@@ -1124,21 +1319,16 @@
1124
1319
  }
1125
1320
 
1126
1321
  function resolveElements(elementOrSelector, scope, selectorCache) {
1127
- var _a;
1128
1322
  if (elementOrSelector instanceof EventTarget) {
1129
1323
  return [elementOrSelector];
1130
1324
  }
1131
1325
  else if (typeof elementOrSelector === "string") {
1132
1326
  let root = document;
1133
1327
  if (scope) {
1134
- // TODO: Refactor to utils package
1135
- // invariant(
1136
- // Boolean(scope.current),
1137
- // "Scope provided, but no element detected."
1138
- // )
1139
1328
  root = scope.current;
1140
1329
  }
1141
- const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
1330
+ const elements = selectorCache?.[elementOrSelector] ??
1331
+ root.querySelectorAll(elementOrSelector);
1142
1332
  return elements ? Array.from(elements) : [];
1143
1333
  }
1144
1334
  return Array.from(elementOrSelector);
@@ -1337,7 +1527,7 @@
1337
1527
  if (target instanceof HTMLElement) {
1338
1528
  target.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions));
1339
1529
  if (!isElementKeyboardAccessible(target) &&
1340
- target.tabIndex === null) {
1530
+ !target.hasAttribute("tabindex")) {
1341
1531
  target.tabIndex = 0;
1342
1532
  }
1343
1533
  }
@@ -1373,7 +1563,7 @@
1373
1563
  * This will be replaced by the build step with the latest version number.
1374
1564
  * When MotionValues are provided to motion components, warn if versions are mixed.
1375
1565
  */
1376
- this.version = "12.6.1";
1566
+ this.version = "12.6.3";
1377
1567
  /**
1378
1568
  * Tracks whether this value can output a velocity. Currently this is only true
1379
1569
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -2044,11 +2234,10 @@
2044
2234
  const colorRegex = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
2045
2235
 
2046
2236
  function test(v) {
2047
- var _a, _b;
2048
2237
  return (isNaN(v) &&
2049
2238
  typeof v === "string" &&
2050
- (((_a = v.match(floatRegex)) === null || _a === void 0 ? void 0 : _a.length) || 0) +
2051
- (((_b = v.match(colorRegex)) === null || _b === void 0 ? void 0 : _b.length) || 0) >
2239
+ (v.match(floatRegex)?.length || 0) +
2240
+ (v.match(colorRegex)?.length || 0) >
2052
2241
  0);
2053
2242
  }
2054
2243
  const NUMBER_TOKEN = "number";
@@ -2436,8 +2625,7 @@
2436
2625
  const restore = transformsToRestore.get(element);
2437
2626
  if (restore) {
2438
2627
  restore.forEach(([key, value]) => {
2439
- var _a;
2440
- (_a = element.getValue(key)) === null || _a === void 0 ? void 0 : _a.set(value);
2628
+ element.getValue(key)?.set(value);
2441
2629
  });
2442
2630
  }
2443
2631
  });
@@ -2524,7 +2712,7 @@
2524
2712
  * If the first keyframe is null, we need to find its value by sampling the element
2525
2713
  */
2526
2714
  if (i === 0) {
2527
- const currentValue = motionValue === null || motionValue === void 0 ? void 0 : motionValue.get();
2715
+ const currentValue = motionValue?.get();
2528
2716
  const finalKeyframe = unresolvedKeyframes[unresolvedKeyframes.length - 1];
2529
2717
  if (currentValue !== undefined) {
2530
2718
  unresolvedKeyframes[0] = currentValue;
@@ -2605,7 +2793,7 @@
2605
2793
  if (!match)
2606
2794
  return [,];
2607
2795
  const [, token1, token2, fallback] = match;
2608
- return [`--${token1 !== null && token1 !== void 0 ? token1 : token2}`, fallback];
2796
+ return [`--${token1 ?? token2}`, fallback];
2609
2797
  }
2610
2798
  const maxDepth = 4;
2611
2799
  function getVariableValue(current, element, depth = 1) {
@@ -2744,7 +2932,6 @@
2744
2932
  }
2745
2933
  }
2746
2934
  measureEndState() {
2747
- var _a;
2748
2935
  const { element, name, unresolvedKeyframes } = this;
2749
2936
  if (!element || !element.current)
2750
2937
  return;
@@ -2757,7 +2944,7 @@
2757
2944
  this.finalKeyframe = finalKeyframe;
2758
2945
  }
2759
2946
  // If we removed transform values, reapply them before the next render
2760
- if ((_a = this.removedTransforms) === null || _a === void 0 ? void 0 : _a.length) {
2947
+ if (this.removedTransforms?.length) {
2761
2948
  this.removedTransforms.forEach(([unsetTransformName, unsetTransformValue]) => {
2762
2949
  element
2763
2950
  .getValue(unsetTransformName)
@@ -3113,13 +3300,12 @@
3113
3300
  };
3114
3301
  }
3115
3302
  function matchOrder(origin, target) {
3116
- var _a;
3117
3303
  const orderedOrigin = [];
3118
3304
  const pointers = { color: 0, var: 0, number: 0 };
3119
3305
  for (let i = 0; i < target.values.length; i++) {
3120
3306
  const type = target.types[i];
3121
3307
  const originIndex = origin.indexes[type][pointers[type]];
3122
- const originValue = (_a = origin.values[originIndex]) !== null && _a !== void 0 ? _a : 0;
3308
+ const originValue = origin.values[originIndex] ?? 0;
3123
3309
  orderedOrigin[i] = originValue;
3124
3310
  pointers[type]++;
3125
3311
  }
@@ -3423,9 +3609,17 @@
3423
3609
  const easing = generateLinearEasing((progress) => generator.next(calculatedDuration * progress).value, calculatedDuration, 30);
3424
3610
  return calculatedDuration + "ms " + easing;
3425
3611
  },
3612
+ toTransition: () => { },
3426
3613
  };
3427
3614
  return generator;
3428
3615
  }
3616
+ spring.applyToOptions = (options) => {
3617
+ const generatorOptions = createGeneratorEasing(options, 100, spring);
3618
+ options.ease = supportsLinearEasing() ? generatorOptions.ease : "easeOut";
3619
+ options.duration = secondsToMilliseconds(generatorOptions.duration);
3620
+ options.type = "keyframes";
3621
+ return options;
3622
+ };
3429
3623
 
3430
3624
  function inertia({ keyframes, velocity = 0.0, power = 0.8, timeConstant = 325, bounceDamping = 10, bounceStiffness = 500, modifyTarget, min, max, restDelta = 0.5, restSpeed, }) {
3431
3625
  const origin = keyframes[0];
@@ -3634,7 +3828,7 @@
3634
3828
  return offset.map((o) => o * duration);
3635
3829
  }
3636
3830
 
3637
- function defaultEasing$1(values, easing) {
3831
+ function defaultEasing(values, easing) {
3638
3832
  return values.map(() => easing || easeInOut).splice(0, values.length - 1);
3639
3833
  }
3640
3834
  function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "easeInOut", }) {
@@ -3665,7 +3859,7 @@
3665
3859
  const mapTimeToKeyframe = interpolate(absoluteTimes, keyframeValues, {
3666
3860
  ease: Array.isArray(easingFunctions)
3667
3861
  ? easingFunctions
3668
- : defaultEasing$1(keyframeValues, easingFunctions),
3862
+ : defaultEasing(keyframeValues, easingFunctions),
3669
3863
  });
3670
3864
  return {
3671
3865
  calculatedDuration: duration,
@@ -3747,7 +3941,7 @@
3747
3941
  onStop && onStop();
3748
3942
  };
3749
3943
  const { name, motionValue, element, keyframes } = this.options;
3750
- const KeyframeResolver$1 = (element === null || element === void 0 ? void 0 : element.KeyframeResolver) || KeyframeResolver;
3944
+ const KeyframeResolver$1 = element?.KeyframeResolver || KeyframeResolver;
3751
3945
  const onResolved = (resolvedKeyframes, finalKeyframe) => this.onKeyframesResolved(resolvedKeyframes, finalKeyframe);
3752
3946
  this.resolver = new KeyframeResolver$1(keyframes, onResolved, name, motionValue, element);
3753
3947
  this.resolver.scheduleResolve();
@@ -3995,7 +4189,7 @@
3995
4189
  this.startTime = now - this.holdTime;
3996
4190
  }
3997
4191
  else if (!this.startTime) {
3998
- this.startTime = startTime !== null && startTime !== void 0 ? startTime : this.calcStartTime();
4192
+ this.startTime = startTime ?? this.calcStartTime();
3999
4193
  }
4000
4194
  else if (this.state === "finished") {
4001
4195
  this.startTime = now;
@@ -4013,13 +4207,12 @@
4013
4207
  this.driver.start();
4014
4208
  }
4015
4209
  pause() {
4016
- var _a;
4017
4210
  if (!this._resolved) {
4018
4211
  this.pendingPlayState = "paused";
4019
4212
  return;
4020
4213
  }
4021
4214
  this.state = "paused";
4022
- this.holdTime = (_a = this.currentTime) !== null && _a !== void 0 ? _a : 0;
4215
+ this.holdTime = this.currentTime ?? 0;
4023
4216
  }
4024
4217
  complete() {
4025
4218
  if (this.state !== "running") {
@@ -4059,6 +4252,9 @@
4059
4252
  this.startTime = 0;
4060
4253
  return this.tick(time, true);
4061
4254
  }
4255
+ get finished() {
4256
+ return this.currentFinishedPromise;
4257
+ }
4062
4258
  }
4063
4259
  // Legacy interface
4064
4260
  function animateValue(options) {
@@ -4078,27 +4274,6 @@
4078
4274
  // "background-color"
4079
4275
  ]);
4080
4276
 
4081
- function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}) {
4082
- const keyframeOptions = { [valueName]: keyframes };
4083
- if (times)
4084
- keyframeOptions.offset = times;
4085
- const easing = mapEasingToNativeEasing(ease, duration);
4086
- /**
4087
- * If this is an easing array, apply to keyframes, not animation as a whole
4088
- */
4089
- if (Array.isArray(easing))
4090
- keyframeOptions.easing = easing;
4091
- const animation = element.animate(keyframeOptions, {
4092
- delay,
4093
- duration,
4094
- easing: !Array.isArray(easing) ? easing : "linear",
4095
- fill: "both",
4096
- iterations: repeat + 1,
4097
- direction: repeatType === "reverse" ? "alternate" : "normal",
4098
- });
4099
- return animation;
4100
- }
4101
-
4102
4277
  const supportsWaapi = /*@__PURE__*/ memo(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
4103
4278
 
4104
4279
  /**
@@ -4209,7 +4384,7 @@
4209
4384
  const animation = startWaapiAnimation(motionValue.owner.current, name, keyframes, { ...this.options, duration, times, ease });
4210
4385
  // Override the browser calculated startTime with one synchronised to other JS
4211
4386
  // and WAAPI animations starting this event loop.
4212
- animation.startTime = startTime !== null && startTime !== void 0 ? startTime : this.calcStartTime();
4387
+ animation.startTime = startTime ?? this.calcStartTime();
4213
4388
  if (this.pendingTimeline) {
4214
4389
  attachTimeline(animation, this.pendingTimeline);
4215
4390
  this.pendingTimeline = undefined;
@@ -4268,6 +4443,9 @@
4268
4443
  const { animation } = resolved;
4269
4444
  return animation.playbackRate;
4270
4445
  }
4446
+ get finished() {
4447
+ return this.resolved.animation.finished;
4448
+ }
4271
4449
  set speed(newSpeed) {
4272
4450
  const { resolved } = this;
4273
4451
  if (!resolved)
@@ -4539,7 +4717,7 @@
4539
4717
  });
4540
4718
  // We still want to return some animation controls here rather
4541
4719
  // than returning undefined
4542
- return new GroupPlaybackControls([]);
4720
+ return new GroupAnimationWithThen([]);
4543
4721
  }
4544
4722
  }
4545
4723
  /**
@@ -5117,7 +5295,7 @@
5117
5295
  */
5118
5296
  const xTranslate = delta.x.translate / treeScale.x;
5119
5297
  const yTranslate = delta.y.translate / treeScale.y;
5120
- const zTranslate = (latestTransform === null || latestTransform === void 0 ? void 0 : latestTransform.z) || 0;
5298
+ const zTranslate = latestTransform?.z || 0;
5121
5299
  if (xTranslate || yTranslate || zTranslate) {
5122
5300
  transform = `translate3d(${xTranslate}px, ${yTranslate}px, ${zTranslate}px) `;
5123
5301
  }
@@ -5215,7 +5393,7 @@
5215
5393
  }
5216
5394
  function createProjectionNode$1({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
5217
5395
  return class ProjectionNode {
5218
- constructor(latestValues = {}, parent = defaultParent === null || defaultParent === void 0 ? void 0 : defaultParent()) {
5396
+ constructor(latestValues = {}, parent = defaultParent?.()) {
5219
5397
  /**
5220
5398
  * A unique ID generated for every projection node.
5221
5399
  */
@@ -5733,12 +5911,11 @@
5733
5911
  };
5734
5912
  }
5735
5913
  measurePageBox() {
5736
- var _a;
5737
5914
  const { visualElement } = this.options;
5738
5915
  if (!visualElement)
5739
5916
  return createBox();
5740
5917
  const box = visualElement.measureViewportBox();
5741
- const wasInScrollRoot = ((_a = this.scroll) === null || _a === void 0 ? void 0 : _a.wasRoot) || this.path.some(checkNodeWasScrollRoot);
5918
+ const wasInScrollRoot = this.scroll?.wasRoot || this.path.some(checkNodeWasScrollRoot);
5742
5919
  if (!wasInScrollRoot) {
5743
5920
  // Remove viewport scroll to give page-relative coordinates
5744
5921
  const { scroll } = this.root;
@@ -5750,10 +5927,9 @@
5750
5927
  return box;
5751
5928
  }
5752
5929
  removeElementScroll(box) {
5753
- var _a;
5754
5930
  const boxWithoutScroll = createBox();
5755
5931
  copyBoxInto(boxWithoutScroll, box);
5756
- if ((_a = this.scroll) === null || _a === void 0 ? void 0 : _a.wasRoot) {
5932
+ if (this.scroll?.wasRoot) {
5757
5933
  return boxWithoutScroll;
5758
5934
  }
5759
5935
  /**
@@ -5856,7 +6032,6 @@
5856
6032
  }
5857
6033
  }
5858
6034
  resolveTargetDelta(forceRecalculation = false) {
5859
- var _a;
5860
6035
  /**
5861
6036
  * Once the dirty status of nodes has been spread through the tree, we also
5862
6037
  * need to check if we have a shared node of a different depth that has itself
@@ -5874,7 +6049,7 @@
5874
6049
  const canSkip = !(forceRecalculation ||
5875
6050
  (isShared && this.isSharedProjectionDirty) ||
5876
6051
  this.isProjectionDirty ||
5877
- ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.isProjectionDirty) ||
6052
+ this.parent?.isProjectionDirty ||
5878
6053
  this.attemptToResolveRelativeTarget ||
5879
6054
  this.root.updateBlockedByResize);
5880
6055
  if (canSkip)
@@ -5993,7 +6168,6 @@
5993
6168
  this.layout);
5994
6169
  }
5995
6170
  calcProjection() {
5996
- var _a;
5997
6171
  const lead = this.getLead();
5998
6172
  const isShared = Boolean(this.resumingFrom) || this !== lead;
5999
6173
  let canSkip = true;
@@ -6001,7 +6175,7 @@
6001
6175
  * If this is a normal layout animation and neither this node nor its nearest projecting
6002
6176
  * is dirty then we can't skip.
6003
6177
  */
6004
- if (this.isProjectionDirty || ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.isProjectionDirty)) {
6178
+ if (this.isProjectionDirty || this.parent?.isProjectionDirty) {
6005
6179
  canSkip = false;
6006
6180
  }
6007
6181
  /**
@@ -6107,8 +6281,7 @@
6107
6281
  // TODO: Schedule render
6108
6282
  }
6109
6283
  scheduleRender(notifyAll = true) {
6110
- var _a;
6111
- (_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.scheduleRender();
6284
+ this.options.visualElement?.scheduleRender();
6112
6285
  if (notifyAll) {
6113
6286
  const stack = this.getStack();
6114
6287
  stack && stack.scheduleRender();
@@ -6292,14 +6465,12 @@
6292
6465
  return stack ? stack.lead === this : true;
6293
6466
  }
6294
6467
  getLead() {
6295
- var _a;
6296
6468
  const { layoutId } = this.options;
6297
- return layoutId ? ((_a = this.getStack()) === null || _a === void 0 ? void 0 : _a.lead) || this : this;
6469
+ return layoutId ? this.getStack()?.lead || this : this;
6298
6470
  }
6299
6471
  getPrevLead() {
6300
- var _a;
6301
6472
  const { layoutId } = this.options;
6302
- return layoutId ? (_a = this.getStack()) === null || _a === void 0 ? void 0 : _a.prevLead : undefined;
6473
+ return layoutId ? this.getStack()?.prevLead : undefined;
6303
6474
  }
6304
6475
  getStack() {
6305
6476
  const { layoutId } = this.options;
@@ -6373,7 +6544,6 @@
6373
6544
  visualElement.scheduleRender();
6374
6545
  }
6375
6546
  getProjectionStyles(styleProp) {
6376
- var _a, _b;
6377
6547
  if (!this.instance || this.isSVG)
6378
6548
  return undefined;
6379
6549
  if (!this.isVisible) {
@@ -6387,7 +6557,7 @@
6387
6557
  this.needsReset = false;
6388
6558
  styles.opacity = "";
6389
6559
  styles.pointerEvents =
6390
- resolveMotionValue(styleProp === null || styleProp === void 0 ? void 0 : styleProp.pointerEvents) || "";
6560
+ resolveMotionValue(styleProp?.pointerEvents) || "";
6391
6561
  styles.transform = transformTemplate
6392
6562
  ? transformTemplate(this.latestValues, "")
6393
6563
  : "none";
@@ -6402,7 +6572,7 @@
6402
6572
  ? this.latestValues.opacity
6403
6573
  : 1;
6404
6574
  emptyStyles.pointerEvents =
6405
- resolveMotionValue(styleProp === null || styleProp === void 0 ? void 0 : styleProp.pointerEvents) || "";
6575
+ resolveMotionValue(styleProp?.pointerEvents) || "";
6406
6576
  }
6407
6577
  if (this.hasProjected && !hasTransform(this.latestValues)) {
6408
6578
  emptyStyles.transform = transformTemplate
@@ -6427,7 +6597,9 @@
6427
6597
  */
6428
6598
  styles.opacity =
6429
6599
  lead === this
6430
- ? (_b = (_a = valuesToRender.opacity) !== null && _a !== void 0 ? _a : this.latestValues.opacity) !== null && _b !== void 0 ? _b : 1
6600
+ ? valuesToRender.opacity ??
6601
+ this.latestValues.opacity ??
6602
+ 1
6431
6603
  : this.preserveOpacity
6432
6604
  ? this.latestValues.opacity
6433
6605
  : valuesToRender.opacityExit;
@@ -6488,7 +6660,7 @@
6488
6660
  if (this.options.layoutId) {
6489
6661
  styles.pointerEvents =
6490
6662
  lead === this
6491
- ? resolveMotionValue(styleProp === null || styleProp === void 0 ? void 0 : styleProp.pointerEvents) || ""
6663
+ ? resolveMotionValue(styleProp?.pointerEvents) || ""
6492
6664
  : "none";
6493
6665
  }
6494
6666
  return styles;
@@ -6498,7 +6670,7 @@
6498
6670
  }
6499
6671
  // Only run on root
6500
6672
  resetTree() {
6501
- this.root.nodes.forEach((node) => { var _a; return (_a = node.currentAnimation) === null || _a === void 0 ? void 0 : _a.stop(); });
6673
+ this.root.nodes.forEach((node) => node.currentAnimation?.stop());
6502
6674
  this.root.nodes.forEach(clearMeasurements);
6503
6675
  this.root.sharedNodes.clear();
6504
6676
  }
@@ -6508,8 +6680,7 @@
6508
6680
  node.updateLayout();
6509
6681
  }
6510
6682
  function notifyLayoutUpdate(node) {
6511
- var _a;
6512
- const snapshot = ((_a = node.resumeFrom) === null || _a === void 0 ? void 0 : _a.snapshot) || node.snapshot;
6683
+ const snapshot = node.resumeFrom?.snapshot || node.snapshot;
6513
6684
  if (node.isLead() &&
6514
6685
  node.layout &&
6515
6686
  snapshot &&
@@ -6709,8 +6880,7 @@
6709
6880
  !isNear(aspectRatio(snapshot), aspectRatio(layout), 0.2)));
6710
6881
  }
6711
6882
  function checkNodeWasScrollRoot(node) {
6712
- var _a;
6713
- return node !== node.root && ((_a = node.scroll) === null || _a === void 0 ? void 0 : _a.wasRoot);
6883
+ return node !== node.root && node.scroll?.wasRoot;
6714
6884
  }
6715
6885
 
6716
6886
  function addDomEvent(target, eventName, handler, options = { passive: true }) {
@@ -6968,7 +7138,7 @@
6968
7138
  * and warn against mismatches.
6969
7139
  */
6970
7140
  {
6971
- warnOnce(nextValue.version === "12.6.2", `Attempting to mix Motion versions ${nextValue.version} with 12.6.2 may not work as expected.`);
7141
+ warnOnce(nextValue.version === "12.6.3", `Attempting to mix Motion versions ${nextValue.version} with 12.6.3 may not work as expected.`);
6972
7142
  }
6973
7143
  }
6974
7144
  else if (isMotionValue(prevValue)) {
@@ -7009,7 +7179,7 @@
7009
7179
 
7010
7180
  function getValueState(visualElement) {
7011
7181
  const state = [{}, {}];
7012
- visualElement === null || visualElement === void 0 ? void 0 : visualElement.values.forEach((value, key) => {
7182
+ visualElement?.values.forEach((value, key) => {
7013
7183
  state[0][key] = value.get();
7014
7184
  state[1][key] = value.getVelocity();
7015
7185
  });
@@ -7427,10 +7597,10 @@
7427
7597
  * directly from the instance (which might have performance implications).
7428
7598
  */
7429
7599
  readValue(key, target) {
7430
- var _a;
7431
7600
  let value = this.latestValues[key] !== undefined || !this.current
7432
7601
  ? this.latestValues[key]
7433
- : (_a = this.getBaseTargetFromProps(this.props, key)) !== null && _a !== void 0 ? _a : this.readValueFromInstance(this.current, key, this.options);
7602
+ : this.getBaseTargetFromProps(this.props, key) ??
7603
+ this.readValueFromInstance(this.current, key, this.options);
7434
7604
  if (value !== undefined && value !== null) {
7435
7605
  if (typeof value === "string" &&
7436
7606
  (isNumericalString(value) || isZeroValueString(value))) {
@@ -7456,11 +7626,10 @@
7456
7626
  * props.
7457
7627
  */
7458
7628
  getBaseTarget(key) {
7459
- var _a;
7460
7629
  const { initial } = this.props;
7461
7630
  let valueFromInitial;
7462
7631
  if (typeof initial === "string" || typeof initial === "object") {
7463
- const variant = resolveVariantFromProps(this.props, initial, (_a = this.presenceContext) === null || _a === void 0 ? void 0 : _a.custom);
7632
+ const variant = resolveVariantFromProps(this.props, initial, this.presenceContext?.custom);
7464
7633
  if (variant) {
7465
7634
  valueFromInitial = variant[key];
7466
7635
  }
@@ -7678,7 +7847,6 @@
7678
7847
  }
7679
7848
 
7680
7849
  function scrapeMotionValuesFromProps$1(props, prevProps, visualElement) {
7681
- var _a;
7682
7850
  const { style } = props;
7683
7851
  const newValues = {};
7684
7852
  for (const key in style) {
@@ -7686,7 +7854,7 @@
7686
7854
  (prevProps.style &&
7687
7855
  isMotionValue(prevProps.style[key])) ||
7688
7856
  isForcedMotionValue(key, props) ||
7689
- ((_a = visualElement === null || visualElement === void 0 ? void 0 : visualElement.getValue(key)) === null || _a === void 0 ? void 0 : _a.liveStyle) !== undefined) {
7857
+ visualElement?.getValue(key)?.liveStyle !== undefined) {
7690
7858
  newValues[key] = style[key];
7691
7859
  }
7692
7860
  }
@@ -7929,7 +8097,7 @@
7929
8097
  */
7930
8098
  loadExternalIsValidProp(require("@emotion/is-prop-valid").default);
7931
8099
  }
7932
- catch (_a) {
8100
+ catch {
7933
8101
  // We don't need to actually do anything here - the fallback is the existing `isPropValid`.
7934
8102
  }
7935
8103
  function filterProps(props, isDom, forwardMotionProps) {
@@ -8088,7 +8256,6 @@
8088
8256
  return shouldBlock;
8089
8257
  }
8090
8258
  function animateTarget(visualElement, targetAndTransition, { delay = 0, transitionOverride, type } = {}) {
8091
- var _a;
8092
8259
  let { transition = visualElement.getDefaultTransition(), transitionEnd, ...target } = targetAndTransition;
8093
8260
  if (transitionOverride)
8094
8261
  transition = transitionOverride;
@@ -8097,7 +8264,7 @@
8097
8264
  visualElement.animationState &&
8098
8265
  visualElement.animationState.getState()[type];
8099
8266
  for (const key in target) {
8100
- const value = visualElement.getValue(key, (_a = visualElement.latestValues[key]) !== null && _a !== void 0 ? _a : null);
8267
+ const value = visualElement.getValue(key, visualElement.latestValues[key] ?? null);
8101
8268
  const valueTarget = target[key];
8102
8269
  if (valueTarget === undefined ||
8103
8270
  (animationTypeState &&
@@ -8143,9 +8310,8 @@
8143
8310
  }
8144
8311
 
8145
8312
  function animateVariant(visualElement, variant, options = {}) {
8146
- var _a;
8147
8313
  const resolved = resolveVariant(visualElement, variant, options.type === "exit"
8148
- ? (_a = visualElement.presenceContext) === null || _a === void 0 ? void 0 : _a.custom
8314
+ ? visualElement.presenceContext?.custom
8149
8315
  : undefined);
8150
8316
  let { transition = visualElement.getDefaultTransition() || {} } = resolved || {};
8151
8317
  if (options.transitionOverride) {
@@ -8276,9 +8442,8 @@
8276
8442
  * each active animation type into an object of resolved values for it.
8277
8443
  */
8278
8444
  const buildResolvedTypeValues = (type) => (acc, definition) => {
8279
- var _a;
8280
8445
  const resolved = resolveVariant(visualElement, definition, type === "exit"
8281
- ? (_a = visualElement.presenceContext) === null || _a === void 0 ? void 0 : _a.custom
8446
+ ? visualElement.presenceContext?.custom
8282
8447
  : undefined);
8283
8448
  if (resolved) {
8284
8449
  const { transition, transitionEnd, ...target } = resolved;
@@ -8526,7 +8691,7 @@
8526
8691
  if (motionValue)
8527
8692
  motionValue.liveStyle = true;
8528
8693
  // @ts-expect-error - @mattgperry to figure if we should do something here
8529
- fallbackAnimation[key] = fallbackTarget !== null && fallbackTarget !== void 0 ? fallbackTarget : null;
8694
+ fallbackAnimation[key] = fallbackTarget ?? null;
8530
8695
  });
8531
8696
  animations.push({ animation: fallbackAnimation });
8532
8697
  }
@@ -8543,12 +8708,11 @@
8543
8708
  * Change whether a certain animation type is active.
8544
8709
  */
8545
8710
  function setActive(type, isActive) {
8546
- var _a;
8547
8711
  // If the active state hasn't changed, we can safely do nothing here
8548
8712
  if (state[type].isActive === isActive)
8549
8713
  return Promise.resolve();
8550
8714
  // Propagate active change to children
8551
- (_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); });
8715
+ visualElement.variantChildren?.forEach((child) => child.animationState?.setActive(type, isActive));
8552
8716
  state[type].isActive = isActive;
8553
8717
  const animations = animateChanges(type);
8554
8718
  for (const key in state) {
@@ -8634,9 +8798,8 @@
8634
8798
  }
8635
8799
  }
8636
8800
  unmount() {
8637
- var _a;
8638
8801
  this.node.animationState.reset();
8639
- (_a = this.unmountControls) === null || _a === void 0 ? void 0 : _a.call(this);
8802
+ this.unmountControls?.();
8640
8803
  }
8641
8804
  }
8642
8805
 
@@ -9104,11 +9267,8 @@
9104
9267
  onDrag && onDrag(event, info);
9105
9268
  };
9106
9269
  const onSessionEnd = (event, info) => this.stop(event, info);
9107
- const resumeAnimation = () => eachAxis((axis) => {
9108
- var _a;
9109
- return this.getAnimationState(axis) === "paused" &&
9110
- ((_a = this.getAxisMotionValue(axis).animation) === null || _a === void 0 ? void 0 : _a.play());
9111
- });
9270
+ const resumeAnimation = () => eachAxis((axis) => this.getAnimationState(axis) === "paused" &&
9271
+ this.getAxisMotionValue(axis).animation?.play());
9112
9272
  const { dragSnapToOrigin } = this.getProps();
9113
9273
  this.panSession = new PanSession(originEvent, {
9114
9274
  onSessionStart,
@@ -9163,12 +9323,11 @@
9163
9323
  axisValue.set(next);
9164
9324
  }
9165
9325
  resolveConstraints() {
9166
- var _a;
9167
9326
  const { dragConstraints, dragElastic } = this.getProps();
9168
9327
  const layout = this.visualElement.projection &&
9169
9328
  !this.visualElement.projection.layout
9170
9329
  ? this.visualElement.projection.measure(false)
9171
- : (_a = this.visualElement.projection) === null || _a === void 0 ? void 0 : _a.layout;
9330
+ : this.visualElement.projection?.layout;
9172
9331
  const prevConstraints = this.constraints;
9173
9332
  if (dragConstraints && isRefObject(dragConstraints)) {
9174
9333
  if (!this.constraints) {
@@ -9271,11 +9430,10 @@
9271
9430
  eachAxis((axis) => this.getAxisMotionValue(axis).stop());
9272
9431
  }
9273
9432
  pauseAnimation() {
9274
- eachAxis((axis) => { var _a; return (_a = this.getAxisMotionValue(axis).animation) === null || _a === void 0 ? void 0 : _a.pause(); });
9433
+ eachAxis((axis) => this.getAxisMotionValue(axis).animation?.pause());
9275
9434
  }
9276
9435
  getAnimationState(axis) {
9277
- var _a;
9278
- return (_a = this.getAxisMotionValue(axis).animation) === null || _a === void 0 ? void 0 : _a.state;
9436
+ return this.getAxisMotionValue(axis).animation?.state;
9279
9437
  }
9280
9438
  /**
9281
9439
  * Drag works differently depending on which props are provided.
@@ -9936,7 +10094,6 @@
9936
10094
  }
9937
10095
 
9938
10096
  function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor) {
9939
- var _a, _b;
9940
10097
  const { visualElement: parent } = React$1.useContext(MotionContext);
9941
10098
  const lazyContext = React$1.useContext(LazyContext);
9942
10099
  const presenceContext = React$1.useContext(PresenceContext);
@@ -9986,8 +10143,8 @@
9986
10143
  */
9987
10144
  const optimisedAppearId = props[optimizedAppearDataAttribute];
9988
10145
  const wantsHandoff = React$1.useRef(Boolean(optimisedAppearId) &&
9989
- !((_a = window.MotionHandoffIsComplete) === null || _a === void 0 ? void 0 : _a.call(window, optimisedAppearId)) &&
9990
- ((_b = window.MotionHasOptimisedAnimation) === null || _b === void 0 ? void 0 : _b.call(window, optimisedAppearId)));
10146
+ !window.MotionHandoffIsComplete?.(optimisedAppearId) &&
10147
+ window.MotionHasOptimisedAnimation?.(optimisedAppearId));
9991
10148
  useIsomorphicLayoutEffect(() => {
9992
10149
  if (!visualElement)
9993
10150
  return;
@@ -10018,8 +10175,7 @@
10018
10175
  if (wantsHandoff.current) {
10019
10176
  // This ensures all future calls to animateChanges() in this component will run in useEffect
10020
10177
  queueMicrotask(() => {
10021
- var _a;
10022
- (_a = window.MotionHandoffMarkAsComplete) === null || _a === void 0 ? void 0 : _a.call(window, optimisedAppearId);
10178
+ window.MotionHandoffMarkAsComplete?.(optimisedAppearId);
10023
10179
  });
10024
10180
  wantsHandoff.current = false;
10025
10181
  }
@@ -10067,7 +10223,6 @@
10067
10223
  * component "offline", or outside the React render cycle.
10068
10224
  */
10069
10225
  function createRendererMotionComponent({ preloadedFeatures, createVisualElement, useRender, useVisualState, Component, }) {
10070
- var _a, _b;
10071
10226
  preloadedFeatures && loadFeatures(preloadedFeatures);
10072
10227
  function MotionComponent(props, externalRef) {
10073
10228
  /**
@@ -10103,7 +10258,7 @@
10103
10258
  }
10104
10259
  MotionComponent.displayName = `motion.${typeof Component === "string"
10105
10260
  ? Component
10106
- : `create(${(_b = (_a = Component.displayName) !== null && _a !== void 0 ? _a : Component.name) !== null && _b !== void 0 ? _b : ""})`}`;
10261
+ : `create(${Component.displayName ?? Component.name ?? ""})`}`;
10107
10262
  const ForwardRefMotionComponent = React$1.forwardRef(MotionComponent);
10108
10263
  ForwardRefMotionComponent[motionComponentSymbol] = Component;
10109
10264
  return ForwardRefMotionComponent;
@@ -10134,7 +10289,7 @@
10134
10289
  return {};
10135
10290
  const combined = { ...drag, ...layout };
10136
10291
  return {
10137
- MeasureLayout: (drag === null || drag === void 0 ? void 0 : drag.isEnabled(props)) || (layout === null || layout === void 0 ? void 0 : layout.isEnabled(props))
10292
+ MeasureLayout: drag?.isEnabled(props) || layout?.isEnabled(props)
10138
10293
  ? combined.MeasureLayout
10139
10294
  : undefined,
10140
10295
  ProjectionNode: combined.ProjectionNode,
@@ -10920,7 +11075,6 @@
10920
11075
  * calculate an absolute time for the next keyframes.
10921
11076
  */
10922
11077
  function calcNextTime(current, next, prev, labels) {
10923
- var _a;
10924
11078
  if (typeof next === "number") {
10925
11079
  return next;
10926
11080
  }
@@ -10931,7 +11085,7 @@
10931
11085
  return prev;
10932
11086
  }
10933
11087
  else {
10934
- return (_a = labels.get(next)) !== null && _a !== void 0 ? _a : current;
11088
+ return labels.get(next) ?? current;
10935
11089
  }
10936
11090
  }
10937
11091
 
@@ -11044,7 +11198,7 @@
11044
11198
  const numKeyframes = valueKeyframesAsList.length;
11045
11199
  const createGenerator = isGenerator(type)
11046
11200
  ? type
11047
- : generators === null || generators === void 0 ? void 0 : generators[type];
11201
+ : generators?.[type];
11048
11202
  if (numKeyframes <= 2 && createGenerator) {
11049
11203
  /**
11050
11204
  * As we're creating an easing function from a spring,
@@ -11066,7 +11220,7 @@
11066
11220
  ease = springEasing.ease;
11067
11221
  duration = springEasing.duration;
11068
11222
  }
11069
- duration !== null && duration !== void 0 ? duration : (duration = defaultDuration);
11223
+ duration ?? (duration = defaultDuration);
11070
11224
  const startTime = currentTime + calculatedDelay;
11071
11225
  /**
11072
11226
  * If there's only one time offset of 0, fill in a second with length 1
@@ -11369,7 +11523,7 @@
11369
11523
  else {
11370
11524
  animations = animateSubject(subjectOrSequence, optionsOrKeyframes, options, scope);
11371
11525
  }
11372
- const animation = new GroupPlaybackControls(animations);
11526
+ const animation = new GroupAnimationWithThen(animations);
11373
11527
  if (scope) {
11374
11528
  scope.animations.push(animation);
11375
11529
  }
@@ -11379,125 +11533,6 @@
11379
11533
  }
11380
11534
  const animate = createScopedAnimate();
11381
11535
 
11382
- function setCSSVar(element, name, value) {
11383
- element.style.setProperty(name, value);
11384
- }
11385
- function setStyle(element, name, value) {
11386
- element.style[name] = value;
11387
- }
11388
-
11389
- const supportsPartialKeyframes = /*@__PURE__*/ memo(() => {
11390
- try {
11391
- document.createElement("div").animate({ opacity: [1] });
11392
- }
11393
- catch (e) {
11394
- return false;
11395
- }
11396
- return true;
11397
- });
11398
-
11399
- const state = new WeakMap();
11400
- function hydrateKeyframes(valueName, keyframes, read) {
11401
- for (let i = 0; i < keyframes.length; i++) {
11402
- if (keyframes[i] === null) {
11403
- keyframes[i] = i === 0 ? read() : keyframes[i - 1];
11404
- }
11405
- if (typeof keyframes[i] === "number" &&
11406
- browserNumberValueTypes[valueName]) {
11407
- keyframes[i] = browserNumberValueTypes[valueName].transform(keyframes[i]);
11408
- }
11409
- }
11410
- if (!supportsPartialKeyframes() && keyframes.length < 2) {
11411
- keyframes.unshift(read());
11412
- }
11413
- }
11414
- const defaultEasing = "easeOut";
11415
- function getElementAnimationState(element) {
11416
- const animationState = state.get(element) || new Map();
11417
- state.set(element, animationState);
11418
- return state.get(element);
11419
- }
11420
- class NativeAnimation extends NativeAnimationControls {
11421
- constructor(element, valueName, valueKeyframes, options) {
11422
- const isCSSVar = valueName.startsWith("--");
11423
- exports.invariant(typeof options.type !== "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "framer-motion"?`);
11424
- const existingAnimation = getElementAnimationState(element).get(valueName);
11425
- existingAnimation && existingAnimation.stop();
11426
- const readInitialKeyframe = () => {
11427
- return valueName.startsWith("--")
11428
- ? element.style.getPropertyValue(valueName)
11429
- : window.getComputedStyle(element)[valueName];
11430
- };
11431
- if (!Array.isArray(valueKeyframes)) {
11432
- valueKeyframes = [valueKeyframes];
11433
- }
11434
- hydrateKeyframes(valueName, valueKeyframes, readInitialKeyframe);
11435
- // TODO: Replace this with toString()?
11436
- if (isGenerator(options.type)) {
11437
- const generatorOptions = createGeneratorEasing(options, 100, options.type);
11438
- options.ease = supportsLinearEasing()
11439
- ? generatorOptions.ease
11440
- : defaultEasing;
11441
- options.duration = secondsToMilliseconds(generatorOptions.duration);
11442
- options.type = "keyframes";
11443
- }
11444
- else {
11445
- options.ease = options.ease || defaultEasing;
11446
- }
11447
- const onFinish = () => {
11448
- this.setValue(element, valueName, getFinalKeyframe(valueKeyframes, options));
11449
- this.cancel();
11450
- this.resolveFinishedPromise();
11451
- };
11452
- const init = () => {
11453
- this.setValue = isCSSVar ? setCSSVar : setStyle;
11454
- this.options = options;
11455
- this.updateFinishedPromise();
11456
- this.removeAnimation = () => {
11457
- const elementState = state.get(element);
11458
- elementState && elementState.delete(valueName);
11459
- };
11460
- };
11461
- if (!supportsWaapi()) {
11462
- super();
11463
- init();
11464
- onFinish();
11465
- }
11466
- else {
11467
- super(startWaapiAnimation(element, valueName, valueKeyframes, options));
11468
- init();
11469
- if (options.autoplay === false) {
11470
- this.animation.pause();
11471
- }
11472
- this.animation.onfinish = onFinish;
11473
- getElementAnimationState(element).set(valueName, this);
11474
- }
11475
- }
11476
- /**
11477
- * Allows the returned animation to be awaited or promise-chained. Currently
11478
- * resolves when the animation finishes at all but in a future update could/should
11479
- * reject if its cancels.
11480
- */
11481
- then(resolve, reject) {
11482
- return this.currentFinishedPromise.then(resolve, reject);
11483
- }
11484
- updateFinishedPromise() {
11485
- this.currentFinishedPromise = new Promise((resolve) => {
11486
- this.resolveFinishedPromise = resolve;
11487
- });
11488
- }
11489
- play() {
11490
- if (this.state === "finished") {
11491
- this.updateFinishedPromise();
11492
- }
11493
- super.play();
11494
- }
11495
- cancel() {
11496
- this.removeAnimation();
11497
- super.cancel();
11498
- }
11499
- }
11500
-
11501
11536
  function animateElements(elementOrSelector, keyframes, options, scope) {
11502
11537
  const elements = resolveElements(elementOrSelector, scope);
11503
11538
  const numElements = elements.length;
@@ -11517,13 +11552,15 @@
11517
11552
  const valueOptions = {
11518
11553
  ...getValueTransition$1(elementTransition, valueName),
11519
11554
  };
11520
- valueOptions.duration = valueOptions.duration
11521
- ? secondsToMilliseconds(valueOptions.duration)
11522
- : valueOptions.duration;
11523
- valueOptions.delay = secondsToMilliseconds(valueOptions.delay || 0);
11524
- valueOptions.allowFlatten =
11525
- !elementTransition.type && !elementTransition.ease;
11526
- animations.push(new NativeAnimation(element, valueName, valueKeyframes, valueOptions));
11555
+ valueOptions.duration && (valueOptions.duration = secondsToMilliseconds(valueOptions.duration));
11556
+ valueOptions.delay && (valueOptions.delay = secondsToMilliseconds(valueOptions.delay));
11557
+ animations.push(new NativeAnimation({
11558
+ element,
11559
+ name: valueName,
11560
+ keyframes: valueKeyframes,
11561
+ transition: valueOptions,
11562
+ allowFlatten: !elementTransition.type && !elementTransition.ease,
11563
+ }));
11527
11564
  }
11528
11565
  }
11529
11566
  return animations;
@@ -11531,7 +11568,7 @@
11531
11568
 
11532
11569
  const createScopedWaapiAnimate = (scope) => {
11533
11570
  function scopedAnimate(elementOrSelector, keyframes, options) {
11534
- return new GroupPlaybackControls(animateElements(elementOrSelector, keyframes, options, scope));
11571
+ return new GroupAnimationWithThen(animateElements(elementOrSelector, keyframes, options, scope));
11535
11572
  }
11536
11573
  return scopedAnimate;
11537
11574
  };
@@ -11570,8 +11607,7 @@
11570
11607
  }
11571
11608
  }
11572
11609
  function notifyTarget({ target, contentRect, borderBoxSize, }) {
11573
- var _a;
11574
- (_a = resizeHandlers.get(target)) === null || _a === void 0 ? void 0 : _a.forEach((handler) => {
11610
+ resizeHandlers.get(target)?.forEach((handler) => {
11575
11611
  handler({
11576
11612
  target,
11577
11613
  contentSize: contentRect,
@@ -11600,14 +11636,14 @@
11600
11636
  resizeHandlers.set(element, elementHandlers);
11601
11637
  }
11602
11638
  elementHandlers.add(handler);
11603
- observer === null || observer === void 0 ? void 0 : observer.observe(element);
11639
+ observer?.observe(element);
11604
11640
  });
11605
11641
  return () => {
11606
11642
  elements.forEach((element) => {
11607
11643
  const elementHandlers = resizeHandlers.get(element);
11608
- elementHandlers === null || elementHandlers === void 0 ? void 0 : elementHandlers.delete(handler);
11609
- if (!(elementHandlers === null || elementHandlers === void 0 ? void 0 : elementHandlers.size)) {
11610
- observer === null || observer === void 0 ? void 0 : observer.unobserve(element);
11644
+ elementHandlers?.delete(handler);
11645
+ if (!elementHandlers?.size) {
11646
+ observer?.unobserve(element);
11611
11647
  }
11612
11648
  });
11613
11649
  };
@@ -11986,7 +12022,6 @@
11986
12022
  const listener = scrollListeners.get(container);
11987
12023
  frame.read(listener, false, true);
11988
12024
  return () => {
11989
- var _a;
11990
12025
  cancelFrame(listener);
11991
12026
  /**
11992
12027
  * Check if we even have any handlers for this container.
@@ -12004,7 +12039,7 @@
12004
12039
  scrollListeners.delete(container);
12005
12040
  if (scrollListener) {
12006
12041
  getEventTarget(container).removeEventListener("scroll", scrollListener);
12007
- (_a = resizeListeners.get(container)) === null || _a === void 0 ? void 0 : _a();
12042
+ resizeListeners.get(container)?.();
12008
12043
  window.removeEventListener("resize", scrollListener);
12009
12044
  }
12010
12045
  };
@@ -12235,8 +12270,8 @@
12235
12270
  values.scrollYProgress.set(y.progress);
12236
12271
  }, {
12237
12272
  ...options,
12238
- container: (container === null || container === void 0 ? void 0 : container.current) || undefined,
12239
- target: (target === null || target === void 0 ? void 0 : target.current) || undefined,
12273
+ container: container?.current || undefined,
12274
+ target: target?.current || undefined,
12240
12275
  });
12241
12276
  }, [container, target, JSON.stringify(options.offset)]);
12242
12277
  return values;
@@ -12894,7 +12929,6 @@
12894
12929
  };
12895
12930
 
12896
12931
  function handoffOptimizedAppearAnimation(elementId, valueName, frame) {
12897
- var _a;
12898
12932
  const storeId = appearStoreId(elementId, valueName);
12899
12933
  const optimisedAnimation = appearAnimationStore.get(storeId);
12900
12934
  if (!optimisedAnimation) {
@@ -12902,8 +12936,7 @@
12902
12936
  }
12903
12937
  const { animation, startTime } = optimisedAnimation;
12904
12938
  function cancelAnimation() {
12905
- var _a;
12906
- (_a = window.MotionCancelOptimisedAnimation) === null || _a === void 0 ? void 0 : _a.call(window, elementId, valueName, frame);
12939
+ window.MotionCancelOptimisedAnimation?.(elementId, valueName, frame);
12907
12940
  }
12908
12941
  /**
12909
12942
  * We can cancel the animation once it's finished now that we've synced
@@ -12913,7 +12946,7 @@
12913
12946
  * older browsers.
12914
12947
  */
12915
12948
  animation.onfinish = cancelAnimation;
12916
- if (startTime === null || ((_a = window.MotionHandoffIsComplete) === null || _a === void 0 ? void 0 : _a.call(window, elementId))) {
12949
+ if (startTime === null || window.MotionHandoffIsComplete?.(elementId)) {
12917
12950
  /**
12918
12951
  * If the startTime is null, this animation is the Paint Ready detection animation
12919
12952
  * and we can cancel it immediately without handoff.
@@ -13047,18 +13080,16 @@
13047
13080
  }
13048
13081
  };
13049
13082
  window.MotionCheckAppearSync = (visualElement, valueName, value) => {
13050
- var _a, _b;
13051
13083
  const appearId = getOptimisedAppearId(visualElement);
13052
13084
  if (!appearId)
13053
13085
  return;
13054
- const valueIsOptimised = (_a = window.MotionHasOptimisedAnimation) === null || _a === void 0 ? void 0 : _a.call(window, appearId, valueName);
13055
- const externalAnimationValue = (_b = visualElement.props.values) === null || _b === void 0 ? void 0 : _b[valueName];
13086
+ const valueIsOptimised = window.MotionHasOptimisedAnimation?.(appearId, valueName);
13087
+ const externalAnimationValue = visualElement.props.values?.[valueName];
13056
13088
  if (!valueIsOptimised || !externalAnimationValue)
13057
13089
  return;
13058
13090
  const removeSyncCheck = value.on("change", (latestValue) => {
13059
- var _a;
13060
13091
  if (externalAnimationValue.get() !== latestValue) {
13061
- (_a = window.MotionCancelOptimisedAnimation) === null || _a === void 0 ? void 0 : _a.call(window, appearId, valueName);
13092
+ window.MotionCancelOptimisedAnimation?.(appearId, valueName);
13062
13093
  removeSyncCheck();
13063
13094
  }
13064
13095
  });