react-ui-animate 3.0.0-rc.0 → 3.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/dist/animation/core/helpers/isDefined.d.ts +1 -1
  2. package/dist/animation/core/helpers/isFluidValue.d.ts +8 -4
  3. package/dist/animation/lib/interpolation.d.ts +20 -15
  4. package/dist/gestures/helpers/math.d.ts +1 -1
  5. package/dist/index.js +1 -2897
  6. package/dist/index.js.map +1 -1
  7. package/package.json +2 -1
  8. package/.vscode/settings.json +0 -3
  9. package/dist/animation/animationType.d.ts +0 -15
  10. package/dist/animation/core/animation/Animation.d.ts +0 -16
  11. package/dist/animation/core/animation/FluidValue.d.ts +0 -21
  12. package/dist/animation/core/animation/RequestAnimationFrame.d.ts +0 -8
  13. package/dist/animation/core/animation/SpringAnimation.d.ts +0 -41
  14. package/dist/animation/core/animation/TimingAnimation.d.ts +0 -35
  15. package/dist/animation/core/animation/TransitionValue.d.ts +0 -21
  16. package/dist/animation/core/helpers/camelToDash.d.ts +0 -7
  17. package/dist/animation/core/helpers/canInterpolate.d.ts +0 -11
  18. package/dist/animation/core/helpers/getAnimatableObject.d.ts +0 -22
  19. package/dist/animation/core/helpers/getNonAnimatableStyle.d.ts +0 -6
  20. package/dist/animation/core/react/Tags.d.ts +0 -3
  21. package/dist/animation/core/react/TransformStyles.d.ts +0 -8
  22. package/dist/animation/core/react/animated.d.ts +0 -29
  23. package/dist/animation/core/react/combineRefs.d.ts +0 -2
  24. package/dist/animation/core/react/functions/camelToDash.d.ts +0 -7
  25. package/dist/animation/core/react/functions/getAnimatableObject.d.ts +0 -22
  26. package/dist/animation/core/react/functions/getCleanProps.d.ts +0 -4
  27. package/dist/animation/core/react/functions/getCssValue.d.ts +0 -8
  28. package/dist/animation/core/react/functions/getNonAnimatableStyle.d.ts +0 -6
  29. package/dist/animation/core/react/functions/index.d.ts +0 -7
  30. package/dist/animation/core/react/functions/isDefined.d.ts +0 -6
  31. package/dist/animation/core/react/functions/isTransitionValue.d.ts +0 -6
  32. package/dist/animation/core/react/helpers/camelToDash.d.ts +0 -7
  33. package/dist/animation/core/react/helpers/canInterpolate.d.ts +0 -7
  34. package/dist/animation/core/react/helpers/getAnimatableObject.d.ts +0 -22
  35. package/dist/animation/core/react/helpers/getCleanProps.d.ts +0 -4
  36. package/dist/animation/core/react/helpers/getCssValue.d.ts +0 -8
  37. package/dist/animation/core/react/helpers/getNonAnimatableStyle.d.ts +0 -6
  38. package/dist/animation/core/react/helpers/index.d.ts +0 -7
  39. package/dist/animation/core/react/helpers/isDefined.d.ts +0 -6
  40. package/dist/animation/core/react/helpers/isFluidValue.d.ts +0 -6
  41. package/dist/animation/core/react/helpers/isTransitionValue.d.ts +0 -6
  42. package/dist/animation/core/react/useMounts.d.ts +0 -26
  43. package/dist/animation/core/react/useTransition.d.ts +0 -9
  44. package/dist/animation/core/react/useTransitions.d.ts +0 -11
  45. package/dist/animation/core/types/animation.d.ts +0 -54
  46. package/dist/animation/core/types/common.d.ts +0 -4
  47. package/dist/animation/core/types/fluid.d.ts +0 -19
  48. package/dist/animation/core/types/index.d.ts +0 -2
  49. package/dist/animation/getInitialConfig.d.ts +0 -3
  50. package/dist/animation/index.d.ts +0 -6
  51. package/dist/animation/interpolation.d.ts +0 -21
  52. package/dist/animation/modules/AnimatedBlock.d.ts +0 -8
  53. package/dist/animation/modules/AnimatedImage.d.ts +0 -8
  54. package/dist/animation/modules/AnimatedInline.d.ts +0 -8
  55. package/dist/animation/modules/MountedBlock.d.ts +0 -29
  56. package/dist/animation/modules/ScrollableBlock.d.ts +0 -21
  57. package/dist/animation/modules/TransitionBlock.d.ts +0 -17
  58. package/dist/animation/modules/index.d.ts +0 -6
  59. package/dist/animation/useAnimatedValue.d.ts +0 -22
  60. package/dist/animation/useMountedValue.d.ts +0 -15
  61. package/dist/gestures/eventAttacher.d.ts +0 -11
  62. package/dist/gestures/index.d.ts +0 -2
  63. package/dist/gestures/math.d.ts +0 -34
  64. package/dist/gestures/types.d.ts +0 -51
  65. package/dist/gestures/withDefault.d.ts +0 -4
  66. package/dist/utils/isDefined.d.ts +0 -1
  67. package/ecosystem.config.js +0 -12
  68. package/example/README.md +0 -46
  69. package/example/package-lock.json +0 -19597
  70. package/example/package.json +0 -45
  71. package/example/public/favicon.ico +0 -0
  72. package/example/public/index.html +0 -20
  73. package/example/public/logo192.png +0 -0
  74. package/example/public/logo512.png +0 -0
  75. package/example/public/manifest.json +0 -25
  76. package/example/public/robots.txt +0 -3
  77. package/example/src/App.tsx +0 -41
  78. package/example/src/components/Draggable.tsx +0 -46
  79. package/example/src/components/Gestures.tsx +0 -151
  80. package/example/src/components/Interpolation.tsx +0 -21
  81. package/example/src/components/Loop.tsx +0 -48
  82. package/example/src/components/MountedBlock.tsx +0 -25
  83. package/example/src/components/MouseMove.tsx +0 -59
  84. package/example/src/components/MultistageTransition.tsx +0 -34
  85. package/example/src/components/Scroll.tsx +0 -39
  86. package/example/src/components/ScrollableBlock.tsx +0 -27
  87. package/example/src/components/SnapTo.tsx +0 -55
  88. package/example/src/components/TransitionBlock.tsx +0 -37
  89. package/example/src/components/Wheel.tsx +0 -39
  90. package/example/src/components/index.ts +0 -18
  91. package/example/src/components/svgLine.tsx +0 -48
  92. package/example/src/components/useAnimatedValue.tsx +0 -57
  93. package/example/src/components/useMountedValue.tsx +0 -62
  94. package/example/src/index.css +0 -8
  95. package/example/src/index.tsx +0 -16
  96. package/example/tsconfig.json +0 -26
  97. package/rollup.config.mjs +0 -18
  98. package/src/animation/core/controllers/Animation.ts +0 -27
  99. package/src/animation/core/controllers/FluidValue.ts +0 -97
  100. package/src/animation/core/controllers/RequestAnimationFrame.ts +0 -13
  101. package/src/animation/core/controllers/SpringAnimation.ts +0 -218
  102. package/src/animation/core/controllers/TimingAnimation.ts +0 -152
  103. package/src/animation/core/easing/Bezier.ts +0 -146
  104. package/src/animation/core/easing/Easing.ts +0 -132
  105. package/src/animation/core/helpers/camelCaseToKebabCase.ts +0 -10
  106. package/src/animation/core/helpers/getCleanProps.ts +0 -16
  107. package/src/animation/core/helpers/getCssValue.ts +0 -60
  108. package/src/animation/core/helpers/index.ts +0 -5
  109. package/src/animation/core/helpers/isDefined.ts +0 -14
  110. package/src/animation/core/helpers/isFluidValue.ts +0 -11
  111. package/src/animation/core/index.ts +0 -16
  112. package/src/animation/core/interpolation/Colors.ts +0 -232
  113. package/src/animation/core/interpolation/Interpolation.ts +0 -395
  114. package/src/animation/core/interpolation/__tests__/Colors.test.tsx +0 -35
  115. package/src/animation/core/react/fluid.ts +0 -197
  116. package/src/animation/core/react/makeFluid.ts +0 -294
  117. package/src/animation/core/react/transforms.ts +0 -90
  118. package/src/animation/core/react/useFluidValue.ts +0 -43
  119. package/src/animation/core/react/useMount.ts +0 -58
  120. package/src/animation/core/types/animation.d.ts +0 -56
  121. package/src/animation/core/types/common.d.ts +0 -4
  122. package/src/animation/core/types/fluid.d.ts +0 -38
  123. package/src/animation/lib/animationType.ts +0 -17
  124. package/src/animation/lib/getInitialConfig.ts +0 -61
  125. package/src/animation/lib/index.ts +0 -12
  126. package/src/animation/lib/interpolation.ts +0 -47
  127. package/src/animation/lib/modules/AnimatedBlock.ts +0 -8
  128. package/src/animation/lib/modules/AnimatedImage.ts +0 -8
  129. package/src/animation/lib/modules/AnimatedInline.ts +0 -8
  130. package/src/animation/lib/modules/MountedBlock.tsx +0 -51
  131. package/src/animation/lib/modules/ScrollableBlock.tsx +0 -68
  132. package/src/animation/lib/modules/TransitionBlock.tsx +0 -28
  133. package/src/animation/lib/modules/index.ts +0 -6
  134. package/src/animation/lib/useAnimatedValue.ts +0 -60
  135. package/src/animation/lib/useMountedValue.ts +0 -18
  136. package/src/gestures/controllers/DragGesture.ts +0 -178
  137. package/src/gestures/controllers/Gesture.ts +0 -54
  138. package/src/gestures/controllers/MouseMoveGesture.ts +0 -111
  139. package/src/gestures/controllers/ScrollGesture.ts +0 -107
  140. package/src/gestures/controllers/WheelGesture.ts +0 -123
  141. package/src/gestures/controllers/index.ts +0 -4
  142. package/src/gestures/helpers/eventAttacher.ts +0 -67
  143. package/src/gestures/helpers/index.ts +0 -1
  144. package/src/gestures/helpers/math.ts +0 -120
  145. package/src/gestures/helpers/withDefault.ts +0 -3
  146. package/src/gestures/hooks/index.ts +0 -5
  147. package/src/gestures/hooks/useDrag.ts +0 -14
  148. package/src/gestures/hooks/useGesture.ts +0 -38
  149. package/src/gestures/hooks/useMouseMove.ts +0 -11
  150. package/src/gestures/hooks/useRecognizer.ts +0 -59
  151. package/src/gestures/hooks/useScroll.ts +0 -11
  152. package/src/gestures/hooks/useWheel.ts +0 -11
  153. package/src/gestures/types/index.d.ts +0 -49
  154. package/src/hooks/index.ts +0 -3
  155. package/src/hooks/useMeasure.ts +0 -132
  156. package/src/hooks/useOutsideClick.ts +0 -36
  157. package/src/hooks/useWindowDimension.ts +0 -58
  158. package/src/index.ts +0 -42
  159. package/src/utils/delay.ts +0 -9
  160. package/src/utils/index.ts +0 -1
  161. package/tsconfig.json +0 -24
package/dist/index.js CHANGED
@@ -1,2898 +1,2 @@
1
- var React = require('react');
2
- var jsxRuntime = require('react/jsx-runtime');
3
-
4
- function _interopNamespaceDefault(e) {
5
- var n = Object.create(null);
6
- if (e) {
7
- Object.keys(e).forEach(function (k) {
8
- if (k !== 'default') {
9
- var d = Object.getOwnPropertyDescriptor(e, k);
10
- Object.defineProperty(n, k, d.get ? d : {
11
- enumerable: true,
12
- get: function () { return e[k]; }
13
- });
14
- }
15
- });
16
- }
17
- n.default = e;
18
- return Object.freeze(n);
19
- }
20
-
21
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
22
-
23
- /******************************************************************************
24
- Copyright (c) Microsoft Corporation.
25
-
26
- Permission to use, copy, modify, and/or distribute this software for any
27
- purpose with or without fee is hereby granted.
28
-
29
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
30
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
31
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
32
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
33
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
34
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
35
- PERFORMANCE OF THIS SOFTWARE.
36
- ***************************************************************************** */
37
- /* global Reflect, Promise, SuppressedError, Symbol */
38
-
39
- var extendStatics = function(d, b) {
40
- extendStatics = Object.setPrototypeOf ||
41
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
42
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
43
- return extendStatics(d, b);
44
- };
45
-
46
- function __extends(d, b) {
47
- if (typeof b !== "function" && b !== null)
48
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
49
- extendStatics(d, b);
50
- function __() { this.constructor = d; }
51
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
52
- }
53
-
54
- var __assign = function() {
55
- __assign = Object.assign || function __assign(t) {
56
- for (var s, i = 1, n = arguments.length; i < n; i++) {
57
- s = arguments[i];
58
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
59
- }
60
- return t;
61
- };
62
- return __assign.apply(this, arguments);
63
- };
64
-
65
- function __rest(s, e) {
66
- var t = {};
67
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
68
- t[p] = s[p];
69
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
70
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
71
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
72
- t[p[i]] = s[p[i]];
73
- }
74
- return t;
75
- }
76
-
77
- function __values(o) {
78
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
79
- if (m) return m.call(o);
80
- if (o && typeof o.length === "number") return {
81
- next: function () {
82
- if (o && i >= o.length) o = void 0;
83
- return { value: o && o[i++], done: !o };
84
- }
85
- };
86
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
87
- }
88
-
89
- function __read(o, n) {
90
- var m = typeof Symbol === "function" && o[Symbol.iterator];
91
- if (!m) return o;
92
- var i = m.call(o), r, ar = [], e;
93
- try {
94
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
95
- }
96
- catch (error) { e = { error: error }; }
97
- finally {
98
- try {
99
- if (r && !r.done && (m = i["return"])) m.call(i);
100
- }
101
- finally { if (e) throw e.error; }
102
- }
103
- return ar;
104
- }
105
-
106
- function __spreadArray(to, from, pack) {
107
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
108
- if (ar || !(i in from)) {
109
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
110
- ar[i] = from[i];
111
- }
112
- }
113
- return to.concat(ar || Array.prototype.slice.call(from));
114
- }
115
-
116
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
117
- var e = new Error(message);
118
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
119
- };
120
-
121
- /**
122
- * Base Animation class
123
- */
124
- var Animation = /** @class */ (function () {
125
- function Animation() {
126
- }
127
- Animation.prototype._debounceOnEnd = function (result) {
128
- var onEnd = this._onEnd;
129
- var onRest = this._onRest;
130
- this._onEnd = null;
131
- this._onRest = null;
132
- onRest && onRest(result);
133
- onEnd && onEnd(result);
134
- };
135
- Animation.prototype.stop = function () { };
136
- return Animation;
137
- }());
138
-
139
- var RequestAnimationFrame = {
140
- current: function (cb) { return window.requestAnimationFrame(cb); },
141
- inject: function (injected) {
142
- RequestAnimationFrame.current = injected;
143
- },
144
- };
145
- var CancelAnimationFrame = {
146
- current: function (id) { return window.cancelAnimationFrame(id); },
147
- inject: function (injected) {
148
- CancelAnimationFrame.current = injected;
149
- },
150
- };
151
-
152
- /**
153
- * Class implementing spring based animation
154
- */
155
- var SpringAnimation = /** @class */ (function (_super) {
156
- __extends(SpringAnimation, _super);
157
- function SpringAnimation(_a) {
158
- var initialPosition = _a.initialPosition, config = _a.config;
159
- var _b, _c, _d, _e, _f, _g;
160
- var _this = _super.call(this) || this;
161
- _this._overshootClamping = false;
162
- _this._initialVelocity = 0;
163
- _this._lastVelocity = 0;
164
- _this._startPosition = initialPosition;
165
- _this._position = _this._startPosition;
166
- _this._restDisplacementThreshold = (_b = config === null || config === void 0 ? void 0 : config.restDistance) !== null && _b !== void 0 ? _b : 0.001;
167
- _this._restSpeedThreshold = (_c = config === null || config === void 0 ? void 0 : config.restDistance) !== null && _c !== void 0 ? _c : 0.001;
168
- _this._mass = (_d = config === null || config === void 0 ? void 0 : config.mass) !== null && _d !== void 0 ? _d : 1;
169
- _this._tension = (_e = config === null || config === void 0 ? void 0 : config.tension) !== null && _e !== void 0 ? _e : 170;
170
- _this._friction = (_f = config === null || config === void 0 ? void 0 : config.friction) !== null && _f !== void 0 ? _f : 26;
171
- _this._delay = (_g = config === null || config === void 0 ? void 0 : config.delay) !== null && _g !== void 0 ? _g : 0;
172
- _this._onRest = config === null || config === void 0 ? void 0 : config.onRest;
173
- _this._onChange = config === null || config === void 0 ? void 0 : config.onChange;
174
- return _this;
175
- }
176
- SpringAnimation.prototype.onChange = function (value) {
177
- this._onFrame(value);
178
- if (this._lastPosition !== value) {
179
- if (this._onChange) {
180
- this._onChange(value);
181
- }
182
- }
183
- this._lastPosition = value;
184
- };
185
- SpringAnimation.prototype.onUpdate = function () {
186
- var _this = this;
187
- var now = Date.now();
188
- var deltaTime = Math.min(now - this._lastTime, 64);
189
- this._lastTime = now;
190
- var c = this._friction;
191
- var m = this._mass;
192
- var k = this._tension;
193
- var v0 = -this._lastVelocity;
194
- var x0 = this._toValue - this._position;
195
- var zeta = c / (2 * Math.sqrt(k * m)); // damping ratio
196
- var omega0 = Math.sqrt(k / m); // undamped angular frequency of the oscillator (rad/ms)
197
- var omega1 = omega0 * Math.sqrt(1 - Math.pow(zeta, 2)); // exponential decay
198
- var t = deltaTime / 1000;
199
- var sin1 = Math.sin(omega1 * t);
200
- var cos1 = Math.cos(omega1 * t);
201
- // under damped
202
- var underDampedEnvelope = Math.exp(-zeta * omega0 * t);
203
- var underDampedFrag1 = underDampedEnvelope *
204
- (sin1 * ((v0 + zeta * omega0 * x0) / omega1) + x0 * cos1);
205
- var underDampedPosition = this._toValue - underDampedFrag1;
206
- // This looks crazy -- it's actually just the derivative of the oscillation function
207
- var underDampedVelocity = zeta * omega0 * underDampedFrag1 -
208
- underDampedEnvelope *
209
- (cos1 * (v0 + zeta * omega0 * x0) - omega1 * x0 * sin1);
210
- // critically damped
211
- var criticallyDampedEnvelope = Math.exp(-omega0 * t);
212
- var criticallyDampedPosition = this._toValue - criticallyDampedEnvelope * (x0 + (v0 + omega0 * x0) * t);
213
- var criticallyDampedVelocity = criticallyDampedEnvelope *
214
- (v0 * (t * omega0 - 1) + t * x0 * omega0 * omega0);
215
- this.onChange(this._position);
216
- var isOvershooting = function () {
217
- if (_this._overshootClamping && _this._tension !== 0) {
218
- return _this._position < _this._toValue
219
- ? _this._position > _this._toValue
220
- : _this._position < _this._toValue;
221
- }
222
- else {
223
- return false;
224
- }
225
- };
226
- var isVelocity = Math.abs(this._lastVelocity) < this._restSpeedThreshold;
227
- var isDisplacement = this._tension === 0 ||
228
- Math.abs(this._toValue - this._position) <
229
- this._restDisplacementThreshold;
230
- if (zeta < 1) {
231
- this._position = underDampedPosition;
232
- this._lastVelocity = underDampedVelocity;
233
- }
234
- else {
235
- this._position = criticallyDampedPosition;
236
- this._lastVelocity = criticallyDampedVelocity;
237
- }
238
- if (isOvershooting() || (isVelocity && isDisplacement)) {
239
- if (this._tension !== 0) {
240
- this._lastVelocity = 0;
241
- this._position = this._toValue;
242
- this.onChange(this._position);
243
- }
244
- // clear lastTimestamp to avoid using stale value by the next spring animation that starts after this one
245
- this._lastTime = 0;
246
- this._debounceOnEnd({ finished: true, value: this._toValue });
247
- return;
248
- }
249
- this._animationFrame = RequestAnimationFrame.current(this.onUpdate.bind(this));
250
- };
251
- SpringAnimation.prototype.stop = function () {
252
- this._active = false;
253
- clearTimeout(this._timeout);
254
- CancelAnimationFrame.current(this._animationFrame);
255
- this._debounceOnEnd({ finished: false, value: this._position });
256
- };
257
- // Set value
258
- SpringAnimation.prototype.set = function (toValue) {
259
- this.stop();
260
- this._position = toValue;
261
- this._lastTime = 0;
262
- this._lastVelocity = 0;
263
- this.onChange(toValue);
264
- };
265
- SpringAnimation.prototype.start = function (_a) {
266
- var _this = this;
267
- var toValue = _a.toValue, onFrame = _a.onFrame, previousAnimation = _a.previousAnimation, onEnd = _a.onEnd;
268
- var onStart = function () {
269
- _this._onFrame = onFrame;
270
- _this._active = true;
271
- _this._toValue = toValue;
272
- _this._onEnd = onEnd;
273
- var now = Date.now();
274
- if (previousAnimation instanceof SpringAnimation) {
275
- _this._lastVelocity =
276
- previousAnimation._lastVelocity || _this._lastVelocity || 0;
277
- _this._lastTime = previousAnimation._lastTime || now;
278
- }
279
- else {
280
- _this._lastTime = now;
281
- }
282
- _this._animationFrame = RequestAnimationFrame.current(_this.onUpdate.bind(_this));
283
- };
284
- if (this._delay !== 0) {
285
- this._timeout = setTimeout(function () { return onStart(); }, this._delay);
286
- }
287
- else {
288
- onStart();
289
- }
290
- };
291
- return SpringAnimation;
292
- }(Animation));
293
-
294
- /**
295
- * https://github.com/gre/bezier-easing
296
- * BezierEasing - use bezier curve for transition easing function
297
- * by Gaëtan Renaudeau 2014 - 2015 – MIT License
298
- */
299
- // These values are established by empiricism with tests (tradeoff: performance VS precision)
300
- var NEWTON_ITERATIONS = 4;
301
- var NEWTON_MIN_SLOPE = 0.001;
302
- var SUBDIVISION_PRECISION = 0.0000001;
303
- var SUBDIVISION_MAX_ITERATIONS = 10;
304
- var kSplineTableSize = 11;
305
- var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
306
- var float32ArraySupported = typeof Float32Array === "function";
307
- function A(aA1, aA2) {
308
- return 1.0 - 3.0 * aA2 + 3.0 * aA1;
309
- }
310
- function B(aA1, aA2) {
311
- return 3.0 * aA2 - 6.0 * aA1;
312
- }
313
- function C(aA1) {
314
- return 3.0 * aA1;
315
- }
316
- // Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
317
- function calcBezier(aT, aA1, aA2) {
318
- return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT;
319
- }
320
- // Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
321
- function getSlope(aT, aA1, aA2) {
322
- return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1);
323
- }
324
- function binarySubdivide(aX, aA, aB, mX1, mX2) {
325
- var currentX, currentT, i = 0;
326
- do {
327
- currentT = aA + (aB - aA) / 2.0;
328
- currentX = calcBezier(currentT, mX1, mX2) - aX;
329
- if (currentX > 0.0) {
330
- aB = currentT;
331
- }
332
- else {
333
- aA = currentT;
334
- }
335
- } while (Math.abs(currentX) > SUBDIVISION_PRECISION &&
336
- ++i < SUBDIVISION_MAX_ITERATIONS);
337
- return currentT;
338
- }
339
- function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
340
- for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
341
- var currentSlope = getSlope(aGuessT, mX1, mX2);
342
- if (currentSlope === 0.0) {
343
- return aGuessT;
344
- }
345
- var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
346
- aGuessT -= currentX / currentSlope;
347
- }
348
- return aGuessT;
349
- }
350
- function LinearEasing(x) {
351
- return x;
352
- }
353
- function bezier(mX1, mY1, mX2, mY2) {
354
- if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) {
355
- throw new Error("bezier x values must be in [0, 1] range");
356
- }
357
- if (mX1 === mY1 && mX2 === mY2) {
358
- return LinearEasing;
359
- }
360
- // Precompute samples table
361
- var sampleValues = float32ArraySupported
362
- ? new Float32Array(kSplineTableSize)
363
- : new Array(kSplineTableSize);
364
- for (var i = 0; i < kSplineTableSize; ++i) {
365
- sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
366
- }
367
- function getTForX(aX) {
368
- var intervalStart = 0.0;
369
- var currentSample = 1;
370
- var lastSample = kSplineTableSize - 1;
371
- for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
372
- intervalStart += kSampleStepSize;
373
- }
374
- --currentSample;
375
- // Interpolate to provide an initial guess for t
376
- var dist = (aX - sampleValues[currentSample]) /
377
- (sampleValues[currentSample + 1] - sampleValues[currentSample]);
378
- var guessForT = intervalStart + dist * kSampleStepSize;
379
- var initialSlope = getSlope(guessForT, mX1, mX2);
380
- if (initialSlope >= NEWTON_MIN_SLOPE) {
381
- return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
382
- }
383
- else if (initialSlope === 0.0) {
384
- return guessForT;
385
- }
386
- else {
387
- return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
388
- }
389
- }
390
- return function BezierEasing(x) {
391
- // Because JavaScript number are imprecise, we should guarantee the extremes are right.
392
- if (x === 0 || x === 1) {
393
- return x;
394
- }
395
- return calcBezier(getTForX(x), mY1, mY2);
396
- };
397
- }
398
-
399
- /**
400
- * Copyright (c) 2015-present, Facebook, Inc.
401
- * All rights reserved.
402
- *
403
- * This source code is licensed under the MIT license found in the
404
- * LICENSE file in the root directory of this source tree.
405
- *
406
- */
407
- /**
408
- * This class implements common easing functions. The math is pretty obscure,
409
- * but this cool website has nice visual illustrations of what they represent:
410
- * http://xaedes.de/dev/transitions/
411
- */
412
- var Easing = /** @class */ (function () {
413
- function Easing() {
414
- }
415
- Easing.step0 = function (n) {
416
- return n > 0 ? 1 : 0;
417
- };
418
- Easing.step1 = function (n) {
419
- return n >= 1 ? 1 : 0;
420
- };
421
- Easing.linear = function (t) {
422
- return t;
423
- };
424
- Easing.ease = function (t) {
425
- return ease(t);
426
- };
427
- Easing.quad = function (t) {
428
- return t * t;
429
- };
430
- Easing.cubic = function (t) {
431
- return t * t * t;
432
- };
433
- Easing.poly = function (n) {
434
- return function (t) { return Math.pow(t, n); };
435
- };
436
- Easing.sin = function (t) {
437
- return 1 - Math.cos((t * Math.PI) / 2);
438
- };
439
- Easing.circle = function (t) {
440
- return 1 - Math.sqrt(1 - t * t);
441
- };
442
- Easing.exp = function (t) {
443
- return Math.pow(2, 10 * (t - 1));
444
- };
445
- /**
446
- * A simple elastic interaction, similar to a spring. Default bounciness
447
- * is 1, which overshoots a little bit once. 0 bounciness doesn't overshoot
448
- * at all, and bounciness of N > 1 will overshoot about N times.
449
- *
450
- * Wolfram Plots:
451
- *
452
- * http://tiny.cc/elastic_b_1 (default bounciness = 1)
453
- * http://tiny.cc/elastic_b_3 (bounciness = 3)
454
- */
455
- Easing.elastic = function (bounciness) {
456
- if (bounciness === void 0) { bounciness = 1; }
457
- var p = bounciness * Math.PI;
458
- return function (t) {
459
- return 1 - Math.pow(Math.cos((t * Math.PI) / 2), 3) * Math.cos(t * p);
460
- };
461
- };
462
- Easing.back = function (s) {
463
- if (s === undefined) {
464
- s = 1.70158;
465
- }
466
- return function (t) { return t * t * ((s + 1) * t - s); };
467
- };
468
- Easing.bounce = function (t) {
469
- if (t < 1 / 2.75) {
470
- return 7.5625 * t * t;
471
- }
472
- if (t < 2 / 2.75) {
473
- t -= 1.5 / 2.75;
474
- return 7.5625 * t * t + 0.75;
475
- }
476
- if (t < 2.5 / 2.75) {
477
- t -= 2.25 / 2.75;
478
- return 7.5625 * t * t + 0.9375;
479
- }
480
- t -= 2.625 / 2.75;
481
- return 7.5625 * t * t + 0.984375;
482
- };
483
- Easing.bezier = function (x1, y1, x2, y2) {
484
- return bezier(x1, y1, x2, y2);
485
- };
486
- Easing.in = function (easing) {
487
- return easing;
488
- };
489
- /**
490
- * Runs an easing function backwards.
491
- */
492
- Easing.out = function (easing) {
493
- return function (t) { return 1 - easing(1 - t); };
494
- };
495
- /**
496
- * Makes any easing function symmetrical.
497
- */
498
- Easing.inOut = function (easing) {
499
- return function (t) {
500
- if (t < 0.5) {
501
- return easing(t * 2) / 2;
502
- }
503
- return 1 - easing((1 - t) * 2) / 2;
504
- };
505
- };
506
- return Easing;
507
- }());
508
- var ease = Easing.bezier(0.42, 0, 1, 1);
509
-
510
- /**
511
- * Class implementing timing based animation
512
- */
513
- var TimingAnimation = /** @class */ (function (_super) {
514
- __extends(TimingAnimation, _super);
515
- function TimingAnimation(_a) {
516
- var initialPosition = _a.initialPosition, config = _a.config;
517
- var _b, _c, _d;
518
- var _this = _super.call(this) || this;
519
- _this._fromValue = initialPosition;
520
- _this._position = _this._fromValue;
521
- _this._easing = (_b = config === null || config === void 0 ? void 0 : config.easing) !== null && _b !== void 0 ? _b : Easing.linear;
522
- _this._duration = (_c = config === null || config === void 0 ? void 0 : config.duration) !== null && _c !== void 0 ? _c : 500;
523
- _this._tempDuration = _this._duration;
524
- // Modifiers
525
- // here immediate acts like duration: 0
526
- if (config === null || config === void 0 ? void 0 : config.immediate) {
527
- _this._duration = 0;
528
- }
529
- _this._delay = (_d = config === null || config === void 0 ? void 0 : config.delay) !== null && _d !== void 0 ? _d : 0;
530
- _this._onRest = config === null || config === void 0 ? void 0 : config.onRest;
531
- _this._onChange = config === null || config === void 0 ? void 0 : config.onChange;
532
- return _this;
533
- }
534
- TimingAnimation.prototype.onChange = function (value) {
535
- this._onFrame(value);
536
- if (this._lastPosition !== value) {
537
- if (this._onChange) {
538
- this._onChange(value);
539
- }
540
- }
541
- this._lastPosition = value;
542
- };
543
- TimingAnimation.prototype.onUpdate = function () {
544
- var now = Date.now();
545
- var runTime = now - this._startTime;
546
- if (runTime >= this._duration) {
547
- this._startTime = 0;
548
- this._position = this._toValue;
549
- this.onChange(this._position);
550
- this._debounceOnEnd({ finished: true, value: this._position });
551
- return;
552
- }
553
- var progress = this._easing(runTime / this._duration);
554
- this._position =
555
- this._fromValue + (this._toValue - this._fromValue) * progress;
556
- this.onChange(this._position);
557
- this._animationFrame = RequestAnimationFrame.current(this.onUpdate.bind(this));
558
- };
559
- TimingAnimation.prototype.stop = function () {
560
- this._active = false;
561
- clearTimeout(this._timeout);
562
- CancelAnimationFrame.current(this._animationFrame);
563
- this._debounceOnEnd({ finished: false, value: this._position });
564
- };
565
- // Set value
566
- TimingAnimation.prototype.set = function (toValue) {
567
- this.stop();
568
- this._position = toValue;
569
- this.onChange(toValue);
570
- };
571
- TimingAnimation.prototype.start = function (_a) {
572
- var _this = this;
573
- var toValue = _a.toValue, onFrame = _a.onFrame, previousAnimation = _a.previousAnimation, onEnd = _a.onEnd;
574
- var onStart = function () {
575
- _this._onFrame = onFrame;
576
- _this._active = true;
577
- _this._onEnd = onEnd;
578
- _this._toValue = toValue;
579
- if (previousAnimation &&
580
- previousAnimation instanceof TimingAnimation &&
581
- previousAnimation._toValue === toValue &&
582
- previousAnimation._startTime) {
583
- _this._startTime = previousAnimation._startTime;
584
- _this._fromValue = previousAnimation._fromValue;
585
- }
586
- else {
587
- var now = Date.now();
588
- _this._startTime = now;
589
- _this._fromValue = _this._position;
590
- }
591
- _this._animationFrame = RequestAnimationFrame.current(_this.onUpdate.bind(_this));
592
- };
593
- if (this._delay !== 0) {
594
- this._timeout = setTimeout(function () { return onStart(); }, this._delay);
595
- }
596
- else {
597
- onStart();
598
- }
599
- };
600
- return TimingAnimation;
601
- }(Animation));
602
-
603
- var COLOR_NUMBER_REGEX = /[+-]?\d+(\.\d+)?|[\s]?\.\d+|#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})/gi;
604
- var HEX_NAME_COLOR = /#[a-f\d]{3,}|transparent|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|burntsienna|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen/gi;
605
- // Named colors
606
- var colorNames = {
607
- transparent: "#00000000",
608
- aliceblue: "#f0f8ffff",
609
- antiquewhite: "#faebd7ff",
610
- aqua: "#00ffffff",
611
- aquamarine: "#7fffd4ff",
612
- azure: "#f0ffffff",
613
- beige: "#f5f5dcff",
614
- bisque: "#ffe4c4ff",
615
- black: "#000000ff",
616
- blanchedalmond: "#ffebcdff",
617
- blue: "#0000ffff",
618
- blueviolet: "#8a2be2ff",
619
- brown: "#a52a2aff",
620
- burlywood: "#deb887ff",
621
- burntsienna: "#ea7e5dff",
622
- cadetblue: "#5f9ea0ff",
623
- chartreuse: "#7fff00ff",
624
- chocolate: "#d2691eff",
625
- coral: "#ff7f50ff",
626
- cornflowerblue: "#6495edff",
627
- cornsilk: "#fff8dcff",
628
- crimson: "#dc143cff",
629
- cyan: "#00ffffff",
630
- darkblue: "#00008bff",
631
- darkcyan: "#008b8bff",
632
- darkgoldenrod: "#b8860bff",
633
- darkgray: "#a9a9a9ff",
634
- darkgreen: "#006400ff",
635
- darkgrey: "#a9a9a9ff",
636
- darkkhaki: "#bdb76bff",
637
- darkmagenta: "#8b008bff",
638
- darkolivegreen: "#556b2fff",
639
- darkorange: "#ff8c00ff",
640
- darkorchid: "#9932ccff",
641
- darkred: "#8b0000ff",
642
- darksalmon: "#e9967aff",
643
- darkseagreen: "#8fbc8fff",
644
- darkslateblue: "#483d8bff",
645
- darkslategray: "#2f4f4fff",
646
- darkslategrey: "#2f4f4fff",
647
- darkturquoise: "#00ced1ff",
648
- darkviolet: "#9400d3ff",
649
- deeppink: "#ff1493ff",
650
- deepskyblue: "#00bfffff",
651
- dimgray: "#696969ff",
652
- dimgrey: "#696969ff",
653
- dodgerblue: "#1e90ffff",
654
- firebrick: "#b22222ff",
655
- floralwhite: "#fffaf0ff",
656
- forestgreen: "#228b22ff",
657
- fuchsia: "#ff00ffff",
658
- gainsboro: "#dcdcdcff",
659
- ghostwhite: "#f8f8ffff",
660
- gold: "#ffd700ff",
661
- goldenrod: "#daa520ff",
662
- gray: "#808080ff",
663
- green: "#008000ff",
664
- greenyellow: "#adff2fff",
665
- grey: "#808080ff",
666
- honeydew: "#f0fff0ff",
667
- hotpink: "#ff69b4ff",
668
- indianred: "#cd5c5cff",
669
- indigo: "#4b0082ff",
670
- ivory: "#fffff0ff",
671
- khaki: "#f0e68cff",
672
- lavender: "#e6e6faff",
673
- lavenderblush: "#fff0f5ff",
674
- lawngreen: "#7cfc00ff",
675
- lemonchiffon: "#fffacdff",
676
- lightblue: "#add8e6ff",
677
- lightcoral: "#f08080ff",
678
- lightcyan: "#e0ffffff",
679
- lightgoldenrodyellow: "#fafad2ff",
680
- lightgray: "#d3d3d3ff",
681
- lightgreen: "#90ee90ff",
682
- lightgrey: "#d3d3d3ff",
683
- lightpink: "#ffb6c1ff",
684
- lightsalmon: "#ffa07aff",
685
- lightseagreen: "#20b2aaff",
686
- lightskyblue: "#87cefaff",
687
- lightslategray: "#778899ff",
688
- lightslategrey: "#778899ff",
689
- lightsteelblue: "#b0c4deff",
690
- lightyellow: "#ffffe0ff",
691
- lime: "#00ff00ff",
692
- limegreen: "#32cd32ff",
693
- linen: "#faf0e6ff",
694
- magenta: "#ff00ffff",
695
- maroon: "#800000ff",
696
- mediumaquamarine: "#66cdaaff",
697
- mediumblue: "#0000cdff",
698
- mediumorchid: "#ba55d3ff",
699
- mediumpurple: "#9370dbff",
700
- mediumseagreen: "#3cb371ff",
701
- mediumslateblue: "#7b68eeff",
702
- mediumspringgreen: "#00fa9aff",
703
- mediumturquoise: "#48d1ccff",
704
- mediumvioletred: "#c71585ff",
705
- midnightblue: "#191970ff",
706
- mintcream: "#f5fffaff",
707
- mistyrose: "#ffe4e1ff",
708
- moccasin: "#ffe4b5ff",
709
- navajowhite: "#ffdeadff",
710
- navy: "#000080ff",
711
- oldlace: "#fdf5e6ff",
712
- olive: "#808000ff",
713
- olivedrab: "#6b8e23ff",
714
- orange: "#ffa500ff",
715
- orangered: "#ff4500ff",
716
- orchid: "#da70d6ff",
717
- palegoldenrod: "#eee8aaff",
718
- palegreen: "#98fb98ff",
719
- paleturquoise: "#afeeeeff",
720
- palevioletred: "#db7093ff",
721
- papayawhip: "#ffefd5ff",
722
- peachpuff: "#ffdab9ff",
723
- peru: "#cd853fff",
724
- pink: "#ffc0cbff",
725
- plum: "#dda0ddff",
726
- powderblue: "#b0e0e6ff",
727
- purple: "#800080ff",
728
- rebeccapurple: "#663399ff",
729
- red: "#ff0000ff",
730
- rosybrown: "#bc8f8fff",
731
- royalblue: "#4169e1ff",
732
- saddlebrown: "#8b4513ff",
733
- salmon: "#fa8072ff",
734
- sandybrown: "#f4a460ff",
735
- seagreen: "#2e8b57ff",
736
- seashell: "#fff5eeff",
737
- sienna: "#a0522dff",
738
- silver: "#c0c0c0ff",
739
- skyblue: "#87ceebff",
740
- slateblue: "#6a5acdff",
741
- slategray: "#708090ff",
742
- slategrey: "#708090ff",
743
- snow: "#fffafaff",
744
- springgreen: "#00ff7fff",
745
- steelblue: "#4682b4ff",
746
- tan: "#d2b48cff",
747
- teal: "#008080ff",
748
- thistle: "#d8bfd8ff",
749
- tomato: "#ff6347ff",
750
- turquoise: "#40e0d0ff",
751
- violet: "#ee82eeff",
752
- wheat: "#f5deb3ff",
753
- white: "#ffffffff",
754
- whitesmoke: "#f5f5f5ff",
755
- yellow: "#ffff00ff",
756
- yellowgreen: "#9acd32ff",
757
- };
758
- function conv3to6(hex) {
759
- var regex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
760
- return hex.replace(regex, function (_, r, g, b) {
761
- return "#" + r + r + g + g + b + b;
762
- });
763
- }
764
- function conv6to8(hex) {
765
- if (hex.length === 7) {
766
- return hex + "FF";
767
- }
768
- return hex;
769
- }
770
- function hexToRgba(hex) {
771
- var hex6 = conv3to6(hex);
772
- var hex8 = conv6to8(hex6);
773
- var hexRgba = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex8);
774
- return {
775
- r: parseInt(hexRgba[1], 16),
776
- g: parseInt(hexRgba[2], 16),
777
- b: parseInt(hexRgba[3], 16),
778
- a: parseInt(hexRgba[4], 16) / 255,
779
- };
780
- }
781
- function rgbaToHex(rgba) {
782
- var r = rgba.r, g = rgba.g, b = rgba.b, a = rgba.a;
783
- var hexR = (r | (1 << 8)).toString(16).slice(1);
784
- var hexG = (g | (1 << 8)).toString(16).slice(1);
785
- var hexB = (b | (1 << 8)).toString(16).slice(1);
786
- var hexA = ((a * 255) | (1 << 8)).toString(16).slice(1);
787
- return "#" + hexR + hexG + hexB + hexA;
788
- }
789
-
790
- /**
791
- * isFluidValue to check the value is FluidValue or not
792
- * @param value - any
793
- * @returns - boolean
794
- */
795
- var isFluidValue = function (value) {
796
- return (typeof value === 'object' &&
797
- Object.prototype.hasOwnProperty.call(value, '_subscribe'));
798
- };
799
-
800
- /**
801
- * Filters out properties with fluid values from a given props object.
802
- * This function removes any properties that are considered fluid values,
803
- * typically those that subscribe to updates and therefore should not be
804
- * included in a static props object.
805
- *
806
- * @param props - The original props object, which may include fluid values.
807
- * @returns A new props object with fluid values removed.
808
- */
809
- var getCleanProps = function (_a) {
810
- _a.style; var props = __rest(_a, ["style"]);
811
- return Object.fromEntries(Object.entries(props).filter(function (_a) {
812
- var _b = __read(_a, 2); _b[0]; var value = _b[1];
813
- return !isFluidValue(value);
814
- }));
815
- };
816
-
817
- var unitlessStyleProps = [
818
- 'borderImageOutset',
819
- 'borderImageSlice',
820
- 'borderImageWidth',
821
- 'fontWeight',
822
- 'lineHeight',
823
- 'opacity',
824
- 'orphans',
825
- 'tabSize',
826
- 'widows',
827
- 'zIndex',
828
- 'zoom',
829
- // SVG-related properties
830
- 'fillOpacity',
831
- 'floodOpacity',
832
- 'stopOpacity',
833
- 'strokeDasharray',
834
- 'strokeDashoffset',
835
- 'strokeMiterlimit',
836
- 'strokeOpacity',
837
- 'strokeWidth',
838
- // prefixed
839
- 'animationIterationCount',
840
- 'boxFlex',
841
- 'boxFlexGroup',
842
- 'boxOrdinalGroup',
843
- 'columnCount',
844
- 'flex',
845
- 'flexGrow',
846
- 'flexPositive',
847
- 'flexShrink',
848
- 'flexNegative',
849
- 'flexOrder',
850
- 'gridRow',
851
- 'gridColumn',
852
- 'order',
853
- 'lineClamp',
854
- ];
855
- /**
856
- * getCssValue() function to get css value with unit or without unit
857
- * it is only for style property - it cannot be used with transform keys
858
- * @param property - style property
859
- * @param value - style value
860
- * @returns - value with unit or without unit
861
- */
862
- function getCssValue(property, value) {
863
- var cssValue;
864
- if (typeof value === 'number') {
865
- if (unitlessStyleProps.includes(property)) {
866
- cssValue = value;
867
- }
868
- else {
869
- cssValue = value + 'px';
870
- }
871
- }
872
- else {
873
- cssValue = value;
874
- }
875
- return cssValue;
876
- }
877
-
878
- /**
879
- * Checks if a value is defined (not null or undefined).
880
- *
881
- * This utility function helps in determining whether a given value is neither `null` nor `undefined`.
882
- * It can be useful for validation checks to ensure that a value is properly defined before proceeding
883
- * with further operations.
884
- *
885
- * @param {T} value - The value to check.
886
- * @returns {boolean} - Returns `true` if the value is neither `null` nor `undefined`, otherwise returns `false`.
887
- *
888
- */
889
- var isDefined = function (value) {
890
- return value !== null && value !== undefined;
891
- };
892
-
893
- /**
894
- * Converts a camelCase string to kebab-case.
895
- * e.g. backgroundColor -> background-color
896
- *
897
- * @param str - The camelCase string to convert.
898
- * @returns The converted kebab-case string.
899
- */
900
- function camelCaseToKebabCase(str) {
901
- return str.replace(/([A-Z])/g, function (match) { return '-' + match.toLowerCase(); });
902
- }
903
-
904
- var _internalInterpolate = function (val, arr, extrapolateLeft, extrapolateRight) {
905
- var _a = __read(arr, 4), inputMin = _a[0], inputMax = _a[1], outputMin = _a[2], outputMax = _a[3];
906
- var result = val;
907
- // EXTRAPOLATE
908
- if (result < inputMin) {
909
- if (extrapolateLeft === 'identity') {
910
- return result;
911
- }
912
- else if (extrapolateLeft === 'clamp') {
913
- result = inputMin;
914
- }
915
- else ;
916
- }
917
- if (result > inputMax) {
918
- if (extrapolateRight === 'identity') {
919
- return result;
920
- }
921
- else if (extrapolateRight === 'clamp') {
922
- result = inputMax;
923
- }
924
- else ;
925
- }
926
- if (outputMin === outputMax) {
927
- return outputMin;
928
- }
929
- if (inputMin === inputMax) {
930
- if (val <= inputMin) {
931
- return outputMin;
932
- }
933
- return outputMax;
934
- }
935
- // Input Range
936
- if (inputMin === -Infinity) {
937
- result = -result;
938
- }
939
- else if (inputMax === Infinity) {
940
- result = result - inputMin;
941
- }
942
- else {
943
- result = (result - inputMin) / (inputMax - inputMin);
944
- }
945
- // Output Range
946
- if (outputMin === -Infinity) {
947
- result = -result;
948
- }
949
- else if (outputMax === Infinity) {
950
- result = result + outputMin;
951
- }
952
- else {
953
- result = result * (outputMax - outputMin) + outputMin;
954
- }
955
- return result;
956
- };
957
- var _getNarrowedInputArray = function (x, input, output) {
958
- var length = input.length;
959
- var narrowedInput = [];
960
- // Boundaries
961
- if (x < input[0]) {
962
- narrowedInput = [input[0], input[1], output[0], output[1]];
963
- }
964
- else if (x > input[length - 1]) {
965
- narrowedInput = [
966
- input[length - 2],
967
- input[length - 1],
968
- output[length - 2],
969
- output[length - 1],
970
- ];
971
- }
972
- // Narrow the input and output ranges
973
- for (var i = 1; i < length; ++i) {
974
- if (x <= input[i]) {
975
- narrowedInput = [input[i - 1], input[i], output[i - 1], output[i]];
976
- break;
977
- }
978
- }
979
- return narrowedInput;
980
- };
981
- var _getColorInterpolate = function (value, narrowedInput) {
982
- var _a = __read(narrowedInput, 4), inputMin = _a[0], inputMax = _a[1], outputMin = _a[2], outputMax = _a[3];
983
- var outputMinProcessed = hexToRgba(outputMin);
984
- var outputMaxProcessed = hexToRgba(outputMax);
985
- var red = _internalInterpolate(value, [inputMin, inputMax, outputMinProcessed.r, outputMaxProcessed.r], 'clamp', 'clamp');
986
- var green = _internalInterpolate(value, [inputMin, inputMax, outputMinProcessed.g, outputMaxProcessed.g], 'clamp', 'clamp');
987
- var blue = _internalInterpolate(value, [inputMin, inputMax, outputMinProcessed.b, outputMaxProcessed.b], 'clamp', 'clamp');
988
- var alpha = _internalInterpolate(value, [inputMin, inputMax, outputMinProcessed.a, outputMaxProcessed.a], 'clamp', 'clamp');
989
- return rgbaToHex({ r: red, g: green, b: blue, a: alpha });
990
- };
991
- var _getArrayInterpolate = function (value, narrowedInput, _extrapolateLeft, _extrapolateRight) {
992
- var _a = __read(narrowedInput, 4), inputMin = _a[0], inputMax = _a[1], outputMin = _a[2], outputMax = _a[3];
993
- if (outputMin.length === outputMax.length) {
994
- return outputMin.map(function (val, index) {
995
- if (typeof val === 'string') {
996
- // IF IT IS STRING THEN IT MUST BE HEX COLOR
997
- return _getColorInterpolate(value, [
998
- inputMin,
999
- inputMax,
1000
- val,
1001
- outputMax[index],
1002
- ]);
1003
- }
1004
- else {
1005
- return _internalInterpolate(value, [inputMin, inputMax, val, outputMax[index]], _extrapolateLeft, _extrapolateRight);
1006
- }
1007
- });
1008
- }
1009
- else {
1010
- throw new Error("Array length doesn't match");
1011
- }
1012
- };
1013
- var _getTemplateString = function (str) {
1014
- return str.replace(COLOR_NUMBER_REGEX, '$');
1015
- };
1016
- var _getParsedStringArray = function (str) {
1017
- return str.match(COLOR_NUMBER_REGEX).map(function (v) {
1018
- if (v.indexOf('#') !== -1) {
1019
- return v;
1020
- }
1021
- else {
1022
- return Number(v);
1023
- }
1024
- });
1025
- };
1026
- /**
1027
- * Function returns if the template of two strings are matched
1028
- * i.e. they can be interpolated
1029
- * @param str1 - first string
1030
- * @param str2 - second string
1031
- * @returns boolean indicating two strings matched or not
1032
- */
1033
- var stringMatched = function (str1, str2) {
1034
- return _getTemplateString(str1).trim().replace(/\s/g, '') ===
1035
- _getTemplateString(str2).trim().replace(/\s/g, '');
1036
- };
1037
- /**
1038
- * Function which proccess the
1039
- * hexadecimal colors to its proper formats
1040
- * @param str - string
1041
- * @returns hex color string
1042
- */
1043
- var getProcessedColor = function (str) {
1044
- return str.replace(HEX_NAME_COLOR, function (match) {
1045
- if (match.indexOf('#') !== -1) {
1046
- return rgbaToHex(hexToRgba(match));
1047
- }
1048
- else if (Object.prototype.hasOwnProperty.call(colorNames, match)) {
1049
- return colorNames[match];
1050
- }
1051
- else {
1052
- throw new Error('String cannot be parsed!');
1053
- }
1054
- });
1055
- };
1056
- /**
1057
- * interpolateNumbers to interpolate the numeric value
1058
- * @param value - number
1059
- * @param inputRange
1060
- * @param outputRange
1061
- * @param extrapolateConfig
1062
- * @returns - number | string
1063
- */
1064
- function interpolateNumbers(value, inputRange, outputRange, extrapolateConfig) {
1065
- var e_1, _a;
1066
- var extrapolate = extrapolateConfig === null || extrapolateConfig === void 0 ? void 0 : extrapolateConfig.extrapolate;
1067
- var extrapolateLeft = extrapolateConfig === null || extrapolateConfig === void 0 ? void 0 : extrapolateConfig.extrapolateLeft;
1068
- var extrapolateRight = extrapolateConfig === null || extrapolateConfig === void 0 ? void 0 : extrapolateConfig.extrapolateRight;
1069
- var narrowedInput = _getNarrowedInputArray(value, inputRange, outputRange);
1070
- var _extrapolateLeft = 'extend';
1071
- if (extrapolateLeft !== undefined) {
1072
- _extrapolateLeft = extrapolateLeft;
1073
- }
1074
- else if (extrapolate !== undefined) {
1075
- _extrapolateLeft = extrapolate;
1076
- }
1077
- var _extrapolateRight = 'extend';
1078
- if (extrapolateRight !== undefined) {
1079
- _extrapolateRight = extrapolateRight;
1080
- }
1081
- else if (extrapolate !== undefined) {
1082
- _extrapolateRight = extrapolate;
1083
- }
1084
- if (outputRange.length) {
1085
- if (typeof outputRange[0] === 'number') {
1086
- return _internalInterpolate(value, narrowedInput, _extrapolateLeft, _extrapolateRight);
1087
- }
1088
- else if (Array.isArray(outputRange[0])) {
1089
- return _getArrayInterpolate(value, narrowedInput, _extrapolateLeft, _extrapolateRight);
1090
- }
1091
- else {
1092
- var _b = __read(narrowedInput, 4), inputMin = _b[0], inputMax = _b[1], outputMin = _b[2], outputMax = _b[3];
1093
- var processedOutputMin = getProcessedColor(outputMin);
1094
- var processedOutputMax = getProcessedColor(outputMax);
1095
- var templateString = _getTemplateString(processedOutputMin);
1096
- if (stringMatched(processedOutputMin, processedOutputMax)) {
1097
- var outputMinParsed = _getParsedStringArray(processedOutputMin);
1098
- var outputMaxParsed = _getParsedStringArray(processedOutputMax);
1099
- var result = _getArrayInterpolate(value, [inputMin, inputMax, outputMinParsed, outputMaxParsed], _extrapolateLeft, _extrapolateRight);
1100
- try {
1101
- for (var result_1 = __values(result), result_1_1 = result_1.next(); !result_1_1.done; result_1_1 = result_1.next()) {
1102
- var v = result_1_1.value;
1103
- templateString = templateString.replace('$', v);
1104
- }
1105
- }
1106
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1107
- finally {
1108
- try {
1109
- if (result_1_1 && !result_1_1.done && (_a = result_1.return)) _a.call(result_1);
1110
- }
1111
- finally { if (e_1) throw e_1.error; }
1112
- }
1113
- return templateString;
1114
- }
1115
- else {
1116
- throw new Error("Output range doesn't match string format!");
1117
- }
1118
- }
1119
- }
1120
- else {
1121
- throw new Error('Output range cannot be Empty');
1122
- }
1123
- }
1124
- /**
1125
- * interpolateTransitionValue to interpolating TransitionValue type value
1126
- * @param value
1127
- * @param inputRange
1128
- * @param outputRange
1129
- * @param extrapolateConfig
1130
- * @returns TransitionValue
1131
- */
1132
- var interpolateTransitionValue = function (value, inputRange, outputRange, extrapolateConfig) {
1133
- return __assign(__assign({}, value), { isInterpolation: true, interpolationConfig: {
1134
- inputRange: inputRange,
1135
- outputRange: outputRange,
1136
- extrapolateConfig: extrapolateConfig,
1137
- } });
1138
- };
1139
- /**
1140
- * interpolate function to interpolate both transition
1141
- * as well as numerical value
1142
- * @param value
1143
- * @param inputRange
1144
- * @param outputRange
1145
- * @param extrapolateConfig
1146
- */
1147
- var interpolate$1 = function (value, inputRange, outputRange, extrapolateConfig) {
1148
- if (isFluidValue(value)) {
1149
- return interpolateTransitionValue(value, inputRange, outputRange, extrapolateConfig);
1150
- }
1151
- else if (typeof value === 'number') {
1152
- return interpolateNumbers(value, inputRange, outputRange, extrapolateConfig);
1153
- }
1154
- else {
1155
- throw new Error("'".concat(typeof value, "' cannot be interpolated!"));
1156
- }
1157
- };
1158
- /**
1159
- * Determines if two values can be interpolated.
1160
- * This function checks if two values, either numbers or strings,
1161
- * can be interpolated by ensuring they are of the same type and, in the case of strings,
1162
- * that they are compatible for interpolation based on processed color values.
1163
- *
1164
- * @param previousValue - The previous value to compare. Can be a number or a string.
1165
- * @param newValue - The new value to compare. Can be a number or a string.
1166
- * @returns True if interpolation is possible, false otherwise.
1167
- */
1168
- function canInterpolate(previousValue, newValue) {
1169
- if (typeof previousValue !== typeof newValue) {
1170
- return false;
1171
- }
1172
- if (typeof newValue === 'number') {
1173
- return true;
1174
- }
1175
- if (typeof previousValue === 'string') {
1176
- var processedPreviousValue = getProcessedColor(previousValue);
1177
- var processedNewValue = getProcessedColor(newValue);
1178
- return (processedPreviousValue !== processedNewValue &&
1179
- _getTemplateString(processedPreviousValue) ===
1180
- _getTemplateString(processedNewValue));
1181
- }
1182
- return false;
1183
- }
1184
-
1185
- var styleTrasformKeys = [
1186
- 'translate',
1187
- 'translateX',
1188
- 'translateY',
1189
- 'translateZ',
1190
- 'scale',
1191
- 'scaleX',
1192
- 'scaleY',
1193
- 'scaleZ',
1194
- 'rotate',
1195
- 'rotateX',
1196
- 'rotateY',
1197
- 'rotateZ',
1198
- 'skew',
1199
- 'skewX',
1200
- 'skewY',
1201
- ];
1202
- function splitCSSValueAndUnit(value) {
1203
- var valueMatch = value.match(/(-)?(\d+.)?\d+/g);
1204
- var unitMatch = value.match(/px|rem|em|ex|%|cm|mm|in|pt|pc|ch|vh|vw|vmin|vmax/);
1205
- return {
1206
- value: Number(valueMatch),
1207
- unit: unitMatch && unitMatch[0],
1208
- };
1209
- }
1210
- // get unit of transform style property
1211
- function getValueUnit(property, value) {
1212
- var unit;
1213
- var splitValue = splitCSSValueAndUnit(String(value)).value;
1214
- var splitUnit = splitCSSValueAndUnit(String(value)).unit;
1215
- // if string value is passed with unit then split it
1216
- if (splitUnit) {
1217
- return { value: splitValue, unit: splitUnit };
1218
- }
1219
- if (property.includes('translate') || property.includes('perspective')) {
1220
- unit = 'px';
1221
- }
1222
- else if (property.includes('scale')) {
1223
- unit = '';
1224
- }
1225
- else if (property.includes('rotate') || property.includes('skew')) {
1226
- unit = 'deg';
1227
- }
1228
- return { value: value, unit: unit };
1229
- }
1230
- function getTransformValueWithUnits(property, value) {
1231
- var valueUnit = getValueUnit(property, value);
1232
- if (property.includes('X') ||
1233
- property.includes('Y') ||
1234
- property.includes('Z') ||
1235
- property.includes('perspective') ||
1236
- property.includes('rotate') ||
1237
- property.includes('skew')) {
1238
- // axis value
1239
- return "".concat(property, "(").concat(valueUnit.value).concat(valueUnit.unit, ")");
1240
- }
1241
- else if (property.includes('translate') || property.indexOf('scale')) {
1242
- // two parameter value
1243
- return "".concat(property, "(").concat(valueUnit.value).concat(valueUnit.unit, ", ").concat(valueUnit.value).concat(valueUnit.unit, ")");
1244
- }
1245
- else {
1246
- throw new Error("Error! Property '".concat(property, "' cannot be transformed"));
1247
- }
1248
- }
1249
- /**
1250
- * getTransform function returns transform string from style object
1251
- */
1252
- function getTransform(style) {
1253
- return Object.entries(style)
1254
- .map(function (_a) {
1255
- var _b = __read(_a, 2), prop = _b[0], value = _b[1];
1256
- return getTransformValueWithUnits(prop, value);
1257
- })
1258
- .reduce(function (transform, value) { return (transform += " ".concat(value)); }, '')
1259
- .trim();
1260
- }
1261
- function isTransformKey(key) {
1262
- return styleTrasformKeys.includes(key);
1263
- }
1264
-
1265
- /**
1266
- * Higher-order component to make any component animatable.
1267
- *
1268
- * This function takes a React component or an HTML tag and returns a new component
1269
- * that can smoothly transition between states using fluid animations. It enhances
1270
- * the user experience by adding dynamic and engaging animations to the wrapped component.
1271
- *
1272
- * @param WrapperComponent - The React component or HTML tag to be wrapped with animation functionality.
1273
- * @returns - A new component with added animation capabilities.
1274
- *
1275
- * The returned component uses fluid animations to smoothly transition between different
1276
- * states. It supports both style and prop animations, handling transforms and other
1277
- * properties seamlessly. The component ensures that animations are efficiently applied
1278
- * and updated based on the current state and configuration of fluid values.
1279
- *
1280
- * @example
1281
- * const AnimatedDiv = makeFluid('div');
1282
- *
1283
- * const MyComponent = () => {
1284
- * const opacity = useAnimatedValue(1)
1285
- * return (
1286
- * <AnimatedDiv style={{ opacity: opacity.value }}>
1287
- * Hello, world!
1288
- * </AnimatedDiv>
1289
- * )};
1290
- */
1291
- function makeFluid(WrapperComponent) {
1292
- return React.forwardRef(function (givenProps, givenRef) {
1293
- var instanceRef = React.useRef(null);
1294
- var transformStyleRef = React.useRef({});
1295
- var _a = React.useMemo(function () {
1296
- var style = givenProps.style, props = __rest(givenProps, ["style"]);
1297
- var fluidStyle = getFluids('style', style);
1298
- var fluidProps = getFluids('props', props);
1299
- return {
1300
- fluids: __spreadArray(__spreadArray([], __read(fluidStyle.fluids), false), __read(fluidProps.fluids), false),
1301
- nonFluids: __spreadArray(__spreadArray([], __read(fluidStyle.nonFluids), false), __read(fluidProps.nonFluids), false),
1302
- };
1303
- }, [givenProps]), fluids = _a.fluids, nonFluids = _a.nonFluids;
1304
- var applyAnimationValues = function (_a) {
1305
- var isTransform = _a.isTransform, propertyType = _a.propertyType, property = _a.property, value = _a.value;
1306
- if (!instanceRef.current)
1307
- return;
1308
- if (propertyType === 'style') {
1309
- if (isTransform) {
1310
- transformStyleRef.current[property] = value;
1311
- instanceRef.current.style.transform = getTransform(transformStyleRef.current);
1312
- }
1313
- else {
1314
- instanceRef.current.style[property] = getCssValue(property, value);
1315
- }
1316
- }
1317
- else if (propertyType === 'props') {
1318
- instanceRef.current.setAttribute(camelCaseToKebabCase(property), value);
1319
- }
1320
- };
1321
- React.useLayoutEffect(function () {
1322
- nonFluids.forEach(function (_a) {
1323
- var isTransform = _a.isTransform, property = _a.property, propertyType = _a.propertyType, value = _a.value;
1324
- return applyAnimationValues({
1325
- isTransform: isTransform,
1326
- property: property,
1327
- propertyType: propertyType,
1328
- value: value,
1329
- });
1330
- });
1331
- }, [nonFluids]);
1332
- React.useLayoutEffect(function () {
1333
- var subscribers = [];
1334
- fluids.forEach(function (f) {
1335
- var fluidValue = f.value, propertyType = f.propertyType, property = f.property, isTransform = f.isTransform;
1336
- var _subscribe = fluidValue._subscribe, _value = fluidValue._value, _currentValue = fluidValue._currentValue, _config = fluidValue._config;
1337
- var interpolationOutputRange = [];
1338
- var generateAnimation = animationObjectGenerator(_config);
1339
- var animation = null;
1340
- var onFrame = function (value) {
1341
- _currentValue.current = value;
1342
- var updatedValue = fluidValue.isInterpolation
1343
- ? interpolateNumbers(value, fluidValue.interpolationConfig.inputRange, fluidValue.interpolationConfig.outputRange, fluidValue.interpolationConfig.extrapolateConfig)
1344
- : value;
1345
- applyAnimationValues({
1346
- isTransform: isTransform,
1347
- propertyType: propertyType,
1348
- property: property,
1349
- value: updatedValue,
1350
- });
1351
- };
1352
- var onUpdate = function (value, config, callback) {
1353
- if (canInterpolate(_value, value)) {
1354
- var previousAnimation = animation;
1355
- if (previousAnimation._value !== value) {
1356
- animation.stop();
1357
- animation = generateAnimation(previousAnimation._position, config);
1358
- (config === null || config === void 0 ? void 0 : config.onStart) && config.onStart(previousAnimation._position);
1359
- if (typeof value === 'string') {
1360
- if (!interpolationOutputRange.includes(_value)) {
1361
- interpolationOutputRange.push(_value);
1362
- }
1363
- if (!interpolationOutputRange.includes(value)) {
1364
- interpolationOutputRange.push(value);
1365
- }
1366
- fluidValue.isInterpolation = true;
1367
- fluidValue.interpolationConfig = {
1368
- inputRange: interpolationOutputRange.map(function (_, i) { return i; }),
1369
- outputRange: interpolationOutputRange,
1370
- };
1371
- }
1372
- animation.start({
1373
- toValue: typeof value === 'string'
1374
- ? interpolationOutputRange.indexOf(value)
1375
- : value,
1376
- onFrame: onFrame,
1377
- previousAnimation: previousAnimation,
1378
- onEnd: callback,
1379
- });
1380
- }
1381
- }
1382
- else {
1383
- if (typeof value !== typeof _value) {
1384
- throw new Error("Cannot assign ".concat(typeof value, " to animated ").concat(typeof _value));
1385
- }
1386
- applyAnimationValues({
1387
- isTransform: isTransform,
1388
- propertyType: propertyType,
1389
- property: property,
1390
- value: value,
1391
- });
1392
- }
1393
- };
1394
- animation = generateAnimation(typeof _value === 'string' ? 0 : _value);
1395
- applyAnimationValues({
1396
- isTransform: isTransform,
1397
- propertyType: propertyType,
1398
- property: property,
1399
- value: _value,
1400
- });
1401
- var subscribe = _subscribe(onUpdate, property, Date.now());
1402
- subscribers.push(subscribe);
1403
- });
1404
- return function () {
1405
- subscribers.forEach(function (subscriber) { return subscriber(); });
1406
- };
1407
- }, []);
1408
- return React.createElement(WrapperComponent, __assign(__assign({}, getCleanProps(givenProps)), { ref: combineRefs(instanceRef, givenRef) }));
1409
- });
1410
- }
1411
- function combineRefs() {
1412
- var refs = [];
1413
- for (var _i = 0; _i < arguments.length; _i++) {
1414
- refs[_i] = arguments[_i];
1415
- }
1416
- return function applyRef(element) {
1417
- refs.forEach(function (ref) {
1418
- if (!ref)
1419
- return;
1420
- if (typeof ref === 'function') {
1421
- ref(element);
1422
- return;
1423
- }
1424
- if ('current' in ref)
1425
- ref.current = element;
1426
- });
1427
- };
1428
- }
1429
- function animationObjectGenerator(defaultConfig) {
1430
- return function (value, config) {
1431
- var animationConfig = __assign(__assign({}, defaultConfig), config);
1432
- var Animation = isDefined(animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.duration) || (animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.immediate)
1433
- ? TimingAnimation
1434
- : SpringAnimation;
1435
- return new Animation({
1436
- initialPosition: value,
1437
- config: animationConfig,
1438
- });
1439
- };
1440
- }
1441
- function getFluids(propertyType, props) {
1442
- if (props === void 0) { props = {}; }
1443
- return Object.entries(props).reduce(function (res, _a) {
1444
- var _b = __read(_a, 2), property = _b[0], value = _b[1];
1445
- var isTransform = propertyType === 'style' && isTransformKey(property);
1446
- if (isFluidValue(value)) {
1447
- res.fluids.push({ isTransform: isTransform, property: property, propertyType: propertyType, value: value });
1448
- }
1449
- else {
1450
- res.nonFluids.push({ isTransform: isTransform, property: property, propertyType: propertyType, value: value });
1451
- }
1452
- return res;
1453
- }, { fluids: [], nonFluids: [] });
1454
- }
1455
-
1456
- var tags = [
1457
- 'a',
1458
- 'abbr',
1459
- 'address',
1460
- 'area',
1461
- 'article',
1462
- 'aside',
1463
- 'audio',
1464
- 'b',
1465
- 'base',
1466
- 'bdi',
1467
- 'bdo',
1468
- 'big',
1469
- 'blockquote',
1470
- 'body',
1471
- 'br',
1472
- 'button',
1473
- 'canvas',
1474
- 'caption',
1475
- 'center',
1476
- 'cite',
1477
- 'code',
1478
- 'col',
1479
- 'colgroup',
1480
- 'data',
1481
- 'datalist',
1482
- 'dd',
1483
- 'del',
1484
- 'details',
1485
- 'dfn',
1486
- 'dialog',
1487
- 'div',
1488
- 'dl',
1489
- 'dt',
1490
- 'em',
1491
- 'embed',
1492
- 'fieldset',
1493
- 'figcaption',
1494
- 'figure',
1495
- 'footer',
1496
- 'form',
1497
- 'h1',
1498
- 'h2',
1499
- 'h3',
1500
- 'h4',
1501
- 'h5',
1502
- 'h6',
1503
- 'head',
1504
- 'header',
1505
- 'hgroup',
1506
- 'hr',
1507
- 'html',
1508
- 'i',
1509
- 'iframe',
1510
- 'img',
1511
- 'input',
1512
- 'ins',
1513
- 'kbd',
1514
- 'keygen',
1515
- 'label',
1516
- 'legend',
1517
- 'li',
1518
- 'link',
1519
- 'main',
1520
- 'map',
1521
- 'mark',
1522
- 'menu',
1523
- 'menuitem',
1524
- 'meta',
1525
- 'meter',
1526
- 'nav',
1527
- 'noindex',
1528
- 'noscript',
1529
- 'object',
1530
- 'ol',
1531
- 'optgroup',
1532
- 'option',
1533
- 'output',
1534
- 'p',
1535
- 'param',
1536
- 'picture',
1537
- 'pre',
1538
- 'progress',
1539
- 'q',
1540
- 'rp',
1541
- 'rt',
1542
- 'ruby',
1543
- 's',
1544
- 'samp',
1545
- 'search',
1546
- 'section',
1547
- 'select',
1548
- 'small',
1549
- 'source',
1550
- 'span',
1551
- 'strong',
1552
- 'style',
1553
- 'sub',
1554
- 'summary',
1555
- 'sup',
1556
- 'table',
1557
- 'template',
1558
- 'tbody',
1559
- 'td',
1560
- 'textarea',
1561
- 'tfoot',
1562
- 'th',
1563
- 'thead',
1564
- 'time',
1565
- 'title',
1566
- 'tr',
1567
- 'track',
1568
- 'u',
1569
- 'ul',
1570
- 'var',
1571
- 'video',
1572
- 'wbr',
1573
- // SVG Tags
1574
- 'svg',
1575
- 'animate',
1576
- 'animateMotion',
1577
- 'animateTransform',
1578
- 'circle',
1579
- 'clipPath',
1580
- 'defs',
1581
- 'desc',
1582
- 'ellipse',
1583
- 'feBlend',
1584
- 'feColorMatrix',
1585
- 'feComponentTransfer',
1586
- 'feComposite',
1587
- 'feConvolveMatrix',
1588
- 'feDiffuseLighting',
1589
- 'feDisplacementMap',
1590
- 'feDistantLight',
1591
- 'feDropShadow',
1592
- 'feFlood',
1593
- 'feFuncA',
1594
- 'feFuncB',
1595
- 'feFuncG',
1596
- 'feFuncR',
1597
- 'feGaussianBlur',
1598
- 'feImage',
1599
- 'feMerge',
1600
- 'feMergeNode',
1601
- 'feMorphology',
1602
- 'feOffset',
1603
- 'fePointLight',
1604
- 'feSpecularLighting',
1605
- 'feSpotLight',
1606
- 'feTile',
1607
- 'feTurbulence',
1608
- 'filter',
1609
- 'foreignObject',
1610
- 'g',
1611
- 'image',
1612
- 'line',
1613
- 'linearGradient',
1614
- 'marker',
1615
- 'mask',
1616
- 'metadata',
1617
- 'mpath',
1618
- 'path',
1619
- 'pattern',
1620
- 'polygon',
1621
- 'polyline',
1622
- 'radialGradient',
1623
- 'rect',
1624
- 'set',
1625
- 'stop',
1626
- 'switch',
1627
- 'symbol',
1628
- 'text',
1629
- 'textPath',
1630
- 'tspan',
1631
- 'use',
1632
- 'view',
1633
- ];
1634
- var fluid = {};
1635
- tags.forEach(function (tag) {
1636
- fluid[tag] = makeFluid(tag);
1637
- });
1638
-
1639
- /**
1640
- * Represents a fluid value that can animate between states.
1641
- */
1642
- var FluidValue = /** @class */ (function () {
1643
- /**
1644
- * Creates a new FluidValue instance.
1645
- * @param initialValue - The initial value of the fluid value.
1646
- * @param config - Optional configuration for the fluid value.
1647
- */
1648
- function FluidValue(initialValue, config) {
1649
- var _this = this;
1650
- this._subscriptions = new Map();
1651
- this._subscribe = function (onUpdate, property, uuid) {
1652
- var e_1, _a;
1653
- var _loop_1 = function (key) {
1654
- if (key.property === property) {
1655
- _this._subscriptions.set(key, onUpdate);
1656
- return { value: function () { return _this._subscriptions.delete(key); } };
1657
- }
1658
- };
1659
- try {
1660
- for (var _b = __values(_this._subscriptions.keys()), _c = _b.next(); !_c.done; _c = _b.next()) {
1661
- var key = _c.value;
1662
- var state_1 = _loop_1(key);
1663
- if (typeof state_1 === "object")
1664
- return state_1.value;
1665
- }
1666
- }
1667
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1668
- finally {
1669
- try {
1670
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1671
- }
1672
- finally { if (e_1) throw e_1.error; }
1673
- }
1674
- _this._subscriptions.set({ uuid: uuid, property: property }, onUpdate);
1675
- return function () { return _this._subscriptions.delete({ uuid: uuid, property: property }); };
1676
- };
1677
- this._value = initialValue;
1678
- this._currentValue = { current: initialValue };
1679
- this._config = config;
1680
- this.get = function () { return _this._currentValue.current; };
1681
- }
1682
- /**
1683
- * Animates from the current value to the updated value.
1684
- * Determines whether to perform a multi-stage or single-stage transition.
1685
- * @param updatedValue - The value to animate to, or a function that defines a multi-stage transition.
1686
- * @param config - Optional configuration for the animation.
1687
- * @param callback - Optional callback to be called after the animation ends.
1688
- */
1689
- FluidValue.prototype.setValue = function (updatedValue, config, callback) {
1690
- var e_2, _a;
1691
- var _this = this;
1692
- /** Multistage transition */
1693
- if (typeof updatedValue === 'function') {
1694
- updatedValue(function (nextValue, nextConfig) {
1695
- var multiStagePromise = new Promise(function (resolve) {
1696
- var e_3, _a;
1697
- try {
1698
- for (var _b = __values(_this._subscriptions.keys()), _c = _b.next(); !_c.done; _c = _b.next()) {
1699
- var subscriptionKey = _c.value;
1700
- var updater = _this._subscriptions.get(subscriptionKey);
1701
- if (updater) {
1702
- updater(nextValue, nextConfig !== null && nextConfig !== void 0 ? nextConfig : config, function (result) {
1703
- if (result.finished) {
1704
- resolve(nextValue);
1705
- }
1706
- if (callback) {
1707
- callback(result);
1708
- }
1709
- });
1710
- }
1711
- }
1712
- }
1713
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1714
- finally {
1715
- try {
1716
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1717
- }
1718
- finally { if (e_3) throw e_3.error; }
1719
- }
1720
- });
1721
- return multiStagePromise;
1722
- });
1723
- return;
1724
- }
1725
- try {
1726
- /** Singlestage transition */
1727
- for (var _b = __values(this._subscriptions.keys()), _c = _b.next(); !_c.done; _c = _b.next()) {
1728
- var subscriptionKey = _c.value;
1729
- var updater = this._subscriptions.get(subscriptionKey);
1730
- updater && updater(updatedValue, config, callback);
1731
- }
1732
- }
1733
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1734
- finally {
1735
- try {
1736
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1737
- }
1738
- finally { if (e_2) throw e_2.error; }
1739
- }
1740
- };
1741
- return FluidValue;
1742
- }());
1743
-
1744
- /**
1745
- * useFluidValue
1746
- *
1747
- * @param value - initial value
1748
- * @param config - the config object for `FluidValue`
1749
- */
1750
- var useFluidValue = function (value, config) {
1751
- var fluid = React.useMemo(function () { return new FluidValue(value, config); }, []);
1752
- var setFluid = React.useCallback(function (updateValue, config, callback) {
1753
- fluid.setValue(updateValue, config, callback);
1754
- }, []);
1755
- return [fluid, setFluid];
1756
- };
1757
-
1758
- /**
1759
- * `useMount`
1760
- *
1761
- * applies mounting and unmounting of a component according to state change
1762
- * applying transitions
1763
- *
1764
- * @param state - boolean indicating mount state of a component
1765
- * @param config - the config object `UseMountConfig`
1766
- */
1767
- var useMount = function (state, config) {
1768
- var _a = __read(React.useState(false), 2), mounted = _a[0], setMounted = _a[1];
1769
- var _b = React.useRef(config).current, from = _b.from, enter = _b.enter, exit = _b.exit, innerConfig = _b.config, enterConfig = _b.enterConfig, exitConfig = _b.exitConfig;
1770
- var _c = __read(useFluidValue(from, innerConfig), 2), animation = _c[0], setAnimation = _c[1];
1771
- React.useLayoutEffect(function () {
1772
- if (state) {
1773
- setMounted(true);
1774
- queueMicrotask(function () { return setAnimation(enter, enterConfig); });
1775
- }
1776
- else {
1777
- setAnimation(exit, exitConfig, function (_a) {
1778
- var finished = _a.finished;
1779
- if (finished) {
1780
- setMounted(false);
1781
- }
1782
- });
1783
- }
1784
- }, [state]);
1785
- return function (callback) { return callback(animation, mounted); };
1786
- };
1787
-
1788
- /**
1789
- * interpolate functions maps input range to given output range
1790
- * @param value - number | TransitionValue
1791
- * @param inputRange - Array<number>
1792
- * @param outputRange - Array<number | string>
1793
- * @param extrapolateConfig - "clamp" | "identity" | "extend"
1794
- * @returns - number | TransitionValue
1795
- */
1796
- function interpolate(value, inputRange, outputRange, extrapolateConfig) {
1797
- return interpolate$1(value, inputRange, outputRange, extrapolateConfig);
1798
- }
1799
- /**
1800
- * bInterpolate functions maps input range [0, 1] to given [minOutput, maxOutput]
1801
- * sorthand function to interpolate input range [0, 1]
1802
- * @param value - number | TransitionValue
1803
- * @param minOutput - number | string
1804
- * @param maxOutput - number | string
1805
- * @param extrapolateConfig - "clamp" | "identity" | "extend"
1806
- * @returns - number | TransitionValue
1807
- */
1808
- function bInterpolate(value, minOutput, maxOutput, extrapolateConfig) {
1809
- return interpolate$1(value, [0, 1], [minOutput, maxOutput], extrapolateConfig);
1810
- }
1811
-
1812
- /**
1813
- * AnimatedBlock - A higher order component built upon `div` element
1814
- * which can accept `AnimatedValue`. It also exposes some extra style properties like
1815
- * translateX, translateY, rotateX, rotateY, scaleX, etc.
1816
- */
1817
- var AnimatedBlock = makeFluid('div');
1818
-
1819
- /**
1820
- * AnimatedInline - A higher order component built upon `span` element
1821
- * which can accept `AnimatedValue`. It also exposes some extra style properties like
1822
- * translateX, translateY, rotateX, rotateY, scaleX, etc.
1823
- */
1824
- var AnimatedInline = makeFluid('span');
1825
-
1826
- /**
1827
- * AnimatedImage - A higher order component built upon `img` element
1828
- * which can accept `AnimatedValue`. It also exposes some extra style properties like
1829
- * translateX, translateY, rotateX, rotateY, scaleX, etc.
1830
- */
1831
- var AnimatedImage = makeFluid('img');
1832
-
1833
- /**
1834
- * `useMountedValue` handles mounting and unmounting of a component which captures current state
1835
- * passed as an arugment (`state`) and exposes the shadow state which handles the mount and unmount
1836
- * of a component.
1837
- *
1838
- * @param { boolean } state - Boolean indicating the component should mount or unmount.
1839
- * @param { UseMountedValueConfig } config - Animation configuration.
1840
- */
1841
- function useMountedValue(state, config) {
1842
- var mv = useMount(state, config);
1843
- return function (cb) { return mv(function (a, m) { return cb({ value: a }, m); }); };
1844
- }
1845
-
1846
- /**
1847
- * MountedBlock - Higher order component which handles mounting and unmounting of a component.
1848
- * @prop { boolean } state - Boolean indicating the component should mount or unmount.
1849
- * @prop { function } children - Child as a function with `AnimatedValue` on `.value` property.
1850
- * @prop { number } from - Number that dictates the beginning state for animation.
1851
- * @prop { number } enter - Number that dictates the entry state for animation.
1852
- * @prop { number } exit - Number that dictates the exit state for animation.
1853
- * @prop { MountedValueConfig } config - Animation configuration for overall animation.
1854
- * @prop { MountedValueConfig } enterConfig - Animation configuration for the entering state of animation.
1855
- * @prop { MountedValueConfig } exitConfig - Animation configuration for the entering state of animation.
1856
- */
1857
- var MountedBlock = function (_a) {
1858
- var state = _a.state, children = _a.children, _b = _a.from, from = _b === void 0 ? 0 : _b, _c = _a.enter, enter = _c === void 0 ? 1 : _c, _d = _a.exit, exit = _d === void 0 ? 0 : _d, config = _a.config, enterConfig = _a.enterConfig, exitConfig = _a.exitConfig;
1859
- var open = useMountedValue(state, {
1860
- from: from,
1861
- enter: enter,
1862
- exit: exit,
1863
- config: config,
1864
- enterConfig: enterConfig,
1865
- exitConfig: exitConfig,
1866
- });
1867
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: open(function (animation, mounted) { return mounted && children(animation); }) }));
1868
- };
1869
-
1870
- var getInitialConfig = function (animationType) {
1871
- switch (animationType) {
1872
- case 'elastic':
1873
- return { mass: 1, friction: 18, tension: 250 };
1874
- case 'stiff':
1875
- return { mass: 1, friction: 18, tension: 350 };
1876
- case 'wooble':
1877
- return { mass: 1, friction: 8, tension: 250 };
1878
- case 'bounce':
1879
- return { duration: 500, easing: Easing.bounce };
1880
- case 'power1':
1881
- return { duration: 500, easing: Easing.bezier(0.17, 0.42, 0.51, 0.97) };
1882
- case 'power2':
1883
- return { duration: 500, easing: Easing.bezier(0.07, 0.11, 0.13, 1) };
1884
- case 'power3':
1885
- return { duration: 500, easing: Easing.bezier(0.09, 0.7, 0.16, 1.04) };
1886
- case 'power4':
1887
- return { duration: 500, easing: Easing.bezier(0.05, 0.54, 0, 1.03) };
1888
- case 'linear':
1889
- return { duration: 500, easing: Easing.linear };
1890
- case 'easein':
1891
- return { duration: 500, easing: Easing.in(Easing.ease) };
1892
- case 'easeout':
1893
- return { duration: 500, easing: Easing.out(Easing.ease) };
1894
- case 'easeinout':
1895
- return { duration: 500, easing: Easing.inOut(Easing.ease) };
1896
- case 'ease':
1897
- default:
1898
- return { mass: 1, friction: 34, tension: 290 };
1899
- }
1900
- };
1901
-
1902
- var AnimationConfigUtils = {
1903
- ELASTIC: getInitialConfig('elastic'),
1904
- BOUNCE: getInitialConfig('bounce'),
1905
- EASE: getInitialConfig('ease'),
1906
- STIFF: getInitialConfig('stiff'),
1907
- WOOBLE: getInitialConfig('wooble'),
1908
- EASE_IN: getInitialConfig('easein'),
1909
- EASE_OUT: getInitialConfig('easeout'),
1910
- EASE_IN_OUT: getInitialConfig('easeinout'),
1911
- POWER1: getInitialConfig('power1'),
1912
- POWER2: getInitialConfig('power2'),
1913
- POWER3: getInitialConfig('power3'),
1914
- POWER4: getInitialConfig('power4'),
1915
- LINEAR: getInitialConfig('linear'),
1916
- };
1917
-
1918
- /**
1919
- * `useAnimatedValue` returns an animation value with `.value` and `.currentValue` property which is
1920
- * initialized when passed to argument (`initialValue`). The retured value persist until the lifetime of
1921
- * a component. It doesnot cast any re-renders which can is very good for performance optimization.
1922
- *
1923
- * @param { string | number } initialValue - Initial value
1924
- * @param { UseAnimatedValueConfig } config - Animation configuration object.
1925
- */
1926
- function useAnimatedValue(initialValue, config) {
1927
- var _a = __read(useFluidValue(initialValue, __assign(__assign({}, AnimationConfigUtils.EASE), config)), 2), animation = _a[0], setAnimation = _a[1];
1928
- var targetObject = {
1929
- value: animation,
1930
- currentValue: animation.get(),
1931
- };
1932
- return new Proxy(targetObject, {
1933
- set: function (_, key, value) {
1934
- if (key === 'value') {
1935
- if (typeof value === 'number' || typeof value === 'string') {
1936
- setAnimation(value);
1937
- }
1938
- return true;
1939
- }
1940
- throw new Error('You cannot set any other property to animation node.');
1941
- },
1942
- get: function (_, key) {
1943
- if (key === 'value') {
1944
- return animation;
1945
- }
1946
- if (key === 'currentValue') {
1947
- return animation.get();
1948
- }
1949
- throw new Error('You cannot access any other property from animation node.');
1950
- },
1951
- });
1952
- }
1953
-
1954
- /**
1955
- * ScrollableBlock - Higher order component to handle the entrance or exit animation
1956
- * of a component when it enters or exit the viewport. Accepts child as a function with
1957
- * `AnimatedValue` as its first argument which can be interpolated on input range [0, 1]
1958
- * @prop { function } children - child as a function with `AnimatedValue` as its first argument.
1959
- * @prop { 'single' | 'both' } direction - single applies animation on enter once, both applies on enter and exit.
1960
- * @prop { number } threshold - should be in range 0 to 1 which equivalent to `IntersectionObserver` threshold.
1961
- * @prop { UseAnimatedValueConfig } animationConfig - Animation config
1962
- */
1963
- var ScrollableBlock = function (props) {
1964
- var children = props.children, _a = props.direction, direction = _a === void 0 ? 'single' : _a, animationConfig = props.animationConfig, _b = props.threshold, threshold = _b === void 0 ? 0.2 : _b;
1965
- var scrollableBlockRef = React__namespace.useRef(null);
1966
- var animation = useAnimatedValue(0, animationConfig); // 0: not intersecting | 1: intersecting
1967
- React__namespace.useEffect(function () {
1968
- var _scrollableBlock = scrollableBlockRef.current;
1969
- var observer = new IntersectionObserver(function (_a) {
1970
- var _b = __read(_a, 1), entry = _b[0];
1971
- var isIntersecting = entry.isIntersecting;
1972
- if (isIntersecting) {
1973
- animation.value = 1;
1974
- }
1975
- else {
1976
- if (direction === 'both')
1977
- animation.value = 0;
1978
- }
1979
- }, {
1980
- root: null, // FOR VIEWPORT ONLY
1981
- threshold: threshold,
1982
- });
1983
- if (_scrollableBlock) {
1984
- observer.observe(_scrollableBlock);
1985
- }
1986
- return function () {
1987
- if (_scrollableBlock) {
1988
- observer.unobserve(_scrollableBlock);
1989
- }
1990
- };
1991
- }, []);
1992
- return (jsxRuntime.jsx("div", { ref: scrollableBlockRef, children: children && children({ value: animation.value }) }));
1993
- };
1994
-
1995
- /**
1996
- * bin(booleanValue)
1997
- * returns 1 if booleanValue == true and 0 if booleanValue == false
1998
- */
1999
- function bin(bool) {
2000
- return bool ? 1 : 0;
2001
- }
2002
- /**
2003
- * mix(progress, a, b)
2004
- * linear interpolation between a and b
2005
- */
2006
- function mix(perc, val1, val2) {
2007
- return val1 * (1 - perc) + val2 * perc;
2008
- }
2009
- /**
2010
- * clamp(value, min, max)
2011
- * clamps value for min and max bounds
2012
- */
2013
- function clamp(value, lowerbound, upperbound) {
2014
- return Math.min(Math.max(value, lowerbound), upperbound);
2015
- }
2016
- function rubber2(distanceFromEdge, constant) {
2017
- return Math.pow(distanceFromEdge, constant * 5);
2018
- }
2019
- function rubber(distanceFromEdge, dimension, constant) {
2020
- if (dimension === 0 || Math.abs(dimension) === Infinity)
2021
- return rubber2(distanceFromEdge, constant);
2022
- return ((distanceFromEdge * dimension * constant) /
2023
- (dimension + constant * distanceFromEdge));
2024
- }
2025
- /**
2026
- * rubberClamp(value, min, max, constant?)
2027
- * constant is optional : default 0.15
2028
- * clamps the value for min and max value and
2029
- * extends beyond min and max values with constant
2030
- * factor to create elastic rubber band effect
2031
- */
2032
- function rubberClamp(value, lowerbound, upperbound, constant) {
2033
- if (constant === void 0) { constant = 0.15; }
2034
- if (constant === 0)
2035
- return clamp(value, lowerbound, upperbound);
2036
- if (value < lowerbound) {
2037
- return (-rubber(lowerbound - value, upperbound - lowerbound, constant) +
2038
- lowerbound);
2039
- }
2040
- if (value > upperbound) {
2041
- return (+rubber(value - upperbound, upperbound - lowerbound, constant) +
2042
- upperbound);
2043
- }
2044
- return value;
2045
- }
2046
- /**
2047
- * snapTo(value, velocity, snapPoints[])
2048
- * Calculates the final snapPoint according to given current value,
2049
- * velocity and snapPoints array
2050
- */
2051
- function snapTo(value, velocity, snapPoints) {
2052
- var finalValue = value + velocity * 0.2;
2053
- var getDiff = function (point) { return Math.abs(point - finalValue); };
2054
- var deltas = snapPoints.map(getDiff);
2055
- var minDelta = Math.min.apply(Math, __spreadArray([], __read(deltas), false));
2056
- return snapPoints.reduce(function (acc, point) {
2057
- if (getDiff(point) === minDelta) {
2058
- return point;
2059
- }
2060
- else {
2061
- return acc;
2062
- }
2063
- });
2064
- }
2065
- /**
2066
- * move(array, moveIndex, toIndex)
2067
- * move array item from moveIndex to toIndex without array modification
2068
- */
2069
- function move(array, moveIndex, toIndex) {
2070
- var item = array[moveIndex];
2071
- var length = array.length;
2072
- var diff = moveIndex - toIndex;
2073
- if (diff > 0) {
2074
- return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(array.slice(0, toIndex)), false), [
2075
- item
2076
- ], false), __read(array.slice(toIndex, moveIndex)), false), __read(array.slice(moveIndex + 1, length)), false);
2077
- }
2078
- else if (diff < 0) {
2079
- var targetIndex = toIndex + 1;
2080
- return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(array.slice(0, moveIndex)), false), __read(array.slice(moveIndex + 1, targetIndex)), false), [
2081
- item
2082
- ], false), __read(array.slice(targetIndex, length)), false);
2083
- }
2084
- return array;
2085
- }
2086
-
2087
- /**
2088
- * TransitionBlock - Higher order component which animates on state change.
2089
- * @prop { boolean } state - Boolean indicating the current state of animation, usually `false = 0 and true = 1`.
2090
- * @prop { function } children - Child as a function with `AnimatedValue` on `.value` property.
2091
- * @prop { UseAnimatedValueConfig } config - Animation configuration.
2092
- */
2093
- var TransitionBlock = function (_a) {
2094
- var state = _a.state, children = _a.children, config = _a.config;
2095
- var amv = useAnimatedValue(bin(state), config);
2096
- return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children({ value: amv.value }) });
2097
- };
2098
-
2099
- /**
2100
- * @param { number } ms - number of milliseconds to delay code execution
2101
- * @returns Promise
2102
- */
2103
- function delay(ms) {
2104
- return new Promise(function (resolve) {
2105
- setTimeout(function () { return resolve(null); }, ms);
2106
- });
2107
- }
2108
-
2109
- /**
2110
- * Attach single document / window event / HTMLElement
2111
- */
2112
- function attachEvent(domTargets, event, callback, capture) {
2113
- if (capture === void 0) { capture = false; }
2114
- domTargets.forEach(function (target) {
2115
- target.addEventListener(event, callback, capture);
2116
- });
2117
- return function () {
2118
- domTargets.forEach(function (target) {
2119
- target.removeEventListener(event, callback, capture);
2120
- });
2121
- };
2122
- }
2123
- /**
2124
- * Attach multiple document / window event / HTMLElement
2125
- */
2126
- function attachEvents(domTargets, events) {
2127
- var subscribers = new Map();
2128
- events.forEach(function (_a) {
2129
- var _b = __read(_a, 3), event = _b[0], callback = _b[1], _c = _b[2], capture = _c === void 0 ? false : _c;
2130
- subscribers.set(event, attachEvent(domTargets, event, callback, capture));
2131
- });
2132
- return function (eventKeys) {
2133
- var e_1, _a;
2134
- try {
2135
- for (var _b = __values(subscribers.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
2136
- var _d = __read(_c.value, 2), eventKey = _d[0], subscriber = _d[1];
2137
- if (!eventKeys) {
2138
- subscriber();
2139
- return;
2140
- }
2141
- if (eventKeys.indexOf(eventKey) !== -1) {
2142
- subscriber();
2143
- }
2144
- }
2145
- }
2146
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2147
- finally {
2148
- try {
2149
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2150
- }
2151
- finally { if (e_1) throw e_1.error; }
2152
- }
2153
- };
2154
- }
2155
-
2156
- function useOutsideClick(elementRef, callback, deps) {
2157
- var callbackRef = React.useRef();
2158
- if (!callbackRef.current) {
2159
- callbackRef.current = callback;
2160
- }
2161
- // Reinitiate callback when dependency change
2162
- React.useEffect(function () {
2163
- callbackRef.current = callback;
2164
- return function () {
2165
- callbackRef.current = function () { return false; };
2166
- };
2167
- }, deps);
2168
- React.useEffect(function () {
2169
- var handleOutsideClick = function (e) {
2170
- var _a;
2171
- if (!((_a = elementRef === null || elementRef === void 0 ? void 0 : elementRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
2172
- callbackRef.current && callbackRef.current(e);
2173
- }
2174
- };
2175
- var subscribe = attachEvents([document], [['click', handleOutsideClick]]);
2176
- return function () { return subscribe && subscribe(); };
2177
- }, []);
2178
- }
2179
-
2180
- function useMeasure(callback, deps) {
2181
- var ref = React.useRef(null);
2182
- var elementRefs = React.useRef([]);
2183
- var callbackRef = React.useRef(callback);
2184
- // Reinitiate callback when dependency change
2185
- React.useEffect(function () {
2186
- callbackRef.current = callback;
2187
- return function () {
2188
- callbackRef.current = function () { return false; };
2189
- };
2190
- }, deps);
2191
- React.useEffect(function () {
2192
- var _refElement = ref.current || document.documentElement;
2193
- var _refElementsMultiple = elementRefs.current;
2194
- var resizeObserver = new ResizeObserver(function (_a) {
2195
- var _b = __read(_a, 1), entry = _b[0];
2196
- var _c = entry.target.getBoundingClientRect(), left = _c.left, top = _c.top, width = _c.width, height = _c.height;
2197
- var pageXOffset = window.pageXOffset, pageYOffset = window.pageYOffset;
2198
- if (callbackRef) {
2199
- if (_refElement === document.documentElement) {
2200
- return; // no-op for document
2201
- }
2202
- else {
2203
- callbackRef.current({
2204
- left: left + pageXOffset,
2205
- top: top + pageYOffset,
2206
- width: width,
2207
- height: height,
2208
- vLeft: left,
2209
- vTop: top,
2210
- });
2211
- }
2212
- }
2213
- });
2214
- var resizeObserverMultiple = new ResizeObserver(function (entries) {
2215
- var left = [];
2216
- var top = [];
2217
- var width = [];
2218
- var height = [];
2219
- var vLeft = [];
2220
- var vTop = [];
2221
- entries.forEach(function (entry) {
2222
- var _a = entry.target.getBoundingClientRect(), _left = _a.left, _top = _a.top, _width = _a.width, _height = _a.height;
2223
- var pageXOffset = window.pageXOffset, pageYOffset = window.pageYOffset;
2224
- var _pageLeft = _left + pageXOffset;
2225
- var _pageTop = _top + pageYOffset;
2226
- left.push(_pageLeft);
2227
- top.push(_pageTop);
2228
- width.push(_width);
2229
- height.push(_height);
2230
- vLeft.push(_left);
2231
- vTop.push(_top);
2232
- });
2233
- if (callbackRef) {
2234
- callbackRef.current({
2235
- left: left,
2236
- top: top,
2237
- width: width,
2238
- height: height,
2239
- vLeft: vLeft,
2240
- vTop: vTop,
2241
- });
2242
- }
2243
- });
2244
- if (_refElement) {
2245
- if (_refElement === document.documentElement &&
2246
- _refElementsMultiple.length > 0) {
2247
- _refElementsMultiple.forEach(function (element) {
2248
- resizeObserverMultiple.observe(element.current);
2249
- });
2250
- }
2251
- else {
2252
- resizeObserver.observe(_refElement);
2253
- }
2254
- }
2255
- return function () {
2256
- if (_refElement) {
2257
- if (_refElement === document.documentElement &&
2258
- _refElementsMultiple.length > 0) {
2259
- _refElementsMultiple.forEach(function (element) {
2260
- resizeObserverMultiple.unobserve(element.current);
2261
- });
2262
- }
2263
- else {
2264
- resizeObserver.unobserve(_refElement);
2265
- }
2266
- }
2267
- };
2268
- }, []);
2269
- return function (index) {
2270
- if (index === null || index === undefined) {
2271
- return { ref: ref };
2272
- }
2273
- else {
2274
- elementRefs.current[index] = elementRefs.current[index] || React.createRef();
2275
- return { ref: elementRefs.current[index] };
2276
- }
2277
- }; // ...bind() or ...bind(index) for multiple
2278
- }
2279
-
2280
- function useWindowDimension(callback, deps) {
2281
- var windowDimensionsRef = React.useRef({
2282
- width: 0,
2283
- height: 0,
2284
- innerWidth: 0,
2285
- innerHeight: 0,
2286
- });
2287
- var callbackRef = React.useRef(callback);
2288
- var handleCallback = function () {
2289
- if (callbackRef) {
2290
- callbackRef.current(__assign({}, windowDimensionsRef.current));
2291
- }
2292
- };
2293
- // Reinitiate callback when dependency change
2294
- React.useEffect(function () {
2295
- callbackRef.current = callback;
2296
- return function () {
2297
- callbackRef.current = function () { return false; };
2298
- };
2299
- }, deps);
2300
- React.useEffect(function () {
2301
- var resizeObserver = new ResizeObserver(function (_a) {
2302
- var _b = __read(_a, 1), entry = _b[0];
2303
- var _c = entry.target, clientWidth = _c.clientWidth, clientHeight = _c.clientHeight;
2304
- var innerWidth = window.innerWidth, innerHeight = window.innerHeight;
2305
- windowDimensionsRef.current = {
2306
- width: clientWidth,
2307
- height: clientHeight,
2308
- innerWidth: innerWidth,
2309
- innerHeight: innerHeight,
2310
- };
2311
- handleCallback();
2312
- });
2313
- resizeObserver.observe(document.documentElement);
2314
- return function () { return resizeObserver.unobserve(document.documentElement); };
2315
- }, []);
2316
- }
2317
-
2318
- var withDefault = function (x, y) {
2319
- return { x: x, y: y };
2320
- };
2321
-
2322
- var Gesture = /** @class */ (function () {
2323
- function Gesture() {
2324
- this.lastTimeStamp = Date.now();
2325
- this.isActive = false;
2326
- this.targetElements = []; // represents the bounded elements
2327
- }
2328
- // it must be overridden by other child classes
2329
- Gesture.prototype._initEvents = function () { };
2330
- // cancel events
2331
- // we only canceled down and move events because mouse up
2332
- // will not be triggered
2333
- Gesture.prototype._cancelEvents = function () {
2334
- if (this._subscribe) {
2335
- this._subscribe();
2336
- }
2337
- };
2338
- // re-apply new callback
2339
- Gesture.prototype.applyCallback = function (callback) {
2340
- this.callback = callback;
2341
- };
2342
- // apply gesture
2343
- Gesture.prototype.applyGesture = function (_a) {
2344
- var _this = this;
2345
- var targetElement = _a.targetElement, targetElements = _a.targetElements, callback = _a.callback, config = _a.config;
2346
- this.targetElement = targetElement;
2347
- this.targetElements = targetElements.map(function (element) { return element.current; });
2348
- this.callback = callback;
2349
- this.config = config;
2350
- // initialize events
2351
- this._initEvents();
2352
- // unbind
2353
- return function () { return _this._subscribe && _this._subscribe(); };
2354
- };
2355
- Gesture._VELOCITY_LIMIT = 20;
2356
- return Gesture;
2357
- }());
2358
-
2359
- var DragGesture = /** @class */ (function (_super) {
2360
- __extends(DragGesture, _super);
2361
- function DragGesture() {
2362
- var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
2363
- _this.movementStart = withDefault(0, 0);
2364
- _this.initialMovement = withDefault(0, 0);
2365
- _this.movement = withDefault(0, 0);
2366
- _this.previousMovement = withDefault(0, 0);
2367
- _this.translation = withDefault(0, 0);
2368
- _this.offset = withDefault(0, 0);
2369
- _this.velocity = withDefault(0, 0);
2370
- return _this;
2371
- }
2372
- // @override
2373
- // initialize the events
2374
- DragGesture.prototype._initEvents = function () {
2375
- if (this.targetElement || this.targetElements.length > 0) {
2376
- this._subscribe = attachEvents([window], [
2377
- ['mousedown', this.pointerDown.bind(this)],
2378
- ['mousemove', this.pointerMove.bind(this)],
2379
- ['mouseup', this.pointerUp.bind(this)],
2380
- ['touchstart', this.pointerDown.bind(this), { passive: false }],
2381
- ['touchmove', this.pointerMove.bind(this), { passive: false }],
2382
- ['touchend', this.pointerUp.bind(this)],
2383
- ]);
2384
- }
2385
- };
2386
- // @override - cancel events
2387
- // we only canceled down and move events because mouse up
2388
- // will not be triggered
2389
- DragGesture.prototype._cancelEvents = function () {
2390
- if (this._subscribe) {
2391
- this._subscribe(['mousedown', 'mousemove', 'touchstart', 'touchmove']);
2392
- }
2393
- };
2394
- DragGesture.prototype._handleCallback = function () {
2395
- var _this = this;
2396
- if (this.callback) {
2397
- this.callback({
2398
- args: [this.currentIndex],
2399
- down: this.isActive,
2400
- movementX: this.movement.x,
2401
- movementY: this.movement.y,
2402
- offsetX: this.translation.x,
2403
- offsetY: this.translation.y,
2404
- velocityX: this.velocity.x,
2405
- velocityY: this.velocity.y,
2406
- distanceX: Math.abs(this.movement.x),
2407
- distanceY: Math.abs(this.movement.y),
2408
- directionX: Math.sign(this.movement.x),
2409
- directionY: Math.sign(this.movement.y),
2410
- cancel: function () {
2411
- _this._cancelEvents();
2412
- },
2413
- });
2414
- }
2415
- };
2416
- DragGesture.prototype.pointerDown = function (e) {
2417
- var _a;
2418
- if (e.type === 'touchstart') {
2419
- this.movementStart = {
2420
- x: e.touches[0].clientX,
2421
- y: e.touches[0].clientY,
2422
- };
2423
- }
2424
- else {
2425
- this.movementStart = { x: e.clientX, y: e.clientY };
2426
- }
2427
- this.movement = { x: 0, y: 0 };
2428
- this.offset = { x: this.translation.x, y: this.translation.y };
2429
- this.previousMovement = { x: 0, y: 0 };
2430
- this.velocity = { x: 0, y: 0 };
2431
- // find current selected element
2432
- var currElem = this.targetElements.find(function (elem) { return elem === e.target; });
2433
- if (e.target === this.targetElement || currElem) {
2434
- this.isActive = true;
2435
- e.preventDefault();
2436
- // set args
2437
- if (currElem) {
2438
- this.currentIndex = this.targetElements.indexOf(currElem);
2439
- }
2440
- // if initial function is defined then call it to get initial movementX and movementY
2441
- // if only select to bounded draggable element
2442
- var initial = ((_a = this.config) === null || _a === void 0 ? void 0 : _a.initial) && this.config.initial();
2443
- var initialMovementX = initial === null || initial === void 0 ? void 0 : initial.movementX;
2444
- var initialMovementY = initial === null || initial === void 0 ? void 0 : initial.movementY;
2445
- this.initialMovement = {
2446
- x: initialMovementX !== null && initialMovementX !== void 0 ? initialMovementX : 0,
2447
- y: initialMovementY !== null && initialMovementY !== void 0 ? initialMovementY : 0,
2448
- };
2449
- this.movement = {
2450
- x: this.initialMovement.x,
2451
- y: this.initialMovement.y,
2452
- };
2453
- this.previousMovement = {
2454
- x: this.initialMovement.x,
2455
- y: this.initialMovement.y,
2456
- };
2457
- this._handleCallback();
2458
- }
2459
- };
2460
- DragGesture.prototype.pointerMove = function (e) {
2461
- if (this.isActive) {
2462
- e.preventDefault();
2463
- var now = Date.now();
2464
- var deltaTime = clamp(now - this.lastTimeStamp, 0.1, 64);
2465
- this.lastTimeStamp = now;
2466
- var t = deltaTime / 1000;
2467
- if (e.type === 'touchmove') {
2468
- this.movement = {
2469
- x: this.initialMovement.x +
2470
- (e.touches[0].clientX - this.movementStart.x),
2471
- y: this.initialMovement.y +
2472
- (e.touches[0].clientY - this.movementStart.y),
2473
- };
2474
- }
2475
- else {
2476
- this.movement = {
2477
- x: this.initialMovement.x + (e.clientX - this.movementStart.x),
2478
- y: this.initialMovement.y + (e.clientY - this.movementStart.y),
2479
- };
2480
- }
2481
- this.translation = {
2482
- x: this.offset.x + this.movement.x,
2483
- y: this.offset.y + this.movement.y,
2484
- };
2485
- this.velocity = {
2486
- x: clamp((this.movement.x - this.previousMovement.x) / t / 1000, -1 * Gesture._VELOCITY_LIMIT, Gesture._VELOCITY_LIMIT),
2487
- y: clamp((this.movement.y - this.previousMovement.y) / t / 1000, -1 * Gesture._VELOCITY_LIMIT, Gesture._VELOCITY_LIMIT),
2488
- };
2489
- this.previousMovement = {
2490
- x: this.movement.x,
2491
- y: this.movement.y,
2492
- };
2493
- this._handleCallback();
2494
- }
2495
- };
2496
- DragGesture.prototype.pointerUp = function () {
2497
- if (this.isActive) {
2498
- this.isActive = false;
2499
- this._handleCallback();
2500
- this._cancelEvents();
2501
- this._initEvents();
2502
- }
2503
- };
2504
- return DragGesture;
2505
- }(Gesture));
2506
-
2507
- var MouseMoveGesture = /** @class */ (function (_super) {
2508
- __extends(MouseMoveGesture, _super);
2509
- function MouseMoveGesture() {
2510
- var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
2511
- _this.movement = withDefault(0, 0);
2512
- _this.previousMovement = withDefault(0, 0);
2513
- _this.velocity = withDefault(0, 0);
2514
- _this.direction = withDefault(0, 0);
2515
- return _this;
2516
- }
2517
- // @override
2518
- // initialize the events
2519
- MouseMoveGesture.prototype._initEvents = function () {
2520
- if (this.targetElement) {
2521
- this._subscribe = attachEvents([this.targetElement], [['mousemove', this.onMouseMove.bind(this)]]);
2522
- }
2523
- else if (this.targetElements.length > 0) {
2524
- this._subscribe = attachEvents(this.targetElements, [
2525
- ['mousemove', this.onMouseMove.bind(this)],
2526
- ]);
2527
- }
2528
- else {
2529
- this._subscribe = attachEvents([window], [['mousemove', this.onMouseMove.bind(this)]]);
2530
- }
2531
- };
2532
- MouseMoveGesture.prototype._handleCallback = function () {
2533
- var _a;
2534
- if (this.callback) {
2535
- this.callback({
2536
- args: [this.currentIndex],
2537
- event: this.event,
2538
- isMoving: this.isActive,
2539
- target: (_a = this.event) === null || _a === void 0 ? void 0 : _a.target,
2540
- mouseX: this.movement.x,
2541
- mouseY: this.movement.y,
2542
- velocityX: this.velocity.x,
2543
- velocityY: this.velocity.y,
2544
- directionX: this.direction.x,
2545
- directionY: this.direction.y,
2546
- });
2547
- }
2548
- };
2549
- MouseMoveGesture.prototype.onMouseMove = function (e) {
2550
- var _this = this;
2551
- // find current selected element
2552
- var currElem = this.targetElements.find(function (elem) { return elem === e.target; });
2553
- // set args
2554
- if (currElem) {
2555
- this.currentIndex = this.targetElements.indexOf(currElem);
2556
- }
2557
- this.event = e;
2558
- var now = Date.now();
2559
- var deltaTime = Math.min(now - this.lastTimeStamp, 64);
2560
- this.lastTimeStamp = now;
2561
- var t = deltaTime / 1000; // seconds
2562
- var x = e.clientX;
2563
- var y = e.clientY;
2564
- this.movement = { x: x, y: y };
2565
- if (this.isActiveID !== -1) {
2566
- this.isActive = true;
2567
- clearTimeout(this.isActiveID);
2568
- }
2569
- this.isActiveID = setTimeout(function () {
2570
- _this.isActive = false;
2571
- _this.direction = { x: 0, y: 0 };
2572
- _this.velocity = { x: 0, y: 0 };
2573
- _this._handleCallback();
2574
- }, 250); // Debounce 250 milliseconds
2575
- var diffX = this.movement.x - this.previousMovement.x;
2576
- var diffY = this.movement.y - this.previousMovement.y;
2577
- this.direction = {
2578
- x: Math.sign(diffX),
2579
- y: Math.sign(diffY),
2580
- };
2581
- this.velocity = {
2582
- x: clamp(diffX / t / 1000, -1 * Gesture._VELOCITY_LIMIT, Gesture._VELOCITY_LIMIT),
2583
- y: clamp(diffY / t / 1000, -1 * Gesture._VELOCITY_LIMIT, Gesture._VELOCITY_LIMIT),
2584
- };
2585
- this.previousMovement = { x: this.movement.x, y: this.movement.y };
2586
- this._handleCallback();
2587
- };
2588
- return MouseMoveGesture;
2589
- }(Gesture));
2590
-
2591
- var ScrollGesture = /** @class */ (function (_super) {
2592
- __extends(ScrollGesture, _super);
2593
- function ScrollGesture() {
2594
- var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
2595
- _this.movement = withDefault(0, 0);
2596
- _this.previousMovement = withDefault(0, 0);
2597
- _this.direction = withDefault(0, 0);
2598
- _this.velocity = withDefault(0, 0);
2599
- return _this;
2600
- }
2601
- // @override
2602
- // initialize the events
2603
- ScrollGesture.prototype._initEvents = function () {
2604
- if (this.targetElement) {
2605
- this._subscribe = attachEvents([this.targetElement], [['scroll', this.scrollElementListener.bind(this)]]);
2606
- }
2607
- else {
2608
- this._subscribe = attachEvents([window], [['scroll', this.scrollListener.bind(this)]]);
2609
- }
2610
- };
2611
- ScrollGesture.prototype._handleCallback = function () {
2612
- if (this.callback) {
2613
- this.callback({
2614
- isScrolling: this.isActive,
2615
- scrollX: this.movement.x,
2616
- scrollY: this.movement.y,
2617
- velocityX: this.velocity.x,
2618
- velocityY: this.velocity.y,
2619
- directionX: this.direction.x,
2620
- directionY: this.direction.y,
2621
- });
2622
- }
2623
- };
2624
- ScrollGesture.prototype.onScroll = function (_a) {
2625
- var _this = this;
2626
- var x = _a.x, y = _a.y;
2627
- var now = Date.now();
2628
- var deltaTime = Math.min(now - this.lastTimeStamp, 64);
2629
- this.lastTimeStamp = now;
2630
- var t = deltaTime / 1000; // seconds
2631
- this.movement = { x: x, y: y };
2632
- // Clear if scrolling
2633
- if (this.isActiveID !== -1) {
2634
- this.isActive = true;
2635
- clearTimeout(this.isActiveID);
2636
- }
2637
- this.isActiveID = setTimeout(function () {
2638
- _this.isActive = false;
2639
- _this.direction = { x: 0, y: 0 };
2640
- // Reset Velocity
2641
- _this.velocity = { x: 0, y: 0 };
2642
- _this._handleCallback(); // Debounce 250milliseconds
2643
- }, 250);
2644
- var diffX = this.movement.x - this.previousMovement.x;
2645
- var diffY = this.movement.y - this.previousMovement.y;
2646
- this.direction = {
2647
- x: Math.sign(diffX),
2648
- y: Math.sign(diffY),
2649
- };
2650
- this.velocity = {
2651
- x: clamp(diffX / t / 1000, -1 * Gesture._VELOCITY_LIMIT, Gesture._VELOCITY_LIMIT),
2652
- y: clamp(diffY / t / 1000, -1 * Gesture._VELOCITY_LIMIT, Gesture._VELOCITY_LIMIT),
2653
- };
2654
- this.previousMovement = {
2655
- x: this.movement.x,
2656
- y: this.movement.y,
2657
- };
2658
- this._handleCallback();
2659
- };
2660
- ScrollGesture.prototype.scrollListener = function () {
2661
- var y = window.pageYOffset, x = window.pageXOffset;
2662
- this.onScroll({ x: x, y: y });
2663
- };
2664
- ScrollGesture.prototype.scrollElementListener = function () {
2665
- var _a, _b;
2666
- var x = ((_a = this.targetElement) === null || _a === void 0 ? void 0 : _a.scrollLeft) || 0;
2667
- var y = ((_b = this.targetElement) === null || _b === void 0 ? void 0 : _b.scrollTop) || 0;
2668
- this.onScroll({ x: x, y: y });
2669
- };
2670
- return ScrollGesture;
2671
- }(Gesture));
2672
-
2673
- var LINE_HEIGHT = 40;
2674
- var PAGE_HEIGHT = 800;
2675
- var WheelGesture = /** @class */ (function (_super) {
2676
- __extends(WheelGesture, _super);
2677
- function WheelGesture() {
2678
- var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
2679
- _this.movement = withDefault(0, 0);
2680
- _this.previousMovement = withDefault(0, 0);
2681
- _this.direction = withDefault(0, 0);
2682
- _this.velocity = withDefault(0, 0);
2683
- _this.delta = withDefault(0, 0);
2684
- // Holds offsets
2685
- _this.offset = withDefault(0, 0);
2686
- _this.translation = withDefault(0, 0);
2687
- return _this;
2688
- }
2689
- // @override
2690
- // initialize the events
2691
- WheelGesture.prototype._initEvents = function () {
2692
- if (this.targetElement) {
2693
- this._subscribe = attachEvents([this.targetElement], [['wheel', this.onWheel.bind(this)]]);
2694
- }
2695
- };
2696
- WheelGesture.prototype._handleCallback = function () {
2697
- if (this.callback) {
2698
- this.callback({
2699
- target: this.targetElement,
2700
- isWheeling: this.isActive,
2701
- deltaX: this.delta.x,
2702
- deltaY: this.delta.y,
2703
- directionX: this.direction.x,
2704
- directionY: this.direction.y,
2705
- movementX: this.movement.x,
2706
- movementY: this.movement.y,
2707
- offsetX: this.offset.x,
2708
- offsetY: this.offset.y,
2709
- velocityX: this.velocity.x,
2710
- velocityY: this.velocity.y,
2711
- });
2712
- }
2713
- };
2714
- WheelGesture.prototype.onWheel = function (event) {
2715
- var _this = this;
2716
- var deltaX = event.deltaX, deltaY = event.deltaY, deltaMode = event.deltaMode;
2717
- var now = Date.now();
2718
- var deltaTime = Math.min(now - this.lastTimeStamp, 64);
2719
- this.lastTimeStamp = now;
2720
- var t = deltaTime / 1000; // seconds
2721
- this.isActive = true;
2722
- if (this.isActiveID !== -1) {
2723
- this.isActive = true;
2724
- clearTimeout(this.isActiveID);
2725
- }
2726
- this.isActiveID = setTimeout(function () {
2727
- _this.isActive = false;
2728
- _this.translation = { x: _this.offset.x, y: _this.offset.y };
2729
- _this._handleCallback();
2730
- _this.velocity = { x: 0, y: 0 }; // Reset Velocity
2731
- _this.movement = { x: 0, y: 0 };
2732
- }, 200);
2733
- // normalize wheel values, especially for Firefox
2734
- if (deltaMode === 1) {
2735
- deltaX *= LINE_HEIGHT;
2736
- deltaY *= LINE_HEIGHT;
2737
- }
2738
- else if (deltaMode === 2) {
2739
- deltaX *= PAGE_HEIGHT;
2740
- deltaY *= PAGE_HEIGHT;
2741
- }
2742
- this.delta = { x: deltaX, y: deltaY };
2743
- this.movement = {
2744
- x: this.movement.x + deltaX,
2745
- y: this.movement.y + deltaY,
2746
- };
2747
- this.offset = {
2748
- x: this.translation.x + this.movement.x,
2749
- y: this.translation.y + this.movement.y,
2750
- };
2751
- var diffX = this.movement.x - this.previousMovement.x;
2752
- var diffY = this.movement.y - this.previousMovement.y;
2753
- this.direction = {
2754
- x: Math.sign(diffX),
2755
- y: Math.sign(diffY),
2756
- };
2757
- this.velocity = {
2758
- x: clamp(diffX / t / 1000, -1 * Gesture._VELOCITY_LIMIT, Gesture._VELOCITY_LIMIT),
2759
- y: clamp(diffY / t / 1000, -1 * Gesture._VELOCITY_LIMIT, Gesture._VELOCITY_LIMIT),
2760
- };
2761
- this.previousMovement = {
2762
- x: this.movement.x,
2763
- y: this.movement.y,
2764
- };
2765
- this._handleCallback();
2766
- };
2767
- return WheelGesture;
2768
- }(Gesture));
2769
-
2770
- var useRecognizer = function (handlers) {
2771
- var ref = React__namespace.useRef();
2772
- var elementRefs = React__namespace.useRef([]);
2773
- var subscribers = React__namespace.useRef(new Map()).current;
2774
- // re-initiate callback on change
2775
- React__namespace.useEffect(function () {
2776
- var e_1, _a;
2777
- try {
2778
- for (var _b = __values(subscribers.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
2779
- var _d = __read(_c.value, 2), _e = _d[1], keyIndex = _e.keyIndex, gesture = _e.gesture;
2780
- var _f = __read(handlers[keyIndex], 3), callback = _f[2];
2781
- gesture.applyCallback(callback);
2782
- }
2783
- }
2784
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2785
- finally {
2786
- try {
2787
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2788
- }
2789
- finally { if (e_1) throw e_1.error; }
2790
- }
2791
- }, [handlers]);
2792
- React__namespace.useEffect(function () {
2793
- handlers.forEach(function (_a, keyIndex) {
2794
- var _b = __read(_a, 4), key = _b[0], gesture = _b[1], callback = _b[2], config = _b[3];
2795
- subscribers.set(key, {
2796
- keyIndex: keyIndex,
2797
- gesture: gesture,
2798
- unsubscribe: gesture.applyGesture({
2799
- targetElement: ref.current,
2800
- targetElements: elementRefs.current,
2801
- callback: callback,
2802
- config: config,
2803
- }),
2804
- });
2805
- });
2806
- return function () {
2807
- var e_2, _a;
2808
- try {
2809
- for (var _b = __values(subscribers.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
2810
- var _d = __read(_c.value, 2), unsubscribe = _d[1].unsubscribe;
2811
- unsubscribe && unsubscribe();
2812
- }
2813
- }
2814
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
2815
- finally {
2816
- try {
2817
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2818
- }
2819
- finally { if (e_2) throw e_2.error; }
2820
- }
2821
- };
2822
- }, []);
2823
- return function (index) {
2824
- if (index === null || index === undefined) {
2825
- return { ref: ref };
2826
- }
2827
- else {
2828
- elementRefs.current[index] =
2829
- elementRefs.current[index] || React__namespace.createRef();
2830
- return { ref: elementRefs.current[index] };
2831
- }
2832
- };
2833
- };
2834
-
2835
- function useDrag(callback, config) {
2836
- var gesture = React__namespace.useRef(new DragGesture()).current;
2837
- return useRecognizer([['drag', gesture, callback, config]]);
2838
- }
2839
-
2840
- function useMouseMove(callback) {
2841
- var gesture = React__namespace.useRef(new MouseMoveGesture()).current;
2842
- return useRecognizer([['move', gesture, callback]]);
2843
- }
2844
-
2845
- function useScroll(callback) {
2846
- var gesture = React__namespace.useRef(new ScrollGesture()).current;
2847
- return useRecognizer([['scroll', gesture, callback]]);
2848
- }
2849
-
2850
- function useWheel(callback) {
2851
- var gesture = React__namespace.useRef(new WheelGesture()).current;
2852
- return useRecognizer([['wheel', gesture, callback]]);
2853
- }
2854
-
2855
- function useGesture(_a) {
2856
- var onDrag = _a.onDrag, onWheel = _a.onWheel, onScroll = _a.onScroll, onMouseMove = _a.onMouseMove;
2857
- var dragGesture = React__namespace.useRef(new DragGesture()).current;
2858
- var wheelGesture = React__namespace.useRef(new WheelGesture()).current;
2859
- var scrollGesture = React__namespace.useRef(new ScrollGesture()).current;
2860
- var mouseMoveGesture = React__namespace.useRef(new MouseMoveGesture()).current;
2861
- return useRecognizer([
2862
- ['drag', dragGesture, onDrag],
2863
- ['wheel', wheelGesture, onWheel],
2864
- ['scroll', scrollGesture, onScroll],
2865
- ['move', mouseMoveGesture, onMouseMove],
2866
- ]);
2867
- }
2868
-
2869
- exports.AnimatedBlock = AnimatedBlock;
2870
- exports.AnimatedImage = AnimatedImage;
2871
- exports.AnimatedInline = AnimatedInline;
2872
- exports.AnimationConfigUtils = AnimationConfigUtils;
2873
- exports.Easing = Easing;
2874
- exports.MountedBlock = MountedBlock;
2875
- exports.ScrollableBlock = ScrollableBlock;
2876
- exports.TransitionBlock = TransitionBlock;
2877
- exports.bInterpolate = bInterpolate;
2878
- exports.bin = bin;
2879
- exports.clamp = clamp;
2880
- exports.delay = delay;
2881
- exports.fluid = fluid;
2882
- exports.interpolate = interpolate;
2883
- exports.makeFluid = makeFluid;
2884
- exports.mix = mix;
2885
- exports.move = move;
2886
- exports.rubberClamp = rubberClamp;
2887
- exports.snapTo = snapTo;
2888
- exports.useAnimatedValue = useAnimatedValue;
2889
- exports.useDrag = useDrag;
2890
- exports.useGesture = useGesture;
2891
- exports.useMeasure = useMeasure;
2892
- exports.useMountedValue = useMountedValue;
2893
- exports.useMouseMove = useMouseMove;
2894
- exports.useOutsideClick = useOutsideClick;
2895
- exports.useScroll = useScroll;
2896
- exports.useWheel = useWheel;
2897
- exports.useWindowDimension = useWindowDimension;
1
+ var e=require("react"),t=require("react/jsx-runtime");function n(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var i=n(e),r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var a=function(){return a=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},a.apply(this,arguments)};function s(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}function f(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return a}function l(e,t,n){if(n||2===arguments.length)for(var i,r=0,o=t.length;r<o;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var c=function(){function e(){}return e.prototype._debounceOnEnd=function(e){var t=this._onEnd,n=this._onRest;this._onEnd=null,this._onRest=null,n&&n(e),t&&t(e)},e.prototype.stop=function(){},e}(),h={current:function(e){return window.requestAnimationFrame(e)},inject:function(e){h.current=e}},d={current:function(e){return window.cancelAnimationFrame(e)},inject:function(e){d.current=e}},p=function(e){function t(t){var n,i,r,o,a,s,f=t.initialPosition,u=t.config,l=e.call(this)||this;return l._overshootClamping=!1,l._initialVelocity=0,l._lastVelocity=0,l._startPosition=f,l._position=l._startPosition,l._restDisplacementThreshold=null!==(n=null==u?void 0:u.restDistance)&&void 0!==n?n:.001,l._restSpeedThreshold=null!==(i=null==u?void 0:u.restDistance)&&void 0!==i?i:.001,l._mass=null!==(r=null==u?void 0:u.mass)&&void 0!==r?r:1,l._tension=null!==(o=null==u?void 0:u.tension)&&void 0!==o?o:170,l._friction=null!==(a=null==u?void 0:u.friction)&&void 0!==a?a:26,l._delay=null!==(s=null==u?void 0:u.delay)&&void 0!==s?s:0,l._onRest=null==u?void 0:u.onRest,l._onChange=null==u?void 0:u.onChange,l}return o(t,e),t.prototype.onChange=function(e){this._onFrame(e),this._lastPosition!==e&&this._onChange&&this._onChange(e),this._lastPosition=e},t.prototype.onUpdate=function(){var e=this,t=Date.now(),n=Math.min(t-this._lastTime,64);this._lastTime=t;var i=this._friction,r=this._mass,o=this._tension,a=-this._lastVelocity,s=this._toValue-this._position,f=i/(2*Math.sqrt(o*r)),u=Math.sqrt(o/r),l=u*Math.sqrt(1-Math.pow(f,2)),c=n/1e3,d=Math.sin(l*c),p=Math.cos(l*c),m=Math.exp(-f*u*c),v=m*(d*((a+f*u*s)/l)+s*p),y=this._toValue-v,g=f*u*v-m*(p*(a+f*u*s)-l*s*d),b=Math.exp(-u*c),_=this._toValue-b*(s+(a+u*s)*c),w=b*(a*(c*u-1)+c*s*u*u);this.onChange(this._position);var x=Math.abs(this._lastVelocity)<this._restSpeedThreshold,E=0===this._tension||Math.abs(this._toValue-this._position)<this._restDisplacementThreshold;if(f<1?(this._position=y,this._lastVelocity=g):(this._position=_,this._lastVelocity=w),e._overshootClamping&&0!==e._tension&&(e._position<e._toValue?e._position>e._toValue:e._position<e._toValue)||x&&E)return 0!==this._tension&&(this._lastVelocity=0,this._position=this._toValue,this.onChange(this._position)),this._lastTime=0,void this._debounceOnEnd({finished:!0,value:this._toValue});this._animationFrame=h.current(this.onUpdate.bind(this))},t.prototype.stop=function(){this._active=!1,clearTimeout(this._timeout),d.current(this._animationFrame),this._debounceOnEnd({finished:!1,value:this._position})},t.prototype.set=function(e){this.stop(),this._position=e,this._lastTime=0,this._lastVelocity=0,this.onChange(e)},t.prototype.start=function(e){var n=this,i=e.toValue,r=e.onFrame,o=e.previousAnimation,a=e.onEnd,s=function(){n._onFrame=r,n._active=!0,n._toValue=i,n._onEnd=a;var e=Date.now();o instanceof t?(n._lastVelocity=o._lastVelocity||n._lastVelocity||0,n._lastTime=o._lastTime||e):n._lastTime=e,n._animationFrame=h.current(n.onUpdate.bind(n))};0!==this._delay?this._timeout=setTimeout((function(){return s()}),this._delay):s()},t}(c),m=4,v=1e-7,y=10,g=.1,b="function"==typeof Float32Array;function _(e,t){return 1-3*t+3*e}function w(e,t){return 3*t-6*e}function x(e){return 3*e}function E(e,t,n){return((_(t,n)*e+w(t,n))*e+x(t))*e}function k(e,t,n){return 3*_(t,n)*e*e+2*w(t,n)*e+x(t)}function M(e){return e}function T(e,t,n,i){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===i)return M;for(var r=b?new Float32Array(11):new Array(11),o=0;o<11;++o)r[o]=E(o*g,e,n);function a(t){for(var i=0,o=1;10!==o&&r[o]<=t;++o)i+=g;--o;var a=i+(t-r[o])/(r[o+1]-r[o])*g,s=k(a,e,n);return s>=.001?function(e,t,n,i){for(var r=0;r<m;++r){var o=k(t,n,i);if(0===o)return t;t-=(E(t,n,i)-e)/o}return t}(t,a,e,n):0===s?a:function(e,t,n,i,r){var o,a,s=0;do{(o=E(a=t+(n-t)/2,i,r)-e)>0?n=a:t=a}while(Math.abs(o)>v&&++s<y);return a}(t,i,i+g,e,n)}return function(e){return 0===e||1===e?e:E(a(e),t,i)}}var I=function(){function e(){}return e.step0=function(e){return e>0?1:0},e.step1=function(e){return e>=1?1:0},e.linear=function(e){return e},e.ease=function(e){return O(e)},e.quad=function(e){return e*e},e.cubic=function(e){return e*e*e},e.poly=function(e){return function(t){return Math.pow(t,e)}},e.sin=function(e){return 1-Math.cos(e*Math.PI/2)},e.circle=function(e){return 1-Math.sqrt(1-e*e)},e.exp=function(e){return Math.pow(2,10*(e-1))},e.elastic=function(e){void 0===e&&(e=1);var t=e*Math.PI;return function(e){return 1-Math.pow(Math.cos(e*Math.PI/2),3)*Math.cos(e*t)}},e.back=function(e){return void 0===e&&(e=1.70158),function(t){return t*t*((e+1)*t-e)}},e.bounce=function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},e.bezier=function(e,t,n,i){return T(e,t,n,i)},e.in=function(e){return e},e.out=function(e){return function(t){return 1-e(1-t)}},e.inOut=function(e){return function(t){return t<.5?e(2*t)/2:1-e(2*(1-t))/2}},e}(),O=I.bezier(.42,0,1,1),C=function(e){function t(t){var n,i,r,o=t.initialPosition,a=t.config,s=e.call(this)||this;return s._fromValue=o,s._position=s._fromValue,s._easing=null!==(n=null==a?void 0:a.easing)&&void 0!==n?n:I.linear,s._duration=null!==(i=null==a?void 0:a.duration)&&void 0!==i?i:500,s._tempDuration=s._duration,(null==a?void 0:a.immediate)&&(s._duration=0),s._delay=null!==(r=null==a?void 0:a.delay)&&void 0!==r?r:0,s._onRest=null==a?void 0:a.onRest,s._onChange=null==a?void 0:a.onChange,s}return o(t,e),t.prototype.onChange=function(e){this._onFrame(e),this._lastPosition!==e&&this._onChange&&this._onChange(e),this._lastPosition=e},t.prototype.onUpdate=function(){var e=Date.now()-this._startTime;if(e>=this._duration)return this._startTime=0,this._position=this._toValue,this.onChange(this._position),void this._debounceOnEnd({finished:!0,value:this._position});var t=this._easing(e/this._duration);this._position=this._fromValue+(this._toValue-this._fromValue)*t,this.onChange(this._position),this._animationFrame=h.current(this.onUpdate.bind(this))},t.prototype.stop=function(){this._active=!1,clearTimeout(this._timeout),d.current(this._animationFrame),this._debounceOnEnd({finished:!1,value:this._position})},t.prototype.set=function(e){this.stop(),this._position=e,this.onChange(e)},t.prototype.start=function(e){var n=this,i=e.toValue,r=e.onFrame,o=e.previousAnimation,a=e.onEnd,s=function(){if(n._onFrame=r,n._active=!0,n._onEnd=a,n._toValue=i,o&&o instanceof t&&o._toValue===i&&o._startTime)n._startTime=o._startTime,n._fromValue=o._fromValue;else{var e=Date.now();n._startTime=e,n._fromValue=n._position}n._animationFrame=h.current(n.onUpdate.bind(n))};0!==this._delay?this._timeout=setTimeout((function(){return s()}),this._delay):s()},t}(c),V=/[+-]?\d+(\.\d+)?|[\s]?\.\d+|#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})/gi,S=/#[a-f\d]{3,}|transparent|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|burntsienna|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen/gi,L={transparent:"#00000000",aliceblue:"#f0f8ffff",antiquewhite:"#faebd7ff",aqua:"#00ffffff",aquamarine:"#7fffd4ff",azure:"#f0ffffff",beige:"#f5f5dcff",bisque:"#ffe4c4ff",black:"#000000ff",blanchedalmond:"#ffebcdff",blue:"#0000ffff",blueviolet:"#8a2be2ff",brown:"#a52a2aff",burlywood:"#deb887ff",burntsienna:"#ea7e5dff",cadetblue:"#5f9ea0ff",chartreuse:"#7fff00ff",chocolate:"#d2691eff",coral:"#ff7f50ff",cornflowerblue:"#6495edff",cornsilk:"#fff8dcff",crimson:"#dc143cff",cyan:"#00ffffff",darkblue:"#00008bff",darkcyan:"#008b8bff",darkgoldenrod:"#b8860bff",darkgray:"#a9a9a9ff",darkgreen:"#006400ff",darkgrey:"#a9a9a9ff",darkkhaki:"#bdb76bff",darkmagenta:"#8b008bff",darkolivegreen:"#556b2fff",darkorange:"#ff8c00ff",darkorchid:"#9932ccff",darkred:"#8b0000ff",darksalmon:"#e9967aff",darkseagreen:"#8fbc8fff",darkslateblue:"#483d8bff",darkslategray:"#2f4f4fff",darkslategrey:"#2f4f4fff",darkturquoise:"#00ced1ff",darkviolet:"#9400d3ff",deeppink:"#ff1493ff",deepskyblue:"#00bfffff",dimgray:"#696969ff",dimgrey:"#696969ff",dodgerblue:"#1e90ffff",firebrick:"#b22222ff",floralwhite:"#fffaf0ff",forestgreen:"#228b22ff",fuchsia:"#ff00ffff",gainsboro:"#dcdcdcff",ghostwhite:"#f8f8ffff",gold:"#ffd700ff",goldenrod:"#daa520ff",gray:"#808080ff",green:"#008000ff",greenyellow:"#adff2fff",grey:"#808080ff",honeydew:"#f0fff0ff",hotpink:"#ff69b4ff",indianred:"#cd5c5cff",indigo:"#4b0082ff",ivory:"#fffff0ff",khaki:"#f0e68cff",lavender:"#e6e6faff",lavenderblush:"#fff0f5ff",lawngreen:"#7cfc00ff",lemonchiffon:"#fffacdff",lightblue:"#add8e6ff",lightcoral:"#f08080ff",lightcyan:"#e0ffffff",lightgoldenrodyellow:"#fafad2ff",lightgray:"#d3d3d3ff",lightgreen:"#90ee90ff",lightgrey:"#d3d3d3ff",lightpink:"#ffb6c1ff",lightsalmon:"#ffa07aff",lightseagreen:"#20b2aaff",lightskyblue:"#87cefaff",lightslategray:"#778899ff",lightslategrey:"#778899ff",lightsteelblue:"#b0c4deff",lightyellow:"#ffffe0ff",lime:"#00ff00ff",limegreen:"#32cd32ff",linen:"#faf0e6ff",magenta:"#ff00ffff",maroon:"#800000ff",mediumaquamarine:"#66cdaaff",mediumblue:"#0000cdff",mediumorchid:"#ba55d3ff",mediumpurple:"#9370dbff",mediumseagreen:"#3cb371ff",mediumslateblue:"#7b68eeff",mediumspringgreen:"#00fa9aff",mediumturquoise:"#48d1ccff",mediumvioletred:"#c71585ff",midnightblue:"#191970ff",mintcream:"#f5fffaff",mistyrose:"#ffe4e1ff",moccasin:"#ffe4b5ff",navajowhite:"#ffdeadff",navy:"#000080ff",oldlace:"#fdf5e6ff",olive:"#808000ff",olivedrab:"#6b8e23ff",orange:"#ffa500ff",orangered:"#ff4500ff",orchid:"#da70d6ff",palegoldenrod:"#eee8aaff",palegreen:"#98fb98ff",paleturquoise:"#afeeeeff",palevioletred:"#db7093ff",papayawhip:"#ffefd5ff",peachpuff:"#ffdab9ff",peru:"#cd853fff",pink:"#ffc0cbff",plum:"#dda0ddff",powderblue:"#b0e0e6ff",purple:"#800080ff",rebeccapurple:"#663399ff",red:"#ff0000ff",rosybrown:"#bc8f8fff",royalblue:"#4169e1ff",saddlebrown:"#8b4513ff",salmon:"#fa8072ff",sandybrown:"#f4a460ff",seagreen:"#2e8b57ff",seashell:"#fff5eeff",sienna:"#a0522dff",silver:"#c0c0c0ff",skyblue:"#87ceebff",slateblue:"#6a5acdff",slategray:"#708090ff",slategrey:"#708090ff",snow:"#fffafaff",springgreen:"#00ff7fff",steelblue:"#4682b4ff",tan:"#d2b48cff",teal:"#008080ff",thistle:"#d8bfd8ff",tomato:"#ff6347ff",turquoise:"#40e0d0ff",violet:"#ee82eeff",wheat:"#f5deb3ff",white:"#ffffffff",whitesmoke:"#f5f5f5ff",yellow:"#ffff00ff",yellowgreen:"#9acd32ff"};function A(e){var t=function(e){return e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(e,t,n,i){return"#"+t+t+n+n+i+i}))}(e),n=function(e){return 7===e.length?e+"FF":e}(t),i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return{r:parseInt(i[1],16),g:parseInt(i[2],16),b:parseInt(i[3],16),a:parseInt(i[4],16)/255}}function Y(e){var t=e.r,n=e.g,i=e.b,r=e.a;return"#"+(256|t).toString(16).slice(1)+(256|n).toString(16).slice(1)+(256|i).toString(16).slice(1)+(255*r|256).toString(16).slice(1)}var R=function(e){return null!=e},D=function(e){return R(e)&&"object"==typeof e&&"_subscribe"in e},F=["borderImageOutset","borderImageSlice","borderImageWidth","fontWeight","lineHeight","opacity","orphans","tabSize","widows","zIndex","zoom","fillOpacity","floodOpacity","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","animationIterationCount","boxFlex","boxFlexGroup","boxOrdinalGroup","columnCount","flex","flexGrow","flexPositive","flexShrink","flexNegative","flexOrder","gridRow","gridColumn","order","lineClamp"];var P=function(e,t,n,i){var r=u(t,4),o=r[0],a=r[1],s=r[2],f=r[3],l=e;if(l<o){if("identity"===n)return l;"clamp"===n&&(l=o)}if(l>a){if("identity"===i)return l;"clamp"===i&&(l=a)}return s===f?s:o===a?e<=o?s:f:(o===-1/0?l=-l:a===1/0?l-=o:l=(l-o)/(a-o),s===-1/0?l=-l:f===1/0?l+=s:l=l*(f-s)+s,l)},j=function(e,t,n){var i=t.length,r=[];e<t[0]?r=[t[0],t[1],n[0],n[1]]:e>t[i-1]&&(r=[t[i-2],t[i-1],n[i-2],n[i-1]]);for(var o=1;o<i;++o)if(e<=t[o]){r=[t[o-1],t[o],n[o-1],n[o]];break}return r},X=function(e,t,n,i){var r=u(t,4),o=r[0],a=r[1],s=r[2],f=r[3];if(s.length===f.length)return s.map((function(t,r){return"string"==typeof t?function(e,t){var n=u(t,4),i=n[0],r=n[1],o=n[2],a=n[3],s=A(o),f=A(a);return Y({r:P(e,[i,r,s.r,f.r],"clamp","clamp"),g:P(e,[i,r,s.g,f.g],"clamp","clamp"),b:P(e,[i,r,s.b,f.b],"clamp","clamp"),a:P(e,[i,r,s.a,f.a],"clamp","clamp")})}(e,[o,a,t,f[r]]):P(e,[o,a,t,f[r]],n,i)}));throw new Error("Array length doesn't match")},q=function(e){return e.replace(V,"$")},W=function(e){return e.match(V).map((function(e){return-1!==e.indexOf("#")?e:Number(e)}))},z=function(e,t){return q(e).trim().replace(/\s/g,"")===q(t).trim().replace(/\s/g,"")},U=function(e){return e.replace(S,(function(e){if(-1!==e.indexOf("#"))return Y(A(e));if(Object.prototype.hasOwnProperty.call(L,e))return L[e];throw new Error("String cannot be parsed!")}))};function B(e,t,n,i){var r,o,a=null==i?void 0:i.extrapolate,s=null==i?void 0:i.extrapolateLeft,l=null==i?void 0:i.extrapolateRight,c=j(e,t,n),h="extend";void 0!==s?h=s:void 0!==a&&(h=a);var d="extend";if(void 0!==l?d=l:void 0!==a&&(d=a),n.length){if("number"==typeof n[0])return P(e,c,h,d);if(Array.isArray(n[0]))return X(e,c,h,d);var p=u(c,4),m=p[0],v=p[1],y=p[2],g=p[3],b=U(y),_=U(g),w=q(b);if(z(b,_)){var x=W(b),E=W(_),k=X(e,[m,v,x,E],h,d);try{for(var M=f(k),T=M.next();!T.done;T=M.next()){var I=T.value;w=w.replace("$",I)}}catch(e){r={error:e}}finally{try{T&&!T.done&&(o=M.return)&&o.call(M)}finally{if(r)throw r.error}}return w}throw new Error("Output range doesn't match string format!")}throw new Error("Output range cannot be Empty")}var G=function(e,t,n,i){if(D(e))return function(e,t,n,i){return a(a({},e),{isInterpolation:!0,interpolationConfig:{inputRange:t,outputRange:n,extrapolateConfig:i}})}(e,t,n,i);if("number"==typeof e)return B(e,t,n,i);throw new Error("'".concat(typeof e,"' cannot be interpolated!"))};var N=["translate","translateX","translateY","translateZ","scale","scaleX","scaleY","scaleZ","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"];function H(e){var t=e.match(/(-)?(\d+.)?\d+/g),n=e.match(/px|rem|em|ex|%|cm|mm|in|pt|pc|ch|vh|vw|vmin|vmax/);return{value:Number(t),unit:n&&n[0]}}function Z(e,t){var n=function(e,t){var n,i=H(String(t)).value,r=H(String(t)).unit;return r?{value:i,unit:r}:(e.includes("translate")||e.includes("perspective")?n="px":e.includes("scale")?n="":(e.includes("rotate")||e.includes("skew"))&&(n="deg"),{value:t,unit:n})}(e,t);if(e.includes("X")||e.includes("Y")||e.includes("Z")||e.includes("perspective")||e.includes("rotate")||e.includes("skew"))return"".concat(e,"(").concat(n.value).concat(n.unit,")");if(e.includes("translate")||e.indexOf("scale"))return"".concat(e,"(").concat(n.value).concat(n.unit,", ").concat(n.value).concat(n.unit,")");throw new Error("Error! Property '".concat(e,"' cannot be transformed"))}function $(t){return e.forwardRef((function(n,i){var r=e.useRef(null),o=e.useRef({}),f=e.useMemo((function(){var e=n.style,t=s(n,["style"]),i=K("style",e),r=K("props",t);return{fluids:l(l([],u(i.fluids),!1),u(r.fluids),!1),nonFluids:l(l([],u(i.nonFluids),!1),u(r.nonFluids),!1)}}),[n]),c=f.fluids,h=f.nonFluids,d=function(e){var t,n=e.isTransform,i=e.propertyType,a=e.property,s=e.value;r.current&&("style"===i?n?(o.current[a]=s,r.current.style.transform=(t=o.current,Object.entries(t).map((function(e){var t=u(e,2);return Z(t[0],t[1])})).reduce((function(e,t){return e+" ".concat(t)}),"").trim())):r.current.style[a]=function(e,t){return"number"==typeof t?F.includes(e)?t:t+"px":t}(a,s):"props"===i&&r.current.setAttribute(a.replace(/([A-Z])/g,(function(e){return"-"+e.toLowerCase()})),s))};return e.useLayoutEffect((function(){h.forEach((function(e){var t=e.isTransform,n=e.property,i=e.propertyType,r=e.value;return d({isTransform:t,property:n,propertyType:i,value:r})}))}),[h]),e.useLayoutEffect((function(){var e=[];return c.forEach((function(t){var n,i=t.value,r=t.propertyType,o=t.property,s=t.isTransform,f=i._subscribe,u=i._value,l=i._currentValue,c=i._config,h=[],m=(n=c,function(e,t){var i=a(a({},n),t);return new(R(null==i?void 0:i.duration)||(null==i?void 0:i.immediate)?C:p)({initialPosition:e,config:i})}),v=null,y=function(e){l.current=e;var t=i.isInterpolation&&i.interpolationConfig?B(e,i.interpolationConfig.inputRange,i.interpolationConfig.outputRange,i.interpolationConfig.extrapolateConfig):e;d({isTransform:s,propertyType:r,property:o,value:t})};v=m("string"==typeof u?0:u),d({isTransform:s,propertyType:r,property:o,value:u});var g=f((function(e,t,n){if(function(e,t){if(typeof e!=typeof t)return!1;if("number"==typeof t)return!0;if("string"==typeof e){var n=U(e),i=U(t);return n!==i&&q(n)===q(i)}return!1}(u,e)){var a=v;a._value!==e&&(v.stop(),v=m(a._position,t),(null==t?void 0:t.onStart)&&t.onStart(a._position),"string"==typeof e&&(h.includes(u)||h.push(u),h.includes(e)||h.push(e),i.isInterpolation=!0,i.interpolationConfig={inputRange:h.map((function(e,t){return t})),outputRange:h}),v.start({toValue:"string"==typeof e?h.indexOf(e):e,onFrame:y,previousAnimation:a,onEnd:n}))}else{if(typeof e!=typeof u)throw new Error("Cannot assign ".concat(typeof e," to animated ").concat(typeof u));d({isTransform:s,propertyType:r,property:o,value:e})}}),o,Date.now());e.push(g)})),function(){e.forEach((function(e){return e()}))}}),[]),e.createElement(t,a(a({},function(e){e.style;var t=s(e,["style"]);return Object.fromEntries(Object.entries(t).filter((function(e){var t=u(e,2);t[0];var n=t[1];return!D(n)})))}(n)),{ref:J(r,i)}))}))}function J(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){e.forEach((function(e){e&&("function"!=typeof e?"current"in e&&(e.current=t):e(t))}))}}function K(e,t){return void 0===t&&(t={}),Object.entries(t).reduce((function(t,n){var i,r=u(n,2),o=r[0],a=r[1],s="style"===e&&(i=o,N.includes(i));return D(a)?t.fluids.push({isTransform:s,property:o,propertyType:e,value:a}):t.nonFluids.push({isTransform:s,property:o,propertyType:e,value:a}),t}),{fluids:[],nonFluids:[]})}var Q={};["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noindex","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","small","source","span","strong","style","sub","summary","sup","table","template","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","svg","animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","switch","symbol","text","textPath","tspan","use","view"].forEach((function(e){Q[e]=$(e)}));var ee=function(){function e(e,t){var n=this;this._subscriptions=new Map,this._subscribe=function(e,t,i){var r,o,a=function(i){if(i.property===t)return n._subscriptions.set(i,e),{value:function(){return n._subscriptions.delete(i)}}};try{for(var s=f(n._subscriptions.keys()),u=s.next();!u.done;u=s.next()){var l=a(u.value);if("object"==typeof l)return l.value}}catch(e){r={error:e}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}return n._subscriptions.set({uuid:i,property:t},e),function(){return n._subscriptions.delete({uuid:i,property:t})}},this._value=e,this._currentValue={current:e},this._config=t,this.get=function(){return n._currentValue.current}}return e.prototype.setValue=function(e,t,n){var i,r,o=this;if("function"!=typeof e)try{for(var a=f(this._subscriptions.keys()),s=a.next();!s.done;s=a.next()){var u=s.value,l=this._subscriptions.get(u);l&&l(e,t,n)}}catch(e){i={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}else e((function(e,i){var r=new Promise((function(r){var a,s;try{for(var u=f(o._subscriptions.keys()),l=u.next();!l.done;l=u.next()){var c=l.value,h=o._subscriptions.get(c);h&&h(e,null!=i?i:t,(function(t){t.finished&&r(e),n&&n(t)}))}}catch(e){a={error:e}}finally{try{l&&!l.done&&(s=u.return)&&s.call(u)}finally{if(a)throw a.error}}}));return r}))},e}(),te=function(t,n){var i=e.useMemo((function(){return new ee(t,n)}),[]),r=e.useCallback((function(e,t,n){i.setValue(e,t,n)}),[]);return[i,r]};var ne=$("div"),ie=$("span"),re=$("img");function oe(t,n){var i=function(t,n){var i=u(e.useState(!1),2),r=i[0],o=i[1],a=e.useRef(n).current,s=a.from,f=a.enter,l=a.exit,c=a.config,h=a.enterConfig,d=a.exitConfig,p=u(te(s,c),2),m=p[0],v=p[1];return e.useLayoutEffect((function(){t?(o(!0),queueMicrotask((function(){return v(f,h)}))):v(l,d,(function(e){e.finished&&o(!1)}))}),[t]),function(e){return e(m,r)}}(t,n);return function(e){return i((function(t,n){return e({value:t},n)}))}}var ae=function(e){switch(e){case"elastic":return{mass:1,friction:18,tension:250};case"stiff":return{mass:1,friction:18,tension:350};case"wooble":return{mass:1,friction:8,tension:250};case"bounce":return{duration:500,easing:I.bounce};case"power1":return{duration:500,easing:I.bezier(.17,.42,.51,.97)};case"power2":return{duration:500,easing:I.bezier(.07,.11,.13,1)};case"power3":return{duration:500,easing:I.bezier(.09,.7,.16,1.04)};case"power4":return{duration:500,easing:I.bezier(.05,.54,0,1.03)};case"linear":return{duration:500,easing:I.linear};case"easein":return{duration:500,easing:I.in(I.ease)};case"easeout":return{duration:500,easing:I.out(I.ease)};case"easeinout":return{duration:500,easing:I.inOut(I.ease)};default:return{mass:1,friction:34,tension:290}}},se={ELASTIC:ae("elastic"),BOUNCE:ae("bounce"),EASE:ae("ease"),STIFF:ae("stiff"),WOOBLE:ae("wooble"),EASE_IN:ae("easein"),EASE_OUT:ae("easeout"),EASE_IN_OUT:ae("easeinout"),POWER1:ae("power1"),POWER2:ae("power2"),POWER3:ae("power3"),POWER4:ae("power4"),LINEAR:ae("linear")};function fe(e,t){var n=u(te(e,a(a({},se.EASE),t)),2),i=n[0],r=n[1],o={value:i,currentValue:i.get()};return new Proxy(o,{set:function(e,t,n){if("value"===t)return"number"!=typeof n&&"string"!=typeof n||r(n),!0;throw new Error("You cannot set any other property to animation node.")},get:function(e,t){if("value"===t)return i;if("currentValue"===t)return i.get();throw new Error("You cannot access any other property from animation node.")}})}function ue(e){return e?1:0}function le(e,t,n){return Math.min(Math.max(e,t),n)}function ce(e,t,n){return 0===t||Math.abs(t)===1/0?function(e,t){return Math.pow(e,5*t)}(e,n):e*t*n/(t+n*e)}function he(e,t){var n=new Map;return t.forEach((function(t){var i=u(t,3),r=i[0],o=i[1],a=i[2],s=void 0!==a&&a;n.set(r,function(e,t,n,i){return void 0===i&&(i=!1),e.forEach((function(e){e.addEventListener(t,n,i)})),function(){e.forEach((function(e){e.removeEventListener(t,n,i)}))}}(e,r,o,s))})),function(e){var t,i;try{for(var r=f(n.entries()),o=r.next();!o.done;o=r.next()){var a=u(o.value,2),s=a[0],l=a[1];if(!e)return void l();-1!==e.indexOf(s)&&l()}}catch(e){t={error:e}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}}}var de=function(e,t){return{x:e,y:t}},pe=function(){function e(){this.lastTimeStamp=Date.now(),this.isActive=!1,this.targetElements=[]}return e.prototype._initEvents=function(){},e.prototype._cancelEvents=function(){this._subscribe&&this._subscribe()},e.prototype.applyCallback=function(e){this.callback=e},e.prototype.applyGesture=function(e){var t=this,n=e.targetElement,i=e.targetElements,r=e.callback,o=e.config;return this.targetElement=n,this.targetElements=i.map((function(e){return e.current})),this.callback=r,this.config=o,this._initEvents(),function(){return t._subscribe&&t._subscribe()}},e._VELOCITY_LIMIT=20,e}(),me=function(e){function t(){var t=e.apply(this,l([],u(arguments),!1))||this;return t.movementStart=de(0,0),t.initialMovement=de(0,0),t.movement=de(0,0),t.previousMovement=de(0,0),t.translation=de(0,0),t.offset=de(0,0),t.velocity=de(0,0),t}return o(t,e),t.prototype._initEvents=function(){(this.targetElement||this.targetElements.length>0)&&(this._subscribe=he([window],[["mousedown",this.pointerDown.bind(this)],["mousemove",this.pointerMove.bind(this)],["mouseup",this.pointerUp.bind(this)],["touchstart",this.pointerDown.bind(this),{passive:!1}],["touchmove",this.pointerMove.bind(this),{passive:!1}],["touchend",this.pointerUp.bind(this)]]))},t.prototype._cancelEvents=function(){this._subscribe&&this._subscribe(["mousedown","mousemove","touchstart","touchmove"])},t.prototype._handleCallback=function(){var e=this;this.callback&&this.callback({args:[this.currentIndex],down:this.isActive,movementX:this.movement.x,movementY:this.movement.y,offsetX:this.translation.x,offsetY:this.translation.y,velocityX:this.velocity.x,velocityY:this.velocity.y,distanceX:Math.abs(this.movement.x),distanceY:Math.abs(this.movement.y),directionX:Math.sign(this.movement.x),directionY:Math.sign(this.movement.y),cancel:function(){e._cancelEvents()}})},t.prototype.pointerDown=function(e){var t;"touchstart"===e.type?this.movementStart={x:e.touches[0].clientX,y:e.touches[0].clientY}:this.movementStart={x:e.clientX,y:e.clientY},this.movement={x:0,y:0},this.offset={x:this.translation.x,y:this.translation.y},this.previousMovement={x:0,y:0},this.velocity={x:0,y:0};var n=this.targetElements.find((function(t){return t===e.target}));if(e.target===this.targetElement||n){this.isActive=!0,e.preventDefault(),n&&(this.currentIndex=this.targetElements.indexOf(n));var i=(null===(t=this.config)||void 0===t?void 0:t.initial)&&this.config.initial(),r=null==i?void 0:i.movementX,o=null==i?void 0:i.movementY;this.initialMovement={x:null!=r?r:0,y:null!=o?o:0},this.movement={x:this.initialMovement.x,y:this.initialMovement.y},this.previousMovement={x:this.initialMovement.x,y:this.initialMovement.y},this._handleCallback()}},t.prototype.pointerMove=function(e){if(this.isActive){e.preventDefault();var t=Date.now(),n=le(t-this.lastTimeStamp,.1,64);this.lastTimeStamp=t;var i=n/1e3;"touchmove"===e.type?this.movement={x:this.initialMovement.x+(e.touches[0].clientX-this.movementStart.x),y:this.initialMovement.y+(e.touches[0].clientY-this.movementStart.y)}:this.movement={x:this.initialMovement.x+(e.clientX-this.movementStart.x),y:this.initialMovement.y+(e.clientY-this.movementStart.y)},this.translation={x:this.offset.x+this.movement.x,y:this.offset.y+this.movement.y},this.velocity={x:le((this.movement.x-this.previousMovement.x)/i/1e3,-1*pe._VELOCITY_LIMIT,pe._VELOCITY_LIMIT),y:le((this.movement.y-this.previousMovement.y)/i/1e3,-1*pe._VELOCITY_LIMIT,pe._VELOCITY_LIMIT)},this.previousMovement={x:this.movement.x,y:this.movement.y},this._handleCallback()}},t.prototype.pointerUp=function(){this.isActive&&(this.isActive=!1,this._handleCallback(),this._cancelEvents(),this._initEvents())},t}(pe),ve=function(e){function t(){var t=e.apply(this,l([],u(arguments),!1))||this;return t.movement=de(0,0),t.previousMovement=de(0,0),t.velocity=de(0,0),t.direction=de(0,0),t}return o(t,e),t.prototype._initEvents=function(){this.targetElement?this._subscribe=he([this.targetElement],[["mousemove",this.onMouseMove.bind(this)]]):this.targetElements.length>0?this._subscribe=he(this.targetElements,[["mousemove",this.onMouseMove.bind(this)]]):this._subscribe=he([window],[["mousemove",this.onMouseMove.bind(this)]])},t.prototype._handleCallback=function(){var e;this.callback&&this.callback({args:[this.currentIndex],event:this.event,isMoving:this.isActive,target:null===(e=this.event)||void 0===e?void 0:e.target,mouseX:this.movement.x,mouseY:this.movement.y,velocityX:this.velocity.x,velocityY:this.velocity.y,directionX:this.direction.x,directionY:this.direction.y})},t.prototype.onMouseMove=function(e){var t=this,n=this.targetElements.find((function(t){return t===e.target}));n&&(this.currentIndex=this.targetElements.indexOf(n)),this.event=e;var i=Date.now(),r=Math.min(i-this.lastTimeStamp,64);this.lastTimeStamp=i;var o=r/1e3,a=e.clientX,s=e.clientY;this.movement={x:a,y:s},-1!==this.isActiveID&&(this.isActive=!0,clearTimeout(this.isActiveID)),this.isActiveID=setTimeout((function(){t.isActive=!1,t.direction={x:0,y:0},t.velocity={x:0,y:0},t._handleCallback()}),250);var f=this.movement.x-this.previousMovement.x,u=this.movement.y-this.previousMovement.y;this.direction={x:Math.sign(f),y:Math.sign(u)},this.velocity={x:le(f/o/1e3,-1*pe._VELOCITY_LIMIT,pe._VELOCITY_LIMIT),y:le(u/o/1e3,-1*pe._VELOCITY_LIMIT,pe._VELOCITY_LIMIT)},this.previousMovement={x:this.movement.x,y:this.movement.y},this._handleCallback()},t}(pe),ye=function(e){function t(){var t=e.apply(this,l([],u(arguments),!1))||this;return t.movement=de(0,0),t.previousMovement=de(0,0),t.direction=de(0,0),t.velocity=de(0,0),t}return o(t,e),t.prototype._initEvents=function(){this.targetElement?this._subscribe=he([this.targetElement],[["scroll",this.scrollElementListener.bind(this)]]):this._subscribe=he([window],[["scroll",this.scrollListener.bind(this)]])},t.prototype._handleCallback=function(){this.callback&&this.callback({isScrolling:this.isActive,scrollX:this.movement.x,scrollY:this.movement.y,velocityX:this.velocity.x,velocityY:this.velocity.y,directionX:this.direction.x,directionY:this.direction.y})},t.prototype.onScroll=function(e){var t=this,n=e.x,i=e.y,r=Date.now(),o=Math.min(r-this.lastTimeStamp,64);this.lastTimeStamp=r;var a=o/1e3;this.movement={x:n,y:i},-1!==this.isActiveID&&(this.isActive=!0,clearTimeout(this.isActiveID)),this.isActiveID=setTimeout((function(){t.isActive=!1,t.direction={x:0,y:0},t.velocity={x:0,y:0},t._handleCallback()}),250);var s=this.movement.x-this.previousMovement.x,f=this.movement.y-this.previousMovement.y;this.direction={x:Math.sign(s),y:Math.sign(f)},this.velocity={x:le(s/a/1e3,-1*pe._VELOCITY_LIMIT,pe._VELOCITY_LIMIT),y:le(f/a/1e3,-1*pe._VELOCITY_LIMIT,pe._VELOCITY_LIMIT)},this.previousMovement={x:this.movement.x,y:this.movement.y},this._handleCallback()},t.prototype.scrollListener=function(){var e=window.pageYOffset,t=window.pageXOffset;this.onScroll({x:t,y:e})},t.prototype.scrollElementListener=function(){var e,t,n=(null===(e=this.targetElement)||void 0===e?void 0:e.scrollLeft)||0,i=(null===(t=this.targetElement)||void 0===t?void 0:t.scrollTop)||0;this.onScroll({x:n,y:i})},t}(pe),ge=function(e){function t(){var t=e.apply(this,l([],u(arguments),!1))||this;return t.movement=de(0,0),t.previousMovement=de(0,0),t.direction=de(0,0),t.velocity=de(0,0),t.delta=de(0,0),t.offset=de(0,0),t.translation=de(0,0),t}return o(t,e),t.prototype._initEvents=function(){this.targetElement&&(this._subscribe=he([this.targetElement],[["wheel",this.onWheel.bind(this)]]))},t.prototype._handleCallback=function(){this.callback&&this.callback({target:this.targetElement,isWheeling:this.isActive,deltaX:this.delta.x,deltaY:this.delta.y,directionX:this.direction.x,directionY:this.direction.y,movementX:this.movement.x,movementY:this.movement.y,offsetX:this.offset.x,offsetY:this.offset.y,velocityX:this.velocity.x,velocityY:this.velocity.y})},t.prototype.onWheel=function(e){var t=this,n=e.deltaX,i=e.deltaY,r=e.deltaMode,o=Date.now(),a=Math.min(o-this.lastTimeStamp,64);this.lastTimeStamp=o;var s=a/1e3;this.isActive=!0,-1!==this.isActiveID&&(this.isActive=!0,clearTimeout(this.isActiveID)),this.isActiveID=setTimeout((function(){t.isActive=!1,t.translation={x:t.offset.x,y:t.offset.y},t._handleCallback(),t.velocity={x:0,y:0},t.movement={x:0,y:0}}),200),1===r?(n*=40,i*=40):2===r&&(n*=800,i*=800),this.delta={x:n,y:i},this.movement={x:this.movement.x+n,y:this.movement.y+i},this.offset={x:this.translation.x+this.movement.x,y:this.translation.y+this.movement.y};var f=this.movement.x-this.previousMovement.x,u=this.movement.y-this.previousMovement.y;this.direction={x:Math.sign(f),y:Math.sign(u)},this.velocity={x:le(f/s/1e3,-1*pe._VELOCITY_LIMIT,pe._VELOCITY_LIMIT),y:le(u/s/1e3,-1*pe._VELOCITY_LIMIT,pe._VELOCITY_LIMIT)},this.previousMovement={x:this.movement.x,y:this.movement.y},this._handleCallback()},t}(pe),be=function(e){var t=i.useRef(),n=i.useRef([]),r=i.useRef(new Map).current;return i.useEffect((function(){var t,n;try{for(var i=f(r.entries()),o=i.next();!o.done;o=i.next()){var a=u(o.value,2)[1],s=a.keyIndex,l=a.gesture,c=u(e[s],3)[2];l.applyCallback(c)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}}),[e]),i.useEffect((function(){return e.forEach((function(e,i){var o=u(e,4),a=o[0],s=o[1],f=o[2],l=o[3];r.set(a,{keyIndex:i,gesture:s,unsubscribe:s.applyGesture({targetElement:t.current,targetElements:n.current,callback:f,config:l})})})),function(){var e,t;try{for(var n=f(r.entries()),i=n.next();!i.done;i=n.next()){var o=u(i.value,2)[1].unsubscribe;o&&o()}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}}}),[]),function(e){return null==e?{ref:t}:(n.current[e]=n.current[e]||i.createRef(),{ref:n.current[e]})}};exports.AnimatedBlock=ne,exports.AnimatedImage=re,exports.AnimatedInline=ie,exports.AnimationConfigUtils=se,exports.Easing=I,exports.MountedBlock=function(e){var n=e.state,i=e.children,r=e.from,o=void 0===r?0:r,a=e.enter,s=void 0===a?1:a,f=e.exit,u=oe(n,{from:o,enter:s,exit:void 0===f?0:f,config:e.config,enterConfig:e.enterConfig,exitConfig:e.exitConfig});return t.jsx(t.Fragment,{children:u((function(e,t){return t&&i(e)}))})},exports.ScrollableBlock=function(e){var n=e.children,r=e.direction,o=void 0===r?"single":r,a=e.animationConfig,s=e.threshold,f=void 0===s?.2:s,l=i.useRef(null),c=fe(0,a);return i.useEffect((function(){var e=l.current,t=new IntersectionObserver((function(e){u(e,1)[0].isIntersecting?c.value=1:"both"===o&&(c.value=0)}),{root:null,threshold:f});return e&&t.observe(e),function(){e&&t.unobserve(e)}}),[]),t.jsx("div",{ref:l,children:n&&n({value:c.value})})},exports.TransitionBlock=function(e){var n=e.state,i=e.children,r=e.config,o=fe(ue(n),r);return t.jsx(t.Fragment,{children:i({value:o.value})})},exports.bInterpolate=function(e,t,n,i){if(!R(e)||"number"!=typeof e||!D(e))throw new Error("Invalid ".concat(e," type for interpolate function. Expected number or FluidValue."));return G(e,[0,1],[t,n],i)},exports.bin=ue,exports.clamp=le,exports.delay=function(e){return new Promise((function(t){setTimeout((function(){return t(null)}),e)}))},exports.fluid=Q,exports.interpolate=function(e,t,n,i){if(!R(e)||"number"!=typeof e||!D(e))throw new Error("Invalid ".concat(e," type for interpolate function. Expected number or FluidValue."));return G(e,t,n,i)},exports.makeFluid=$,exports.mix=function(e,t,n){return t*(1-e)+n*e},exports.move=function(e,t,n){var i=e[t],r=e.length,o=t-n;if(o>0)return l(l(l(l([],u(e.slice(0,n)),!1),[i],!1),u(e.slice(n,t)),!1),u(e.slice(t+1,r)),!1);if(o<0){var a=n+1;return l(l(l(l([],u(e.slice(0,t)),!1),u(e.slice(t+1,a)),!1),[i],!1),u(e.slice(a,r)),!1)}return e},exports.rubberClamp=function(e,t,n,i){return void 0===i&&(i=.15),0===i?le(e,t,n):e<t?-ce(t-e,n-t,i)+t:e>n?+ce(e-n,n-t,i)+n:e},exports.snapTo=function(e,t,n){var i=e+.2*t,r=function(e){return Math.abs(e-i)},o=n.map(r),a=Math.min.apply(Math,l([],u(o),!1));return n.reduce((function(e,t){return r(t)===a?t:e}))},exports.useAnimatedValue=fe,exports.useDrag=function(e,t){var n=i.useRef(new me).current;return be([["drag",n,e,t]])},exports.useGesture=function(e){var t=e.onDrag,n=e.onWheel,r=e.onScroll,o=e.onMouseMove,a=i.useRef(new me).current,s=i.useRef(new ge).current,f=i.useRef(new ye).current,u=i.useRef(new ve).current;return be([["drag",a,t],["wheel",s,n],["scroll",f,r],["move",u,o]])},exports.useMeasure=function(t,n){var i=e.useRef(null),r=e.useRef([]),o=e.useRef(t);return e.useEffect((function(){return o.current=t,function(){o.current=function(){return!1}}}),n),e.useEffect((function(){var e=i.current||document.documentElement,t=r.current,n=new ResizeObserver((function(t){var n=u(t,1)[0].target.getBoundingClientRect(),i=n.left,r=n.top,a=n.width,s=n.height,f=window.pageXOffset,l=window.pageYOffset;if(o){if(e===document.documentElement)return;o.current({left:i+f,top:r+l,width:a,height:s,vLeft:i,vTop:r})}})),a=new ResizeObserver((function(e){var t=[],n=[],i=[],r=[],a=[],s=[];e.forEach((function(e){var o=e.target.getBoundingClientRect(),f=o.left,u=o.top,l=o.width,c=o.height,h=f+window.pageXOffset,d=u+window.pageYOffset;t.push(h),n.push(d),i.push(l),r.push(c),a.push(f),s.push(u)})),o&&o.current({left:t,top:n,width:i,height:r,vLeft:a,vTop:s})}));return e&&(e===document.documentElement&&t.length>0?t.forEach((function(e){a.observe(e.current)})):n.observe(e)),function(){e&&(e===document.documentElement&&t.length>0?t.forEach((function(e){a.unobserve(e.current)})):n.unobserve(e))}}),[]),function(t){return null==t?{ref:i}:(r.current[t]=r.current[t]||e.createRef(),{ref:r.current[t]})}},exports.useMountedValue=oe,exports.useMouseMove=function(e){var t=i.useRef(new ve).current;return be([["move",t,e]])},exports.useOutsideClick=function(t,n,i){var r=e.useRef();r.current||(r.current=n),e.useEffect((function(){return r.current=n,function(){r.current=function(){return!1}}}),i),e.useEffect((function(){var e=he([document],[["click",function(e){var n;(null===(n=null==t?void 0:t.current)||void 0===n?void 0:n.contains(e.target))||r.current&&r.current(e)}]]);return function(){return e&&e()}}),[])},exports.useScroll=function(e){var t=i.useRef(new ye).current;return be([["scroll",t,e]])},exports.useWheel=function(e){var t=i.useRef(new ge).current;return be([["wheel",t,e]])},exports.useWindowDimension=function(t,n){var i=e.useRef({width:0,height:0,innerWidth:0,innerHeight:0}),r=e.useRef(t);e.useEffect((function(){return r.current=t,function(){r.current=function(){return!1}}}),n),e.useEffect((function(){var e=new ResizeObserver((function(e){var t=u(e,1)[0].target,n=t.clientWidth,o=t.clientHeight,s=window.innerWidth,f=window.innerHeight;i.current={width:n,height:o,innerWidth:s,innerHeight:f},r&&r.current(a({},i.current))}));return e.observe(document.documentElement),function(){return e.unobserve(document.documentElement)}}),[])};
2898
2
  //# sourceMappingURL=index.js.map