motion-v 0.5.2-beta.1 → 0.6.1

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 (296) hide show
  1. package/dist/cjs/index.js +1788 -1539
  2. package/dist/es/animation/use-animate.mjs +1 -1
  3. package/dist/es/components/LayoutGroup.vue.mjs +2 -7
  4. package/dist/es/components/Motion.vue.mjs +47 -30
  5. package/dist/es/components/Primitive.mjs +14 -6
  6. package/dist/es/components/{AnimatePresence.vue.mjs → animate-presence/AnimatePresence.vue.mjs} +34 -15
  7. package/dist/es/components/{use-pop-layout.mjs → animate-presence/use-pop-layout.mjs} +8 -5
  8. package/dist/es/components/group.mjs +5 -2
  9. package/dist/es/components/presence.mjs +0 -2
  10. package/dist/es/components/utils.mjs +7 -0
  11. package/dist/es/constants/index.mjs +2 -1
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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
  19. 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
  20. 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
  21. 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
  22. 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
  23. package/dist/es/external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +6 -0
  24. 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
  25. 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
  26. 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
  27. 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
  28. 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
  29. 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
  30. 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
  31. 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
  32. 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
  33. 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
  34. 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
  35. 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
  36. 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
  37. 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
  38. 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
  39. 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
  40. 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
  41. 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
  42. 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
  43. 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
  44. 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
  45. 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
  46. 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
  47. 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
  48. package/dist/es/external/.pnpm/framer-motion@11.16.6/external/framer-motion/dist/es/render/html/utils/keys-position.mjs +13 -0
  49. 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
  50. 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
  51. 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
  52. 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
  53. 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
  54. 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
  55. 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
  56. 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
  57. 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
  58. 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
  59. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/animation/controls/Group.mjs +9 -0
  60. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/animation/generators/utils/create-generator-easing.mjs +17 -0
  61. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/animation/waapi/NativeAnimationControls.mjs +81 -0
  62. 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
  63. 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
  64. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/drag/state/is-active.mjs +11 -0
  65. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/hover.mjs +30 -0
  66. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/press/index.mjs +51 -0
  67. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/press/utils/is-keyboard-accessible.mjs +13 -0
  68. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/press/utils/keyboard.mjs +32 -0
  69. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/press/utils/state.mjs +4 -0
  70. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/utils/is-node-or-child.mjs +12 -0
  71. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/utils/is-primary-pointer.mjs +10 -0
  72. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/gestures/utils/setup.mjs +15 -0
  73. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/utils/resolve-elements.mjs +17 -0
  74. 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
  75. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/utils/supports/memo.mjs +13 -0
  76. package/dist/es/external/.pnpm/motion-dom@11.16.4/external/motion-dom/dist/es/utils/supports/scroll-timeline.mjs +6 -0
  77. package/dist/es/features/gestures/drag/VisualElementDragControls.mjs +2 -2
  78. package/dist/es/features/gestures/drag/index.mjs +2 -2
  79. package/dist/es/features/gestures/hover/index.mjs +3 -2
  80. package/dist/es/features/gestures/in-view/index.mjs +2 -2
  81. package/dist/es/features/gestures/pan/PanSession.mjs +3 -3
  82. package/dist/es/features/gestures/pan/index.mjs +3 -3
  83. package/dist/es/features/gestures/press/index.mjs +3 -2
  84. package/dist/es/features/layout/config.mjs +2 -2
  85. package/dist/es/features/layout/layout.mjs +19 -10
  86. package/dist/es/features/layout/projection.mjs +19 -3
  87. package/dist/es/features/svg.mjs +1 -1
  88. package/dist/es/index.mjs +37 -37
  89. package/dist/es/state/animate-variants-children.mjs +6 -4
  90. package/dist/es/state/create-visual-element.mjs +2 -2
  91. package/dist/es/state/motion-state.mjs +59 -26
  92. package/dist/es/state/utils.mjs +0 -9
  93. package/dist/es/utils/use-animation-frame.mjs +1 -1
  94. package/dist/es/utils/use-in-view.mjs +1 -1
  95. package/dist/es/value/use-combine-values.mjs +2 -2
  96. package/dist/es/value/use-computed.mjs +1 -1
  97. package/dist/es/value/use-scroll.mjs +2 -2
  98. package/dist/es/value/use-spring.mjs +3 -3
  99. package/dist/es/value/use-time.mjs +1 -1
  100. package/dist/es/value/use-transform.mjs +1 -1
  101. package/dist/es/value/use-velocity.mjs +2 -2
  102. package/dist/src/animation/types.d.ts +0 -12
  103. package/dist/src/components/LayoutGroup.d.ts +1 -10
  104. package/dist/src/components/Motion.d.ts +1 -1
  105. package/dist/src/components/Primitive.d.ts +14 -5
  106. package/dist/src/components/Slot.d.ts +1 -1
  107. package/dist/src/components/animate-presence/AnimatePresence.d.ts +21 -0
  108. package/dist/src/components/animate-presence/index.d.ts +2 -0
  109. package/dist/src/components/{type.d.ts → animate-presence/types.d.ts} +2 -0
  110. package/dist/src/components/{use-pop-layout.d.ts → animate-presence/use-pop-layout.d.ts} +3 -2
  111. package/dist/src/components/animate-presence/use-presence.d.ts +2 -0
  112. package/dist/src/components/context.d.ts +1 -0
  113. package/dist/src/components/group.d.ts +1 -0
  114. package/dist/src/components/hooks/use-motion-elm.d.ts +13 -0
  115. package/dist/src/components/index.d.ts +2 -0
  116. package/dist/src/components/motion-config/MotionConfig.d.ts +2 -23
  117. package/dist/src/components/presence.d.ts +3 -5
  118. package/dist/src/components/utils.d.ts +7 -0
  119. package/dist/src/features/gestures/base.d.ts +0 -2
  120. package/dist/src/index.d.ts +1 -3
  121. package/dist/src/state/animate-variants-children.d.ts +1 -1
  122. package/dist/src/state/event.d.ts +1 -1
  123. package/dist/src/state/motion-state.d.ts +9 -6
  124. package/dist/src/state/utils.d.ts +2 -2
  125. package/dist/src/types/index.d.ts +0 -1
  126. package/dist/src/types/state.d.ts +8 -5
  127. package/dist/src/types/transform.d.ts +0 -24
  128. package/dist/src/utils/use-dom-ref.d.ts +2 -1
  129. package/dist/src/utils/use-in-view.d.ts +1 -1
  130. package/package.json +10 -5
  131. package/dist/es/external/.pnpm/framer-motion@11.15.0/external/framer-motion/dist/es/animation/animators/waapi/utils/memo-supports.mjs +0 -12
  132. package/dist/es/external/.pnpm/framer-motion@11.15.0/external/framer-motion/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +0 -5
  133. package/dist/es/external/.pnpm/framer-motion@11.15.0/external/framer-motion/dist/es/easing/utils/create-generator-easing.mjs +0 -14
  134. package/dist/es/external/.pnpm/framer-motion@11.15.0/external/framer-motion/dist/es/render/dom/scroll/supports.mjs +0 -5
  135. package/dist/es/state/schedule.mjs +0 -30
  136. package/dist/src/animation/animation-controls.d.ts +0 -7
  137. package/dist/src/components/AnimatePresence.d.ts +0 -46
  138. package/dist/src/state/schedule.d.ts +0 -3
  139. package/dist/es/components/{AnimatePresence.vue2.mjs → animate-presence/AnimatePresence.vue2.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/animate/sequence.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/animate/single-value.mjs +1 -1
  142. /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
  143. /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
  144. /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
  145. /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
  146. /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
  147. /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
  148. /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
  149. /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
  150. /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
  151. /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
  152. /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
  153. /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
  154. /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
  155. /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
  156. /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
  157. /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
  158. /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
  159. /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
  160. /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
  161. /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
  162. /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
  163. /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
  164. /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
  165. /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
  166. /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
  167. /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
  168. /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
  169. /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
  170. /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
  171. /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
  172. /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
  173. /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
  174. /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
  175. /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
  176. /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
  177. /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
  178. /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
  179. /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
  180. /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
  181. /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
  182. /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
  183. /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
  184. /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
  185. /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
  186. /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
  187. /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
  188. /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
  189. /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
  190. /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
  191. /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
  192. /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
  193. /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
  194. /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
  195. /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
  196. /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
  197. /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
  198. /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
  199. /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
  200. /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
  201. /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
  202. /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
  203. /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
  204. /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
  205. /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
  206. /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
  207. /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
  208. /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
  209. /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
  210. /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
  211. /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
  212. /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
  213. /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
  214. /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
  215. /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
  216. /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
  217. /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
  218. /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
  219. /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
  220. /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
  221. /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
  222. /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
  223. /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
  224. /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
  225. /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
  226. /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
  227. /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
  228. /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
  229. /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
  230. /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
  231. /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
  232. /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
  233. /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
  234. /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
  235. /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
  236. /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
  237. /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
  238. /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
  239. /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
  240. /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
  241. /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
  242. /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
  243. /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
  244. /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
  245. /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
  246. /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
  247. /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
  248. /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
  249. /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
  250. /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
  251. /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
  252. /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
  253. /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
  254. /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
  255. /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
  256. /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
  257. /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
  258. /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
  259. /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
  260. /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
  261. /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
  262. /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
  263. /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
  264. /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
  265. /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
  266. /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
  267. /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
  268. /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
  269. /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
  270. /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
  271. /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
  272. /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
  273. /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
  274. /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
  275. /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
  276. /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
  277. /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
  278. /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
  279. /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
  280. /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
  281. /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
  282. /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
  283. /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
  284. /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
  285. /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
  286. /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
  287. /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
  288. /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
  289. /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
  290. /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
  291. /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
  292. /package/dist/es/external/.pnpm/{motion-utils@11.14.3 → motion-utils@11.16.0}/external/motion-utils/dist/es/errors.mjs +0 -0
  293. /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
  294. /package/dist/es/external/.pnpm/{motion-utils@11.14.3 → motion-utils@11.16.0}/external/motion-utils/dist/es/noop.mjs +0 -0
  295. /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
  296. /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,578 +17,414 @@ if (process.env.NODE_ENV !== "production") {
18
17
  }
19
18
  };
20
19
  }
21
- function addUniqueItem$1(arr, item) {
22
- if (arr.indexOf(item) === -1)
23
- arr.push(item);
24
- }
25
- function removeItem$1(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$1(this.subscriptions, handler);
36
- return () => removeItem$1(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);
177
- }
178
- };
179
- const wake = () => {
180
- runNextFrame = true;
181
- useDefaultElapsed = true;
182
- if (!state2.isProcessing) {
183
- 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);
184
160
  }
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;
365
194
  }
195
+ if (this.animation.commitStyles) {
196
+ this.animation.commitStyles();
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;
372
- }
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();
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" });
384
205
  }
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;
206
+ attachTimeline(timeline) {
207
+ if (this.animation)
208
+ attachTimeline(this.animation, timeline);
209
+ return noop;
397
210
  }
398
- /**
399
- * @public
400
- */
401
- getPrevious() {
402
- return this.prev;
211
+ complete() {
212
+ this.animation && this.animation.finish();
403
213
  }
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;
214
+ cancel() {
215
+ try {
216
+ this.animation && this.animation.cancel();
217
+ } catch (e) {
415
218
  }
416
- const delta = Math.min(this.updatedAt - this.prevUpdatedAt, MAX_VELOCITY_DELTA);
417
- return velocityPerSecond(parseFloat(this.current) - parseFloat(this.prevFrameValue), delta);
418
219
  }
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);
232
+ const supportsLinearEasing = /* @__PURE__ */ memoSupports(() => {
233
+ try {
234
+ document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" });
235
+ } catch (e) {
236
+ return false;
504
237
  }
505
- then(onResolve, onReject) {
506
- return Promise.all(this.animations).then(onResolve).catch(onReject);
238
+ return true;
239
+ }, "linearEasing");
240
+ const generateLinearEasing = (easing, duration, resolution = 10) => {
241
+ let points = "";
242
+ const numPoints = Math.max(Math.round(duration / resolution), 2);
243
+ for (let i = 0; i < numPoints; i++) {
244
+ points += easing(progress$1(0, numPoints - 1, i)) + ", ";
507
245
  }
508
- /**
509
- * TODO: Filter out cancelled or stopped animations before returning
510
- */
511
- getAll(propName) {
512
- return this.animations[0][propName];
246
+ return `linear(${points.substring(0, points.length - 2)})`;
247
+ };
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));
250
+ }
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])
262
+ };
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];
513
274
  }
514
- setAll(propName, newValue) {
515
- for (let i = 0; i < this.animations.length; i++) {
516
- this.animations[i][propName] = newValue;
275
+ }
276
+ const isDragging = {
277
+ x: false,
278
+ y: false
279
+ };
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;
517
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) : [];
518
294
  }
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
- }
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);
526
325
  });
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");
573
- }
326
+ target.addEventListener("pointerleave", onPointerLeave, eventOptions);
327
+ });
328
+ elements.forEach((element) => {
329
+ element.addEventListener("pointerenter", onPointerEnter, eventOptions);
330
+ });
331
+ return cancel;
574
332
  }
575
- const progress$1 = (from, to, value) => {
576
- const toFromDifference = to - from;
577
- return toFromDifference === 0 ? 1 : (value - from) / toFromDifference;
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
+ }
578
341
  };
579
- const generateLinearEasing = (easing, duration, resolution = 10) => {
580
- let points = "";
581
- const numPoints = Math.max(Math.round(duration / resolution), 2);
582
- for (let i = 0; i < numPoints; i++) {
583
- points += easing(progress$1(0, numPoints - 1, i)) + ", ";
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;
584
347
  }
585
- return `linear(${points.substring(0, points.length - 2)})`;
586
348
  };
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);
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;
593
428
  }
594
429
  const clamp$1 = (min, max, v) => {
595
430
  if (v > max)
@@ -598,10 +433,18 @@ const clamp$1 = (min, max, v) => {
598
433
  return min;
599
434
  return v;
600
435
  };
601
- const springDefaults = {
602
- // Default spring physics
603
- stiffness: 100,
604
- damping: 10,
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,
605
448
  mass: 1,
606
449
  velocity: 0,
607
450
  // Default duration/bounce-based options
@@ -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,21 +695,20 @@ 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++) {
877
709
  const keyframe = sequence[i];
878
710
  if (keyframe.at > startTime && keyframe.at < endTime) {
879
- removeItem$1(sequence, keyframe);
711
+ removeItem(sequence, keyframe);
880
712
  i--;
881
713
  }
882
714
  }
@@ -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,150 +915,6 @@ 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
1094
- };
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
1104
- };
1105
- const ease = {
1106
- type: "keyframes",
1107
- ease: [0.25, 0.1, 0.35, 1],
1108
- duration: 0.3
1109
- };
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;
1117
- };
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;
1141
- }
1142
- } while (Math.abs(currentX) > subdivisionPrecision && ++i < subdivisionMaxIterations);
1143
- return currentT;
1144
- }
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);
1150
- }
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
- }
1169
- }
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());
1179
- };
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];
1191
- }
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)
1197
- 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;
1204
- }
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
1217
- };
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)
1232
- };
1233
918
  const positionalKeys = /* @__PURE__ */ new Set([
1234
919
  "width",
1235
920
  "height",
@@ -1237,190 +922,588 @@ const positionalKeys = /* @__PURE__ */ new Set([
1237
922
  "left",
1238
923
  "right",
1239
924
  "bottom",
1240
- "x",
1241
- "y",
1242
- "translateX",
1243
- "translateY"
925
+ ...transformPropOrder
1244
926
  ]);
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;
1259
- }
1260
- }
927
+ const isKeyframesTarget = (v) => {
928
+ return Array.isArray(v);
1261
929
  };
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);
1271
- }
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)
930
+ const isCustomValue = (v) => {
931
+ return Boolean(v && typeof v === "object" && v.mix && v.toValue);
1286
932
  };
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
933
+ const resolveFinalValueInKeyframes = (v) => {
934
+ return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
1293
935
  };
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)
936
+ const MotionGlobalConfig = {
937
+ skipAnimations: false,
938
+ useManualTiming: false
939
+ };
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();
955
+ }
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;
1307
985
  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);
1319
- });
1320
986
  }
1321
- });
1322
- resolversToMeasure.forEach((resolver) => resolver.measureEndState());
1323
- resolversToMeasure.forEach((resolver) => {
1324
- if (resolver.suspendedScrollY !== void 0) {
1325
- window.scrollTo(0, resolver.suspendedScrollY);
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);
1326
995
  }
1327
- });
1328
- }
1329
- anyNeedsMeasurement = false;
1330
- isScheduled = false;
1331
- toResolve.forEach((resolver) => resolver.complete());
1332
- toResolve.clear();
996
+ }
997
+ };
998
+ return step;
1333
999
  }
1334
- function readAllKeyframes() {
1335
- toResolve.forEach((resolver) => {
1336
- resolver.readKeyframes();
1337
- if (resolver.needsMeasurement) {
1338
- anyNeedsMeasurement = true;
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);
1339
1045
  }
1340
- });
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 };
1341
1069
  }
1342
- function flushKeyframeResolvers() {
1343
- readAllKeyframes();
1344
- measureAllKeyframes();
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;
1345
1074
  }
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;
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);
1358
1085
  }
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);
1367
- }
1086
+ };
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);
1368
1101
  } else {
1369
- this.readKeyframes();
1370
- this.complete();
1102
+ for (let i = 0; i < numSubscriptions; i++) {
1103
+ const handler = this.subscriptions[i];
1104
+ handler && handler(a, b, c);
1105
+ }
1371
1106
  }
1372
1107
  }
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]);
1108
+ getSize() {
1109
+ return this.subscriptions.length;
1110
+ }
1111
+ clear() {
1112
+ this.subscriptions.length = 0;
1113
+ }
1114
+ }
1115
+ const warned = /* @__PURE__ */ new Set();
1116
+ function warnOnce(condition, message, element) {
1117
+ if (condition || warned.has(message))
1118
+ return;
1119
+ console.warn(message);
1120
+ warned.add(message);
1121
+ }
1122
+ const MAX_VELOCITY_DELTA = 30;
1123
+ const isFloat = (value) => {
1124
+ return !isNaN(parseFloat(value));
1125
+ };
1126
+ const collectMotionValues = {
1127
+ current: void 0
1128
+ };
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);
1165
+ }
1166
+ }
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).`);
1214
+ }
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();
1393
1228
  }
1394
- } else {
1395
- unresolvedKeyframes[i] = unresolvedKeyframes[i - 1];
1396
- }
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();
1341
+ }
1342
+ }).then(() => {
1343
+ if (this.events.animationComplete) {
1344
+ this.events.animationComplete.notify();
1345
+ }
1346
+ this.clearAnimation();
1347
+ });
1348
+ }
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();
1397
1359
  }
1398
1360
  }
1361
+ this.clearAnimation();
1399
1362
  }
1400
- setFinalKeyframe() {
1363
+ /**
1364
+ * Returns `true` if this value is currently animating.
1365
+ *
1366
+ * @public
1367
+ */
1368
+ isAnimating() {
1369
+ return !!this.animation;
1401
1370
  }
1402
- measureInitialState() {
1371
+ clearAnimation() {
1372
+ delete this.animation;
1403
1373
  }
1404
- renderEndStyles() {
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();
1388
+ }
1389
+ }
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);
1406
+ }
1407
+ if (typeof definition === "string") {
1408
+ definition = props.variants && props.variants[definition];
1409
+ }
1410
+ if (typeof definition === "function") {
1411
+ const [current, velocity] = getValueState(visualElement);
1412
+ definition = definition(custom !== void 0 ? custom : props.custom, current, velocity);
1413
+ }
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));
1405
1425
  }
1406
- measureEndState() {
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);
1407
1434
  }
1408
- complete() {
1409
- this.isComplete = true;
1410
- this.onComplete(this.unresolvedKeyframes, this.finalKeyframe);
1411
- toResolve.delete(this);
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);
1412
1443
  }
1413
- cancel() {
1414
- if (!this.isComplete) {
1415
- this.isScheduled = false;
1416
- toResolve.delete(this);
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;
1417
1465
  }
1418
- }
1419
- resume() {
1420
- if (!this.isComplete)
1421
- this.scheduleResolve();
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"),
@@ -1714,14 +1812,228 @@ function makeNoneKeyframesAnimatable(unresolvedKeyframes, noneKeyframeIndexes, n
1714
1812
  if (typeof keyframe === "string" && !invalidTemplates.has(keyframe) && analyseComplexValue(keyframe).values.length) {
1715
1813
  animatableTemplate = unresolvedKeyframes[i];
1716
1814
  }
1717
- i++;
1815
+ i++;
1816
+ }
1817
+ if (animatableTemplate && name) {
1818
+ for (const noneIndex of noneKeyframeIndexes) {
1819
+ unresolvedKeyframes[noneIndex] = getAnimatableNone(name, animatableTemplate);
1820
+ }
1821
+ }
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
+ }
1718
1970
  }
1719
- if (animatableTemplate && name) {
1720
- for (const noneIndex of noneKeyframeIndexes) {
1721
- unresolvedKeyframes[noneIndex] = getAnimatableNone(name, animatableTemplate);
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);
1722
1988
  }
1723
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;
1724
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)) {
@@ -2151,44 +2379,133 @@ function mixObject(a, b) {
2151
2379
  for (const key in blendValue) {
2152
2380
  output[key] = blendValue[key](v);
2153
2381
  }
2154
- return output;
2382
+ return output;
2383
+ };
2384
+ }
2385
+ function matchOrder(origin, target) {
2386
+ var _a;
2387
+ const orderedOrigin = [];
2388
+ const pointers = { color: 0, var: 0, number: 0 };
2389
+ for (let i = 0; i < target.values.length; i++) {
2390
+ const type = target.types[i];
2391
+ const originIndex = origin.indexes[type][pointers[type]];
2392
+ const originValue = (_a = origin.values[originIndex]) !== null && _a !== void 0 ? _a : 0;
2393
+ orderedOrigin[i] = originValue;
2394
+ pointers[type]++;
2395
+ }
2396
+ return orderedOrigin;
2397
+ }
2398
+ const mixComplex = (origin, target) => {
2399
+ const template = complex.createTransformer(target);
2400
+ const originStats = analyseComplexValue(origin);
2401
+ const targetStats = analyseComplexValue(target);
2402
+ const canInterpolate = originStats.indexes.var.length === targetStats.indexes.var.length && originStats.indexes.color.length === targetStats.indexes.color.length && originStats.indexes.number.length >= targetStats.indexes.number.length;
2403
+ if (canInterpolate) {
2404
+ if (invisibleValues.has(origin) && !targetStats.values.length || invisibleValues.has(target) && !originStats.values.length) {
2405
+ return mixVisibility(origin, target);
2406
+ }
2407
+ return pipe(mixArray(matchOrder(originStats, targetStats), targetStats.values), template);
2408
+ } else {
2409
+ warning(true, `Complex values '${origin}' and '${target}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`);
2410
+ return mixImmediate(origin, target);
2411
+ }
2412
+ };
2413
+ function mix(from, to, p) {
2414
+ if (typeof from === "number" && typeof to === "number" && typeof p === "number") {
2415
+ return mixNumber$2(from, to, p);
2416
+ }
2417
+ const mixer = getMixer$1(from);
2418
+ return mixer(from, to);
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
+ }
2155
2480
  };
2156
2481
  }
2157
- function matchOrder(origin, target) {
2158
- var _a;
2159
- const orderedOrigin = [];
2160
- const pointers = { color: 0, var: 0, number: 0 };
2161
- for (let i = 0; i < target.values.length; i++) {
2162
- const type = target.types[i];
2163
- const originIndex = origin.indexes[type][pointers[type]];
2164
- const originValue = (_a = origin.values[originIndex]) !== null && _a !== void 0 ? _a : 0;
2165
- orderedOrigin[i] = originValue;
2166
- pointers[type]++;
2167
- }
2168
- return orderedOrigin;
2169
- }
2170
- const mixComplex = (origin, target) => {
2171
- const template = complex.createTransformer(target);
2172
- const originStats = analyseComplexValue(origin);
2173
- const targetStats = analyseComplexValue(target);
2174
- const canInterpolate = originStats.indexes.var.length === targetStats.indexes.var.length && originStats.indexes.color.length === targetStats.indexes.color.length && originStats.indexes.number.length >= targetStats.indexes.number.length;
2175
- if (canInterpolate) {
2176
- if (invisibleValues.has(origin) && !targetStats.values.length || invisibleValues.has(target) && !originStats.values.length) {
2177
- return mixVisibility(origin, target);
2178
- }
2179
- return pipe(mixArray(matchOrder(originStats, targetStats), targetStats.values), template);
2180
- } else {
2181
- warning(true, `Complex values '${origin}' and '${target}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`);
2182
- return mixImmediate(origin, target);
2183
- }
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
2184
2497
  };
2185
- function mix(from, to, p) {
2186
- if (typeof from === "number" && typeof to === "number" && typeof p === "number") {
2187
- return mixNumber$2(from, to, p);
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];
2188
2506
  }
2189
- const mixer = getMixer$1(from);
2190
- return mixer(from, to);
2191
- }
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++) {
@@ -2543,52 +2863,6 @@ const acceleratedValues = /* @__PURE__ */ new Set([
2543
2863
  // or until we implement support for linear() easing.
2544
2864
  // "background-color"
2545
2865
  ]);
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
- }
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) {
@@ -2997,52 +3230,65 @@ function animateTarget(visualElement, targetAndTransition, { delay: delay2 = 0,
2997
3230
  }
2998
3231
  }
2999
3232
  }
3000
- addValueToWillChange$1(visualElement, key);
3001
- value.start(animateMotionValue(key, value, valueTarget, visualElement.shouldReduceMotion && transformProps.has(key) ? { type: false } : valueTransition, visualElement, isHandoff));
3002
- const animation = value.animation;
3003
- if (animation) {
3004
- animations.push(animation);
3005
- }
3006
- }
3007
- if (transitionEnd) {
3008
- Promise.all(animations).then(() => {
3009
- frame.update(() => {
3010
- transitionEnd && setTarget(visualElement, transitionEnd);
3011
- });
3012
- });
3013
- }
3014
- return animations;
3015
- }
3016
- function isSVGElement$2(element) {
3017
- return element instanceof SVGElement && element.tagName !== "svg";
3018
- }
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];
3233
+ addValueToWillChange$1(visualElement, key);
3234
+ value.start(animateMotionValue(key, value, valueTarget, visualElement.shouldReduceMotion && positionalKeys.has(key) ? { type: false } : valueTransition, visualElement, isHandoff));
3235
+ const animation = value.animation;
3236
+ if (animation) {
3237
+ animations.push(animation);
3043
3238
  }
3044
3239
  }
3045
- return newValues;
3240
+ if (transitionEnd) {
3241
+ Promise.all(animations).then(() => {
3242
+ frame.update(() => {
3243
+ transitionEnd && setTarget(visualElement, transitionEnd);
3244
+ });
3245
+ });
3246
+ }
3247
+ return animations;
3248
+ }
3249
+ function isSVGElement$2(element) {
3250
+ return element instanceof SVGElement && element.tagName !== "svg";
3251
+ }
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);
@@ -4836,13 +5010,6 @@ function shallowCompare(next, prev) {
4836
5010
  }
4837
5011
  return true;
4838
5012
  }
4839
- function addUniqueItem(array, item) {
4840
- !array.includes(item) && array.push(item);
4841
- }
4842
- function removeItem(array, item) {
4843
- const index = array.indexOf(item);
4844
- index !== -1 && array.splice(index, 1);
4845
- }
4846
5013
  function getOptions(options, key) {
4847
5014
  return options[key] ? { ...options, ...options[key] } : { ...options };
4848
5015
  }
@@ -5133,17 +5300,25 @@ const Primitive = vue.defineComponent({
5133
5300
  as: {
5134
5301
  type: [String, Object],
5135
5302
  default: "div"
5303
+ },
5304
+ getProps: {
5305
+ type: Function,
5306
+ default: () => ({})
5136
5307
  }
5137
5308
  },
5138
5309
  setup(props, { attrs, slots }) {
5139
5310
  const asTag = props.asChild ? "template" : props.as;
5140
5311
  const SELF_CLOSING_TAGS = ["area", "img", "input"];
5141
- if (typeof asTag === "string" && SELF_CLOSING_TAGS.includes(asTag))
5142
- return () => vue.h(asTag, attrs);
5143
- if (asTag !== "template") {
5144
- return () => vue.h(props.as, attrs, { default: slots.default });
5145
- }
5146
- 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
+ };
5147
5322
  }
5148
5323
  });
5149
5324
  class Feature {
@@ -5185,7 +5360,7 @@ class HoverGesture extends Feature {
5185
5360
  const element = this.state.element;
5186
5361
  if (!element)
5187
5362
  return;
5188
- this.unmount = motionDom.hover(
5363
+ this.unmount = hover(
5189
5364
  element,
5190
5365
  (startEvent) => {
5191
5366
  handleHoverEvent$1(this.state, startEvent, "Start");
@@ -5226,7 +5401,7 @@ class PressGesture extends Feature {
5226
5401
  const element = this.state.element;
5227
5402
  if (!element)
5228
5403
  return;
5229
- this.unmount = motionDom.press(
5404
+ this.unmount = press(
5230
5405
  element,
5231
5406
  (startEvent) => {
5232
5407
  handlePressEvent(this.state, startEvent, "Start");
@@ -5644,7 +5819,6 @@ function measurePageBox(element, rootProjectionNode2, transformPagePoint) {
5644
5819
  return viewportBox;
5645
5820
  }
5646
5821
  const doneCallbacks = /* @__PURE__ */ new WeakMap();
5647
- vue.ref(/* @__PURE__ */ new WeakMap());
5648
5822
  function removeDoneCallback(element) {
5649
5823
  const prevDoneCallback = doneCallbacks.get(element);
5650
5824
  if (prevDoneCallback) {
@@ -5762,9 +5936,9 @@ class VisualElementDragControls {
5762
5936
  );
5763
5937
  }
5764
5938
  stop(event, info) {
5765
- const isDragging = this.isDragging;
5939
+ const isDragging2 = this.isDragging;
5766
5940
  this.cancel();
5767
- if (!isDragging)
5941
+ if (!isDragging2)
5768
5942
  return;
5769
5943
  const { velocity } = info;
5770
5944
  this.startAnimation(velocity);
@@ -6202,8 +6376,7 @@ class LayoutFeature extends Feature {
6202
6376
  addScaleCorrector(defaultScaleCorrector);
6203
6377
  }
6204
6378
  beforeUpdate() {
6205
- var _a;
6206
- (_a = this.state.visualElement.projection) == null ? void 0 : _a.willUpdate();
6379
+ this.state.willUpdate("beforeUpdate");
6207
6380
  }
6208
6381
  update() {
6209
6382
  var _a;
@@ -6225,15 +6398,25 @@ class LayoutFeature extends Feature {
6225
6398
  }
6226
6399
  }
6227
6400
  beforeUnmount() {
6401
+ const projection = this.state.visualElement.projection;
6402
+ if (projection) {
6403
+ this.state.willUpdate("beforeUnmount");
6404
+ if (this.state.options.layoutId) {
6405
+ projection.isPresent = false;
6406
+ projection.relegate();
6407
+ } else if (this.state.options.layout) {
6408
+ this.state.isSafeToRemove = true;
6409
+ }
6410
+ }
6228
6411
  }
6229
6412
  unmount() {
6413
+ var _a, _b;
6414
+ const layoutGroup = this.state.options.layoutGroup;
6230
6415
  const projection = this.state.visualElement.projection;
6231
- if (projection) {
6232
- projection.root.didUpdate();
6233
- projection.finishAnimation();
6234
- const layoutGroup = this.state.options.layoutGroup;
6235
- if (layoutGroup == null ? void 0 : layoutGroup.group)
6236
- layoutGroup.group.remove(projection);
6416
+ if ((layoutGroup == null ? void 0 : layoutGroup.group) && projection)
6417
+ layoutGroup.group.remove(projection);
6418
+ if (this.state.options.layoutId || this.state.options.layout) {
6419
+ (_b = (_a = this.state.visualElement.projection) == null ? void 0 : _a.root) == null ? void 0 : _b.didUpdate();
6237
6420
  }
6238
6421
  }
6239
6422
  }
@@ -6296,6 +6479,31 @@ class PanGesture extends Feature {
6296
6479
  this.session && this.session.end();
6297
6480
  }
6298
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
+ }
6299
6507
  const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
6300
6508
  const numBorders = borders.length;
6301
6509
  const asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
@@ -6466,11 +6674,11 @@ class NodeStack {
6466
6674
  this.members = [];
6467
6675
  }
6468
6676
  add(node) {
6469
- addUniqueItem$1(this.members, node);
6677
+ addUniqueItem(this.members, node);
6470
6678
  node.scheduleRender();
6471
6679
  }
6472
6680
  remove(node) {
6473
- removeItem$1(this.members, node);
6681
+ removeItem(this.members, node);
6474
6682
  if (node === this.prevLead) {
6475
6683
  this.prevLead = void 0;
6476
6684
  }
@@ -6587,31 +6795,6 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
6587
6795
  function eachAxis(callback) {
6588
6796
  return [callback("x"), callback("y")];
6589
6797
  }
6590
- const compareByDepth$1 = (a, b) => a.depth - b.depth;
6591
- class FlatTree {
6592
- constructor() {
6593
- this.children = [];
6594
- this.isDirty = false;
6595
- }
6596
- add(child) {
6597
- addUniqueItem$1(this.children, child);
6598
- this.isDirty = true;
6599
- }
6600
- remove(child) {
6601
- removeItem$1(this.children, child);
6602
- this.isDirty = true;
6603
- }
6604
- forEach(callback) {
6605
- this.isDirty && this.children.sort(compareByDepth$1);
6606
- this.isDirty = false;
6607
- this.children.forEach(callback);
6608
- }
6609
- }
6610
- function resolveMotionValue(value) {
6611
- const unwrappedValue = isMotionValue$1(value) ? value.get() : value;
6612
- return isCustomValue(unwrappedValue) ? unwrappedValue.toValue() : unwrappedValue;
6613
- }
6614
- const { schedule: microtask, cancel: cancelMicrotask } = createRenderBatcher(queueMicrotask, false);
6615
6798
  const metrics = {
6616
6799
  type: "projectionFrame",
6617
6800
  totalNodes: 0,
@@ -6775,7 +6958,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
6775
6958
  }
6776
6959
  this.setAnimationOrigin(delta, hasOnlyRelativeTargetChanged);
6777
6960
  const animationOptions = {
6778
- ...getValueTransition(layoutTransition, "layout"),
6961
+ ...getValueTransition$1(layoutTransition, "layout"),
6779
6962
  onPlay: onLayoutAnimationStart,
6780
6963
  onComplete: onLayoutAnimationComplete
6781
6964
  };
@@ -7713,6 +7896,7 @@ class ProjectionFeature extends Feature {
7713
7896
  this.state.visualElement.latestValues,
7714
7897
  options["data-framer-portal-id"] ? void 0 : getClosestProjectingNode(this.state.visualElement.parent)
7715
7898
  );
7899
+ this.state.visualElement.projection.isPresent = true;
7716
7900
  this.state.visualElement.projection.setOptions({
7717
7901
  layout: options.layout,
7718
7902
  layoutId: options.layoutId,
@@ -7723,7 +7907,21 @@ class ProjectionFeature extends Feature {
7723
7907
  // initialPromotionConfig
7724
7908
  layoutRoot: options.layoutRoot,
7725
7909
  layoutScroll: options.layoutScroll,
7726
- crossfade: options.crossfade
7910
+ crossfade: options.crossfade,
7911
+ onExitComplete: () => {
7912
+ var _a;
7913
+ if (!((_a = this.state.visualElement.projection) == null ? void 0 : _a.isPresent)) {
7914
+ const done = doneCallbacks.get(this.state.element);
7915
+ this.state.isSafeToRemove = true;
7916
+ if (done) {
7917
+ done({
7918
+ detail: {
7919
+ isExit: true
7920
+ }
7921
+ }, true);
7922
+ }
7923
+ }
7924
+ }
7727
7925
  });
7728
7926
  }
7729
7927
  beforeMount() {
@@ -7788,38 +7986,13 @@ class FeatureManager {
7788
7986
  this.features.forEach((feature) => feature.beforeUnmount());
7789
7987
  }
7790
7988
  }
7791
- let scheduled;
7792
- const fireNext = (iterator) => iterator.next();
7793
- const fireAnimateUpdates = (state2) => state2.animateUpdates();
7794
- function processScheduledAnimations() {
7795
- if (!scheduled)
7796
- return;
7797
- const generators2 = scheduled.sort(compareByDepth).map(fireAnimateUpdates);
7798
- generators2.forEach(fireNext);
7799
- generators2.forEach(fireNext);
7800
- scheduled = void 0;
7801
- }
7802
- function scheduleAnimation(state2) {
7803
- if (!scheduled) {
7804
- scheduled = [state2];
7805
- requestAnimationFrame(processScheduledAnimations);
7806
- } else {
7807
- addUniqueItem(scheduled, state2);
7808
- }
7809
- }
7810
- function unscheduleAnimation(state2) {
7811
- scheduled && removeItem(scheduled, state2);
7812
- }
7813
- function compareByDepth(a, b) {
7814
- return a.depth - b.depth;
7815
- }
7816
7989
  function motionEvent(name, target, isExit) {
7817
7990
  return new CustomEvent(name, { detail: { target, isExit } });
7818
7991
  }
7819
7992
  function createVisualElement(Component, options) {
7820
7993
  return isSVGElement$1(Component) ? new SVGVisualElement(options) : new HTMLVisualElement(options);
7821
7994
  }
7822
- function animateVariantsChildren(state2, activeState) {
7995
+ function animateVariantsChildren(state2, activeState, isFirstAnimate = false) {
7823
7996
  const variantChildren = state2.visualElement.variantChildren;
7824
7997
  if (!(variantChildren == null ? void 0 : variantChildren.size)) {
7825
7998
  return {
@@ -7830,11 +8003,13 @@ function animateVariantsChildren(state2, activeState) {
7830
8003
  const animationFactories = [];
7831
8004
  Array.from(variantChildren).forEach((child, index) => {
7832
8005
  var _a;
7833
- const prevTarget = child.state.target;
8006
+ const prevTarget = isFirstAnimate ? child.state.baseTarget : child.state.target;
7834
8007
  const childState = child.state;
7835
8008
  childState.target = {};
7836
8009
  for (const name in activeState) {
7837
- childState.activeStates[name] = true;
8010
+ if (name === "initial" && !isFirstAnimate) {
8011
+ continue;
8012
+ }
7838
8013
  const { definition, transition } = activeState[name];
7839
8014
  const { staggerChildren = 0, staggerDirection = 1, delayChildren = 0 } = transition || {};
7840
8015
  const maxStaggerDuration = (variantChildren.size - 1) * staggerChildren;
@@ -7889,16 +8064,20 @@ const mountedStates = /* @__PURE__ */ new WeakMap();
7889
8064
  let id = 0;
7890
8065
  class MotionState {
7891
8066
  constructor(options, parent) {
8067
+ var _a;
7892
8068
  this.element = null;
7893
- this.isFirstAnimate = true;
8069
+ this.isSafeToRemove = false;
8070
+ this.isVShow = false;
8071
+ this.children = /* @__PURE__ */ new Set();
7894
8072
  this.activeStates = {
7895
- initial: true,
8073
+ // initial: true,
7896
8074
  animate: true
7897
8075
  };
7898
8076
  this._context = null;
7899
8077
  this.id = `motion-state-${id++}`;
7900
8078
  this.options = options;
7901
8079
  this.parent = parent;
8080
+ (_a = parent == null ? void 0 : parent.children) == null ? void 0 : _a.add(this);
7902
8081
  this.depth = (parent == null ? void 0 : parent.depth) + 1 || 0;
7903
8082
  this.visualElement = createVisualElement(this.options.as, {
7904
8083
  presenceContext: null,
@@ -7922,8 +8101,8 @@ class MotionState {
7922
8101
  reducedMotionConfig: options.motionConfig.reduceMotion
7923
8102
  });
7924
8103
  const initialVariantSource = options.initial === false ? "animate" : "initial";
7925
- this.featureManager = new FeatureManager(this);
7926
8104
  this.initTarget(initialVariantSource);
8105
+ this.featureManager = new FeatureManager(this);
7927
8106
  }
7928
8107
  get context() {
7929
8108
  if (!this._context) {
@@ -7939,7 +8118,7 @@ class MotionState {
7939
8118
  }
7940
8119
  initTarget(initialVariantSource) {
7941
8120
  this.baseTarget = resolveVariant(this.options[initialVariantSource] || this.context[initialVariantSource], this.options.variants) || {};
7942
- this.target = { ...this.baseTarget };
8121
+ this.target = {};
7943
8122
  }
7944
8123
  get initial() {
7945
8124
  return isDef(this.options.initial) ? this.options.initial : this.context.initial;
@@ -7958,7 +8137,7 @@ class MotionState {
7958
8137
  beforeMount() {
7959
8138
  this.featureManager.beforeMount();
7960
8139
  }
7961
- mount(element, options) {
8140
+ mount(element, options, notAnimate = false) {
7962
8141
  heyListen.invariant(
7963
8142
  Boolean(element),
7964
8143
  "Animation state must be mounted with valid Element"
@@ -7982,38 +8161,64 @@ class MotionState {
7982
8161
  }
7983
8162
  }
7984
8163
  this.featureManager.mount();
7985
- scheduleAnimation(this);
8164
+ if (!notAnimate) {
8165
+ this.animateUpdates(true);
8166
+ }
7986
8167
  }
7987
8168
  beforeUnmount() {
7988
8169
  this.featureManager.beforeUnmount();
7989
8170
  }
7990
- unmount() {
7991
- var _a;
8171
+ unmount(unMountChildren = false) {
8172
+ var _a, _b, _c;
7992
8173
  mountedStates.delete(this.element);
7993
- unscheduleAnimation(this);
7994
- (_a = visualElementStore.get(this.element)) == null ? void 0 : _a.unmount();
7995
8174
  this.featureManager.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
+ }
8183
+ if (unMountChildren) {
8184
+ const unmountChild = (child) => {
8185
+ var _a2;
8186
+ child.unmount(true);
8187
+ (_a2 = child.children) == null ? void 0 : _a2.forEach(unmountChild);
8188
+ };
8189
+ Array.from(this.children).forEach(unmountChild);
8190
+ }
8191
+ (_c = (_b = this.parent) == null ? void 0 : _b.children) == null ? void 0 : _c.delete(this);
7996
8192
  }
7997
8193
  beforeUpdate() {
7998
8194
  this.featureManager.beforeUpdate();
7999
8195
  }
8000
- update(options) {
8196
+ update(options, notAnimate = false) {
8197
+ const prevAnimate = JSON.stringify(this.options.animate);
8001
8198
  this.options = options;
8199
+ let hasAnimateChange = false;
8200
+ if (prevAnimate !== JSON.stringify(options.animate)) {
8201
+ hasAnimateChange = true;
8202
+ }
8002
8203
  this.updateOptions();
8003
8204
  this.featureManager.update();
8004
- scheduleAnimation(this);
8205
+ if (hasAnimateChange && !notAnimate) {
8206
+ this.animateUpdates();
8207
+ }
8005
8208
  }
8006
- setActive(name, isActive) {
8209
+ setActive(name, isActive, isAnimate = true) {
8007
8210
  var _a;
8008
8211
  if (!this.element || this.activeStates[name] === isActive)
8009
8212
  return;
8010
8213
  this.activeStates[name] = isActive;
8011
8214
  (_a = this.visualElement.variantChildren) == null ? void 0 : _a.forEach((child) => {
8012
- child.state.setActive(name, isActive);
8215
+ child.state.setActive(name, isActive, false);
8013
8216
  });
8014
- scheduleAnimation(this);
8217
+ if (isAnimate) {
8218
+ this.animateUpdates();
8219
+ }
8015
8220
  }
8016
- *animateUpdates() {
8221
+ animateUpdates(isInitial = false) {
8017
8222
  const prevTarget = this.target;
8018
8223
  this.target = {};
8019
8224
  const activeState = {};
@@ -8021,13 +8226,13 @@ class MotionState {
8021
8226
  let transition;
8022
8227
  for (const name of STATE_TYPES) {
8023
8228
  if (name === "initial") {
8024
- if (!this.isFirstAnimate) {
8229
+ if (!isInitial) {
8025
8230
  continue;
8026
8231
  }
8027
- this.isFirstAnimate = false;
8028
8232
  }
8029
- if (!this.activeStates[name])
8233
+ if (!this.activeStates[name] && name !== "initial") {
8030
8234
  continue;
8235
+ }
8031
8236
  const definition = isDef(this.options[name]) ? this.options[name] : this.context[name];
8032
8237
  const variant = resolveVariant(
8033
8238
  definition,
@@ -8083,11 +8288,10 @@ class MotionState {
8083
8288
  let getChildAnimations = () => Promise.resolve();
8084
8289
  let childAnimations = [];
8085
8290
  if (Object.keys(activeState).length) {
8086
- const { getAnimations, animations: animations2 } = animateVariantsChildren(this, activeState);
8291
+ const { getAnimations, animations: animations2 } = animateVariantsChildren(this, activeState, isInitial);
8087
8292
  getChildAnimations = getAnimations;
8088
8293
  childAnimations = animations2;
8089
8294
  }
8090
- yield;
8091
8295
  let animations;
8092
8296
  const getAnimation = () => {
8093
8297
  animations = animationFactories.map((factory) => factory()).filter(Boolean);
@@ -8125,12 +8329,22 @@ class MotionState {
8125
8329
  getOptions() {
8126
8330
  return this.options;
8127
8331
  }
8332
+ willUpdate(label) {
8333
+ var _a;
8334
+ (_a = this.visualElement.projection) == null ? void 0 : _a.willUpdate();
8335
+ }
8128
8336
  }
8129
8337
  function getMotionElement(el) {
8130
8338
  if ((el == null ? void 0 : el.nodeType) === 3 || (el == null ? void 0 : el.nodeType) === 8)
8131
8339
  return getMotionElement(el.nextSibling);
8132
8340
  return el;
8133
8341
  }
8342
+ function checkMotionIsHidden(instance) {
8343
+ var _a;
8344
+ const isHidden = ((_a = getMotionElement(instance.$el)) == null ? void 0 : _a.style.display) === "none";
8345
+ const hasTransition = instance.$.vnode.transition;
8346
+ return hasTransition && isHidden;
8347
+ }
8134
8348
  const defaultConfig = {
8135
8349
  reduceMotion: "never",
8136
8350
  transition: void 0,
@@ -8160,6 +8374,8 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8160
8374
  transition: {},
8161
8375
  layoutGroup: {},
8162
8376
  motionConfig: {},
8377
+ onAnimationComplete: { type: Function },
8378
+ onUpdate: { type: Function },
8163
8379
  layout: { type: [Boolean, String] },
8164
8380
  layoutId: {},
8165
8381
  layoutScroll: { type: Boolean },
@@ -8213,22 +8429,33 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8213
8429
  dragElastic: 0.2,
8214
8430
  dragMomentum: true,
8215
8431
  whileDrag: void 0,
8216
- crossfade: void 0
8432
+ crossfade: true
8217
8433
  }),
8218
8434
  setup(__props) {
8219
8435
  const props = __props;
8220
- const { initial: presenceInitial, safeUnmount } = injectAnimatePresence({ initial: vue.ref(void 0), safeUnmount: () => true });
8436
+ const animatePresenceContext = injectAnimatePresence({});
8221
8437
  const parentState = injectMotion(null);
8222
8438
  const attrs = vue.useAttrs();
8223
8439
  const layoutGroup = injectLayoutGroup({});
8224
8440
  const config = useMotionConfig();
8225
- const state2 = new MotionState(
8226
- {
8441
+ function getLayoutId() {
8442
+ if (layoutGroup.id && props.layoutId)
8443
+ return `${layoutGroup.id}-${props.layoutId}`;
8444
+ return props.layoutId || void 0;
8445
+ }
8446
+ function getMotionProps() {
8447
+ return {
8227
8448
  ...attrs,
8228
8449
  ...props,
8450
+ layoutId: getLayoutId(),
8451
+ transition: props.transition ?? config.value.transition,
8229
8452
  layoutGroup,
8230
- motionConfig: config.value
8231
- },
8453
+ motionConfig: config.value,
8454
+ initial: animatePresenceContext.initial === false ? animatePresenceContext.initial : props.initial === true ? void 0 : props.initial
8455
+ };
8456
+ }
8457
+ const state2 = new MotionState(
8458
+ getMotionProps(),
8232
8459
  parentState
8233
8460
  );
8234
8461
  provideMotion(state2);
@@ -8237,29 +8464,20 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8237
8464
  state2.beforeMount();
8238
8465
  });
8239
8466
  vue.onMounted(() => {
8240
- state2.mount(getMotionElement(instance.$el), {
8241
- ...attrs,
8242
- ...props,
8243
- transition: props.transition ?? config.value.transition,
8244
- layoutGroup,
8245
- motionConfig: config.value,
8246
- initial: presenceInitial.value === false ? presenceInitial.value : props.initial === true ? void 0 : props.initial
8247
- });
8467
+ state2.mount(getMotionElement(instance.$el), getMotionProps(), checkMotionIsHidden(instance));
8248
8468
  });
8249
8469
  vue.onBeforeUnmount(() => state2.beforeUnmount());
8250
8470
  vue.onUnmounted(() => {
8251
- if (safeUnmount(getMotionElement(instance.$el)))
8471
+ const el = getMotionElement(instance.$el);
8472
+ if (!(el == null ? void 0 : el.isConnected)) {
8252
8473
  state2.unmount();
8474
+ }
8475
+ });
8476
+ vue.onBeforeUpdate(() => {
8477
+ state2.beforeUpdate();
8253
8478
  });
8254
- vue.onBeforeUpdate(() => state2.beforeUpdate());
8255
8479
  vue.onUpdated(() => {
8256
- state2.update({
8257
- ...attrs,
8258
- ...props,
8259
- transition: props.transition ?? config.value.transition,
8260
- motionConfig: config.value,
8261
- initial: presenceInitial.value === false ? presenceInitial.value : props.initial === true ? void 0 : props.initial
8262
- });
8480
+ state2.update(getMotionProps());
8263
8481
  });
8264
8482
  function getProps() {
8265
8483
  const isSVG = state2.visualElement.type === "svg";
@@ -8278,7 +8496,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8278
8496
  Object.assign(styleProps, style2);
8279
8497
  }
8280
8498
  if (!state2.isMounted()) {
8281
- Object.assign(styleProps, state2.target);
8499
+ Object.assign(styleProps, state2.baseTarget);
8282
8500
  }
8283
8501
  if (props.drag && props.dragListener !== false) {
8284
8502
  Object.assign(styleProps, {
@@ -8295,16 +8513,29 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
8295
8513
  attrsProps.style = styleProps;
8296
8514
  return attrsProps;
8297
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
+ }
8298
8523
  return (_ctx, _cache) => {
8299
- return vue.openBlock(), vue.createBlock(vue.unref(Primitive), vue.mergeProps({
8524
+ var _a;
8525
+ return vue.openBlock(), vue.createBlock(vue.unref(Primitive), {
8526
+ ref_key: "PrimitiveRef",
8527
+ ref: PrimitiveRef,
8528
+ "get-props": getProps,
8300
8529
  as: _ctx.as,
8301
- "as-child": _ctx.asChild
8302
- }, getProps()), {
8530
+ "as-child": _ctx.asChild,
8531
+ "data-motion-group": ((_a = vue.unref(layoutGroup).key) == null ? void 0 : _a.value) || void 0,
8532
+ onMotioncomplete: onMotionComplete
8533
+ }, {
8303
8534
  default: vue.withCtx(() => [
8304
8535
  vue.renderSlot(_ctx.$slots, "default")
8305
8536
  ]),
8306
8537
  _: 3
8307
- }, 16, ["as", "as-child"]);
8538
+ }, 8, ["as", "as-child", "data-motion-group"]);
8308
8539
  };
8309
8540
  }
8310
8541
  });
@@ -8346,14 +8577,17 @@ function usePopLayout(props) {
8346
8577
  }
8347
8578
  function removePopStyle(state2) {
8348
8579
  const style2 = styles.get(state2);
8349
- if (style2) {
8350
- styles.delete(state2);
8580
+ if (!style2)
8581
+ return;
8582
+ styles.delete(state2);
8583
+ requestIdleCallback(() => {
8351
8584
  document.head.removeChild(style2);
8352
- }
8585
+ });
8353
8586
  }
8354
8587
  return {
8355
8588
  addPopStyle,
8356
- removePopStyle
8589
+ removePopStyle,
8590
+ styles
8357
8591
  };
8358
8592
  }
8359
8593
  const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
@@ -8366,42 +8600,61 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8366
8600
  mode: { default: "sync" },
8367
8601
  initial: { type: Boolean, default: true },
8368
8602
  multiple: { type: Boolean, default: false },
8369
- as: {}
8603
+ as: {},
8604
+ custom: {},
8605
+ onExitComplete: {}
8370
8606
  },
8371
8607
  setup(__props) {
8372
8608
  const props = __props;
8373
- const { initial } = vue.toRefs(props);
8374
- provideAnimatePresence({
8375
- initial,
8376
- safeUnmount(el) {
8377
- return !doneCallbacks.has(el);
8378
- }
8609
+ const presenceContext = {
8610
+ initial: props.initial,
8611
+ custom: props.custom
8612
+ };
8613
+ provideAnimatePresence(presenceContext);
8614
+ vue.onMounted(() => {
8615
+ presenceContext.initial = void 0;
8379
8616
  });
8380
8617
  function enter(el) {
8381
8618
  const state2 = mountedStates.get(el);
8382
8619
  if (!state2) {
8383
8620
  return;
8384
8621
  }
8622
+ state2.isVShow = true;
8385
8623
  removeDoneCallback(el);
8386
8624
  state2.setActive("exit", false);
8387
8625
  }
8388
- const { addPopStyle, removePopStyle } = usePopLayout(props);
8626
+ const { addPopStyle, removePopStyle, styles } = usePopLayout(props);
8627
+ const exitDom = /* @__PURE__ */ new Map();
8628
+ vue.onUnmounted(() => {
8629
+ exitDom.clear();
8630
+ });
8389
8631
  function exit(el, done) {
8390
8632
  const state2 = mountedStates.get(el);
8391
8633
  if (!state2) {
8392
8634
  return done();
8393
8635
  }
8636
+ exitDom.set(el, true);
8394
8637
  removeDoneCallback(el);
8395
8638
  addPopStyle(state2);
8396
8639
  function doneCallback(e) {
8397
8640
  var _a, _b;
8398
- removePopStyle(state2);
8399
8641
  if ((_a = e == null ? void 0 : e.detail) == null ? void 0 : _a.isExit) {
8642
+ const projection = state2.visualElement.projection;
8643
+ if ((projection == null ? void 0 : projection.animationProgress) > 0 && !state2.isSafeToRemove && !state2.isVShow) {
8644
+ return;
8645
+ }
8400
8646
  removeDoneCallback(el);
8401
- (_b = state2.visualElement.projection) == null ? void 0 : _b.willUpdate();
8647
+ exitDom.delete(el);
8648
+ if (exitDom.size === 0) {
8649
+ (_b = props.onExitComplete) == null ? void 0 : _b.call(props);
8650
+ }
8651
+ if (!styles.has(state2)) {
8652
+ state2.willUpdate("done");
8653
+ }
8402
8654
  done();
8403
- if (!el.isConnected) {
8404
- state2.unmount();
8655
+ removePopStyle(state2);
8656
+ if (!(el == null ? void 0 : el.isConnected)) {
8657
+ state2.unmount(true);
8405
8658
  }
8406
8659
  }
8407
8660
  }
@@ -8425,6 +8678,31 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
8425
8678
  };
8426
8679
  }
8427
8680
  });
8681
+ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
8682
+ ...{
8683
+ name: "MotionConfig",
8684
+ inheritAttrs: false
8685
+ },
8686
+ __name: "MotionConfig",
8687
+ props: {
8688
+ transition: {},
8689
+ reduceMotion: { default: defaultConfig.reduceMotion },
8690
+ nonce: {}
8691
+ },
8692
+ setup(__props) {
8693
+ const props = __props;
8694
+ const parentConfig = useMotionConfig();
8695
+ const config = vue.computed(() => ({
8696
+ transition: props.transition ?? parentConfig.value.transition,
8697
+ reduceMotion: props.reduceMotion ?? parentConfig.value.reduceMotion,
8698
+ nonce: props.nonce ?? parentConfig.value.nonce
8699
+ }));
8700
+ provideMotionConfig(config);
8701
+ return (_ctx, _cache) => {
8702
+ return vue.renderSlot(_ctx.$slots, "default");
8703
+ };
8704
+ }
8705
+ });
8428
8706
  function useForceUpdate() {
8429
8707
  const key = vue.ref(0);
8430
8708
  function forceUpdate() {
@@ -8454,9 +8732,12 @@ function nodeGroup() {
8454
8732
  unsubscribe();
8455
8733
  subscriptions.delete(node);
8456
8734
  }
8457
- dirtyAll();
8458
8735
  },
8459
- dirty: dirtyAll
8736
+ dirty: dirtyAll,
8737
+ didUpdate: () => {
8738
+ var _a;
8739
+ (_a = nodes[0]) == null ? void 0 : _a.didUpdate();
8740
+ }
8460
8741
  };
8461
8742
  }
8462
8743
  function useLayoutGroupProvider(props) {
@@ -8488,7 +8769,7 @@ function getGroup(props, parentGroup) {
8488
8769
  const shouldInherit = props.inherit === true || props.inherit === "group";
8489
8770
  return shouldInherit ? (parentGroup == null ? void 0 : parentGroup.group) || nodeGroup() : nodeGroup();
8490
8771
  }
8491
- const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
8772
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
8492
8773
  __name: "LayoutGroup",
8493
8774
  props: {
8494
8775
  id: {},
@@ -8496,12 +8777,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
8496
8777
  },
8497
8778
  setup(__props) {
8498
8779
  const props = __props;
8499
- const { forceRender, key, group } = useLayoutGroupProvider(props);
8500
- vue.onUpdated(() => {
8501
- });
8502
- vue.onBeforeUpdate(() => {
8503
- group.dirty();
8504
- });
8780
+ const { forceRender, key } = useLayoutGroupProvider(props);
8505
8781
  return (_ctx, _cache) => {
8506
8782
  return vue.renderSlot(_ctx.$slots, "default", {
8507
8783
  renderKey: vue.unref(key),
@@ -8510,31 +8786,6 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
8510
8786
  };
8511
8787
  }
8512
8788
  });
8513
- const _sfc_main = /* @__PURE__ */ vue.defineComponent({
8514
- ...{
8515
- name: "MotionConfig",
8516
- inheritAttrs: false
8517
- },
8518
- __name: "MotionConfig",
8519
- props: {
8520
- transition: {},
8521
- reduceMotion: { default: defaultConfig.reduceMotion },
8522
- nonce: {}
8523
- },
8524
- setup(__props) {
8525
- const props = __props;
8526
- const parentConfig = useMotionConfig();
8527
- const config = vue.computed(() => ({
8528
- transition: props.transition ?? parentConfig.value.transition,
8529
- reduceMotion: props.reduceMotion ?? parentConfig.value.reduceMotion,
8530
- nonce: props.nonce ?? parentConfig.value.nonce
8531
- }));
8532
- provideMotionConfig(config);
8533
- return (_ctx, _cache) => {
8534
- return vue.renderSlot(_ctx.$slots, "default");
8535
- };
8536
- }
8537
- });
8538
8789
  function useCombineMotionValues(combineValues) {
8539
8790
  const value = motionValue(combineValues());
8540
8791
  const updateValue = () => value.set(combineValues());
@@ -8739,7 +8990,8 @@ const components = {
8739
8990
  motion: [
8740
8991
  "Motion",
8741
8992
  "AnimatePresence",
8742
- "LayoutGroup"
8993
+ "LayoutGroup",
8994
+ "MotionConfig"
8743
8995
  ]
8744
8996
  };
8745
8997
  const utilities = {
@@ -8784,14 +9036,10 @@ function useAnimate() {
8784
9036
  });
8785
9037
  return [domProxy, animate2];
8786
9038
  }
8787
- Object.defineProperty(exports, "isDragActive", {
8788
- enumerable: true,
8789
- get: () => motionDom.isDragActive
8790
- });
8791
9039
  exports.AnimatePresence = _sfc_main$2;
8792
- exports.LayoutGroup = _sfc_main$1;
9040
+ exports.LayoutGroup = _sfc_main;
8793
9041
  exports.Motion = _sfc_main$3;
8794
- exports.MotionConfig = _sfc_main;
9042
+ exports.MotionConfig = _sfc_main$1;
8795
9043
  exports.MotionValue = MotionValue;
8796
9044
  exports.animate = animate;
8797
9045
  exports.animateMini = animateMini;
@@ -8824,6 +9072,7 @@ exports.inertia = inertia;
8824
9072
  exports.injectLayoutGroup = injectLayoutGroup;
8825
9073
  exports.injectMotion = injectMotion;
8826
9074
  exports.interpolate = interpolate;
9075
+ exports.isDragActive = isDragActive;
8827
9076
  exports.isMotionValue = isMotionValue;
8828
9077
  exports.keyframes = keyframes;
8829
9078
  exports.millisecondsToSeconds = millisecondsToSeconds;