motion-v 0.6.0 → 0.6.2

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 (272) hide show
  1. package/dist/cjs/index.js +1628 -1430
  2. package/dist/es/animation/use-animate.mjs +1 -1
  3. package/dist/es/components/LayoutGroup.vue.mjs +2 -5
  4. package/dist/es/components/Motion.vue.mjs +17 -5
  5. package/dist/es/components/Primitive.mjs +14 -6
  6. package/dist/es/components/animate-presence/AnimatePresence.vue.mjs +21 -18
  7. package/dist/es/components/animate-presence/use-pop-layout.mjs +7 -4
  8. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animate/index.mjs +2 -1
  9. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animate/resolve-subjects.mjs +2 -1
  10. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animate/subject.mjs +1 -1
  11. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +7 -7
  12. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +8 -8
  13. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animators/utils/can-animate.mjs +2 -2
  14. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +29 -89
  15. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +4 -4
  16. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +2 -1
  17. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animators/waapi/index.mjs +2 -1
  18. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs +2 -1
  19. package/dist/es/external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +6 -0
  20. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/generators/spring/find.mjs +2 -2
  21. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/generators/spring/index.mjs +7 -6
  22. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/interfaces/motion-value.mjs +6 -5
  23. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +6 -5
  24. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/sequence/create.mjs +8 -8
  25. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/utils/default-transitions.mjs +1 -1
  26. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/easing/cubic-bezier.mjs +2 -2
  27. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/easing/utils/map.mjs +6 -6
  28. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/frameloop/frame.mjs +2 -2
  29. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/motion/utils/is-forced-motion-value.mjs +1 -1
  30. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/animation/mix-values.mjs +3 -3
  31. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/node/create-projection-node.mjs +15 -15
  32. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/VisualElement.mjs +12 -12
  33. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/DOMKeyframesResolver.mjs +4 -3
  34. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/resize/handle-element.mjs +2 -1
  35. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/scroll/index.mjs +4 -4
  36. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/scroll/info.mjs +2 -1
  37. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/scroll/offsets/index.mjs +6 -5
  38. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/utils/css-variables-conversion.mjs +1 -1
  39. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/utils/unit-conversion.mjs +1 -14
  40. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/viewport/index.mjs +3 -2
  41. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/html/HTMLVisualElement.mjs +6 -6
  42. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/html/utils/build-styles.mjs +2 -2
  43. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/html/utils/build-transform.mjs +1 -1
  44. package/dist/es/external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/render/html/utils/keys-position.mjs +13 -0
  45. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/svg/SVGVisualElement.mjs +6 -6
  46. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/svg/utils/scrape-motion-values.mjs +1 -1
  47. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
  48. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/delay.mjs +2 -1
  49. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/interpolate.mjs +8 -5
  50. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/mix/color.mjs +1 -1
  51. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/mix/complex.mjs +1 -1
  52. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/offsets/fill.mjs +2 -1
  53. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/index.mjs +2 -2
  54. package/dist/es/external/.pnpm/{framer-motion@11.15.0/external/framer-motion/dist/es/animation/GroupPlaybackControls.mjs → motion-dom@11.16.4/external/motion-dom/dist/es/animation/controls/BaseGroup.mjs} +6 -6
  55. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/animation/controls/Group.mjs +9 -0
  56. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/animation/generators/utils/create-generator-easing.mjs +17 -0
  57. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/animation/waapi/NativeAnimationControls.mjs +81 -0
  58. package/dist/es/external/.pnpm/{framer-motion@11.15.0/external/framer-motion/dist/es/animation/animators/waapi → motion-dom@11.16.4/external/motion-dom/dist/es/animation/waapi/utils}/easing.mjs +3 -3
  59. package/dist/es/external/.pnpm/{framer-motion@11.15.0/external/framer-motion/dist/es/animation/animators → motion-dom@11.16.4/external/motion-dom/dist/es/animation}/waapi/utils/linear.mjs +2 -1
  60. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/drag/state/is-active.mjs +11 -0
  61. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/hover.mjs +30 -0
  62. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/press/index.mjs +51 -0
  63. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/press/utils/is-keyboard-accessible.mjs +13 -0
  64. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/press/utils/keyboard.mjs +32 -0
  65. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/press/utils/state.mjs +4 -0
  66. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/utils/is-node-or-child.mjs +12 -0
  67. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/utils/is-primary-pointer.mjs +10 -0
  68. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/utils/setup.mjs +15 -0
  69. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/utils/resolve-elements.mjs +17 -0
  70. package/dist/es/external/.pnpm/{framer-motion@11.15.0/external/framer-motion/dist/es/animation/animators/waapi/utils/supports-linear-easing.mjs → motion-dom@11.16.4/external/motion-dom/dist/es/utils/supports/linear-easing.mjs} +1 -1
  71. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/utils/supports/memo.mjs +13 -0
  72. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/utils/supports/scroll-timeline.mjs +6 -0
  73. package/dist/es/features/gestures/drag/VisualElementDragControls.mjs +2 -2
  74. package/dist/es/features/gestures/drag/index.mjs +2 -2
  75. package/dist/es/features/gestures/hover/index.mjs +3 -2
  76. package/dist/es/features/gestures/in-view/index.mjs +2 -2
  77. package/dist/es/features/gestures/pan/PanSession.mjs +3 -3
  78. package/dist/es/features/gestures/pan/index.mjs +3 -3
  79. package/dist/es/features/gestures/press/index.mjs +3 -2
  80. package/dist/es/features/layout/config.mjs +2 -2
  81. package/dist/es/features/layout/layout.mjs +2 -2
  82. package/dist/es/features/layout/projection.mjs +2 -2
  83. package/dist/es/features/svg.mjs +1 -1
  84. package/dist/es/index.mjs +33 -33
  85. package/dist/es/state/animate-variants-children.mjs +1 -1
  86. package/dist/es/state/create-visual-element.mjs +2 -2
  87. package/dist/es/state/motion-state.mjs +21 -15
  88. package/dist/es/utils/use-animation-frame.mjs +1 -1
  89. package/dist/es/utils/use-in-view.mjs +1 -1
  90. package/dist/es/value/use-combine-values.mjs +2 -2
  91. package/dist/es/value/use-computed.mjs +1 -1
  92. package/dist/es/value/use-scroll.mjs +2 -2
  93. package/dist/es/value/use-spring.mjs +3 -3
  94. package/dist/es/value/use-time.mjs +1 -1
  95. package/dist/es/value/use-transform.mjs +1 -1
  96. package/dist/es/value/use-velocity.mjs +2 -2
  97. package/dist/src/animation/types.d.ts +0 -12
  98. package/dist/src/components/Primitive.d.ts +9 -0
  99. package/dist/src/components/animate-presence/use-pop-layout.d.ts +1 -0
  100. package/dist/src/features/gestures/base.d.ts +0 -2
  101. package/dist/src/shared/test.d.ts +1 -0
  102. package/dist/src/state/motion-state.d.ts +2 -2
  103. package/dist/src/state/utils.d.ts +2 -2
  104. package/dist/src/types/index.d.ts +0 -1
  105. package/dist/src/types/state.d.ts +4 -5
  106. package/dist/src/types/transform.d.ts +0 -24
  107. package/package.json +8 -4
  108. package/dist/es/external/.pnpm/framer-motion@11.15.0/external/framer-motion/dist/es/animation/animators/waapi/utils/memo-supports.mjs +0 -12
  109. package/dist/es/external/.pnpm/framer-motion@11.15.0/external/framer-motion/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +0 -5
  110. package/dist/es/external/.pnpm/framer-motion@11.15.0/external/framer-motion/dist/es/easing/utils/create-generator-easing.mjs +0 -14
  111. package/dist/es/external/.pnpm/framer-motion@11.15.0/external/framer-motion/dist/es/render/dom/scroll/supports.mjs +0 -5
  112. package/dist/es/state/schedule.mjs +0 -6
  113. package/dist/src/animation/animation-controls.d.ts +0 -7
  114. package/dist/src/state/schedule.d.ts +0 -3
  115. package/dist/src/utils/events.d.ts +0 -2
  116. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animate/sequence.mjs +0 -0
  117. package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animate/single-value.mjs +1 -1
  118. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animators/BaseAnimation.mjs +0 -0
  119. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animators/drivers/driver-frameloop.mjs +0 -0
  120. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animators/utils/accelerated-values.mjs +0 -0
  121. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animators/waapi/utils/get-final-keyframe.mjs +0 -0
  122. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/animators/waapi/utils/style.mjs +0 -0
  123. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/generators/inertia.mjs +0 -0
  124. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/generators/keyframes.mjs +0 -0
  125. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/generators/spring/defaults.mjs +0 -0
  126. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/generators/utils/velocity.mjs +0 -0
  127. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/optimized-appear/data-id.mjs +0 -0
  128. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/optimized-appear/get-appear-id.mjs +0 -0
  129. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/sequence/utils/calc-repeat-duration.mjs +0 -0
  130. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/sequence/utils/calc-time.mjs +0 -0
  131. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/sequence/utils/edit.mjs +0 -0
  132. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/sequence/utils/normalize-times.mjs +0 -0
  133. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/sequence/utils/sort.mjs +0 -0
  134. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/utils/create-visual-element.mjs +0 -0
  135. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/utils/is-animatable.mjs +0 -0
  136. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/utils/is-animation-controls.mjs +0 -0
  137. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/utils/is-dom-keyframes.mjs +0 -0
  138. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/utils/is-keyframes-target.mjs +0 -0
  139. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/utils/is-none.mjs +0 -0
  140. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/utils/is-transition-defined.mjs +0 -0
  141. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/animation/utils/stagger.mjs +0 -0
  142. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/easing/anticipate.mjs +0 -0
  143. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/easing/back.mjs +0 -0
  144. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/easing/circ.mjs +0 -0
  145. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/easing/ease.mjs +0 -0
  146. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/easing/modifiers/mirror.mjs +0 -0
  147. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/easing/modifiers/reverse.mjs +0 -0
  148. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/easing/steps.mjs +0 -0
  149. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/easing/utils/get-easing-for-segment.mjs +0 -0
  150. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/easing/utils/is-easing-array.mjs +0 -0
  151. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/events/add-dom-event.mjs +0 -0
  152. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/frameloop/batcher.mjs +0 -0
  153. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/frameloop/index-legacy.mjs +0 -0
  154. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/frameloop/microtask.mjs +0 -0
  155. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/frameloop/render-step.mjs +0 -0
  156. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/frameloop/sync-time.mjs +0 -0
  157. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/motion/features/definitions.mjs +0 -0
  158. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/geometry/conversion.mjs +0 -0
  159. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/geometry/copy.mjs +0 -0
  160. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/geometry/delta-apply.mjs +0 -0
  161. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/geometry/delta-calc.mjs +0 -0
  162. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/geometry/delta-remove.mjs +0 -0
  163. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/geometry/models.mjs +0 -0
  164. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/geometry/utils.mjs +0 -0
  165. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/node/DocumentProjectionNode.mjs +0 -0
  166. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/node/HTMLProjectionNode.mjs +0 -0
  167. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/node/state.mjs +0 -0
  168. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/shared/stack.mjs +0 -0
  169. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/styles/scale-border-radius.mjs +0 -0
  170. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/styles/scale-box-shadow.mjs +0 -0
  171. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/styles/scale-correction.mjs +0 -0
  172. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/styles/transform.mjs +0 -0
  173. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/utils/each-axis.mjs +0 -0
  174. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/utils/has-transform.mjs +0 -0
  175. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/projection/utils/measure.mjs +0 -0
  176. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/DOMVisualElement.mjs +0 -0
  177. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/resize/handle-window.mjs +0 -0
  178. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/resize/index.mjs +0 -0
  179. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/scroll/observe.mjs +0 -0
  180. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/scroll/offsets/edge.mjs +0 -0
  181. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/scroll/offsets/inset.mjs +0 -0
  182. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/scroll/offsets/offset.mjs +0 -0
  183. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/scroll/offsets/presets.mjs +0 -0
  184. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/scroll/on-scroll-handler.mjs +0 -0
  185. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/scroll/track.mjs +0 -0
  186. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/utils/camel-to-dash.mjs +0 -0
  187. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/utils/is-css-variable.mjs +0 -0
  188. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/utils/is-svg-element.mjs +0 -0
  189. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/value-types/animatable-none.mjs +0 -0
  190. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/value-types/defaults.mjs +0 -0
  191. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/value-types/dimensions.mjs +0 -0
  192. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/value-types/find.mjs +0 -0
  193. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/value-types/get-as-type.mjs +0 -0
  194. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/value-types/number-browser.mjs +0 -0
  195. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/value-types/number.mjs +0 -0
  196. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/value-types/test.mjs +0 -0
  197. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/value-types/transform.mjs +0 -0
  198. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/value-types/type-auto.mjs +0 -0
  199. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/dom/value-types/type-int.mjs +0 -0
  200. /package/dist/es/external/.pnpm/{framer-motion@11.15.0/external/framer-motion/dist/es/render/html/utils/transform.mjs → framer-motion@11.16.6/external/framer-motion/dist/es/render/html/utils/keys-transform.mjs} +0 -0
  201. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/html/utils/make-none-animatable.mjs +0 -0
  202. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/html/utils/render.mjs +0 -0
  203. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/html/utils/scrape-motion-values.mjs +0 -0
  204. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/object/ObjectVisualElement.mjs +0 -0
  205. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/store.mjs +0 -0
  206. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/svg/utils/build-attrs.mjs +0 -0
  207. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/svg/utils/camel-case-attrs.mjs +0 -0
  208. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/svg/utils/is-svg-tag.mjs +0 -0
  209. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/svg/utils/path.mjs +0 -0
  210. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/svg/utils/render.mjs +0 -0
  211. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/svg/utils/transform-origin.mjs +0 -0
  212. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/utils/KeyframesResolver.mjs +0 -0
  213. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/utils/compare-by-depth.mjs +0 -0
  214. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/utils/flat-tree.mjs +0 -0
  215. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/utils/is-controlling-variants.mjs +0 -0
  216. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/utils/is-variant-label.mjs +0 -0
  217. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/utils/resolve-dynamic-variants.mjs +0 -0
  218. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/utils/resolve-variants.mjs +0 -0
  219. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/utils/setters.mjs +0 -0
  220. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/render/utils/variant-props.mjs +0 -0
  221. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/GlobalConfig.mjs +0 -0
  222. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/array.mjs +0 -0
  223. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/clamp.mjs +0 -0
  224. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/distance.mjs +0 -0
  225. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/hsla-to-rgba.mjs +0 -0
  226. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/is-browser.mjs +0 -0
  227. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/is-numerical-string.mjs +0 -0
  228. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/is-zero-value-string.mjs +0 -0
  229. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/mix/immediate.mjs +0 -0
  230. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/mix/index.mjs +0 -0
  231. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/mix/number.mjs +0 -0
  232. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/mix/visibility.mjs +0 -0
  233. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/offsets/default.mjs +0 -0
  234. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/offsets/time.mjs +0 -0
  235. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/pipe.mjs +0 -0
  236. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/reduced-motion/index.mjs +0 -0
  237. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/reduced-motion/state.mjs +0 -0
  238. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/resolve-value.mjs +0 -0
  239. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/subscription-manager.mjs +0 -0
  240. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/transform.mjs +0 -0
  241. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/velocity-per-second.mjs +0 -0
  242. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/warn-once.mjs +0 -0
  243. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/utils/wrap.mjs +0 -0
  244. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/types/color/hex.mjs +0 -0
  245. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/types/color/hsla.mjs +0 -0
  246. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/types/color/index.mjs +0 -0
  247. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/types/color/rgba.mjs +0 -0
  248. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/types/color/utils.mjs +0 -0
  249. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/types/complex/filter.mjs +0 -0
  250. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/types/complex/index.mjs +0 -0
  251. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/types/numbers/index.mjs +0 -0
  252. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/types/numbers/units.mjs +0 -0
  253. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/types/utils/color-regex.mjs +0 -0
  254. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/types/utils/float-regex.mjs +0 -0
  255. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/types/utils/is-nullish.mjs +0 -0
  256. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/types/utils/sanitize.mjs +0 -0
  257. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/types/utils/single-color-regex.mjs +0 -0
  258. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/use-will-change/add-will-change.mjs +0 -0
  259. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/use-will-change/is.mjs +0 -0
  260. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/utils/is-motion-value.mjs +0 -0
  261. /package/dist/es/external/.pnpm/{framer-motion@11.15.0 → framer-motion@11.16.6}/external/framer-motion/dist/es/value/utils/resolve-motion-value.mjs +0 -0
  262. /package/dist/es/external/.pnpm/{framer-motion@11.15.0/external/framer-motion → motion-dom@11.16.4/external/motion-dom}/dist/es/animation/generators/utils/calc-duration.mjs +0 -0
  263. /package/dist/es/external/.pnpm/{framer-motion@11.15.0/external/framer-motion → motion-dom@11.16.4/external/motion-dom}/dist/es/animation/generators/utils/is-generator.mjs +0 -0
  264. /package/dist/es/external/.pnpm/{framer-motion@11.15.0/external/framer-motion → motion-dom@11.16.4/external/motion-dom}/dist/es/animation/utils/get-value-transition.mjs +0 -0
  265. /package/dist/es/external/.pnpm/{framer-motion@11.15.0/external/framer-motion/dist/es/animation/animators → motion-dom@11.16.4/external/motion-dom/dist/es/animation}/waapi/utils/attach-timeline.mjs +0 -0
  266. /package/dist/es/external/.pnpm/{framer-motion@11.15.0/external/framer-motion/dist/es/easing → motion-dom@11.16.4/external/motion-dom/dist/es}/utils/is-bezier-definition.mjs +0 -0
  267. /package/dist/es/external/.pnpm/{framer-motion@11.15.0/external/framer-motion/dist/es/animation/animators/waapi/utils/supports-flags.mjs → motion-dom@11.16.4/external/motion-dom/dist/es/utils/supports/flags.mjs} +0 -0
  268. /package/dist/es/external/.pnpm/{motion-utils@11.14.3 → motion-utils@11.16.0}/external/motion-utils/dist/es/errors.mjs +0 -0
  269. /package/dist/es/external/.pnpm/{framer-motion@11.15.0/external/framer-motion/dist/es/utils → motion-utils@11.16.0/external/motion-utils/dist/es}/memo.mjs +0 -0
  270. /package/dist/es/external/.pnpm/{motion-utils@11.14.3 → motion-utils@11.16.0}/external/motion-utils/dist/es/noop.mjs +0 -0
  271. /package/dist/es/external/.pnpm/{framer-motion@11.15.0/external/framer-motion/dist/es/utils → motion-utils@11.16.0/external/motion-utils/dist/es}/progress.mjs +0 -0
  272. /package/dist/es/external/.pnpm/{framer-motion@11.15.0/external/framer-motion/dist/es/utils → motion-utils@11.16.0/external/motion-utils/dist/es}/time-conversion.mjs +0 -0
package/dist/cjs/index.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  const vue = require("vue");
4
4
  const heyListen = require("hey-listen");
5
- const motionDom = require("motion-dom");
6
5
  const noop = (any) => any;
7
6
  let warning = noop;
8
7
  exports.invariant = noop;
@@ -18,564 +17,226 @@ if (process.env.NODE_ENV !== "production") {
18
17
  }
19
18
  };
20
19
  }
21
- function addUniqueItem(arr, item) {
22
- if (arr.indexOf(item) === -1)
23
- arr.push(item);
24
- }
25
- function removeItem(arr, item) {
26
- const index = arr.indexOf(item);
27
- if (index > -1)
28
- arr.splice(index, 1);
20
+ function memo(callback) {
21
+ let result;
22
+ return () => {
23
+ if (result === void 0)
24
+ result = callback();
25
+ return result;
26
+ };
29
27
  }
30
- class SubscriptionManager {
31
- constructor() {
32
- this.subscriptions = [];
28
+ const progress$1 = (from, to, value) => {
29
+ const toFromDifference = to - from;
30
+ return toFromDifference === 0 ? 1 : (value - from) / toFromDifference;
31
+ };
32
+ const secondsToMilliseconds$1 = (seconds) => seconds * 1e3;
33
+ const millisecondsToSeconds$1 = (milliseconds) => milliseconds / 1e3;
34
+ const supportsScrollTimeline = memo(() => window.ScrollTimeline !== void 0);
35
+ class BaseGroupPlaybackControls {
36
+ constructor(animations) {
37
+ this.stop = () => this.runAll("stop");
38
+ this.animations = animations.filter(Boolean);
33
39
  }
34
- add(handler) {
35
- addUniqueItem(this.subscriptions, handler);
36
- return () => removeItem(this.subscriptions, handler);
40
+ get finished() {
41
+ return Promise.all(this.animations.map((animation) => "finished" in animation ? animation.finished : animation));
37
42
  }
38
- notify(a, b, c) {
39
- const numSubscriptions = this.subscriptions.length;
40
- if (!numSubscriptions)
41
- return;
42
- if (numSubscriptions === 1) {
43
- this.subscriptions[0](a, b, c);
44
- } else {
45
- for (let i = 0; i < numSubscriptions; i++) {
46
- const handler = this.subscriptions[i];
47
- handler && handler(a, b, c);
43
+ /**
44
+ * TODO: Filter out cancelled or stopped animations before returning
45
+ */
46
+ getAll(propName) {
47
+ return this.animations[0][propName];
48
+ }
49
+ setAll(propName, newValue) {
50
+ for (let i = 0; i < this.animations.length; i++) {
51
+ this.animations[i][propName] = newValue;
52
+ }
53
+ }
54
+ attachTimeline(timeline, fallback) {
55
+ const subscriptions = this.animations.map((animation) => {
56
+ if (supportsScrollTimeline() && animation.attachTimeline) {
57
+ return animation.attachTimeline(timeline);
58
+ } else if (typeof fallback === "function") {
59
+ return fallback(animation);
48
60
  }
61
+ });
62
+ return () => {
63
+ subscriptions.forEach((cancel, i) => {
64
+ cancel && cancel();
65
+ this.animations[i].stop();
66
+ });
67
+ };
68
+ }
69
+ get time() {
70
+ return this.getAll("time");
71
+ }
72
+ set time(time2) {
73
+ this.setAll("time", time2);
74
+ }
75
+ get speed() {
76
+ return this.getAll("speed");
77
+ }
78
+ set speed(speed) {
79
+ this.setAll("speed", speed);
80
+ }
81
+ get startTime() {
82
+ return this.getAll("startTime");
83
+ }
84
+ get duration() {
85
+ let max = 0;
86
+ for (let i = 0; i < this.animations.length; i++) {
87
+ max = Math.max(max, this.animations[i].duration);
49
88
  }
89
+ return max;
50
90
  }
51
- getSize() {
52
- return this.subscriptions.length;
91
+ runAll(methodName) {
92
+ this.animations.forEach((controls) => controls[methodName]());
53
93
  }
54
- clear() {
55
- this.subscriptions.length = 0;
94
+ flatten() {
95
+ this.runAll("flatten");
96
+ }
97
+ play() {
98
+ this.runAll("play");
99
+ }
100
+ pause() {
101
+ this.runAll("pause");
102
+ }
103
+ cancel() {
104
+ this.runAll("cancel");
105
+ }
106
+ complete() {
107
+ this.runAll("complete");
56
108
  }
57
109
  }
58
- function velocityPerSecond(velocity, frameDuration) {
59
- return frameDuration ? velocity * (1e3 / frameDuration) : 0;
110
+ class GroupPlaybackControls extends BaseGroupPlaybackControls {
111
+ then(onResolve, onReject) {
112
+ return Promise.all(this.animations).then(onResolve).catch(onReject);
113
+ }
60
114
  }
61
- const warned = /* @__PURE__ */ new Set();
62
- function warnOnce(condition, message, element) {
63
- if (condition || warned.has(message))
64
- return;
65
- console.warn(message);
66
- warned.add(message);
115
+ function getValueTransition$1(transition, key) {
116
+ return transition ? transition[key] || transition["default"] || transition : void 0;
67
117
  }
68
- const MotionGlobalConfig = {
69
- skipAnimations: false,
70
- useManualTiming: false
71
- };
72
- function createRenderStep(runNextFrame) {
73
- let thisFrame = /* @__PURE__ */ new Set();
74
- let nextFrame = /* @__PURE__ */ new Set();
75
- let isProcessing = false;
76
- let flushNextFrame = false;
77
- const toKeepAlive = /* @__PURE__ */ new WeakSet();
78
- let latestFrameData = {
79
- delta: 0,
80
- timestamp: 0,
81
- isProcessing: false
82
- };
83
- function triggerCallback(callback) {
84
- if (toKeepAlive.has(callback)) {
85
- step.schedule(callback);
86
- runNextFrame();
87
- }
88
- callback(latestFrameData);
118
+ const maxGeneratorDuration = 2e4;
119
+ function calcGeneratorDuration(generator) {
120
+ let duration = 0;
121
+ const timeStep = 50;
122
+ let state2 = generator.next(duration);
123
+ while (!state2.done && duration < maxGeneratorDuration) {
124
+ duration += timeStep;
125
+ state2 = generator.next(duration);
89
126
  }
90
- const step = {
91
- /**
92
- * Schedule a process to run on the next frame.
93
- */
94
- schedule: (callback, keepAlive = false, immediate = false) => {
95
- const addToCurrentFrame = immediate && isProcessing;
96
- const queue = addToCurrentFrame ? thisFrame : nextFrame;
97
- if (keepAlive)
98
- toKeepAlive.add(callback);
99
- if (!queue.has(callback))
100
- queue.add(callback);
101
- return callback;
102
- },
103
- /**
104
- * Cancel the provided callback from running on the next frame.
105
- */
106
- cancel: (callback) => {
107
- nextFrame.delete(callback);
108
- toKeepAlive.delete(callback);
127
+ return duration >= maxGeneratorDuration ? Infinity : duration;
128
+ }
129
+ function createGeneratorEasing(options, scale2 = 100, createGenerator) {
130
+ const generator = createGenerator({ ...options, keyframes: [0, scale2] });
131
+ const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
132
+ return {
133
+ type: "keyframes",
134
+ ease: (progress2) => {
135
+ return generator.next(duration * progress2).value / scale2;
109
136
  },
110
- /**
111
- * Execute all schedule callbacks.
112
- */
113
- process: (frameData2) => {
114
- latestFrameData = frameData2;
115
- if (isProcessing) {
116
- flushNextFrame = true;
117
- return;
118
- }
119
- isProcessing = true;
120
- [thisFrame, nextFrame] = [nextFrame, thisFrame];
121
- thisFrame.forEach(triggerCallback);
122
- thisFrame.clear();
123
- isProcessing = false;
124
- if (flushNextFrame) {
125
- flushNextFrame = false;
126
- step.process(frameData2);
127
- }
128
- }
137
+ duration: millisecondsToSeconds$1(duration)
129
138
  };
130
- return step;
131
139
  }
132
- const stepsOrder = [
133
- "read",
134
- // Read
135
- "resolveKeyframes",
136
- // Write/Read/Write/Read
137
- "update",
138
- // Compute
139
- "preRender",
140
- // Compute
141
- "render",
142
- // Write
143
- "postRender"
144
- // Compute
145
- ];
146
- const maxElapsed$1 = 40;
147
- function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
148
- let runNextFrame = false;
149
- let useDefaultElapsed = true;
150
- const state2 = {
151
- delta: 0,
152
- timestamp: 0,
153
- isProcessing: false
154
- };
155
- const flagRunNextFrame = () => runNextFrame = true;
156
- const steps2 = stepsOrder.reduce((acc, key) => {
157
- acc[key] = createRenderStep(flagRunNextFrame);
158
- return acc;
159
- }, {});
160
- const { read, resolveKeyframes, update, preRender, render, postRender } = steps2;
161
- const processBatch = () => {
162
- const timestamp = performance.now();
163
- runNextFrame = false;
164
- state2.delta = useDefaultElapsed ? 1e3 / 60 : Math.max(Math.min(timestamp - state2.timestamp, maxElapsed$1), 1);
165
- state2.timestamp = timestamp;
166
- state2.isProcessing = true;
167
- read.process(state2);
168
- resolveKeyframes.process(state2);
169
- update.process(state2);
170
- preRender.process(state2);
171
- render.process(state2);
172
- postRender.process(state2);
173
- state2.isProcessing = false;
174
- if (runNextFrame && allowKeepAlive) {
175
- useDefaultElapsed = false;
176
- scheduleNextBatch(processBatch);
140
+ function isGenerator(type) {
141
+ return typeof type === "function";
142
+ }
143
+ function attachTimeline(animation, timeline) {
144
+ animation.timeline = timeline;
145
+ animation.onfinish = null;
146
+ }
147
+ class NativeAnimationControls {
148
+ constructor(animation) {
149
+ this.animation = animation;
150
+ }
151
+ get duration() {
152
+ var _a, _b, _c;
153
+ const durationInMs = ((_b = (_a = this.animation) === null || _a === void 0 ? void 0 : _a.effect) === null || _b === void 0 ? void 0 : _b.getComputedTiming().duration) || ((_c = this.options) === null || _c === void 0 ? void 0 : _c.duration) || 300;
154
+ return millisecondsToSeconds$1(Number(durationInMs));
155
+ }
156
+ get time() {
157
+ var _a;
158
+ if (this.animation) {
159
+ return millisecondsToSeconds$1(((_a = this.animation) === null || _a === void 0 ? void 0 : _a.currentTime) || 0);
177
160
  }
178
- };
179
- const wake = () => {
180
- runNextFrame = true;
181
- useDefaultElapsed = true;
182
- if (!state2.isProcessing) {
183
- scheduleNextBatch(processBatch);
184
- }
185
- };
186
- const schedule = stepsOrder.reduce((acc, key) => {
187
- const step = steps2[key];
188
- acc[key] = (process2, keepAlive = false, immediate = false) => {
189
- if (!runNextFrame)
190
- wake();
191
- return step.schedule(process2, keepAlive, immediate);
192
- };
193
- return acc;
194
- }, {});
195
- const cancel = (process2) => {
196
- for (let i = 0; i < stepsOrder.length; i++) {
197
- steps2[stepsOrder[i]].cancel(process2);
198
- }
199
- };
200
- return { schedule, cancel, state: state2, steps: steps2 };
201
- }
202
- const { schedule: frame, cancel: cancelFrame, state: frameData, steps: frameSteps } = createRenderBatcher(typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : noop, true);
203
- let now;
204
- function clearTime() {
205
- now = void 0;
206
- }
207
- const time = {
208
- now: () => {
209
- if (now === void 0) {
210
- time.set(frameData.isProcessing || MotionGlobalConfig.useManualTiming ? frameData.timestamp : performance.now());
161
+ return 0;
162
+ }
163
+ set time(newTime) {
164
+ if (this.animation) {
165
+ this.animation.currentTime = secondsToMilliseconds$1(newTime);
211
166
  }
212
- return now;
213
- },
214
- set: (newTime) => {
215
- now = newTime;
216
- queueMicrotask(clearTime);
217
167
  }
218
- };
219
- const MAX_VELOCITY_DELTA = 30;
220
- const isFloat = (value) => {
221
- return !isNaN(parseFloat(value));
222
- };
223
- const collectMotionValues = {
224
- current: void 0
225
- };
226
- class MotionValue {
227
- /**
228
- * @param init - The initiating value
229
- * @param config - Optional configuration options
230
- *
231
- * - `transformer`: A function to transform incoming values with.
232
- *
233
- * @internal
234
- */
235
- constructor(init, options = {}) {
236
- this.version = "11.15.0";
237
- this.canTrackVelocity = null;
238
- this.events = {};
239
- this.updateAndNotify = (v, render = true) => {
240
- const currentTime = time.now();
241
- if (this.updatedAt !== currentTime) {
242
- this.setPrevFrameValue();
243
- }
244
- this.prev = this.current;
245
- this.setCurrent(v);
246
- if (this.current !== this.prev && this.events.change) {
247
- this.events.change.notify(this.current);
248
- }
249
- if (render && this.events.renderRequest) {
250
- this.events.renderRequest.notify(this.current);
251
- }
252
- };
253
- this.hasAnimated = false;
254
- this.setCurrent(init);
255
- this.owner = options.owner;
168
+ get speed() {
169
+ return this.animation ? this.animation.playbackRate : 1;
256
170
  }
257
- setCurrent(current) {
258
- this.current = current;
259
- this.updatedAt = time.now();
260
- if (this.canTrackVelocity === null && current !== void 0) {
261
- this.canTrackVelocity = isFloat(this.current);
171
+ set speed(newSpeed) {
172
+ if (this.animation) {
173
+ this.animation.playbackRate = newSpeed;
262
174
  }
263
175
  }
264
- setPrevFrameValue(prevFrameValue = this.current) {
265
- this.prevFrameValue = prevFrameValue;
266
- this.prevUpdatedAt = this.updatedAt;
176
+ get state() {
177
+ return this.animation ? this.animation.playState : "finished";
267
178
  }
268
- /**
269
- * Adds a function that will be notified when the `MotionValue` is updated.
270
- *
271
- * It returns a function that, when called, will cancel the subscription.
272
- *
273
- * When calling `onChange` inside a React component, it should be wrapped with the
274
- * `useEffect` hook. As it returns an unsubscribe function, this should be returned
275
- * from the `useEffect` function to ensure you don't add duplicate subscribers..
276
- *
277
- * ```jsx
278
- * export const MyComponent = () => {
279
- * const x = useMotionValue(0)
280
- * const y = useMotionValue(0)
281
- * const opacity = useMotionValue(1)
282
- *
283
- * useEffect(() => {
284
- * function updateOpacity() {
285
- * const maxXY = Math.max(x.get(), y.get())
286
- * const newOpacity = transform(maxXY, [0, 100], [1, 0])
287
- * opacity.set(newOpacity)
288
- * }
289
- *
290
- * const unsubscribeX = x.on("change", updateOpacity)
291
- * const unsubscribeY = y.on("change", updateOpacity)
292
- *
293
- * return () => {
294
- * unsubscribeX()
295
- * unsubscribeY()
296
- * }
297
- * }, [])
298
- *
299
- * return <motion.div style={{ x }} />
300
- * }
301
- * ```
302
- *
303
- * @param subscriber - A function that receives the latest value.
304
- * @returns A function that, when called, will cancel this subscription.
305
- *
306
- * @deprecated
307
- */
308
- onChange(subscription) {
309
- if (process.env.NODE_ENV !== "production") {
310
- warnOnce(false, `value.onChange(callback) is deprecated. Switch to value.on("change", callback).`);
311
- }
312
- return this.on("change", subscription);
179
+ get startTime() {
180
+ return this.animation ? this.animation.startTime : null;
313
181
  }
314
- on(eventName, callback) {
315
- if (!this.events[eventName]) {
316
- this.events[eventName] = new SubscriptionManager();
317
- }
318
- const unsubscribe = this.events[eventName].add(callback);
319
- if (eventName === "change") {
320
- return () => {
321
- unsubscribe();
322
- frame.read(() => {
323
- if (!this.events.change.getSize()) {
324
- this.stop();
325
- }
326
- });
327
- };
328
- }
329
- return unsubscribe;
182
+ get finished() {
183
+ return this.animation ? this.animation.finished : Promise.resolve();
330
184
  }
331
- clearListeners() {
332
- for (const eventManagers in this.events) {
333
- this.events[eventManagers].clear();
334
- }
185
+ play() {
186
+ this.animation && this.animation.play();
335
187
  }
336
- /**
337
- * Attaches a passive effect to the `MotionValue`.
338
- *
339
- * @internal
340
- */
341
- attach(passiveEffect, stopPassiveEffect) {
342
- this.passiveEffect = passiveEffect;
343
- this.stopPassiveEffect = stopPassiveEffect;
188
+ pause() {
189
+ this.animation && this.animation.pause();
344
190
  }
345
- /**
346
- * Sets the state of the `MotionValue`.
347
- *
348
- * @remarks
349
- *
350
- * ```jsx
351
- * const x = useMotionValue(0)
352
- * x.set(10)
353
- * ```
354
- *
355
- * @param latest - Latest value to set.
356
- * @param render - Whether to notify render subscribers. Defaults to `true`
357
- *
358
- * @public
359
- */
360
- set(v, render = true) {
361
- if (!render || !this.passiveEffect) {
362
- this.updateAndNotify(v, render);
363
- } else {
364
- this.passiveEffect(v, this.updateAndNotify);
191
+ stop() {
192
+ if (!this.animation || this.state === "idle" || this.state === "finished") {
193
+ return;
194
+ }
195
+ if (this.animation.commitStyles) {
196
+ this.animation.commitStyles();
365
197
  }
198
+ this.cancel();
366
199
  }
367
- setWithVelocity(prev, current, delta) {
368
- this.set(current);
369
- this.prev = void 0;
370
- this.prevFrameValue = prev;
371
- this.prevUpdatedAt = this.updatedAt - delta;
200
+ flatten() {
201
+ var _a;
202
+ if (!this.animation)
203
+ return;
204
+ (_a = this.animation.effect) === null || _a === void 0 ? void 0 : _a.updateTiming({ easing: "linear" });
372
205
  }
373
- /**
374
- * Set the state of the `MotionValue`, stopping any active animations,
375
- * effects, and resets velocity to `0`.
376
- */
377
- jump(v, endAnimation = true) {
378
- this.updateAndNotify(v);
379
- this.prev = v;
380
- this.prevUpdatedAt = this.prevFrameValue = void 0;
381
- endAnimation && this.stop();
382
- if (this.stopPassiveEffect)
383
- this.stopPassiveEffect();
206
+ attachTimeline(timeline) {
207
+ if (this.animation)
208
+ attachTimeline(this.animation, timeline);
209
+ return noop;
384
210
  }
385
- /**
386
- * Returns the latest state of `MotionValue`
387
- *
388
- * @returns - The latest state of `MotionValue`
389
- *
390
- * @public
391
- */
392
- get() {
393
- if (collectMotionValues.current) {
394
- collectMotionValues.current.push(this);
395
- }
396
- return this.current;
211
+ complete() {
212
+ this.animation && this.animation.finish();
397
213
  }
398
- /**
399
- * @public
400
- */
401
- getPrevious() {
402
- return this.prev;
214
+ cancel() {
215
+ try {
216
+ this.animation && this.animation.cancel();
217
+ } catch (e) {
218
+ }
403
219
  }
404
- /**
405
- * Returns the latest velocity of `MotionValue`
406
- *
407
- * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
408
- *
409
- * @public
410
- */
411
- getVelocity() {
412
- const currentTime = time.now();
413
- if (!this.canTrackVelocity || this.prevFrameValue === void 0 || currentTime - this.updatedAt > MAX_VELOCITY_DELTA) {
414
- return 0;
415
- }
416
- const delta = Math.min(this.updatedAt - this.prevUpdatedAt, MAX_VELOCITY_DELTA);
417
- return velocityPerSecond(parseFloat(this.current) - parseFloat(this.prevFrameValue), delta);
418
- }
419
- /**
420
- * Registers a new animation to control this `MotionValue`. Only one
421
- * animation can drive a `MotionValue` at one time.
422
- *
423
- * ```jsx
424
- * value.start()
425
- * ```
426
- *
427
- * @param animation - A function that starts the provided animation
428
- *
429
- * @internal
430
- */
431
- start(startAnimation) {
432
- this.stop();
433
- return new Promise((resolve) => {
434
- this.hasAnimated = true;
435
- this.animation = startAnimation(resolve);
436
- if (this.events.animationStart) {
437
- this.events.animationStart.notify();
438
- }
439
- }).then(() => {
440
- if (this.events.animationComplete) {
441
- this.events.animationComplete.notify();
442
- }
443
- this.clearAnimation();
444
- });
445
- }
446
- /**
447
- * Stop the currently active animation.
448
- *
449
- * @public
450
- */
451
- stop() {
452
- if (this.animation) {
453
- this.animation.stop();
454
- if (this.events.animationCancel) {
455
- this.events.animationCancel.notify();
456
- }
457
- }
458
- this.clearAnimation();
459
- }
460
- /**
461
- * Returns `true` if this value is currently animating.
462
- *
463
- * @public
464
- */
465
- isAnimating() {
466
- return !!this.animation;
467
- }
468
- clearAnimation() {
469
- delete this.animation;
470
- }
471
- /**
472
- * Destroy and clean up subscribers to this `MotionValue`.
473
- *
474
- * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
475
- * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
476
- * created a `MotionValue` via the `motionValue` function.
477
- *
478
- * @public
479
- */
480
- destroy() {
481
- this.clearListeners();
482
- this.stop();
483
- if (this.stopPassiveEffect) {
484
- this.stopPassiveEffect();
485
- }
486
- }
487
- }
488
- function motionValue(init, options) {
489
- return new MotionValue(init, options);
490
220
  }
491
- function memo(callback) {
492
- let result;
221
+ const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0] === "number";
222
+ const supportsFlags = {
223
+ linearEasing: void 0
224
+ };
225
+ function memoSupports(callback, supportsFlag) {
226
+ const memoized = memo(callback);
493
227
  return () => {
494
- if (result === void 0)
495
- result = callback();
496
- return result;
228
+ var _a;
229
+ return (_a = supportsFlags[supportsFlag]) !== null && _a !== void 0 ? _a : memoized();
497
230
  };
498
231
  }
499
- const supportsScrollTimeline = memo(() => window.ScrollTimeline !== void 0);
500
- class GroupPlaybackControls {
501
- constructor(animations) {
502
- this.stop = () => this.runAll("stop");
503
- this.animations = animations.filter(Boolean);
504
- }
505
- then(onResolve, onReject) {
506
- return Promise.all(this.animations).then(onResolve).catch(onReject);
507
- }
508
- /**
509
- * TODO: Filter out cancelled or stopped animations before returning
510
- */
511
- getAll(propName) {
512
- return this.animations[0][propName];
513
- }
514
- setAll(propName, newValue) {
515
- for (let i = 0; i < this.animations.length; i++) {
516
- this.animations[i][propName] = newValue;
517
- }
518
- }
519
- attachTimeline(timeline, fallback) {
520
- const subscriptions = this.animations.map((animation) => {
521
- if (supportsScrollTimeline() && animation.attachTimeline) {
522
- return animation.attachTimeline(timeline);
523
- } else {
524
- return fallback(animation);
525
- }
526
- });
527
- return () => {
528
- subscriptions.forEach((cancel, i) => {
529
- cancel && cancel();
530
- this.animations[i].stop();
531
- });
532
- };
533
- }
534
- get time() {
535
- return this.getAll("time");
536
- }
537
- set time(time2) {
538
- this.setAll("time", time2);
539
- }
540
- get speed() {
541
- return this.getAll("speed");
542
- }
543
- set speed(speed) {
544
- this.setAll("speed", speed);
545
- }
546
- get startTime() {
547
- return this.getAll("startTime");
548
- }
549
- get duration() {
550
- let max = 0;
551
- for (let i = 0; i < this.animations.length; i++) {
552
- max = Math.max(max, this.animations[i].duration);
553
- }
554
- return max;
555
- }
556
- runAll(methodName) {
557
- this.animations.forEach((controls) => controls[methodName]());
558
- }
559
- flatten() {
560
- this.runAll("flatten");
561
- }
562
- play() {
563
- this.runAll("play");
564
- }
565
- pause() {
566
- this.runAll("pause");
567
- }
568
- cancel() {
569
- this.runAll("cancel");
570
- }
571
- complete() {
572
- this.runAll("complete");
232
+ const supportsLinearEasing = /* @__PURE__ */ memoSupports(() => {
233
+ try {
234
+ document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" });
235
+ } catch (e) {
236
+ return false;
573
237
  }
574
- }
575
- const progress$1 = (from, to, value) => {
576
- const toFromDifference = to - from;
577
- return toFromDifference === 0 ? 1 : (value - from) / toFromDifference;
578
- };
238
+ return true;
239
+ }, "linearEasing");
579
240
  const generateLinearEasing = (easing, duration, resolution = 10) => {
580
241
  let points = "";
581
242
  const numPoints = Math.max(Math.round(duration / resolution), 2);
@@ -584,65 +245,247 @@ const generateLinearEasing = (easing, duration, resolution = 10) => {
584
245
  }
585
246
  return `linear(${points.substring(0, points.length - 2)})`;
586
247
  };
587
- const secondsToMilliseconds$1 = (seconds) => seconds * 1e3;
588
- const millisecondsToSeconds$1 = (milliseconds) => milliseconds / 1e3;
589
- const velocitySampleDuration = 5;
590
- function calcGeneratorVelocity(resolveValue, t, current) {
591
- const prevT = Math.max(t - velocitySampleDuration, 0);
592
- return velocityPerSecond(current - resolveValue(prevT), t - prevT);
248
+ function isWaapiSupportedEasing(easing) {
249
+ return Boolean(typeof easing === "function" && supportsLinearEasing() || !easing || typeof easing === "string" && (easing in supportedWaapiEasing || supportsLinearEasing()) || isBezierDefinition(easing) || Array.isArray(easing) && easing.every(isWaapiSupportedEasing));
593
250
  }
594
- const clamp$1 = (min, max, v) => {
595
- if (v > max)
596
- return max;
597
- if (v < min)
598
- return min;
599
- return v;
251
+ const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
252
+ const supportedWaapiEasing = {
253
+ linear: "linear",
254
+ ease: "ease",
255
+ easeIn: "ease-in",
256
+ easeOut: "ease-out",
257
+ easeInOut: "ease-in-out",
258
+ circIn: /* @__PURE__ */ cubicBezierAsString([0, 0.65, 0.55, 1]),
259
+ circOut: /* @__PURE__ */ cubicBezierAsString([0.55, 0, 1, 0.45]),
260
+ backIn: /* @__PURE__ */ cubicBezierAsString([0.31, 0.01, 0.66, -0.59]),
261
+ backOut: /* @__PURE__ */ cubicBezierAsString([0.33, 1.53, 0.69, 0.99])
600
262
  };
601
- const springDefaults = {
602
- // Default spring physics
603
- stiffness: 100,
604
- damping: 10,
605
- mass: 1,
606
- velocity: 0,
607
- // Default duration/bounce-based options
608
- duration: 800,
609
- // in ms
610
- bounce: 0.3,
611
- visualDuration: 0.3,
612
- // in seconds
613
- // Rest thresholds
614
- restSpeed: {
615
- granular: 0.01,
616
- default: 2
617
- },
618
- restDelta: {
619
- granular: 5e-3,
620
- default: 0.5
621
- },
622
- // Limits
623
- minDuration: 0.01,
624
- // in seconds
625
- maxDuration: 10,
626
- // in seconds
627
- minDamping: 0.05,
628
- maxDamping: 1
263
+ function mapEasingToNativeEasing(easing, duration) {
264
+ if (!easing) {
265
+ return void 0;
266
+ } else if (typeof easing === "function" && supportsLinearEasing()) {
267
+ return generateLinearEasing(easing, duration);
268
+ } else if (isBezierDefinition(easing)) {
269
+ return cubicBezierAsString(easing);
270
+ } else if (Array.isArray(easing)) {
271
+ return easing.map((segmentEasing) => mapEasingToNativeEasing(segmentEasing, duration) || supportedWaapiEasing.easeOut);
272
+ } else {
273
+ return supportedWaapiEasing[easing];
274
+ }
275
+ }
276
+ const isDragging = {
277
+ x: false,
278
+ y: false
629
279
  };
630
- const safeMin = 1e-3;
631
- function findSpring({ duration = springDefaults.duration, bounce = springDefaults.bounce, velocity = springDefaults.velocity, mass = springDefaults.mass }) {
632
- let envelope;
633
- let derivative;
634
- warning(duration <= secondsToMilliseconds$1(springDefaults.maxDuration), "Spring duration must be 10 seconds or less");
635
- let dampingRatio = 1 - bounce;
636
- dampingRatio = clamp$1(springDefaults.minDamping, springDefaults.maxDamping, dampingRatio);
637
- duration = clamp$1(springDefaults.minDuration, springDefaults.maxDuration, millisecondsToSeconds$1(duration));
638
- if (dampingRatio < 1) {
639
- envelope = (undampedFreq2) => {
640
- const exponentialDecay = undampedFreq2 * dampingRatio;
641
- const delta = exponentialDecay * duration;
642
- const a = exponentialDecay - velocity;
643
- const b = calcAngularFreq(undampedFreq2, dampingRatio);
644
- const c = Math.exp(-delta);
645
- return safeMin - a / b * c;
280
+ function isDragActive() {
281
+ return isDragging.y;
282
+ }
283
+ function resolveElements(elementOrSelector, scope, selectorCache) {
284
+ var _a;
285
+ if (elementOrSelector instanceof Element) {
286
+ return [elementOrSelector];
287
+ } else if (typeof elementOrSelector === "string") {
288
+ let root = document;
289
+ if (scope) {
290
+ root = scope.current;
291
+ }
292
+ const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
293
+ return elements ? Array.from(elements) : [];
294
+ }
295
+ return Array.from(elementOrSelector);
296
+ }
297
+ function setupGesture(elementOrSelector, options) {
298
+ const elements = resolveElements(elementOrSelector);
299
+ const gestureAbortController = new AbortController();
300
+ const eventOptions = {
301
+ passive: true,
302
+ ...options,
303
+ signal: gestureAbortController.signal
304
+ };
305
+ const cancel = () => gestureAbortController.abort();
306
+ return [elements, eventOptions, cancel];
307
+ }
308
+ function filterEvents$1(callback) {
309
+ return (event) => {
310
+ if (event.pointerType === "touch" || isDragActive())
311
+ return;
312
+ callback(event);
313
+ };
314
+ }
315
+ function hover(elementOrSelector, onHoverStart, options = {}) {
316
+ const [elements, eventOptions, cancel] = setupGesture(elementOrSelector, options);
317
+ const onPointerEnter = filterEvents$1((enterEvent) => {
318
+ const { target } = enterEvent;
319
+ const onHoverEnd = onHoverStart(enterEvent);
320
+ if (typeof onHoverEnd !== "function" || !target)
321
+ return;
322
+ const onPointerLeave = filterEvents$1((leaveEvent) => {
323
+ onHoverEnd(leaveEvent);
324
+ target.removeEventListener("pointerleave", onPointerLeave);
325
+ });
326
+ target.addEventListener("pointerleave", onPointerLeave, eventOptions);
327
+ });
328
+ elements.forEach((element) => {
329
+ element.addEventListener("pointerenter", onPointerEnter, eventOptions);
330
+ });
331
+ return cancel;
332
+ }
333
+ const isNodeOrChild = (parent, child) => {
334
+ if (!child) {
335
+ return false;
336
+ } else if (parent === child) {
337
+ return true;
338
+ } else {
339
+ return isNodeOrChild(parent, child.parentElement);
340
+ }
341
+ };
342
+ const isPrimaryPointer$1 = (event) => {
343
+ if (event.pointerType === "mouse") {
344
+ return typeof event.button !== "number" || event.button <= 0;
345
+ } else {
346
+ return event.isPrimary !== false;
347
+ }
348
+ };
349
+ const focusableElements = /* @__PURE__ */ new Set([
350
+ "BUTTON",
351
+ "INPUT",
352
+ "SELECT",
353
+ "TEXTAREA",
354
+ "A"
355
+ ]);
356
+ function isElementKeyboardAccessible(element) {
357
+ return focusableElements.has(element.tagName) || element.tabIndex !== -1;
358
+ }
359
+ const isPressing = /* @__PURE__ */ new WeakSet();
360
+ function filterEvents(callback) {
361
+ return (event) => {
362
+ if (event.key !== "Enter")
363
+ return;
364
+ callback(event);
365
+ };
366
+ }
367
+ function firePointerEvent(target, type) {
368
+ target.dispatchEvent(new PointerEvent("pointer" + type, { isPrimary: true, bubbles: true }));
369
+ }
370
+ const enableKeyboardPress = (focusEvent, eventOptions) => {
371
+ const element = focusEvent.currentTarget;
372
+ if (!element)
373
+ return;
374
+ const handleKeydown = filterEvents(() => {
375
+ if (isPressing.has(element))
376
+ return;
377
+ firePointerEvent(element, "down");
378
+ const handleKeyup = filterEvents(() => {
379
+ firePointerEvent(element, "up");
380
+ });
381
+ const handleBlur = () => firePointerEvent(element, "cancel");
382
+ element.addEventListener("keyup", handleKeyup, eventOptions);
383
+ element.addEventListener("blur", handleBlur, eventOptions);
384
+ });
385
+ element.addEventListener("keydown", handleKeydown, eventOptions);
386
+ element.addEventListener("blur", () => element.removeEventListener("keydown", handleKeydown), eventOptions);
387
+ };
388
+ function isValidPressEvent(event) {
389
+ return isPrimaryPointer$1(event) && !isDragActive();
390
+ }
391
+ function press(elementOrSelector, onPressStart, options = {}) {
392
+ const [elements, eventOptions, cancelEvents] = setupGesture(elementOrSelector, options);
393
+ const startPress = (startEvent) => {
394
+ const element = startEvent.currentTarget;
395
+ if (!isValidPressEvent(startEvent) || isPressing.has(element))
396
+ return;
397
+ isPressing.add(element);
398
+ const onPressEnd = onPressStart(startEvent);
399
+ const onPointerEnd = (endEvent, success) => {
400
+ window.removeEventListener("pointerup", onPointerUp);
401
+ window.removeEventListener("pointercancel", onPointerCancel);
402
+ if (!isValidPressEvent(endEvent) || !isPressing.has(element)) {
403
+ return;
404
+ }
405
+ isPressing.delete(element);
406
+ if (typeof onPressEnd === "function") {
407
+ onPressEnd(endEvent, { success });
408
+ }
409
+ };
410
+ const onPointerUp = (upEvent) => {
411
+ onPointerEnd(upEvent, options.useGlobalTarget || isNodeOrChild(element, upEvent.target));
412
+ };
413
+ const onPointerCancel = (cancelEvent) => {
414
+ onPointerEnd(cancelEvent, false);
415
+ };
416
+ window.addEventListener("pointerup", onPointerUp, eventOptions);
417
+ window.addEventListener("pointercancel", onPointerCancel, eventOptions);
418
+ };
419
+ elements.forEach((element) => {
420
+ if (!isElementKeyboardAccessible(element) && element.getAttribute("tabindex") === null) {
421
+ element.tabIndex = 0;
422
+ }
423
+ const target = options.useGlobalTarget ? window : element;
424
+ target.addEventListener("pointerdown", startPress, eventOptions);
425
+ element.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions), eventOptions);
426
+ });
427
+ return cancelEvents;
428
+ }
429
+ const clamp$1 = (min, max, v) => {
430
+ if (v > max)
431
+ return max;
432
+ if (v < min)
433
+ return min;
434
+ return v;
435
+ };
436
+ function velocityPerSecond(velocity, frameDuration) {
437
+ return frameDuration ? velocity * (1e3 / frameDuration) : 0;
438
+ }
439
+ const velocitySampleDuration = 5;
440
+ function calcGeneratorVelocity(resolveValue, t, current) {
441
+ const prevT = Math.max(t - velocitySampleDuration, 0);
442
+ return velocityPerSecond(current - resolveValue(prevT), t - prevT);
443
+ }
444
+ const springDefaults = {
445
+ // Default spring physics
446
+ stiffness: 100,
447
+ damping: 10,
448
+ mass: 1,
449
+ velocity: 0,
450
+ // Default duration/bounce-based options
451
+ duration: 800,
452
+ // in ms
453
+ bounce: 0.3,
454
+ visualDuration: 0.3,
455
+ // in seconds
456
+ // Rest thresholds
457
+ restSpeed: {
458
+ granular: 0.01,
459
+ default: 2
460
+ },
461
+ restDelta: {
462
+ granular: 5e-3,
463
+ default: 0.5
464
+ },
465
+ // Limits
466
+ minDuration: 0.01,
467
+ // in seconds
468
+ maxDuration: 10,
469
+ // in seconds
470
+ minDamping: 0.05,
471
+ maxDamping: 1
472
+ };
473
+ const safeMin = 1e-3;
474
+ function findSpring({ duration = springDefaults.duration, bounce = springDefaults.bounce, velocity = springDefaults.velocity, mass = springDefaults.mass }) {
475
+ let envelope;
476
+ let derivative;
477
+ warning(duration <= secondsToMilliseconds$1(springDefaults.maxDuration), "Spring duration must be 10 seconds or less");
478
+ let dampingRatio = 1 - bounce;
479
+ dampingRatio = clamp$1(springDefaults.minDamping, springDefaults.maxDamping, dampingRatio);
480
+ duration = clamp$1(springDefaults.minDuration, springDefaults.maxDuration, millisecondsToSeconds$1(duration));
481
+ if (dampingRatio < 1) {
482
+ envelope = (undampedFreq2) => {
483
+ const exponentialDecay = undampedFreq2 * dampingRatio;
484
+ const delta = exponentialDecay * duration;
485
+ const a = exponentialDecay - velocity;
486
+ const b = calcAngularFreq(undampedFreq2, dampingRatio);
487
+ const c = Math.exp(-delta);
488
+ return safeMin - a / b * c;
646
489
  };
647
490
  derivative = (undampedFreq2) => {
648
491
  const exponentialDecay = undampedFreq2 * dampingRatio;
@@ -695,17 +538,6 @@ function approximateRoot(envelope, derivative, initialGuess) {
695
538
  function calcAngularFreq(undampedFreq, dampingRatio) {
696
539
  return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
697
540
  }
698
- const maxGeneratorDuration = 2e4;
699
- function calcGeneratorDuration(generator) {
700
- let duration = 0;
701
- const timeStep = 50;
702
- let state2 = generator.next(duration);
703
- while (!state2.done && duration < maxGeneratorDuration) {
704
- duration += timeStep;
705
- state2 = generator.next(duration);
706
- }
707
- return duration >= maxGeneratorDuration ? Infinity : duration;
708
- }
709
541
  const durationKeys = ["duration", "bounce"];
710
542
  const physicsKeys = ["stiffness", "damping", "mass"];
711
543
  function isSpringType(options, keys2) {
@@ -725,7 +557,7 @@ function getSpringOptions(options) {
725
557
  const visualDuration = options.visualDuration;
726
558
  const root = 2 * Math.PI / (visualDuration * 1.2);
727
559
  const stiffness = root * root;
728
- const damping = 2 * clamp$1(0.05, 1, 1 - options.bounce) * Math.sqrt(stiffness);
560
+ const damping = 2 * clamp$1(0.05, 1, 1 - (options.bounce || 0)) * Math.sqrt(stiffness);
729
561
  springOptions = {
730
562
  ...springOptions,
731
563
  mass: springDefaults.mass,
@@ -808,14 +640,15 @@ function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce
808
640
  };
809
641
  return generator;
810
642
  }
811
- function createGeneratorEasing(options, scale2 = 100, createGenerator) {
812
- const generator = createGenerator({ ...options, keyframes: [0, scale2] });
813
- const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
814
- return {
815
- type: "keyframes",
816
- ease: (progress2) => generator.next(duration * progress2).value / scale2,
817
- duration: millisecondsToSeconds$1(duration)
818
- };
643
+ const wrap = (min, max, v) => {
644
+ const rangeSize = max - min;
645
+ return ((v - min) % rangeSize + rangeSize) % rangeSize + min;
646
+ };
647
+ const isEasingArray = (ease2) => {
648
+ return Array.isArray(ease2) && typeof ease2[0] !== "number";
649
+ };
650
+ function getEasingForSegment(easing, i) {
651
+ return isEasingArray(easing) ? easing[wrap(0, easing.length, i)] : easing;
819
652
  }
820
653
  const mixNumber$2 = (from, to, progress2) => {
821
654
  return from + (to - from) * progress2;
@@ -838,7 +671,7 @@ function isDOMKeyframes(keyframes2) {
838
671
  }
839
672
  function resolveSubjects(subject, keyframes2, scope, selectorCache) {
840
673
  if (typeof subject === "string" && isDOMKeyframes(keyframes2)) {
841
- return motionDom.resolveElements(subject, scope, selectorCache);
674
+ return resolveElements(subject, scope, selectorCache);
842
675
  } else if (subject instanceof NodeList) {
843
676
  return Array.from(subject);
844
677
  } else if (Array.isArray(subject)) {
@@ -847,8 +680,8 @@ function resolveSubjects(subject, keyframes2, scope, selectorCache) {
847
680
  return [subject];
848
681
  }
849
682
  }
850
- function isGenerator(type) {
851
- return typeof type === "function";
683
+ function calculateRepeatDuration(duration, repeat, _repeatDelay) {
684
+ return duration * (repeat + 1);
852
685
  }
853
686
  function calcNextTime(current, next, prev, labels) {
854
687
  var _a;
@@ -862,15 +695,14 @@ function calcNextTime(current, next, prev, labels) {
862
695
  return (_a = labels.get(next)) !== null && _a !== void 0 ? _a : current;
863
696
  }
864
697
  }
865
- const wrap = (min, max, v) => {
866
- const rangeSize = max - min;
867
- return ((v - min) % rangeSize + rangeSize) % rangeSize + min;
868
- };
869
- const isEasingArray = (ease2) => {
870
- return Array.isArray(ease2) && typeof ease2[0] !== "number";
871
- };
872
- function getEasingForSegment(easing, i) {
873
- return isEasingArray(easing) ? easing[wrap(0, easing.length, i)] : easing;
698
+ function addUniqueItem(arr, item) {
699
+ if (arr.indexOf(item) === -1)
700
+ arr.push(item);
701
+ }
702
+ function removeItem(arr, item) {
703
+ const index = arr.indexOf(item);
704
+ if (index > -1)
705
+ arr.splice(index, 1);
874
706
  }
875
707
  function eraseKeyframes(sequence, startTime, endTime) {
876
708
  for (let i = 0; i < sequence.length; i++) {
@@ -891,6 +723,11 @@ function addKeyframes(sequence, keyframes2, easing, offset, startTime, endTime)
891
723
  });
892
724
  }
893
725
  }
726
+ function normalizeTimes(times, repeat) {
727
+ for (let i = 0; i < times.length; i++) {
728
+ times[i] = times[i] / (repeat + 1);
729
+ }
730
+ }
894
731
  function compareByTime(a, b) {
895
732
  if (a.at === b.at) {
896
733
  if (a.value === null)
@@ -902,14 +739,6 @@ function compareByTime(a, b) {
902
739
  return a.at - b.at;
903
740
  }
904
741
  }
905
- function normalizeTimes(times, repeat) {
906
- for (let i = 0; i < times.length; i++) {
907
- times[i] = times[i] / (repeat + 1);
908
- }
909
- }
910
- function calculateRepeatDuration(duration, repeat, _repeatDelay) {
911
- return duration * (repeat + 1);
912
- }
913
742
  const defaultSegmentEasing = "easeInOut";
914
743
  const MAX_REPEAT = 20;
915
744
  function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...sequenceTransition } = {}, scope, generators2) {
@@ -997,7 +826,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
997
826
  const thisSubject = subjects[subjectIndex];
998
827
  const subjectSequence = getSubjectSequence(thisSubject, sequences);
999
828
  for (const key in keyframes2) {
1000
- resolveValueSequence(keyframes2[key], getValueTransition$1(transition, key), getValueSequence(key, subjectSequence), subjectIndex, numSubjects);
829
+ resolveValueSequence(keyframes2[key], getValueTransition(transition, key), getValueSequence(key, subjectSequence), subjectIndex, numSubjects);
1001
830
  }
1002
831
  }
1003
832
  }
@@ -1057,7 +886,7 @@ function getValueSequence(name, sequences) {
1057
886
  function keyframesAsList(keyframes2) {
1058
887
  return Array.isArray(keyframes2) ? keyframes2 : [keyframes2];
1059
888
  }
1060
- function getValueTransition$1(transition, key) {
889
+ function getValueTransition(transition, key) {
1061
890
  return transition && transition[key] ? {
1062
891
  ...transition,
1063
892
  ...transition[key]
@@ -1086,341 +915,595 @@ const transformPropOrder = [
1086
915
  "skewY"
1087
916
  ];
1088
917
  const transformProps = new Set(transformPropOrder);
1089
- const underDampedSpring = {
1090
- type: "spring",
1091
- stiffness: 500,
1092
- damping: 25,
1093
- restSpeed: 10
918
+ const positionalKeys = /* @__PURE__ */ new Set([
919
+ "width",
920
+ "height",
921
+ "top",
922
+ "left",
923
+ "right",
924
+ "bottom",
925
+ ...transformPropOrder
926
+ ]);
927
+ const isKeyframesTarget = (v) => {
928
+ return Array.isArray(v);
1094
929
  };
1095
- const criticallyDampedSpring = (target) => ({
1096
- type: "spring",
1097
- stiffness: 550,
1098
- damping: target === 0 ? 2 * Math.sqrt(550) : 30,
1099
- restSpeed: 10
1100
- });
1101
- const keyframesTransition = {
1102
- type: "keyframes",
1103
- duration: 0.8
930
+ const isCustomValue = (v) => {
931
+ return Boolean(v && typeof v === "object" && v.mix && v.toValue);
1104
932
  };
1105
- const ease = {
1106
- type: "keyframes",
1107
- ease: [0.25, 0.1, 0.35, 1],
1108
- duration: 0.3
933
+ const resolveFinalValueInKeyframes = (v) => {
934
+ return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
1109
935
  };
1110
- const getDefaultTransition = (valueKey, { keyframes: keyframes2 }) => {
1111
- if (keyframes2.length > 2) {
1112
- return keyframesTransition;
1113
- } else if (transformProps.has(valueKey)) {
1114
- return valueKey.startsWith("scale") ? criticallyDampedSpring(keyframes2[1]) : underDampedSpring;
1115
- }
1116
- return ease;
936
+ const MotionGlobalConfig = {
937
+ skipAnimations: false,
938
+ useManualTiming: false
1117
939
  };
1118
- function getValueTransition(transition, key) {
1119
- return transition ? transition[key] || transition["default"] || transition : void 0;
1120
- }
1121
- const isNotNull = (value) => value !== null;
1122
- function getFinalKeyframe(keyframes2, { repeat, repeatType = "loop" }, finalKeyframe) {
1123
- const resolvedKeyframes = keyframes2.filter(isNotNull);
1124
- const index = repeat && repeatType !== "loop" && repeat % 2 === 1 ? 0 : resolvedKeyframes.length - 1;
1125
- return !index || finalKeyframe === void 0 ? resolvedKeyframes[index] : finalKeyframe;
1126
- }
1127
- const calcBezier = (t, a1, a2) => (((1 - 3 * a2 + 3 * a1) * t + (3 * a2 - 6 * a1)) * t + 3 * a1) * t;
1128
- const subdivisionPrecision = 1e-7;
1129
- const subdivisionMaxIterations = 12;
1130
- function binarySubdivide(x, lowerBound, upperBound, mX1, mX2) {
1131
- let currentX;
1132
- let currentT;
1133
- let i = 0;
1134
- do {
1135
- currentT = lowerBound + (upperBound - lowerBound) / 2;
1136
- currentX = calcBezier(currentT, mX1, mX2) - x;
1137
- if (currentX > 0) {
1138
- upperBound = currentT;
1139
- } else {
1140
- lowerBound = currentT;
940
+ function createRenderStep(runNextFrame) {
941
+ let thisFrame = /* @__PURE__ */ new Set();
942
+ let nextFrame = /* @__PURE__ */ new Set();
943
+ let isProcessing = false;
944
+ let flushNextFrame = false;
945
+ const toKeepAlive = /* @__PURE__ */ new WeakSet();
946
+ let latestFrameData = {
947
+ delta: 0,
948
+ timestamp: 0,
949
+ isProcessing: false
950
+ };
951
+ function triggerCallback(callback) {
952
+ if (toKeepAlive.has(callback)) {
953
+ step.schedule(callback);
954
+ runNextFrame();
1141
955
  }
1142
- } while (Math.abs(currentX) > subdivisionPrecision && ++i < subdivisionMaxIterations);
1143
- return currentT;
956
+ callback(latestFrameData);
957
+ }
958
+ const step = {
959
+ /**
960
+ * Schedule a process to run on the next frame.
961
+ */
962
+ schedule: (callback, keepAlive = false, immediate = false) => {
963
+ const addToCurrentFrame = immediate && isProcessing;
964
+ const queue = addToCurrentFrame ? thisFrame : nextFrame;
965
+ if (keepAlive)
966
+ toKeepAlive.add(callback);
967
+ if (!queue.has(callback))
968
+ queue.add(callback);
969
+ return callback;
970
+ },
971
+ /**
972
+ * Cancel the provided callback from running on the next frame.
973
+ */
974
+ cancel: (callback) => {
975
+ nextFrame.delete(callback);
976
+ toKeepAlive.delete(callback);
977
+ },
978
+ /**
979
+ * Execute all schedule callbacks.
980
+ */
981
+ process: (frameData2) => {
982
+ latestFrameData = frameData2;
983
+ if (isProcessing) {
984
+ flushNextFrame = true;
985
+ return;
986
+ }
987
+ isProcessing = true;
988
+ [thisFrame, nextFrame] = [nextFrame, thisFrame];
989
+ thisFrame.forEach(triggerCallback);
990
+ thisFrame.clear();
991
+ isProcessing = false;
992
+ if (flushNextFrame) {
993
+ flushNextFrame = false;
994
+ step.process(frameData2);
995
+ }
996
+ }
997
+ };
998
+ return step;
1144
999
  }
1145
- function cubicBezier(mX1, mY1, mX2, mY2) {
1146
- if (mX1 === mY1 && mX2 === mY2)
1147
- return noop;
1148
- const getTForX = (aX) => binarySubdivide(aX, 0, 1, mX1, mX2);
1149
- return (t) => t === 0 || t === 1 ? t : calcBezier(getTForX(t), mY1, mY2);
1000
+ const stepsOrder = [
1001
+ "read",
1002
+ // Read
1003
+ "resolveKeyframes",
1004
+ // Write/Read/Write/Read
1005
+ "update",
1006
+ // Compute
1007
+ "preRender",
1008
+ // Compute
1009
+ "render",
1010
+ // Write
1011
+ "postRender"
1012
+ // Compute
1013
+ ];
1014
+ const maxElapsed$1 = 40;
1015
+ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
1016
+ let runNextFrame = false;
1017
+ let useDefaultElapsed = true;
1018
+ const state2 = {
1019
+ delta: 0,
1020
+ timestamp: 0,
1021
+ isProcessing: false
1022
+ };
1023
+ const flagRunNextFrame = () => runNextFrame = true;
1024
+ const steps2 = stepsOrder.reduce((acc, key) => {
1025
+ acc[key] = createRenderStep(flagRunNextFrame);
1026
+ return acc;
1027
+ }, {});
1028
+ const { read, resolveKeyframes, update, preRender, render, postRender } = steps2;
1029
+ const processBatch = () => {
1030
+ const timestamp = performance.now();
1031
+ runNextFrame = false;
1032
+ state2.delta = useDefaultElapsed ? 1e3 / 60 : Math.max(Math.min(timestamp - state2.timestamp, maxElapsed$1), 1);
1033
+ state2.timestamp = timestamp;
1034
+ state2.isProcessing = true;
1035
+ read.process(state2);
1036
+ resolveKeyframes.process(state2);
1037
+ update.process(state2);
1038
+ preRender.process(state2);
1039
+ render.process(state2);
1040
+ postRender.process(state2);
1041
+ state2.isProcessing = false;
1042
+ if (runNextFrame && allowKeepAlive) {
1043
+ useDefaultElapsed = false;
1044
+ scheduleNextBatch(processBatch);
1045
+ }
1046
+ };
1047
+ const wake = () => {
1048
+ runNextFrame = true;
1049
+ useDefaultElapsed = true;
1050
+ if (!state2.isProcessing) {
1051
+ scheduleNextBatch(processBatch);
1052
+ }
1053
+ };
1054
+ const schedule = stepsOrder.reduce((acc, key) => {
1055
+ const step = steps2[key];
1056
+ acc[key] = (process2, keepAlive = false, immediate = false) => {
1057
+ if (!runNextFrame)
1058
+ wake();
1059
+ return step.schedule(process2, keepAlive, immediate);
1060
+ };
1061
+ return acc;
1062
+ }, {});
1063
+ const cancel = (process2) => {
1064
+ for (let i = 0; i < stepsOrder.length; i++) {
1065
+ steps2[stepsOrder[i]].cancel(process2);
1066
+ }
1067
+ };
1068
+ return { schedule, cancel, state: state2, steps: steps2 };
1150
1069
  }
1151
- const mirrorEasing = (easing) => (p) => p <= 0.5 ? easing(2 * p) / 2 : (2 - easing(2 * (1 - p))) / 2;
1152
- const reverseEasing = (easing) => (p) => 1 - easing(1 - p);
1153
- const backOut = /* @__PURE__ */ cubicBezier(0.33, 1.53, 0.69, 0.99);
1154
- const backIn = /* @__PURE__ */ reverseEasing(backOut);
1155
- const backInOut = /* @__PURE__ */ mirrorEasing(backIn);
1156
- const anticipate = (p) => (p *= 2) < 1 ? 0.5 * backIn(p) : 0.5 * (2 - Math.pow(2, -10 * (p - 1)));
1157
- const circIn = (p) => 1 - Math.sin(Math.acos(p));
1158
- const circOut = reverseEasing(circIn);
1159
- const circInOut = mirrorEasing(circIn);
1160
- const isZeroValueString = (v) => /^0[^.\s]+$/u.test(v);
1161
- function isNone(value) {
1162
- if (typeof value === "number") {
1163
- return value === 0;
1164
- } else if (value !== null) {
1165
- return value === "none" || value === "0" || isZeroValueString(value);
1166
- } else {
1167
- return true;
1168
- }
1070
+ const { schedule: frame, cancel: cancelFrame, state: frameData, steps: frameSteps } = createRenderBatcher(typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : noop, true);
1071
+ let now;
1072
+ function clearTime() {
1073
+ now = void 0;
1169
1074
  }
1170
- const isNumericalString = (v) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(v);
1171
- const checkStringStartsWith = (token) => (key) => typeof key === "string" && key.startsWith(token);
1172
- const isCSSVariableName = /* @__PURE__ */ checkStringStartsWith("--");
1173
- const startsAsVariableToken = /* @__PURE__ */ checkStringStartsWith("var(--");
1174
- const isCSSVariableToken = (value) => {
1175
- const startsWithToken = startsAsVariableToken(value);
1176
- if (!startsWithToken)
1177
- return false;
1178
- return singleCssVariableRegex.test(value.split("/*")[0].trim());
1075
+ const time = {
1076
+ now: () => {
1077
+ if (now === void 0) {
1078
+ time.set(frameData.isProcessing || MotionGlobalConfig.useManualTiming ? frameData.timestamp : performance.now());
1079
+ }
1080
+ return now;
1081
+ },
1082
+ set: (newTime) => {
1083
+ now = newTime;
1084
+ queueMicrotask(clearTime);
1085
+ }
1179
1086
  };
1180
- const singleCssVariableRegex = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;
1181
- const splitCSSVariableRegex = (
1182
- // eslint-disable-next-line redos-detector/no-unsafe-regex -- false positive, as it can match a lot of words
1183
- /^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u
1184
- );
1185
- function parseCSSVariable(current) {
1186
- const match = splitCSSVariableRegex.exec(current);
1187
- if (!match)
1188
- return [,];
1189
- const [, token1, token2, fallback] = match;
1190
- return [`--${token1 !== null && token1 !== void 0 ? token1 : token2}`, fallback];
1087
+ class SubscriptionManager {
1088
+ constructor() {
1089
+ this.subscriptions = [];
1090
+ }
1091
+ add(handler) {
1092
+ addUniqueItem(this.subscriptions, handler);
1093
+ return () => removeItem(this.subscriptions, handler);
1094
+ }
1095
+ notify(a, b, c) {
1096
+ const numSubscriptions = this.subscriptions.length;
1097
+ if (!numSubscriptions)
1098
+ return;
1099
+ if (numSubscriptions === 1) {
1100
+ this.subscriptions[0](a, b, c);
1101
+ } else {
1102
+ for (let i = 0; i < numSubscriptions; i++) {
1103
+ const handler = this.subscriptions[i];
1104
+ handler && handler(a, b, c);
1105
+ }
1106
+ }
1107
+ }
1108
+ getSize() {
1109
+ return this.subscriptions.length;
1110
+ }
1111
+ clear() {
1112
+ this.subscriptions.length = 0;
1113
+ }
1191
1114
  }
1192
- const maxDepth = 4;
1193
- function getVariableValue(current, element, depth = 1) {
1194
- exports.invariant(depth <= maxDepth, `Max CSS variable fallback depth detected in property "${current}". This may indicate a circular fallback dependency.`);
1195
- const [token, fallback] = parseCSSVariable(current);
1196
- if (!token)
1115
+ const warned = /* @__PURE__ */ new Set();
1116
+ function warnOnce(condition, message, element) {
1117
+ if (condition || warned.has(message))
1197
1118
  return;
1198
- const resolved = window.getComputedStyle(element).getPropertyValue(token);
1199
- if (resolved) {
1200
- const trimmed = resolved.trim();
1201
- return isNumericalString(trimmed) ? parseFloat(trimmed) : trimmed;
1202
- }
1203
- return isCSSVariableToken(fallback) ? getVariableValue(fallback, element, depth + 1) : fallback;
1119
+ console.warn(message);
1120
+ warned.add(message);
1204
1121
  }
1205
- const number = {
1206
- test: (v) => typeof v === "number",
1207
- parse: parseFloat,
1208
- transform: (v) => v
1209
- };
1210
- const alpha = {
1211
- ...number,
1212
- transform: (v) => clamp$1(0, 1, v)
1213
- };
1214
- const scale = {
1215
- ...number,
1216
- default: 1
1122
+ const MAX_VELOCITY_DELTA = 30;
1123
+ const isFloat = (value) => {
1124
+ return !isNaN(parseFloat(value));
1217
1125
  };
1218
- const createUnitType$1 = (unit) => ({
1219
- test: (v) => typeof v === "string" && v.endsWith(unit) && v.split(" ").length === 1,
1220
- parse: parseFloat,
1221
- transform: (v) => `${v}${unit}`
1222
- });
1223
- const degrees = /* @__PURE__ */ createUnitType$1("deg");
1224
- const percent$1 = /* @__PURE__ */ createUnitType$1("%");
1225
- const px = /* @__PURE__ */ createUnitType$1("px");
1226
- const vh = /* @__PURE__ */ createUnitType$1("vh");
1227
- const vw = /* @__PURE__ */ createUnitType$1("vw");
1228
- const progressPercentage = {
1229
- ...percent$1,
1230
- parse: (v) => percent$1.parse(v) / 100,
1231
- transform: (v) => percent$1.transform(v * 100)
1126
+ const collectMotionValues = {
1127
+ current: void 0
1232
1128
  };
1233
- const positionalKeys = /* @__PURE__ */ new Set([
1234
- "width",
1235
- "height",
1236
- "top",
1237
- "left",
1238
- "right",
1239
- "bottom",
1240
- "x",
1241
- "y",
1242
- "translateX",
1243
- "translateY"
1244
- ]);
1245
- const isNumOrPxType = (v) => v === number || v === px;
1246
- const getPosFromMatrix = (matrix, pos) => parseFloat(matrix.split(", ")[pos]);
1247
- const getTranslateFromMatrix = (pos2, pos3) => (_bbox, { transform: transform2 }) => {
1248
- if (transform2 === "none" || !transform2)
1249
- return 0;
1250
- const matrix3d = transform2.match(/^matrix3d\((.+)\)$/u);
1251
- if (matrix3d) {
1252
- return getPosFromMatrix(matrix3d[1], pos3);
1253
- } else {
1254
- const matrix = transform2.match(/^matrix\((.+)\)$/u);
1255
- if (matrix) {
1256
- return getPosFromMatrix(matrix[1], pos2);
1257
- } else {
1258
- return 0;
1129
+ class MotionValue {
1130
+ /**
1131
+ * @param init - The initiating value
1132
+ * @param config - Optional configuration options
1133
+ *
1134
+ * - `transformer`: A function to transform incoming values with.
1135
+ *
1136
+ * @internal
1137
+ */
1138
+ constructor(init, options = {}) {
1139
+ this.version = "11.16.6";
1140
+ this.canTrackVelocity = null;
1141
+ this.events = {};
1142
+ this.updateAndNotify = (v, render = true) => {
1143
+ const currentTime = time.now();
1144
+ if (this.updatedAt !== currentTime) {
1145
+ this.setPrevFrameValue();
1146
+ }
1147
+ this.prev = this.current;
1148
+ this.setCurrent(v);
1149
+ if (this.current !== this.prev && this.events.change) {
1150
+ this.events.change.notify(this.current);
1151
+ }
1152
+ if (render && this.events.renderRequest) {
1153
+ this.events.renderRequest.notify(this.current);
1154
+ }
1155
+ };
1156
+ this.hasAnimated = false;
1157
+ this.setCurrent(init);
1158
+ this.owner = options.owner;
1159
+ }
1160
+ setCurrent(current) {
1161
+ this.current = current;
1162
+ this.updatedAt = time.now();
1163
+ if (this.canTrackVelocity === null && current !== void 0) {
1164
+ this.canTrackVelocity = isFloat(this.current);
1259
1165
  }
1260
1166
  }
1261
- };
1262
- const transformKeys = /* @__PURE__ */ new Set(["x", "y", "z"]);
1263
- const nonTranslationalTransformKeys = transformPropOrder.filter((key) => !transformKeys.has(key));
1264
- function removeNonTranslationalTransform(visualElement) {
1265
- const removedTransforms = [];
1266
- nonTranslationalTransformKeys.forEach((key) => {
1267
- const value = visualElement.getValue(key);
1268
- if (value !== void 0) {
1269
- removedTransforms.push([key, value.get()]);
1270
- value.set(key.startsWith("scale") ? 1 : 0);
1167
+ setPrevFrameValue(prevFrameValue = this.current) {
1168
+ this.prevFrameValue = prevFrameValue;
1169
+ this.prevUpdatedAt = this.updatedAt;
1170
+ }
1171
+ /**
1172
+ * Adds a function that will be notified when the `MotionValue` is updated.
1173
+ *
1174
+ * It returns a function that, when called, will cancel the subscription.
1175
+ *
1176
+ * When calling `onChange` inside a React component, it should be wrapped with the
1177
+ * `useEffect` hook. As it returns an unsubscribe function, this should be returned
1178
+ * from the `useEffect` function to ensure you don't add duplicate subscribers..
1179
+ *
1180
+ * ```jsx
1181
+ * export const MyComponent = () => {
1182
+ * const x = useMotionValue(0)
1183
+ * const y = useMotionValue(0)
1184
+ * const opacity = useMotionValue(1)
1185
+ *
1186
+ * useEffect(() => {
1187
+ * function updateOpacity() {
1188
+ * const maxXY = Math.max(x.get(), y.get())
1189
+ * const newOpacity = transform(maxXY, [0, 100], [1, 0])
1190
+ * opacity.set(newOpacity)
1191
+ * }
1192
+ *
1193
+ * const unsubscribeX = x.on("change", updateOpacity)
1194
+ * const unsubscribeY = y.on("change", updateOpacity)
1195
+ *
1196
+ * return () => {
1197
+ * unsubscribeX()
1198
+ * unsubscribeY()
1199
+ * }
1200
+ * }, [])
1201
+ *
1202
+ * return <motion.div style={{ x }} />
1203
+ * }
1204
+ * ```
1205
+ *
1206
+ * @param subscriber - A function that receives the latest value.
1207
+ * @returns A function that, when called, will cancel this subscription.
1208
+ *
1209
+ * @deprecated
1210
+ */
1211
+ onChange(subscription) {
1212
+ if (process.env.NODE_ENV !== "production") {
1213
+ warnOnce(false, `value.onChange(callback) is deprecated. Switch to value.on("change", callback).`);
1271
1214
  }
1272
- });
1273
- return removedTransforms;
1274
- }
1275
- const positionalValues = {
1276
- // Dimensions
1277
- width: ({ x }, { paddingLeft = "0", paddingRight = "0" }) => x.max - x.min - parseFloat(paddingLeft) - parseFloat(paddingRight),
1278
- height: ({ y }, { paddingTop = "0", paddingBottom = "0" }) => y.max - y.min - parseFloat(paddingTop) - parseFloat(paddingBottom),
1279
- top: (_bbox, { top }) => parseFloat(top),
1280
- left: (_bbox, { left }) => parseFloat(left),
1281
- bottom: ({ y }, { top }) => parseFloat(top) + (y.max - y.min),
1282
- right: ({ x }, { left }) => parseFloat(left) + (x.max - x.min),
1283
- // Transform
1284
- x: getTranslateFromMatrix(4, 13),
1285
- y: getTranslateFromMatrix(5, 14)
1286
- };
1287
- positionalValues.translateX = positionalValues.x;
1288
- positionalValues.translateY = positionalValues.y;
1289
- const testValueType = (v) => (type) => type.test(v);
1290
- const auto = {
1291
- test: (v) => v === "auto",
1292
- parse: (v) => v
1293
- };
1294
- const dimensionValueTypes = [number, px, percent$1, degrees, vw, vh, auto];
1295
- const findDimensionValueType = (v) => dimensionValueTypes.find(testValueType(v));
1296
- const toResolve = /* @__PURE__ */ new Set();
1297
- let isScheduled = false;
1298
- let anyNeedsMeasurement = false;
1299
- function measureAllKeyframes() {
1300
- if (anyNeedsMeasurement) {
1301
- const resolversToMeasure = Array.from(toResolve).filter((resolver) => resolver.needsMeasurement);
1302
- const elementsToMeasure = new Set(resolversToMeasure.map((resolver) => resolver.element));
1303
- const transformsToRestore = /* @__PURE__ */ new Map();
1304
- elementsToMeasure.forEach((element) => {
1305
- const removedTransforms = removeNonTranslationalTransform(element);
1306
- if (!removedTransforms.length)
1307
- return;
1308
- transformsToRestore.set(element, removedTransforms);
1309
- element.render();
1310
- });
1311
- resolversToMeasure.forEach((resolver) => resolver.measureInitialState());
1312
- elementsToMeasure.forEach((element) => {
1313
- element.render();
1314
- const restore = transformsToRestore.get(element);
1315
- if (restore) {
1316
- restore.forEach(([key, value]) => {
1317
- var _a;
1318
- (_a = element.getValue(key)) === null || _a === void 0 ? void 0 : _a.set(value);
1215
+ return this.on("change", subscription);
1216
+ }
1217
+ on(eventName, callback) {
1218
+ if (!this.events[eventName]) {
1219
+ this.events[eventName] = new SubscriptionManager();
1220
+ }
1221
+ const unsubscribe = this.events[eventName].add(callback);
1222
+ if (eventName === "change") {
1223
+ return () => {
1224
+ unsubscribe();
1225
+ frame.read(() => {
1226
+ if (!this.events.change.getSize()) {
1227
+ this.stop();
1228
+ }
1319
1229
  });
1230
+ };
1231
+ }
1232
+ return unsubscribe;
1233
+ }
1234
+ clearListeners() {
1235
+ for (const eventManagers in this.events) {
1236
+ this.events[eventManagers].clear();
1237
+ }
1238
+ }
1239
+ /**
1240
+ * Attaches a passive effect to the `MotionValue`.
1241
+ *
1242
+ * @internal
1243
+ */
1244
+ attach(passiveEffect, stopPassiveEffect) {
1245
+ this.passiveEffect = passiveEffect;
1246
+ this.stopPassiveEffect = stopPassiveEffect;
1247
+ }
1248
+ /**
1249
+ * Sets the state of the `MotionValue`.
1250
+ *
1251
+ * @remarks
1252
+ *
1253
+ * ```jsx
1254
+ * const x = useMotionValue(0)
1255
+ * x.set(10)
1256
+ * ```
1257
+ *
1258
+ * @param latest - Latest value to set.
1259
+ * @param render - Whether to notify render subscribers. Defaults to `true`
1260
+ *
1261
+ * @public
1262
+ */
1263
+ set(v, render = true) {
1264
+ if (!render || !this.passiveEffect) {
1265
+ this.updateAndNotify(v, render);
1266
+ } else {
1267
+ this.passiveEffect(v, this.updateAndNotify);
1268
+ }
1269
+ }
1270
+ setWithVelocity(prev, current, delta) {
1271
+ this.set(current);
1272
+ this.prev = void 0;
1273
+ this.prevFrameValue = prev;
1274
+ this.prevUpdatedAt = this.updatedAt - delta;
1275
+ }
1276
+ /**
1277
+ * Set the state of the `MotionValue`, stopping any active animations,
1278
+ * effects, and resets velocity to `0`.
1279
+ */
1280
+ jump(v, endAnimation = true) {
1281
+ this.updateAndNotify(v);
1282
+ this.prev = v;
1283
+ this.prevUpdatedAt = this.prevFrameValue = void 0;
1284
+ endAnimation && this.stop();
1285
+ if (this.stopPassiveEffect)
1286
+ this.stopPassiveEffect();
1287
+ }
1288
+ /**
1289
+ * Returns the latest state of `MotionValue`
1290
+ *
1291
+ * @returns - The latest state of `MotionValue`
1292
+ *
1293
+ * @public
1294
+ */
1295
+ get() {
1296
+ if (collectMotionValues.current) {
1297
+ collectMotionValues.current.push(this);
1298
+ }
1299
+ return this.current;
1300
+ }
1301
+ /**
1302
+ * @public
1303
+ */
1304
+ getPrevious() {
1305
+ return this.prev;
1306
+ }
1307
+ /**
1308
+ * Returns the latest velocity of `MotionValue`
1309
+ *
1310
+ * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
1311
+ *
1312
+ * @public
1313
+ */
1314
+ getVelocity() {
1315
+ const currentTime = time.now();
1316
+ if (!this.canTrackVelocity || this.prevFrameValue === void 0 || currentTime - this.updatedAt > MAX_VELOCITY_DELTA) {
1317
+ return 0;
1318
+ }
1319
+ const delta = Math.min(this.updatedAt - this.prevUpdatedAt, MAX_VELOCITY_DELTA);
1320
+ return velocityPerSecond(parseFloat(this.current) - parseFloat(this.prevFrameValue), delta);
1321
+ }
1322
+ /**
1323
+ * Registers a new animation to control this `MotionValue`. Only one
1324
+ * animation can drive a `MotionValue` at one time.
1325
+ *
1326
+ * ```jsx
1327
+ * value.start()
1328
+ * ```
1329
+ *
1330
+ * @param animation - A function that starts the provided animation
1331
+ *
1332
+ * @internal
1333
+ */
1334
+ start(startAnimation) {
1335
+ this.stop();
1336
+ return new Promise((resolve) => {
1337
+ this.hasAnimated = true;
1338
+ this.animation = startAnimation(resolve);
1339
+ if (this.events.animationStart) {
1340
+ this.events.animationStart.notify();
1320
1341
  }
1321
- });
1322
- resolversToMeasure.forEach((resolver) => resolver.measureEndState());
1323
- resolversToMeasure.forEach((resolver) => {
1324
- if (resolver.suspendedScrollY !== void 0) {
1325
- window.scrollTo(0, resolver.suspendedScrollY);
1342
+ }).then(() => {
1343
+ if (this.events.animationComplete) {
1344
+ this.events.animationComplete.notify();
1326
1345
  }
1346
+ this.clearAnimation();
1327
1347
  });
1328
1348
  }
1329
- anyNeedsMeasurement = false;
1330
- isScheduled = false;
1331
- toResolve.forEach((resolver) => resolver.complete());
1332
- toResolve.clear();
1333
- }
1334
- function readAllKeyframes() {
1335
- toResolve.forEach((resolver) => {
1336
- resolver.readKeyframes();
1337
- if (resolver.needsMeasurement) {
1338
- anyNeedsMeasurement = true;
1339
- }
1340
- });
1341
- }
1342
- function flushKeyframeResolvers() {
1343
- readAllKeyframes();
1344
- measureAllKeyframes();
1345
- }
1346
- class KeyframeResolver {
1347
- constructor(unresolvedKeyframes, onComplete, name, motionValue2, element, isAsync = false) {
1348
- this.isComplete = false;
1349
- this.isAsync = false;
1350
- this.needsMeasurement = false;
1351
- this.isScheduled = false;
1352
- this.unresolvedKeyframes = [...unresolvedKeyframes];
1353
- this.onComplete = onComplete;
1354
- this.name = name;
1355
- this.motionValue = motionValue2;
1356
- this.element = element;
1357
- this.isAsync = isAsync;
1358
- }
1359
- scheduleResolve() {
1360
- this.isScheduled = true;
1361
- if (this.isAsync) {
1362
- toResolve.add(this);
1363
- if (!isScheduled) {
1364
- isScheduled = true;
1365
- frame.read(readAllKeyframes);
1366
- frame.resolveKeyframes(measureAllKeyframes);
1349
+ /**
1350
+ * Stop the currently active animation.
1351
+ *
1352
+ * @public
1353
+ */
1354
+ stop() {
1355
+ if (this.animation) {
1356
+ this.animation.stop();
1357
+ if (this.events.animationCancel) {
1358
+ this.events.animationCancel.notify();
1367
1359
  }
1368
- } else {
1369
- this.readKeyframes();
1370
- this.complete();
1371
1360
  }
1361
+ this.clearAnimation();
1372
1362
  }
1373
- readKeyframes() {
1374
- const { unresolvedKeyframes, name, element, motionValue: motionValue2 } = this;
1375
- for (let i = 0; i < unresolvedKeyframes.length; i++) {
1376
- if (unresolvedKeyframes[i] === null) {
1377
- if (i === 0) {
1378
- const currentValue = motionValue2 === null || motionValue2 === void 0 ? void 0 : motionValue2.get();
1379
- const finalKeyframe = unresolvedKeyframes[unresolvedKeyframes.length - 1];
1380
- if (currentValue !== void 0) {
1381
- unresolvedKeyframes[0] = currentValue;
1382
- } else if (element && name) {
1383
- const valueAsRead = element.readValue(name, finalKeyframe);
1384
- if (valueAsRead !== void 0 && valueAsRead !== null) {
1385
- unresolvedKeyframes[0] = valueAsRead;
1386
- }
1387
- }
1388
- if (unresolvedKeyframes[0] === void 0) {
1389
- unresolvedKeyframes[0] = finalKeyframe;
1390
- }
1391
- if (motionValue2 && currentValue === void 0) {
1392
- motionValue2.set(unresolvedKeyframes[0]);
1393
- }
1394
- } else {
1395
- unresolvedKeyframes[i] = unresolvedKeyframes[i - 1];
1396
- }
1397
- }
1363
+ /**
1364
+ * Returns `true` if this value is currently animating.
1365
+ *
1366
+ * @public
1367
+ */
1368
+ isAnimating() {
1369
+ return !!this.animation;
1370
+ }
1371
+ clearAnimation() {
1372
+ delete this.animation;
1373
+ }
1374
+ /**
1375
+ * Destroy and clean up subscribers to this `MotionValue`.
1376
+ *
1377
+ * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
1378
+ * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
1379
+ * created a `MotionValue` via the `motionValue` function.
1380
+ *
1381
+ * @public
1382
+ */
1383
+ destroy() {
1384
+ this.clearListeners();
1385
+ this.stop();
1386
+ if (this.stopPassiveEffect) {
1387
+ this.stopPassiveEffect();
1398
1388
  }
1399
1389
  }
1400
- setFinalKeyframe() {
1390
+ }
1391
+ function motionValue(init, options) {
1392
+ return new MotionValue(init, options);
1393
+ }
1394
+ function getValueState(visualElement) {
1395
+ const state2 = [{}, {}];
1396
+ visualElement === null || visualElement === void 0 ? void 0 : visualElement.values.forEach((value, key) => {
1397
+ state2[0][key] = value.get();
1398
+ state2[1][key] = value.getVelocity();
1399
+ });
1400
+ return state2;
1401
+ }
1402
+ function resolveVariantFromProps(props, definition, custom, visualElement) {
1403
+ if (typeof definition === "function") {
1404
+ const [current, velocity] = getValueState(visualElement);
1405
+ definition = definition(custom !== void 0 ? custom : props.custom, current, velocity);
1401
1406
  }
1402
- measureInitialState() {
1407
+ if (typeof definition === "string") {
1408
+ definition = props.variants && props.variants[definition];
1403
1409
  }
1404
- renderEndStyles() {
1410
+ if (typeof definition === "function") {
1411
+ const [current, velocity] = getValueState(visualElement);
1412
+ definition = definition(custom !== void 0 ? custom : props.custom, current, velocity);
1405
1413
  }
1406
- measureEndState() {
1414
+ return definition;
1415
+ }
1416
+ function resolveVariant$1(visualElement, definition, custom) {
1417
+ const props = visualElement.getProps();
1418
+ return resolveVariantFromProps(props, definition, props.custom, visualElement);
1419
+ }
1420
+ function setMotionValue(visualElement, key, value) {
1421
+ if (visualElement.hasValue(key)) {
1422
+ visualElement.getValue(key).set(value);
1423
+ } else {
1424
+ visualElement.addValue(key, motionValue(value));
1407
1425
  }
1408
- complete() {
1409
- this.isComplete = true;
1410
- this.onComplete(this.unresolvedKeyframes, this.finalKeyframe);
1411
- toResolve.delete(this);
1426
+ }
1427
+ function setTarget(visualElement, definition) {
1428
+ const resolved = resolveVariant$1(visualElement, definition);
1429
+ let { transitionEnd = {}, transition = {}, ...target } = resolved || {};
1430
+ target = { ...target, ...transitionEnd };
1431
+ for (const key in target) {
1432
+ const value = resolveFinalValueInKeyframes(target[key]);
1433
+ setMotionValue(visualElement, key, value);
1412
1434
  }
1413
- cancel() {
1414
- if (!this.isComplete) {
1415
- this.isScheduled = false;
1416
- toResolve.delete(this);
1417
- }
1435
+ }
1436
+ function isWillChangeMotionValue$1(value) {
1437
+ return Boolean(isMotionValue$1(value) && value.add);
1438
+ }
1439
+ function addValueToWillChange$1(visualElement, key) {
1440
+ const willChange = visualElement.getValue("willChange");
1441
+ if (isWillChangeMotionValue$1(willChange)) {
1442
+ return willChange.add(key);
1418
1443
  }
1419
- resume() {
1420
- if (!this.isComplete)
1421
- this.scheduleResolve();
1444
+ }
1445
+ const camelToDash = (str) => str.replace(/([a-z])([A-Z])/gu, "$1-$2").toLowerCase();
1446
+ const optimizedAppearDataId = "framerAppearId";
1447
+ const optimizedAppearDataAttribute = "data-" + camelToDash(optimizedAppearDataId);
1448
+ function getOptimisedAppearId(visualElement) {
1449
+ return visualElement.props[optimizedAppearDataAttribute];
1450
+ }
1451
+ const calcBezier = (t, a1, a2) => (((1 - 3 * a2 + 3 * a1) * t + (3 * a2 - 6 * a1)) * t + 3 * a1) * t;
1452
+ const subdivisionPrecision = 1e-7;
1453
+ const subdivisionMaxIterations = 12;
1454
+ function binarySubdivide(x, lowerBound, upperBound, mX1, mX2) {
1455
+ let currentX;
1456
+ let currentT;
1457
+ let i = 0;
1458
+ do {
1459
+ currentT = lowerBound + (upperBound - lowerBound) / 2;
1460
+ currentX = calcBezier(currentT, mX1, mX2) - x;
1461
+ if (currentX > 0) {
1462
+ upperBound = currentT;
1463
+ } else {
1464
+ lowerBound = currentT;
1465
+ }
1466
+ } while (Math.abs(currentX) > subdivisionPrecision && ++i < subdivisionMaxIterations);
1467
+ return currentT;
1468
+ }
1469
+ function cubicBezier(mX1, mY1, mX2, mY2) {
1470
+ if (mX1 === mY1 && mX2 === mY2)
1471
+ return noop;
1472
+ const getTForX = (aX) => binarySubdivide(aX, 0, 1, mX1, mX2);
1473
+ return (t) => t === 0 || t === 1 ? t : calcBezier(getTForX(t), mY1, mY2);
1474
+ }
1475
+ const mirrorEasing = (easing) => (p) => p <= 0.5 ? easing(2 * p) / 2 : (2 - easing(2 * (1 - p))) / 2;
1476
+ const reverseEasing = (easing) => (p) => 1 - easing(1 - p);
1477
+ const backOut = /* @__PURE__ */ cubicBezier(0.33, 1.53, 0.69, 0.99);
1478
+ const backIn = /* @__PURE__ */ reverseEasing(backOut);
1479
+ const backInOut = /* @__PURE__ */ mirrorEasing(backIn);
1480
+ const anticipate = (p) => (p *= 2) < 1 ? 0.5 * backIn(p) : 0.5 * (2 - Math.pow(2, -10 * (p - 1)));
1481
+ const circIn = (p) => 1 - Math.sin(Math.acos(p));
1482
+ const circOut = reverseEasing(circIn);
1483
+ const circInOut = mirrorEasing(circIn);
1484
+ const isZeroValueString = (v) => /^0[^.\s]+$/u.test(v);
1485
+ function isNone(value) {
1486
+ if (typeof value === "number") {
1487
+ return value === 0;
1488
+ } else if (value !== null) {
1489
+ return value === "none" || value === "0" || isZeroValueString(value);
1490
+ } else {
1491
+ return true;
1422
1492
  }
1423
1493
  }
1494
+ const number = {
1495
+ test: (v) => typeof v === "number",
1496
+ parse: parseFloat,
1497
+ transform: (v) => v
1498
+ };
1499
+ const alpha = {
1500
+ ...number,
1501
+ transform: (v) => clamp$1(0, 1, v)
1502
+ };
1503
+ const scale = {
1504
+ ...number,
1505
+ default: 1
1506
+ };
1424
1507
  const sanitize = (v) => Math.round(v * 1e5) / 1e5;
1425
1508
  const floatRegex = /-?(?:\d+(?:\.\d+)?|\.\d+)/gu;
1426
1509
  function isNullish(v) {
@@ -1483,6 +1566,21 @@ const hex = {
1483
1566
  parse: parseHex,
1484
1567
  transform: rgba.transform
1485
1568
  };
1569
+ const createUnitType$1 = (unit) => ({
1570
+ test: (v) => typeof v === "string" && v.endsWith(unit) && v.split(" ").length === 1,
1571
+ parse: parseFloat,
1572
+ transform: (v) => `${v}${unit}`
1573
+ });
1574
+ const degrees = /* @__PURE__ */ createUnitType$1("deg");
1575
+ const percent$1 = /* @__PURE__ */ createUnitType$1("%");
1576
+ const px = /* @__PURE__ */ createUnitType$1("px");
1577
+ const vh = /* @__PURE__ */ createUnitType$1("vh");
1578
+ const vw = /* @__PURE__ */ createUnitType$1("vw");
1579
+ const progressPercentage = {
1580
+ ...percent$1,
1581
+ parse: (v) => percent$1.parse(v) / 100,
1582
+ transform: (v) => percent$1.transform(v * 100)
1583
+ };
1486
1584
  const hsla = {
1487
1585
  test: /* @__PURE__ */ isColorString("hsl", "hue"),
1488
1586
  parse: /* @__PURE__ */ splitColor("hue", "saturation", "lightness"),
@@ -1722,6 +1820,220 @@ function makeNoneKeyframesAnimatable(unresolvedKeyframes, noneKeyframeIndexes, n
1722
1820
  }
1723
1821
  }
1724
1822
  }
1823
+ const isNumOrPxType = (v) => v === number || v === px;
1824
+ const getPosFromMatrix = (matrix, pos) => parseFloat(matrix.split(", ")[pos]);
1825
+ const getTranslateFromMatrix = (pos2, pos3) => (_bbox, { transform: transform2 }) => {
1826
+ if (transform2 === "none" || !transform2)
1827
+ return 0;
1828
+ const matrix3d = transform2.match(/^matrix3d\((.+)\)$/u);
1829
+ if (matrix3d) {
1830
+ return getPosFromMatrix(matrix3d[1], pos3);
1831
+ } else {
1832
+ const matrix = transform2.match(/^matrix\((.+)\)$/u);
1833
+ if (matrix) {
1834
+ return getPosFromMatrix(matrix[1], pos2);
1835
+ } else {
1836
+ return 0;
1837
+ }
1838
+ }
1839
+ };
1840
+ const transformKeys = /* @__PURE__ */ new Set(["x", "y", "z"]);
1841
+ const nonTranslationalTransformKeys = transformPropOrder.filter((key) => !transformKeys.has(key));
1842
+ function removeNonTranslationalTransform(visualElement) {
1843
+ const removedTransforms = [];
1844
+ nonTranslationalTransformKeys.forEach((key) => {
1845
+ const value = visualElement.getValue(key);
1846
+ if (value !== void 0) {
1847
+ removedTransforms.push([key, value.get()]);
1848
+ value.set(key.startsWith("scale") ? 1 : 0);
1849
+ }
1850
+ });
1851
+ return removedTransforms;
1852
+ }
1853
+ const positionalValues = {
1854
+ // Dimensions
1855
+ width: ({ x }, { paddingLeft = "0", paddingRight = "0" }) => x.max - x.min - parseFloat(paddingLeft) - parseFloat(paddingRight),
1856
+ height: ({ y }, { paddingTop = "0", paddingBottom = "0" }) => y.max - y.min - parseFloat(paddingTop) - parseFloat(paddingBottom),
1857
+ top: (_bbox, { top }) => parseFloat(top),
1858
+ left: (_bbox, { left }) => parseFloat(left),
1859
+ bottom: ({ y }, { top }) => parseFloat(top) + (y.max - y.min),
1860
+ right: ({ x }, { left }) => parseFloat(left) + (x.max - x.min),
1861
+ // Transform
1862
+ x: getTranslateFromMatrix(4, 13),
1863
+ y: getTranslateFromMatrix(5, 14)
1864
+ };
1865
+ positionalValues.translateX = positionalValues.x;
1866
+ positionalValues.translateY = positionalValues.y;
1867
+ const toResolve = /* @__PURE__ */ new Set();
1868
+ let isScheduled = false;
1869
+ let anyNeedsMeasurement = false;
1870
+ function measureAllKeyframes() {
1871
+ if (anyNeedsMeasurement) {
1872
+ const resolversToMeasure = Array.from(toResolve).filter((resolver) => resolver.needsMeasurement);
1873
+ const elementsToMeasure = new Set(resolversToMeasure.map((resolver) => resolver.element));
1874
+ const transformsToRestore = /* @__PURE__ */ new Map();
1875
+ elementsToMeasure.forEach((element) => {
1876
+ const removedTransforms = removeNonTranslationalTransform(element);
1877
+ if (!removedTransforms.length)
1878
+ return;
1879
+ transformsToRestore.set(element, removedTransforms);
1880
+ element.render();
1881
+ });
1882
+ resolversToMeasure.forEach((resolver) => resolver.measureInitialState());
1883
+ elementsToMeasure.forEach((element) => {
1884
+ element.render();
1885
+ const restore = transformsToRestore.get(element);
1886
+ if (restore) {
1887
+ restore.forEach(([key, value]) => {
1888
+ var _a;
1889
+ (_a = element.getValue(key)) === null || _a === void 0 ? void 0 : _a.set(value);
1890
+ });
1891
+ }
1892
+ });
1893
+ resolversToMeasure.forEach((resolver) => resolver.measureEndState());
1894
+ resolversToMeasure.forEach((resolver) => {
1895
+ if (resolver.suspendedScrollY !== void 0) {
1896
+ window.scrollTo(0, resolver.suspendedScrollY);
1897
+ }
1898
+ });
1899
+ }
1900
+ anyNeedsMeasurement = false;
1901
+ isScheduled = false;
1902
+ toResolve.forEach((resolver) => resolver.complete());
1903
+ toResolve.clear();
1904
+ }
1905
+ function readAllKeyframes() {
1906
+ toResolve.forEach((resolver) => {
1907
+ resolver.readKeyframes();
1908
+ if (resolver.needsMeasurement) {
1909
+ anyNeedsMeasurement = true;
1910
+ }
1911
+ });
1912
+ }
1913
+ function flushKeyframeResolvers() {
1914
+ readAllKeyframes();
1915
+ measureAllKeyframes();
1916
+ }
1917
+ class KeyframeResolver {
1918
+ constructor(unresolvedKeyframes, onComplete, name, motionValue2, element, isAsync = false) {
1919
+ this.isComplete = false;
1920
+ this.isAsync = false;
1921
+ this.needsMeasurement = false;
1922
+ this.isScheduled = false;
1923
+ this.unresolvedKeyframes = [...unresolvedKeyframes];
1924
+ this.onComplete = onComplete;
1925
+ this.name = name;
1926
+ this.motionValue = motionValue2;
1927
+ this.element = element;
1928
+ this.isAsync = isAsync;
1929
+ }
1930
+ scheduleResolve() {
1931
+ this.isScheduled = true;
1932
+ if (this.isAsync) {
1933
+ toResolve.add(this);
1934
+ if (!isScheduled) {
1935
+ isScheduled = true;
1936
+ frame.read(readAllKeyframes);
1937
+ frame.resolveKeyframes(measureAllKeyframes);
1938
+ }
1939
+ } else {
1940
+ this.readKeyframes();
1941
+ this.complete();
1942
+ }
1943
+ }
1944
+ readKeyframes() {
1945
+ const { unresolvedKeyframes, name, element, motionValue: motionValue2 } = this;
1946
+ for (let i = 0; i < unresolvedKeyframes.length; i++) {
1947
+ if (unresolvedKeyframes[i] === null) {
1948
+ if (i === 0) {
1949
+ const currentValue = motionValue2 === null || motionValue2 === void 0 ? void 0 : motionValue2.get();
1950
+ const finalKeyframe = unresolvedKeyframes[unresolvedKeyframes.length - 1];
1951
+ if (currentValue !== void 0) {
1952
+ unresolvedKeyframes[0] = currentValue;
1953
+ } else if (element && name) {
1954
+ const valueAsRead = element.readValue(name, finalKeyframe);
1955
+ if (valueAsRead !== void 0 && valueAsRead !== null) {
1956
+ unresolvedKeyframes[0] = valueAsRead;
1957
+ }
1958
+ }
1959
+ if (unresolvedKeyframes[0] === void 0) {
1960
+ unresolvedKeyframes[0] = finalKeyframe;
1961
+ }
1962
+ if (motionValue2 && currentValue === void 0) {
1963
+ motionValue2.set(unresolvedKeyframes[0]);
1964
+ }
1965
+ } else {
1966
+ unresolvedKeyframes[i] = unresolvedKeyframes[i - 1];
1967
+ }
1968
+ }
1969
+ }
1970
+ }
1971
+ setFinalKeyframe() {
1972
+ }
1973
+ measureInitialState() {
1974
+ }
1975
+ renderEndStyles() {
1976
+ }
1977
+ measureEndState() {
1978
+ }
1979
+ complete() {
1980
+ this.isComplete = true;
1981
+ this.onComplete(this.unresolvedKeyframes, this.finalKeyframe);
1982
+ toResolve.delete(this);
1983
+ }
1984
+ cancel() {
1985
+ if (!this.isComplete) {
1986
+ this.isScheduled = false;
1987
+ toResolve.delete(this);
1988
+ }
1989
+ }
1990
+ resume() {
1991
+ if (!this.isComplete)
1992
+ this.scheduleResolve();
1993
+ }
1994
+ }
1995
+ const isNumericalString = (v) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(v);
1996
+ const checkStringStartsWith = (token) => (key) => typeof key === "string" && key.startsWith(token);
1997
+ const isCSSVariableName = /* @__PURE__ */ checkStringStartsWith("--");
1998
+ const startsAsVariableToken = /* @__PURE__ */ checkStringStartsWith("var(--");
1999
+ const isCSSVariableToken = (value) => {
2000
+ const startsWithToken = startsAsVariableToken(value);
2001
+ if (!startsWithToken)
2002
+ return false;
2003
+ return singleCssVariableRegex.test(value.split("/*")[0].trim());
2004
+ };
2005
+ const singleCssVariableRegex = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;
2006
+ const splitCSSVariableRegex = (
2007
+ // eslint-disable-next-line redos-detector/no-unsafe-regex -- false positive, as it can match a lot of words
2008
+ /^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u
2009
+ );
2010
+ function parseCSSVariable(current) {
2011
+ const match = splitCSSVariableRegex.exec(current);
2012
+ if (!match)
2013
+ return [,];
2014
+ const [, token1, token2, fallback] = match;
2015
+ return [`--${token1 !== null && token1 !== void 0 ? token1 : token2}`, fallback];
2016
+ }
2017
+ const maxDepth = 4;
2018
+ function getVariableValue(current, element, depth = 1) {
2019
+ exports.invariant(depth <= maxDepth, `Max CSS variable fallback depth detected in property "${current}". This may indicate a circular fallback dependency.`);
2020
+ const [token, fallback] = parseCSSVariable(current);
2021
+ if (!token)
2022
+ return;
2023
+ const resolved = window.getComputedStyle(element).getPropertyValue(token);
2024
+ if (resolved) {
2025
+ const trimmed = resolved.trim();
2026
+ return isNumericalString(trimmed) ? parseFloat(trimmed) : trimmed;
2027
+ }
2028
+ return isCSSVariableToken(fallback) ? getVariableValue(fallback, element, depth + 1) : fallback;
2029
+ }
2030
+ const testValueType = (v) => (type) => type.test(v);
2031
+ const auto = {
2032
+ test: (v) => v === "auto",
2033
+ parse: (v) => v
2034
+ };
2035
+ const dimensionValueTypes = [number, px, percent$1, degrees, vw, vh, auto];
2036
+ const findDimensionValueType = (v) => dimensionValueTypes.find(testValueType(v));
1725
2037
  class DOMKeyframesResolver extends KeyframeResolver {
1726
2038
  constructor(unresolvedKeyframes, onComplete, name, motionValue2, element) {
1727
2039
  super(unresolvedKeyframes, onComplete, name, motionValue2, element, true);
@@ -1849,6 +2161,12 @@ function canAnimate(keyframes2, name, type, velocity) {
1849
2161
  }
1850
2162
  return hasKeyframesChanged(keyframes2) || (type === "spring" || isGenerator(type)) && velocity;
1851
2163
  }
2164
+ const isNotNull = (value) => value !== null;
2165
+ function getFinalKeyframe(keyframes2, { repeat, repeatType = "loop" }, finalKeyframe) {
2166
+ const resolvedKeyframes = keyframes2.filter(isNotNull);
2167
+ const index = repeat && repeatType !== "loop" && repeat % 2 === 1 ? 0 : resolvedKeyframes.length - 1;
2168
+ return !index || finalKeyframe === void 0 ? resolvedKeyframes[index] : finalKeyframe;
2169
+ }
1852
2170
  const MAX_RESOLVE_DELAY = 40;
1853
2171
  class BaseAnimation {
1854
2172
  constructor({ autoplay = true, delay: delay2 = 0, type = "keyframes", repeat = 0, repeatDelay = 0, repeatType = "loop", ...options }) {
@@ -1941,98 +2259,6 @@ class BaseAnimation {
1941
2259
  });
1942
2260
  }
1943
2261
  }
1944
- function inertia({ keyframes: keyframes2, velocity = 0, power = 0.8, timeConstant = 325, bounceDamping = 10, bounceStiffness = 500, modifyTarget, min, max, restDelta = 0.5, restSpeed }) {
1945
- const origin = keyframes2[0];
1946
- const state2 = {
1947
- done: false,
1948
- value: origin
1949
- };
1950
- const isOutOfBounds = (v) => min !== void 0 && v < min || max !== void 0 && v > max;
1951
- const nearestBoundary = (v) => {
1952
- if (min === void 0)
1953
- return max;
1954
- if (max === void 0)
1955
- return min;
1956
- return Math.abs(min - v) < Math.abs(max - v) ? min : max;
1957
- };
1958
- let amplitude = power * velocity;
1959
- const ideal = origin + amplitude;
1960
- const target = modifyTarget === void 0 ? ideal : modifyTarget(ideal);
1961
- if (target !== ideal)
1962
- amplitude = target - origin;
1963
- const calcDelta = (t) => -amplitude * Math.exp(-t / timeConstant);
1964
- const calcLatest = (t) => target + calcDelta(t);
1965
- const applyFriction = (t) => {
1966
- const delta = calcDelta(t);
1967
- const latest = calcLatest(t);
1968
- state2.done = Math.abs(delta) <= restDelta;
1969
- state2.value = state2.done ? target : latest;
1970
- };
1971
- let timeReachedBoundary;
1972
- let spring$1;
1973
- const checkCatchBoundary = (t) => {
1974
- if (!isOutOfBounds(state2.value))
1975
- return;
1976
- timeReachedBoundary = t;
1977
- spring$1 = spring({
1978
- keyframes: [state2.value, nearestBoundary(state2.value)],
1979
- velocity: calcGeneratorVelocity(calcLatest, t, state2.value),
1980
- // TODO: This should be passing * 1000
1981
- damping: bounceDamping,
1982
- stiffness: bounceStiffness,
1983
- restDelta,
1984
- restSpeed
1985
- });
1986
- };
1987
- checkCatchBoundary(0);
1988
- return {
1989
- calculatedDuration: null,
1990
- next: (t) => {
1991
- let hasUpdatedFrame = false;
1992
- if (!spring$1 && timeReachedBoundary === void 0) {
1993
- hasUpdatedFrame = true;
1994
- applyFriction(t);
1995
- checkCatchBoundary(t);
1996
- }
1997
- if (timeReachedBoundary !== void 0 && t >= timeReachedBoundary) {
1998
- return spring$1.next(t - timeReachedBoundary);
1999
- } else {
2000
- !hasUpdatedFrame && applyFriction(t);
2001
- return state2;
2002
- }
2003
- }
2004
- };
2005
- }
2006
- const easeIn = /* @__PURE__ */ cubicBezier(0.42, 0, 1, 1);
2007
- const easeOut = /* @__PURE__ */ cubicBezier(0, 0, 0.58, 1);
2008
- const easeInOut = /* @__PURE__ */ cubicBezier(0.42, 0, 0.58, 1);
2009
- const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0] === "number";
2010
- const easingLookup = {
2011
- linear: noop,
2012
- easeIn,
2013
- easeInOut,
2014
- easeOut,
2015
- circIn,
2016
- circInOut,
2017
- circOut,
2018
- backIn,
2019
- backInOut,
2020
- backOut,
2021
- anticipate
2022
- };
2023
- const easingDefinitionToFunction = (definition) => {
2024
- if (isBezierDefinition(definition)) {
2025
- exports.invariant(definition.length === 4, `Cubic bezier arrays must contain four numerical values.`);
2026
- const [x1, y1, x2, y2] = definition;
2027
- return cubicBezier(x1, y1, x2, y2);
2028
- } else if (typeof definition === "string") {
2029
- exports.invariant(easingLookup[definition] !== void 0, `Invalid easing type '${definition}'`);
2030
- return easingLookup[definition];
2031
- }
2032
- return definition;
2033
- };
2034
- const combineFunctions = (a, b) => (v) => b(a(v));
2035
- const pipe = (...transformers) => transformers.reduce(combineFunctions);
2036
2262
  function hueToRgb(p, q, t) {
2037
2263
  if (t < 0)
2038
2264
  t += 1;
@@ -2105,6 +2331,8 @@ const mixColor = (from, to) => {
2105
2331
  return rgba.transform(blended);
2106
2332
  };
2107
2333
  };
2334
+ const combineFunctions = (a, b) => (v) => b(a(v));
2335
+ const pipe = (...transformers) => transformers.reduce(combineFunctions);
2108
2336
  const invisibleValues = /* @__PURE__ */ new Set(["none", "hidden"]);
2109
2337
  function mixVisibility(origin, target) {
2110
2338
  if (invisibleValues.has(origin)) {
@@ -2189,6 +2417,95 @@ function mix(from, to, p) {
2189
2417
  const mixer = getMixer$1(from);
2190
2418
  return mixer(from, to);
2191
2419
  }
2420
+ function inertia({ keyframes: keyframes2, velocity = 0, power = 0.8, timeConstant = 325, bounceDamping = 10, bounceStiffness = 500, modifyTarget, min, max, restDelta = 0.5, restSpeed }) {
2421
+ const origin = keyframes2[0];
2422
+ const state2 = {
2423
+ done: false,
2424
+ value: origin
2425
+ };
2426
+ const isOutOfBounds = (v) => min !== void 0 && v < min || max !== void 0 && v > max;
2427
+ const nearestBoundary = (v) => {
2428
+ if (min === void 0)
2429
+ return max;
2430
+ if (max === void 0)
2431
+ return min;
2432
+ return Math.abs(min - v) < Math.abs(max - v) ? min : max;
2433
+ };
2434
+ let amplitude = power * velocity;
2435
+ const ideal = origin + amplitude;
2436
+ const target = modifyTarget === void 0 ? ideal : modifyTarget(ideal);
2437
+ if (target !== ideal)
2438
+ amplitude = target - origin;
2439
+ const calcDelta = (t) => -amplitude * Math.exp(-t / timeConstant);
2440
+ const calcLatest = (t) => target + calcDelta(t);
2441
+ const applyFriction = (t) => {
2442
+ const delta = calcDelta(t);
2443
+ const latest = calcLatest(t);
2444
+ state2.done = Math.abs(delta) <= restDelta;
2445
+ state2.value = state2.done ? target : latest;
2446
+ };
2447
+ let timeReachedBoundary;
2448
+ let spring$1;
2449
+ const checkCatchBoundary = (t) => {
2450
+ if (!isOutOfBounds(state2.value))
2451
+ return;
2452
+ timeReachedBoundary = t;
2453
+ spring$1 = spring({
2454
+ keyframes: [state2.value, nearestBoundary(state2.value)],
2455
+ velocity: calcGeneratorVelocity(calcLatest, t, state2.value),
2456
+ // TODO: This should be passing * 1000
2457
+ damping: bounceDamping,
2458
+ stiffness: bounceStiffness,
2459
+ restDelta,
2460
+ restSpeed
2461
+ });
2462
+ };
2463
+ checkCatchBoundary(0);
2464
+ return {
2465
+ calculatedDuration: null,
2466
+ next: (t) => {
2467
+ let hasUpdatedFrame = false;
2468
+ if (!spring$1 && timeReachedBoundary === void 0) {
2469
+ hasUpdatedFrame = true;
2470
+ applyFriction(t);
2471
+ checkCatchBoundary(t);
2472
+ }
2473
+ if (timeReachedBoundary !== void 0 && t >= timeReachedBoundary) {
2474
+ return spring$1.next(t - timeReachedBoundary);
2475
+ } else {
2476
+ !hasUpdatedFrame && applyFriction(t);
2477
+ return state2;
2478
+ }
2479
+ }
2480
+ };
2481
+ }
2482
+ const easeIn = /* @__PURE__ */ cubicBezier(0.42, 0, 1, 1);
2483
+ const easeOut = /* @__PURE__ */ cubicBezier(0, 0, 0.58, 1);
2484
+ const easeInOut = /* @__PURE__ */ cubicBezier(0.42, 0, 0.58, 1);
2485
+ const easingLookup = {
2486
+ linear: noop,
2487
+ easeIn,
2488
+ easeInOut,
2489
+ easeOut,
2490
+ circIn,
2491
+ circInOut,
2492
+ circOut,
2493
+ backIn,
2494
+ backInOut,
2495
+ backOut,
2496
+ anticipate
2497
+ };
2498
+ const easingDefinitionToFunction = (definition) => {
2499
+ if (isBezierDefinition(definition)) {
2500
+ exports.invariant(definition.length === 4, `Cubic bezier arrays must contain four numerical values.`);
2501
+ const [x1, y1, x2, y2] = definition;
2502
+ return cubicBezier(x1, y1, x2, y2);
2503
+ } else if (typeof definition === "string") {
2504
+ exports.invariant(easingLookup[definition] !== void 0, `Invalid easing type '${definition}'`);
2505
+ return easingLookup[definition];
2506
+ }
2507
+ return definition;
2508
+ };
2192
2509
  function createMixers(output, ease2, customMixer) {
2193
2510
  const mixers = [];
2194
2511
  const mixerFactory = customMixer || mix;
@@ -2208,8 +2525,9 @@ function interpolate(input, output, { clamp: isClamp = true, ease: ease2, mixer
2208
2525
  exports.invariant(inputLength === output.length, "Both input and output ranges must be the same length");
2209
2526
  if (inputLength === 1)
2210
2527
  return () => output[0];
2211
- if (inputLength === 2 && input[0] === input[1])
2528
+ if (inputLength === 2 && output[0] === output[1])
2212
2529
  return () => output[1];
2530
+ const isZeroDeltaRange = input[0] === input[1];
2213
2531
  if (input[0] > input[inputLength - 1]) {
2214
2532
  input = [...input].reverse();
2215
2533
  output = [...output].reverse();
@@ -2217,6 +2535,8 @@ function interpolate(input, output, { clamp: isClamp = true, ease: ease2, mixer
2217
2535
  const mixers = createMixers(output, ease2, mixer);
2218
2536
  const numMixers = mixers.length;
2219
2537
  const interpolator = (v) => {
2538
+ if (isZeroDeltaRange && v < input[0])
2539
+ return output[0];
2220
2540
  let i = 0;
2221
2541
  if (numMixers > 1) {
2222
2542
  for (; i < input.length - 2; i++) {
@@ -2536,59 +2856,13 @@ function animateValue(options) {
2536
2856
  }
2537
2857
  const acceleratedValues = /* @__PURE__ */ new Set([
2538
2858
  "opacity",
2539
- "clipPath",
2540
- "filter",
2541
- "transform"
2542
- // TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved
2543
- // or until we implement support for linear() easing.
2544
- // "background-color"
2545
- ]);
2546
- const supportsFlags = {
2547
- linearEasing: void 0
2548
- };
2549
- function memoSupports(callback, supportsFlag) {
2550
- const memoized = memo(callback);
2551
- return () => {
2552
- var _a;
2553
- return (_a = supportsFlags[supportsFlag]) !== null && _a !== void 0 ? _a : memoized();
2554
- };
2555
- }
2556
- const supportsLinearEasing = /* @__PURE__ */ memoSupports(() => {
2557
- try {
2558
- document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" });
2559
- } catch (e) {
2560
- return false;
2561
- }
2562
- return true;
2563
- }, "linearEasing");
2564
- function isWaapiSupportedEasing(easing) {
2565
- return Boolean(typeof easing === "function" && supportsLinearEasing() || !easing || typeof easing === "string" && (easing in supportedWaapiEasing || supportsLinearEasing()) || isBezierDefinition(easing) || Array.isArray(easing) && easing.every(isWaapiSupportedEasing));
2566
- }
2567
- const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
2568
- const supportedWaapiEasing = {
2569
- linear: "linear",
2570
- ease: "ease",
2571
- easeIn: "ease-in",
2572
- easeOut: "ease-out",
2573
- easeInOut: "ease-in-out",
2574
- circIn: /* @__PURE__ */ cubicBezierAsString([0, 0.65, 0.55, 1]),
2575
- circOut: /* @__PURE__ */ cubicBezierAsString([0.55, 0, 1, 0.45]),
2576
- backIn: /* @__PURE__ */ cubicBezierAsString([0.31, 0.01, 0.66, -0.59]),
2577
- backOut: /* @__PURE__ */ cubicBezierAsString([0.33, 1.53, 0.69, 0.99])
2578
- };
2579
- function mapEasingToNativeEasing(easing, duration) {
2580
- if (!easing) {
2581
- return void 0;
2582
- } else if (typeof easing === "function" && supportsLinearEasing()) {
2583
- return generateLinearEasing(easing, duration);
2584
- } else if (isBezierDefinition(easing)) {
2585
- return cubicBezierAsString(easing);
2586
- } else if (Array.isArray(easing)) {
2587
- return easing.map((segmentEasing) => mapEasingToNativeEasing(segmentEasing, duration) || supportedWaapiEasing.easeOut);
2588
- } else {
2589
- return supportedWaapiEasing[easing];
2590
- }
2591
- }
2859
+ "clipPath",
2860
+ "filter",
2861
+ "transform"
2862
+ // TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved
2863
+ // or until we implement support for linear() easing.
2864
+ // "background-color"
2865
+ ]);
2592
2866
  function startWaapiAnimation(element, valueName, keyframes2, { delay: delay2 = 0, duration = 300, repeat = 0, repeatType = "loop", ease: ease2 = "easeInOut", times } = {}) {
2593
2867
  const keyframeOptions = { [valueName]: keyframes2 };
2594
2868
  if (times)
@@ -2605,10 +2879,6 @@ function startWaapiAnimation(element, valueName, keyframes2, { delay: delay2 = 0
2605
2879
  direction: repeatType === "reverse" ? "alternate" : "normal"
2606
2880
  });
2607
2881
  }
2608
- function attachTimeline(animation, timeline) {
2609
- animation.timeline = timeline;
2610
- animation.onfinish = null;
2611
- }
2612
2882
  const supportsWaapi = /* @__PURE__ */ memo(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
2613
2883
  const sampleDelta = 10;
2614
2884
  const maxDuration = 2e4;
@@ -2834,11 +3104,40 @@ class AcceleratedAnimation extends BaseAnimation {
2834
3104
  !motionValue2.owner.getProps().onUpdate && !repeatDelay && repeatType !== "mirror" && damping !== 0 && type !== "inertia";
2835
3105
  }
2836
3106
  }
3107
+ const underDampedSpring = {
3108
+ type: "spring",
3109
+ stiffness: 500,
3110
+ damping: 25,
3111
+ restSpeed: 10
3112
+ };
3113
+ const criticallyDampedSpring = (target) => ({
3114
+ type: "spring",
3115
+ stiffness: 550,
3116
+ damping: target === 0 ? 2 * Math.sqrt(550) : 30,
3117
+ restSpeed: 10
3118
+ });
3119
+ const keyframesTransition = {
3120
+ type: "keyframes",
3121
+ duration: 0.8
3122
+ };
3123
+ const ease = {
3124
+ type: "keyframes",
3125
+ ease: [0.25, 0.1, 0.35, 1],
3126
+ duration: 0.3
3127
+ };
3128
+ const getDefaultTransition = (valueKey, { keyframes: keyframes2 }) => {
3129
+ if (keyframes2.length > 2) {
3130
+ return keyframesTransition;
3131
+ } else if (transformProps.has(valueKey)) {
3132
+ return valueKey.startsWith("scale") ? criticallyDampedSpring(keyframes2[1]) : underDampedSpring;
3133
+ }
3134
+ return ease;
3135
+ };
2837
3136
  function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, elapsed, ...transition }) {
2838
3137
  return !!Object.keys(transition).length;
2839
3138
  }
2840
3139
  const animateMotionValue = (name, value, target, transition = {}, element, isHandoff) => (onComplete) => {
2841
- const valueTransition = getValueTransition(transition, name) || {};
3140
+ const valueTransition = getValueTransition$1(transition, name) || {};
2842
3141
  const delay2 = valueTransition.delay || transition.delay || 0;
2843
3142
  let { elapsed = 0 } = transition;
2844
3143
  elapsed = elapsed - secondsToMilliseconds$1(delay2);
@@ -2898,72 +3197,6 @@ const animateMotionValue = (name, value, target, transition = {}, element, isHan
2898
3197
  return new MainThreadAnimation(options);
2899
3198
  }
2900
3199
  };
2901
- const isKeyframesTarget = (v) => {
2902
- return Array.isArray(v);
2903
- };
2904
- const isCustomValue = (v) => {
2905
- return Boolean(v && typeof v === "object" && v.mix && v.toValue);
2906
- };
2907
- const resolveFinalValueInKeyframes = (v) => {
2908
- return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
2909
- };
2910
- function getValueState(visualElement) {
2911
- const state2 = [{}, {}];
2912
- visualElement === null || visualElement === void 0 ? void 0 : visualElement.values.forEach((value, key) => {
2913
- state2[0][key] = value.get();
2914
- state2[1][key] = value.getVelocity();
2915
- });
2916
- return state2;
2917
- }
2918
- function resolveVariantFromProps(props, definition, custom, visualElement) {
2919
- if (typeof definition === "function") {
2920
- const [current, velocity] = getValueState(visualElement);
2921
- definition = definition(custom !== void 0 ? custom : props.custom, current, velocity);
2922
- }
2923
- if (typeof definition === "string") {
2924
- definition = props.variants && props.variants[definition];
2925
- }
2926
- if (typeof definition === "function") {
2927
- const [current, velocity] = getValueState(visualElement);
2928
- definition = definition(custom !== void 0 ? custom : props.custom, current, velocity);
2929
- }
2930
- return definition;
2931
- }
2932
- function resolveVariant$1(visualElement, definition, custom) {
2933
- const props = visualElement.getProps();
2934
- return resolveVariantFromProps(props, definition, props.custom, visualElement);
2935
- }
2936
- function setMotionValue(visualElement, key, value) {
2937
- if (visualElement.hasValue(key)) {
2938
- visualElement.getValue(key).set(value);
2939
- } else {
2940
- visualElement.addValue(key, motionValue(value));
2941
- }
2942
- }
2943
- function setTarget(visualElement, definition) {
2944
- const resolved = resolveVariant$1(visualElement, definition);
2945
- let { transitionEnd = {}, transition = {}, ...target } = resolved || {};
2946
- target = { ...target, ...transitionEnd };
2947
- for (const key in target) {
2948
- const value = resolveFinalValueInKeyframes(target[key]);
2949
- setMotionValue(visualElement, key, value);
2950
- }
2951
- }
2952
- const camelToDash = (str) => str.replace(/([a-z])([A-Z])/gu, "$1-$2").toLowerCase();
2953
- const optimizedAppearDataId = "framerAppearId";
2954
- const optimizedAppearDataAttribute = "data-" + camelToDash(optimizedAppearDataId);
2955
- function getOptimisedAppearId(visualElement) {
2956
- return visualElement.props[optimizedAppearDataAttribute];
2957
- }
2958
- function isWillChangeMotionValue$1(value) {
2959
- return Boolean(isMotionValue$1(value) && value.add);
2960
- }
2961
- function addValueToWillChange$1(visualElement, key) {
2962
- const willChange = visualElement.getValue("willChange");
2963
- if (isWillChangeMotionValue$1(willChange)) {
2964
- return willChange.add(key);
2965
- }
2966
- }
2967
3200
  function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
2968
3201
  const shouldBlock = protectedKeys.hasOwnProperty(key) && needsAnimating[key] !== true;
2969
3202
  needsAnimating[key] = false;
@@ -2984,7 +3217,7 @@ function animateTarget(visualElement, targetAndTransition, { delay: delay2 = 0,
2984
3217
  }
2985
3218
  const valueTransition = {
2986
3219
  delay: delay2,
2987
- ...getValueTransition(transition || {}, key)
3220
+ ...getValueTransition$1(transition || {}, key)
2988
3221
  };
2989
3222
  let isHandoff = false;
2990
3223
  if (window.MotionHandoffAnimation) {
@@ -2998,7 +3231,7 @@ function animateTarget(visualElement, targetAndTransition, { delay: delay2 = 0,
2998
3231
  }
2999
3232
  }
3000
3233
  addValueToWillChange$1(visualElement, key);
3001
- value.start(animateMotionValue(key, value, valueTarget, visualElement.shouldReduceMotion && transformProps.has(key) ? { type: false } : valueTransition, visualElement, isHandoff));
3234
+ value.start(animateMotionValue(key, value, valueTarget, visualElement.shouldReduceMotion && positionalKeys.has(key) ? { type: false } : valueTransition, visualElement, isHandoff));
3002
3235
  const animation = value.animation;
3003
3236
  if (animation) {
3004
3237
  animations.push(animation);
@@ -3016,33 +3249,46 @@ function animateTarget(visualElement, targetAndTransition, { delay: delay2 = 0,
3016
3249
  function isSVGElement$2(element) {
3017
3250
  return element instanceof SVGElement && element.tagName !== "svg";
3018
3251
  }
3019
- const scaleCorrectors = {};
3020
- function addScaleCorrector(correctors) {
3021
- Object.assign(scaleCorrectors, correctors);
3022
- }
3023
- function isForcedMotionValue(key, { layout, layoutId }) {
3024
- return transformProps.has(key) || key.startsWith("origin") || (layout || layoutId !== void 0) && (!!scaleCorrectors[key] || key === "opacity");
3025
- }
3026
- function scrapeMotionValuesFromProps$1(props, prevProps, visualElement) {
3027
- var _a;
3028
- const { style: style2 } = props;
3029
- const newValues = {};
3030
- for (const key in style2) {
3031
- if (isMotionValue$1(style2[key]) || prevProps.style && isMotionValue$1(prevProps.style[key]) || isForcedMotionValue(key, props) || ((_a = visualElement === null || visualElement === void 0 ? void 0 : visualElement.getValue(key)) === null || _a === void 0 ? void 0 : _a.liveStyle) !== void 0) {
3032
- newValues[key] = style2[key];
3033
- }
3034
- }
3035
- return newValues;
3036
- }
3037
- function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
3038
- const newValues = scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
3039
- for (const key in props) {
3040
- if (isMotionValue$1(props[key]) || isMotionValue$1(prevProps[key])) {
3041
- const targetKey = transformPropOrder.indexOf(key) !== -1 ? "attr" + key.charAt(0).toUpperCase() + key.substring(1) : key;
3042
- newValues[targetKey] = props[key];
3043
- }
3044
- }
3045
- return newValues;
3252
+ const createAxisDelta = () => ({
3253
+ translate: 0,
3254
+ scale: 1,
3255
+ origin: 0,
3256
+ originPoint: 0
3257
+ });
3258
+ const createDelta = () => ({
3259
+ x: createAxisDelta(),
3260
+ y: createAxisDelta()
3261
+ });
3262
+ const createAxis$1 = () => ({ min: 0, max: 0 });
3263
+ const createBox$1 = () => ({
3264
+ x: createAxis$1(),
3265
+ y: createAxis$1()
3266
+ });
3267
+ const featureProps = {
3268
+ animation: [
3269
+ "animate",
3270
+ "variants",
3271
+ "whileHover",
3272
+ "whileTap",
3273
+ "exit",
3274
+ "whileInView",
3275
+ "whileFocus",
3276
+ "whileDrag"
3277
+ ],
3278
+ exit: ["exit"],
3279
+ drag: ["drag", "dragControls"],
3280
+ focus: ["whileFocus"],
3281
+ hover: ["whileHover", "onHoverStart", "onHoverEnd"],
3282
+ tap: ["whileTap", "onTap", "onTapStart", "onTapCancel"],
3283
+ pan: ["onPan", "onPanStart", "onPanSessionStart", "onPanEnd"],
3284
+ inView: ["whileInView", "onViewportEnter", "onViewportLeave"],
3285
+ layout: ["layout", "layoutId"]
3286
+ };
3287
+ const featureDefinitions = {};
3288
+ for (const key in featureProps) {
3289
+ featureDefinitions[key] = {
3290
+ isEnabled: (props) => featureProps[key].some((name) => !!props[name])
3291
+ };
3046
3292
  }
3047
3293
  const isBrowser = typeof window !== "undefined";
3048
3294
  const prefersReducedMotion = { current: null };
@@ -3060,6 +3306,8 @@ function initPrefersReducedMotion() {
3060
3306
  prefersReducedMotion.current = false;
3061
3307
  }
3062
3308
  }
3309
+ const valueTypes = [...dimensionValueTypes, color, complex];
3310
+ const findValueType = (v) => valueTypes.find(testValueType(v));
3063
3311
  function isAnimationControls(v) {
3064
3312
  return v !== null && typeof v === "object" && typeof v.start === "function";
3065
3313
  }
@@ -3089,7 +3337,7 @@ function updateMotionValuesFromProps(element, next, prev) {
3089
3337
  if (isMotionValue$1(nextValue)) {
3090
3338
  element.addValue(key, nextValue);
3091
3339
  if (process.env.NODE_ENV === "development") {
3092
- warnOnce(nextValue.version === "11.15.0", `Attempting to mix Motion versions ${nextValue.version} with 11.15.0 may not work as expected.`);
3340
+ warnOnce(nextValue.version === "11.16.6", `Attempting to mix Motion versions ${nextValue.version} with 11.16.6 may not work as expected.`);
3093
3341
  }
3094
3342
  } else if (isMotionValue$1(prevValue)) {
3095
3343
  element.addValue(key, motionValue(nextValue, { owner: element }));
@@ -3113,49 +3361,6 @@ function updateMotionValuesFromProps(element, next, prev) {
3113
3361
  }
3114
3362
  return next;
3115
3363
  }
3116
- const featureProps = {
3117
- animation: [
3118
- "animate",
3119
- "variants",
3120
- "whileHover",
3121
- "whileTap",
3122
- "exit",
3123
- "whileInView",
3124
- "whileFocus",
3125
- "whileDrag"
3126
- ],
3127
- exit: ["exit"],
3128
- drag: ["drag", "dragControls"],
3129
- focus: ["whileFocus"],
3130
- hover: ["whileHover", "onHoverStart", "onHoverEnd"],
3131
- tap: ["whileTap", "onTap", "onTapStart", "onTapCancel"],
3132
- pan: ["onPan", "onPanStart", "onPanSessionStart", "onPanEnd"],
3133
- inView: ["whileInView", "onViewportEnter", "onViewportLeave"],
3134
- layout: ["layout", "layoutId"]
3135
- };
3136
- const featureDefinitions = {};
3137
- for (const key in featureProps) {
3138
- featureDefinitions[key] = {
3139
- isEnabled: (props) => featureProps[key].some((name) => !!props[name])
3140
- };
3141
- }
3142
- const valueTypes = [...dimensionValueTypes, color, complex];
3143
- const findValueType = (v) => valueTypes.find(testValueType(v));
3144
- const createAxisDelta = () => ({
3145
- translate: 0,
3146
- scale: 1,
3147
- origin: 0,
3148
- originPoint: 0
3149
- });
3150
- const createDelta = () => ({
3151
- x: createAxisDelta(),
3152
- y: createAxisDelta()
3153
- });
3154
- const createAxis$1 = () => ({ min: 0, max: 0 });
3155
- const createBox$1 = () => ({
3156
- x: createAxis$1(),
3157
- y: createAxis$1()
3158
- });
3159
3364
  const propEventHandlers = [
3160
3365
  "AnimationStart",
3161
3366
  "AnimationComplete",
@@ -3701,6 +3906,7 @@ const camelCaseAttributes = /* @__PURE__ */ new Set([
3701
3906
  "textLength",
3702
3907
  "lengthAdjust"
3703
3908
  ]);
3909
+ const isSVGTag = (tag) => typeof tag === "string" && tag.toLowerCase() === "svg";
3704
3910
  function renderHTML(element, { style: style2, vars }, styleProp, projection) {
3705
3911
  Object.assign(element.style, style2, projection && projection.getProjectionStyles(styleProp));
3706
3912
  for (const key in vars) {
@@ -3713,7 +3919,34 @@ function renderSVG(element, renderState, _styleProp, projection) {
3713
3919
  element.setAttribute(!camelCaseAttributes.has(key) ? camelToDash(key) : key, renderState.attrs[key]);
3714
3920
  }
3715
3921
  }
3716
- const isSVGTag = (tag) => typeof tag === "string" && tag.toLowerCase() === "svg";
3922
+ const scaleCorrectors = {};
3923
+ function addScaleCorrector(correctors) {
3924
+ Object.assign(scaleCorrectors, correctors);
3925
+ }
3926
+ function isForcedMotionValue(key, { layout, layoutId }) {
3927
+ return transformProps.has(key) || key.startsWith("origin") || (layout || layoutId !== void 0) && (!!scaleCorrectors[key] || key === "opacity");
3928
+ }
3929
+ function scrapeMotionValuesFromProps$1(props, prevProps, visualElement) {
3930
+ var _a;
3931
+ const { style: style2 } = props;
3932
+ const newValues = {};
3933
+ for (const key in style2) {
3934
+ if (isMotionValue$1(style2[key]) || prevProps.style && isMotionValue$1(prevProps.style[key]) || isForcedMotionValue(key, props) || ((_a = visualElement === null || visualElement === void 0 ? void 0 : visualElement.getValue(key)) === null || _a === void 0 ? void 0 : _a.liveStyle) !== void 0) {
3935
+ newValues[key] = style2[key];
3936
+ }
3937
+ }
3938
+ return newValues;
3939
+ }
3940
+ function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
3941
+ const newValues = scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
3942
+ for (const key in props) {
3943
+ if (isMotionValue$1(props[key]) || isMotionValue$1(prevProps[key])) {
3944
+ const targetKey = transformPropOrder.indexOf(key) !== -1 ? "attr" + key.charAt(0).toUpperCase() + key.substring(1) : key;
3945
+ newValues[targetKey] = props[key];
3946
+ }
3947
+ }
3948
+ return newValues;
3949
+ }
3717
3950
  class SVGVisualElement extends DOMVisualElement {
3718
3951
  constructor() {
3719
3952
  super(...arguments);
@@ -4044,12 +4277,9 @@ function getElementAnimationState(element) {
4044
4277
  state.set(element, animationState);
4045
4278
  return state.get(element);
4046
4279
  }
4047
- class NativeAnimation {
4280
+ class NativeAnimation extends NativeAnimationControls {
4048
4281
  constructor(element, valueName, valueKeyframes, options) {
4049
4282
  const isCSSVar = valueName.startsWith("--");
4050
- this.setValue = isCSSVar ? setCSSVar : setStyle;
4051
- this.options = options;
4052
- this.updateFinishedPromise();
4053
4283
  exports.invariant(typeof options.type !== "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "framer-motion"?`);
4054
4284
  const existingAnimation = getElementAnimationState(element).get(valueName);
4055
4285
  existingAnimation && existingAnimation.stop();
@@ -4068,92 +4298,34 @@ class NativeAnimation {
4068
4298
  } else {
4069
4299
  options.ease = options.ease || defaultEasing;
4070
4300
  }
4071
- this.removeAnimation = () => {
4072
- var _a;
4073
- return (_a = state.get(element)) === null || _a === void 0 ? void 0 : _a.delete(valueName);
4074
- };
4075
4301
  const onFinish = () => {
4076
- this.setValue(element, valueName, getFinalKeyframe(valueKeyframes, this.options));
4302
+ this.setValue(element, valueName, getFinalKeyframe(valueKeyframes, options));
4077
4303
  this.cancel();
4078
4304
  this.resolveFinishedPromise();
4079
4305
  };
4306
+ const init = () => {
4307
+ this.setValue = isCSSVar ? setCSSVar : setStyle;
4308
+ this.options = options;
4309
+ this.updateFinishedPromise();
4310
+ this.removeAnimation = () => {
4311
+ var _a;
4312
+ return (_a = state.get(element)) === null || _a === void 0 ? void 0 : _a.delete(valueName);
4313
+ };
4314
+ };
4080
4315
  if (!supportsWaapi()) {
4316
+ super();
4317
+ init();
4081
4318
  onFinish();
4082
4319
  } else {
4083
- this.animation = startWaapiAnimation(element, valueName, valueKeyframes, options);
4320
+ super(startWaapiAnimation(element, valueName, valueKeyframes, options));
4321
+ init();
4084
4322
  if (options.autoplay === false) {
4085
4323
  this.animation.pause();
4086
4324
  }
4087
4325
  this.animation.onfinish = onFinish;
4088
- if (this.pendingTimeline) {
4089
- attachTimeline(this.animation, this.pendingTimeline);
4090
- }
4091
4326
  getElementAnimationState(element).set(valueName, this);
4092
4327
  }
4093
4328
  }
4094
- get duration() {
4095
- return millisecondsToSeconds$1(this.options.duration || 300);
4096
- }
4097
- get time() {
4098
- var _a;
4099
- if (this.animation) {
4100
- return millisecondsToSeconds$1(((_a = this.animation) === null || _a === void 0 ? void 0 : _a.currentTime) || 0);
4101
- }
4102
- return 0;
4103
- }
4104
- set time(newTime) {
4105
- if (this.animation) {
4106
- this.animation.currentTime = secondsToMilliseconds$1(newTime);
4107
- }
4108
- }
4109
- get speed() {
4110
- return this.animation ? this.animation.playbackRate : 1;
4111
- }
4112
- set speed(newSpeed) {
4113
- if (this.animation) {
4114
- this.animation.playbackRate = newSpeed;
4115
- }
4116
- }
4117
- get state() {
4118
- return this.animation ? this.animation.playState : "finished";
4119
- }
4120
- get startTime() {
4121
- return this.animation ? this.animation.startTime : null;
4122
- }
4123
- flatten() {
4124
- var _a;
4125
- if (!this.animation)
4126
- return;
4127
- (_a = this.animation.effect) === null || _a === void 0 ? void 0 : _a.updateTiming({ easing: "linear" });
4128
- }
4129
- play() {
4130
- if (this.state === "finished") {
4131
- this.updateFinishedPromise();
4132
- }
4133
- this.animation && this.animation.play();
4134
- }
4135
- pause() {
4136
- this.animation && this.animation.pause();
4137
- }
4138
- stop() {
4139
- if (!this.animation || this.state === "idle" || this.state === "finished") {
4140
- return;
4141
- }
4142
- if (this.animation.commitStyles) {
4143
- this.animation.commitStyles();
4144
- }
4145
- this.cancel();
4146
- }
4147
- complete() {
4148
- this.animation && this.animation.finish();
4149
- }
4150
- cancel() {
4151
- this.removeAnimation();
4152
- try {
4153
- this.animation && this.animation.cancel();
4154
- } catch (e) {
4155
- }
4156
- }
4157
4329
  /**
4158
4330
  * Allows the returned animation to be awaited or promise-chained. Currently
4159
4331
  * resolves when the animation finishes at all but in a future update could/should
@@ -4167,17 +4339,19 @@ class NativeAnimation {
4167
4339
  this.resolveFinishedPromise = resolve;
4168
4340
  });
4169
4341
  }
4170
- attachTimeline(timeline) {
4171
- if (!this.animation) {
4172
- this.pendingTimeline = timeline;
4173
- } else {
4174
- attachTimeline(this.animation, timeline);
4342
+ play() {
4343
+ if (this.state === "finished") {
4344
+ this.updateFinishedPromise();
4175
4345
  }
4176
- return noop;
4346
+ super.play();
4347
+ }
4348
+ cancel() {
4349
+ this.removeAnimation();
4350
+ super.cancel();
4177
4351
  }
4178
4352
  }
4179
4353
  function animateElements(elementOrSelector, keyframes2, options, scope) {
4180
- const elements = motionDom.resolveElements(elementOrSelector, scope);
4354
+ const elements = resolveElements(elementOrSelector, scope);
4181
4355
  const numElements = elements.length;
4182
4356
  exports.invariant(Boolean(numElements), "No valid element provided.");
4183
4357
  const animations = [];
@@ -4190,7 +4364,7 @@ function animateElements(elementOrSelector, keyframes2, options, scope) {
4190
4364
  for (const valueName in keyframes2) {
4191
4365
  const valueKeyframes = keyframes2[valueName];
4192
4366
  const valueOptions = {
4193
- ...getValueTransition(elementTransition, valueName)
4367
+ ...getValueTransition$1(elementTransition, valueName)
4194
4368
  };
4195
4369
  valueOptions.duration = valueOptions.duration ? secondsToMilliseconds$1(valueOptions.duration) : valueOptions.duration;
4196
4370
  valueOptions.delay = secondsToMilliseconds$1(valueOptions.delay || 0);
@@ -4206,6 +4380,20 @@ const createScopedWaapiAnimate = (scope) => {
4206
4380
  return scopedAnimate;
4207
4381
  };
4208
4382
  const animateMini = /* @__PURE__ */ createScopedWaapiAnimate();
4383
+ function observeTimeline(update, timeline) {
4384
+ let prevProgress;
4385
+ const onFrame = () => {
4386
+ const { currentTime } = timeline;
4387
+ const percentage = currentTime === null ? 0 : currentTime.value;
4388
+ const progress2 = percentage / 100;
4389
+ if (prevProgress !== progress2) {
4390
+ update(progress2);
4391
+ }
4392
+ prevProgress = progress2;
4393
+ };
4394
+ frame.update(onFrame, true);
4395
+ return () => cancelFrame(onFrame);
4396
+ }
4209
4397
  const resizeHandlers = /* @__PURE__ */ new WeakMap();
4210
4398
  let observer;
4211
4399
  function getElementSize(target, borderBoxSize) {
@@ -4244,7 +4432,7 @@ function createResizeObserver() {
4244
4432
  function resizeElement(target, handler) {
4245
4433
  if (!observer)
4246
4434
  createResizeObserver();
4247
- const elements = motionDom.resolveElements(target);
4435
+ const elements = resolveElements(target);
4248
4436
  elements.forEach((element) => {
4249
4437
  let elementHandlers = resizeHandlers.get(element);
4250
4438
  if (!elementHandlers) {
@@ -4373,24 +4561,6 @@ function calcInset(element, container) {
4373
4561
  }
4374
4562
  return inset;
4375
4563
  }
4376
- const ScrollOffset = {
4377
- Enter: [
4378
- [0, 1],
4379
- [1, 1]
4380
- ],
4381
- Exit: [
4382
- [0, 0],
4383
- [1, 0]
4384
- ],
4385
- Any: [
4386
- [1, 0],
4387
- [0, 1]
4388
- ],
4389
- All: [
4390
- [0, 0],
4391
- [1, 1]
4392
- ]
4393
- };
4394
4564
  const namedEdges = {
4395
4565
  start: 0,
4396
4566
  center: 0.5,
@@ -4439,6 +4609,24 @@ function resolveOffset(offset, containerLength, targetLength, targetInset) {
4439
4609
  containerPoint = resolveEdge(offsetDefinition[1], containerLength);
4440
4610
  return targetPoint - containerPoint;
4441
4611
  }
4612
+ const ScrollOffset = {
4613
+ Enter: [
4614
+ [0, 1],
4615
+ [1, 1]
4616
+ ],
4617
+ Exit: [
4618
+ [0, 0],
4619
+ [1, 0]
4620
+ ],
4621
+ Any: [
4622
+ [1, 0],
4623
+ [0, 1]
4624
+ ],
4625
+ All: [
4626
+ [0, 0],
4627
+ [1, 1]
4628
+ ]
4629
+ };
4442
4630
  const point = { x: 0, y: 0 };
4443
4631
  function getTargetSize(target) {
4444
4632
  return "getBBox" in target && target.tagName !== "svg" ? target.getBBox() : { width: target.clientWidth, height: target.clientHeight };
@@ -4464,10 +4652,10 @@ function resolveOffsets(container, info, options) {
4464
4652
  info[axis].offset[i] = offset;
4465
4653
  }
4466
4654
  if (hasChanged2) {
4467
- info[axis].interpolate = interpolate(info[axis].offset, defaultOffset$1(offsetDefinition));
4655
+ info[axis].interpolate = interpolate(info[axis].offset, defaultOffset$1(offsetDefinition), { clamp: false });
4468
4656
  info[axis].interpolatorOffsets = [...info[axis].offset];
4469
4657
  }
4470
- info[axis].progress = info[axis].interpolate(info[axis].current);
4658
+ info[axis].progress = clamp$1(0, 1, info[axis].interpolate(info[axis].current));
4471
4659
  }
4472
4660
  function measure(container, target = container, info) {
4473
4661
  info.x.targetOffset = 0;
@@ -4562,20 +4750,6 @@ function scrollInfo(onScroll, { container = document.documentElement, ...options
4562
4750
  }
4563
4751
  };
4564
4752
  }
4565
- function observeTimeline(update, timeline) {
4566
- let prevProgress;
4567
- const onFrame = () => {
4568
- const { currentTime } = timeline;
4569
- const percentage = currentTime === null ? 0 : currentTime.value;
4570
- const progress2 = percentage / 100;
4571
- if (prevProgress !== progress2) {
4572
- update(progress2);
4573
- }
4574
- prevProgress = progress2;
4575
- };
4576
- frame.update(onFrame, true);
4577
- return () => cancelFrame(onFrame);
4578
- }
4579
4753
  function scrollTimelineFallback({ source, container, axis = "y" }) {
4580
4754
  if (source)
4581
4755
  container = source;
@@ -4643,7 +4817,7 @@ const thresholds = {
4643
4817
  all: 1
4644
4818
  };
4645
4819
  function inView(elementOrSelector, onStart, { root, margin: rootMargin, amount = "some" } = {}) {
4646
- const elements = motionDom.resolveElements(elementOrSelector);
4820
+ const elements = resolveElements(elementOrSelector);
4647
4821
  const activeIntersections = /* @__PURE__ */ new WeakMap();
4648
4822
  const onIntersectionChange = (entries) => {
4649
4823
  entries.forEach((entry) => {
@@ -4657,7 +4831,7 @@ function inView(elementOrSelector, onStart, { root, margin: rootMargin, amount =
4657
4831
  } else {
4658
4832
  observer2.unobserve(entry.target);
4659
4833
  }
4660
- } else if (onEnd) {
4834
+ } else if (typeof onEnd === "function") {
4661
4835
  onEnd(entry);
4662
4836
  activeIntersections.delete(entry.target);
4663
4837
  }
@@ -4700,23 +4874,6 @@ function stagger(duration = 0.1, { startDelay = 0, from = 0, ease: ease2 } = {})
4700
4874
  return startDelay + delay2;
4701
4875
  };
4702
4876
  }
4703
- const isCustomValueType = (v) => {
4704
- return v && typeof v === "object" && v.mix;
4705
- };
4706
- const getMixer = (v) => isCustomValueType(v) ? v.mix : void 0;
4707
- function transform(...args) {
4708
- const useImmediate = !Array.isArray(args[0]);
4709
- const argOffset = useImmediate ? 0 : -1;
4710
- const inputValue = args[0 + argOffset];
4711
- const inputRange = args[1 + argOffset];
4712
- const outputRange = args[2 + argOffset];
4713
- const options = args[3 + argOffset];
4714
- const interpolator = interpolate(inputRange, outputRange, {
4715
- mixer: getMixer(outputRange[0]),
4716
- ...options
4717
- });
4718
- return useImmediate ? interpolator(inputValue) : interpolator;
4719
- }
4720
4877
  function delay(callback, timeout) {
4721
4878
  const start = time.now();
4722
4879
  const checkElapsed = ({ timestamp }) => {
@@ -4738,6 +4895,23 @@ function distance2D(a, b) {
4738
4895
  const yDelta = distance(a.y, b.y);
4739
4896
  return Math.sqrt(xDelta ** 2 + yDelta ** 2);
4740
4897
  }
4898
+ const isCustomValueType = (v) => {
4899
+ return v && typeof v === "object" && v.mix;
4900
+ };
4901
+ const getMixer = (v) => isCustomValueType(v) ? v.mix : void 0;
4902
+ function transform(...args) {
4903
+ const useImmediate = !Array.isArray(args[0]);
4904
+ const argOffset = useImmediate ? 0 : -1;
4905
+ const inputValue = args[0 + argOffset];
4906
+ const inputRange = args[1 + argOffset];
4907
+ const outputRange = args[2 + argOffset];
4908
+ const options = args[3 + argOffset];
4909
+ const interpolator = interpolate(inputRange, outputRange, {
4910
+ mixer: getMixer(outputRange[0]),
4911
+ ...options
4912
+ });
4913
+ return useImmediate ? interpolator(inputValue) : interpolator;
4914
+ }
4741
4915
  const sync = frame;
4742
4916
  const cancelSync = stepsOrder.reduce((acc, key) => {
4743
4917
  acc[key] = (process2) => cancelFrame(process2);
@@ -5126,17 +5300,25 @@ const Primitive = vue.defineComponent({
5126
5300
  as: {
5127
5301
  type: [String, Object],
5128
5302
  default: "div"
5303
+ },
5304
+ getProps: {
5305
+ type: Function,
5306
+ default: () => ({})
5129
5307
  }
5130
5308
  },
5131
5309
  setup(props, { attrs, slots }) {
5132
5310
  const asTag = props.asChild ? "template" : props.as;
5133
5311
  const SELF_CLOSING_TAGS = ["area", "img", "input"];
5134
- if (typeof asTag === "string" && SELF_CLOSING_TAGS.includes(asTag))
5135
- return () => vue.h(asTag, attrs);
5136
- if (asTag !== "template") {
5137
- return () => vue.h(props.as, attrs, { default: slots.default });
5138
- }
5139
- return () => vue.h(Slot, attrs, { default: slots.default });
5312
+ return () => {
5313
+ const motionProps = props.getProps();
5314
+ const allAttrs = { ...attrs, ...motionProps };
5315
+ if (typeof asTag === "string" && SELF_CLOSING_TAGS.includes(asTag))
5316
+ return vue.h(asTag, allAttrs);
5317
+ if (asTag !== "template") {
5318
+ return vue.h(props.as, allAttrs, { default: slots.default });
5319
+ }
5320
+ return vue.h(Slot, allAttrs, { default: slots.default });
5321
+ };
5140
5322
  }
5141
5323
  });
5142
5324
  class Feature {
@@ -5178,7 +5360,7 @@ class HoverGesture extends Feature {
5178
5360
  const element = this.state.element;
5179
5361
  if (!element)
5180
5362
  return;
5181
- this.unmount = motionDom.hover(
5363
+ this.unmount = hover(
5182
5364
  element,
5183
5365
  (startEvent) => {
5184
5366
  handleHoverEvent$1(this.state, startEvent, "Start");
@@ -5219,7 +5401,7 @@ class PressGesture extends Feature {
5219
5401
  const element = this.state.element;
5220
5402
  if (!element)
5221
5403
  return;
5222
- this.unmount = motionDom.press(
5404
+ this.unmount = press(
5223
5405
  element,
5224
5406
  (startEvent) => {
5225
5407
  handlePressEvent(this.state, startEvent, "Start");
@@ -5754,9 +5936,9 @@ class VisualElementDragControls {
5754
5936
  );
5755
5937
  }
5756
5938
  stop(event, info) {
5757
- const isDragging = this.isDragging;
5939
+ const isDragging2 = this.isDragging;
5758
5940
  this.cancel();
5759
- if (!isDragging)
5941
+ if (!isDragging2)
5760
5942
  return;
5761
5943
  const { velocity } = info;
5762
5944
  this.startAnimation(velocity);
@@ -6297,6 +6479,31 @@ class PanGesture extends Feature {
6297
6479
  this.session && this.session.end();
6298
6480
  }
6299
6481
  }
6482
+ const { schedule: microtask, cancel: cancelMicrotask } = createRenderBatcher(queueMicrotask, false);
6483
+ const compareByDepth = (a, b) => a.depth - b.depth;
6484
+ class FlatTree {
6485
+ constructor() {
6486
+ this.children = [];
6487
+ this.isDirty = false;
6488
+ }
6489
+ add(child) {
6490
+ addUniqueItem(this.children, child);
6491
+ this.isDirty = true;
6492
+ }
6493
+ remove(child) {
6494
+ removeItem(this.children, child);
6495
+ this.isDirty = true;
6496
+ }
6497
+ forEach(callback) {
6498
+ this.isDirty && this.children.sort(compareByDepth);
6499
+ this.isDirty = false;
6500
+ this.children.forEach(callback);
6501
+ }
6502
+ }
6503
+ function resolveMotionValue(value) {
6504
+ const unwrappedValue = isMotionValue$1(value) ? value.get() : value;
6505
+ return isCustomValue(unwrappedValue) ? unwrappedValue.toValue() : unwrappedValue;
6506
+ }
6300
6507
  const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
6301
6508
  const numBorders = borders.length;
6302
6509
  const asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
@@ -6588,31 +6795,6 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
6588
6795
  function eachAxis(callback) {
6589
6796
  return [callback("x"), callback("y")];
6590
6797
  }
6591
- const compareByDepth = (a, b) => a.depth - b.depth;
6592
- class FlatTree {
6593
- constructor() {
6594
- this.children = [];
6595
- this.isDirty = false;
6596
- }
6597
- add(child) {
6598
- addUniqueItem(this.children, child);
6599
- this.isDirty = true;
6600
- }
6601
- remove(child) {
6602
- removeItem(this.children, child);
6603
- this.isDirty = true;
6604
- }
6605
- forEach(callback) {
6606
- this.isDirty && this.children.sort(compareByDepth);
6607
- this.isDirty = false;
6608
- this.children.forEach(callback);
6609
- }
6610
- }
6611
- function resolveMotionValue(value) {
6612
- const unwrappedValue = isMotionValue$1(value) ? value.get() : value;
6613
- return isCustomValue(unwrappedValue) ? unwrappedValue.toValue() : unwrappedValue;
6614
- }
6615
- const { schedule: microtask, cancel: cancelMicrotask } = createRenderBatcher(queueMicrotask, false);
6616
6798
  const metrics = {
6617
6799
  type: "projectionFrame",
6618
6800
  totalNodes: 0,
@@ -6776,7 +6958,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6776
6958
  }
6777
6959
  this.setAnimationOrigin(delta, hasOnlyRelativeTargetChanged);
6778
6960
  const animationOptions = {
6779
- ...getValueTransition(layoutTransition, "layout"),
6961
+ ...getValueTransition$1(layoutTransition, "layout"),
6780
6962
  onPlay: onLayoutAnimationStart,
6781
6963
  onComplete: onLayoutAnimationComplete
6782
6964
  };
@@ -7804,9 +7986,6 @@ class FeatureManager {
7804
7986
  this.features.forEach((feature) => feature.beforeUnmount());
7805
7987
  }
7806
7988
  }
7807
- function scheduleAnimation(state2) {
7808
- state2.animateUpdates();
7809
- }
7810
7989
  function motionEvent(name, target, isExit) {
7811
7990
  return new CustomEvent(name, { detail: { target, isExit } });
7812
7991
  }
@@ -7881,14 +8060,14 @@ function animateVariantsChildren(state2, activeState, isFirstAnimate = false) {
7881
8060
  };
7882
8061
  }
7883
8062
  const STATE_TYPES = ["initial", "animate", "inView", "hover", "press", "whileDrag", "exit"];
7884
- const mountedStates = /* @__PURE__ */ new Map();
8063
+ const mountedStates = /* @__PURE__ */ new WeakMap();
7885
8064
  let id = 0;
7886
8065
  class MotionState {
7887
8066
  constructor(options, parent) {
7888
8067
  var _a;
7889
8068
  this.element = null;
7890
8069
  this.isSafeToRemove = false;
7891
- this.isFirstAnimate = true;
8070
+ this.isVShow = false;
7892
8071
  this.children = /* @__PURE__ */ new Set();
7893
8072
  this.activeStates = {
7894
8073
  // initial: true,
@@ -7896,7 +8075,6 @@ class MotionState {
7896
8075
  };
7897
8076
  this._context = null;
7898
8077
  this.id = `motion-state-${id++}`;
7899
- mountedStates.set(this.id, this);
7900
8078
  this.options = options;
7901
8079
  this.parent = parent;
7902
8080
  (_a = parent == null ? void 0 : parent.children) == null ? void 0 : _a.add(this);
@@ -7991,19 +8169,26 @@ class MotionState {
7991
8169
  this.featureManager.beforeUnmount();
7992
8170
  }
7993
8171
  unmount(unMountChildren = false) {
7994
- var _a, _b;
8172
+ var _a, _b, _c;
7995
8173
  mountedStates.delete(this.element);
7996
- mountedStates.delete(this.id);
7997
8174
  this.featureManager.unmount();
7998
- (_a = this.visualElement) == null ? void 0 : _a.unmount();
8175
+ if (unMountChildren) {
8176
+ frame.render(() => {
8177
+ var _a2;
8178
+ (_a2 = this.visualElement) == null ? void 0 : _a2.unmount();
8179
+ });
8180
+ } else {
8181
+ (_a = this.visualElement) == null ? void 0 : _a.unmount();
8182
+ }
7999
8183
  if (unMountChildren) {
8000
8184
  const unmountChild = (child) => {
8001
8185
  var _a2;
8002
8186
  child.unmount(true);
8003
8187
  (_a2 = child.children) == null ? void 0 : _a2.forEach(unmountChild);
8004
8188
  };
8005
- (_b = this.children) == null ? void 0 : _b.forEach(unmountChild);
8189
+ Array.from(this.children).forEach(unmountChild);
8006
8190
  }
8191
+ (_c = (_b = this.parent) == null ? void 0 : _b.children) == null ? void 0 : _c.delete(this);
8007
8192
  }
8008
8193
  beforeUpdate() {
8009
8194
  this.featureManager.beforeUpdate();
@@ -8018,7 +8203,7 @@ class MotionState {
8018
8203
  this.updateOptions();
8019
8204
  this.featureManager.update();
8020
8205
  if (hasAnimateChange && !notAnimate) {
8021
- scheduleAnimation(this);
8206
+ this.animateUpdates();
8022
8207
  }
8023
8208
  }
8024
8209
  setActive(name, isActive, isAnimate = true) {
@@ -8027,10 +8212,10 @@ class MotionState {
8027
8212
  return;
8028
8213
  this.activeStates[name] = isActive;
8029
8214
  (_a = this.visualElement.variantChildren) == null ? void 0 : _a.forEach((child) => {
8030
- child.state.setActive(name, isActive, false);
8215
+ child.state.setActive(name, isActive, !isActive);
8031
8216
  });
8032
8217
  if (isAnimate) {
8033
- scheduleAnimation(this);
8218
+ this.animateUpdates();
8034
8219
  }
8035
8220
  }
8036
8221
  animateUpdates(isInitial = false) {
@@ -8328,17 +8513,29 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8328
8513
  attrsProps.style = styleProps;
8329
8514
  return attrsProps;
8330
8515
  }
8516
+ const PrimitiveRef = vue.ref();
8517
+ function onMotionComplete() {
8518
+ var _a;
8519
+ if (props.asChild) {
8520
+ (_a = PrimitiveRef.value) == null ? void 0 : _a.$forceUpdate();
8521
+ }
8522
+ }
8331
8523
  return (_ctx, _cache) => {
8332
- return vue.openBlock(), vue.createBlock(vue.unref(Primitive), vue.mergeProps(getProps(), {
8524
+ var _a;
8525
+ return vue.openBlock(), vue.createBlock(vue.unref(Primitive), {
8526
+ ref_key: "PrimitiveRef",
8527
+ ref: PrimitiveRef,
8528
+ "get-props": getProps,
8333
8529
  as: _ctx.as,
8334
8530
  "as-child": _ctx.asChild,
8335
- "data-motion-id": vue.unref(state2).id
8336
- }), {
8531
+ "data-motion-group": ((_a = vue.unref(layoutGroup).key) == null ? void 0 : _a.value) || void 0,
8532
+ onMotioncomplete: onMotionComplete
8533
+ }, {
8337
8534
  default: vue.withCtx(() => [
8338
8535
  vue.renderSlot(_ctx.$slots, "default")
8339
8536
  ]),
8340
8537
  _: 3
8341
- }, 16, ["as", "as-child", "data-motion-id"]);
8538
+ }, 8, ["as", "as-child", "data-motion-group"]);
8342
8539
  };
8343
8540
  }
8344
8541
  });
@@ -8380,14 +8577,17 @@ function usePopLayout(props) {
8380
8577
  }
8381
8578
  function removePopStyle(state2) {
8382
8579
  const style2 = styles.get(state2);
8383
- if (style2) {
8384
- styles.delete(state2);
8580
+ if (!style2)
8581
+ return;
8582
+ styles.delete(state2);
8583
+ requestIdleCallback(() => {
8385
8584
  document.head.removeChild(style2);
8386
- }
8585
+ });
8387
8586
  }
8388
8587
  return {
8389
8588
  addPopStyle,
8390
- removePopStyle
8589
+ removePopStyle,
8590
+ styles
8391
8591
  };
8392
8592
  }
8393
8593
  const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
@@ -8416,19 +8616,14 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8416
8616
  });
8417
8617
  function enter(el) {
8418
8618
  const state2 = mountedStates.get(el);
8419
- const motionStateId = el.dataset.motionId;
8420
- const motionState = mountedStates.get(motionStateId);
8421
- if (motionState) {
8422
- const baseStyle = createStyles(motionState.baseTarget);
8423
- Object.assign(el.style, baseStyle);
8424
- }
8425
8619
  if (!state2) {
8426
8620
  return;
8427
8621
  }
8622
+ state2.isVShow = true;
8428
8623
  removeDoneCallback(el);
8429
8624
  state2.setActive("exit", false);
8430
8625
  }
8431
- const { addPopStyle, removePopStyle } = usePopLayout(props);
8626
+ const { addPopStyle, removePopStyle, styles } = usePopLayout(props);
8432
8627
  const exitDom = /* @__PURE__ */ new Map();
8433
8628
  vue.onUnmounted(() => {
8434
8629
  exitDom.clear();
@@ -8445,17 +8640,19 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8445
8640
  var _a, _b;
8446
8641
  if ((_a = e == null ? void 0 : e.detail) == null ? void 0 : _a.isExit) {
8447
8642
  const projection = state2.visualElement.projection;
8448
- if ((projection == null ? void 0 : projection.animationProgress) > 0 && !state2.isSafeToRemove) {
8643
+ if ((projection == null ? void 0 : projection.animationProgress) > 0 && !state2.isSafeToRemove && !state2.isVShow) {
8449
8644
  return;
8450
8645
  }
8451
- state2.willUpdate("done");
8452
- removePopStyle(state2);
8453
8646
  removeDoneCallback(el);
8454
8647
  exitDom.delete(el);
8455
8648
  if (exitDom.size === 0) {
8456
8649
  (_b = props.onExitComplete) == null ? void 0 : _b.call(props);
8457
8650
  }
8651
+ if (!styles.has(state2)) {
8652
+ state2.willUpdate("done");
8653
+ }
8458
8654
  done();
8655
+ removePopStyle(state2);
8459
8656
  if (!(el == null ? void 0 : el.isConnected)) {
8460
8657
  state2.unmount(true);
8461
8658
  }
@@ -8465,19 +8662,26 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8465
8662
  el.addEventListener("motioncomplete", doneCallback);
8466
8663
  state2.setActive("exit", true);
8467
8664
  }
8665
+ const transitionProps = vue.computed(() => {
8666
+ if (props.multiple) {
8667
+ return {
8668
+ tag: props.as
8669
+ };
8670
+ }
8671
+ return {
8672
+ mode: props.mode === "wait" ? "out-in" : void 0
8673
+ };
8674
+ });
8468
8675
  return (_ctx, _cache) => {
8469
- return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.multiple ? vue.TransitionGroup : vue.Transition), {
8470
- tag: _ctx.multiple ? _ctx.as : void 0,
8471
- css: false,
8472
- mode: _ctx.mode === "wait" ? "out-in" : void 0,
8676
+ return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.multiple ? vue.TransitionGroup : vue.Transition), vue.mergeProps({ css: false }, transitionProps.value, {
8473
8677
  onEnter: enter,
8474
8678
  onLeave: exit
8475
- }, {
8679
+ }), {
8476
8680
  default: vue.withCtx(() => [
8477
8681
  vue.renderSlot(_ctx.$slots, "default")
8478
8682
  ]),
8479
8683
  _: 3
8480
- }, 40, ["tag", "mode"]);
8684
+ }, 16);
8481
8685
  };
8482
8686
  }
8483
8687
  });
@@ -8580,10 +8784,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
8580
8784
  },
8581
8785
  setup(__props) {
8582
8786
  const props = __props;
8583
- const { forceRender, key, group } = useLayoutGroupProvider(props);
8584
- vue.onBeforeUpdate(() => {
8585
- group.dirty();
8586
- });
8787
+ const { forceRender, key } = useLayoutGroupProvider(props);
8587
8788
  return (_ctx, _cache) => {
8588
8789
  return vue.renderSlot(_ctx.$slots, "default", {
8589
8790
  renderKey: vue.unref(key),
@@ -8842,10 +9043,6 @@ function useAnimate() {
8842
9043
  });
8843
9044
  return [domProxy, animate2];
8844
9045
  }
8845
- Object.defineProperty(exports, "isDragActive", {
8846
- enumerable: true,
8847
- get: () => motionDom.isDragActive
8848
- });
8849
9046
  exports.AnimatePresence = _sfc_main$2;
8850
9047
  exports.LayoutGroup = _sfc_main;
8851
9048
  exports.Motion = _sfc_main$3;
@@ -8882,6 +9079,7 @@ exports.inertia = inertia;
8882
9079
  exports.injectLayoutGroup = injectLayoutGroup;
8883
9080
  exports.injectMotion = injectMotion;
8884
9081
  exports.interpolate = interpolate;
9082
+ exports.isDragActive = isDragActive;
8885
9083
  exports.isMotionValue = isMotionValue;
8886
9084
  exports.keyframes = keyframes;
8887
9085
  exports.millisecondsToSeconds = millisecondsToSeconds;