Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

4.5.0

Julian Garnier34f417983c1d
diff --git a/dist/bundles/anime.esm.js b/dist/bundles/anime.esm.js
index 65e03b2c..3d9a4451 100644
--- a/dist/bundles/anime.esm.js
+++ b/dist/bundles/anime.esm.js
@@ -1,6 +1,6 @@
/**
* Anime.js - ESM bundle
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -39,6 +39,12 @@
/** @typedef {Timer&JSAnimation&Timeline} CallbackArgument */
/** @typedef {Animatable|Tickable|WAAPIAnimation|Draggable|ScrollObserver|TextSplitter|Scope|AutoLayout} Revertible */
+/**
+ * @typedef {Object} TweakRegister
+ * @property {String} type
+ * @property {*} defaultValue
+ */
+
// Stagger types
/**
@@ -58,11 +64,18 @@
* @property {Number|'first'|'center'|'last'|'random'|Array.<Number>} [from]
* @property {Boolean} [reversed]
* @property {Array.<Number>|Boolean} [grid]
- * @property {('x'|'y')} [axis]
- * @property {String|((target: Target, i: Number, length: Number) => Number)} [use]
+ * @property {('x'|'y'|'z')} [axis]
+ * @property {String | { method(target: Target, i: Number, length: Number): Number }['method']} [use]
* @property {Number} [total]
* @property {EasingParam} [ease]
* @property {TweenModifier} [modifier]
+ * @property {Number|[Number, Number]} [jitter] Additive uniform noise on the
+ * computed stagger value. Number form gives flat `+/-jitter`; tuple form
+ * ramps the magnitude `start -> end` across the from/axis/grid ordering
+ * and respects `ease`.
+ * @property {Boolean|Number} [seed] Seed for jitter draws and `from: 'random'`
+ * shuffling. `false` (default) uses Math.random. `true` seeds with `0`. A
+ * number is used directly as the seed.
*/
// Targets types
@@ -138,10 +151,7 @@
/**
* @template T
- * @callback Callback
- * @param {T} self - Returns itself
- * @param {PointerEvent} [e]
- * @return {*}
+ * @typedef {{ method(self: T): * }['method']} Callback
*/
/**
@@ -185,12 +195,17 @@
// Tween types
/**
+ * @typedef {Number|String|TweenKeyValue|EasingParam|Array.<Number|String|TweenKeyValue>} FunctionValueReturn
+ */
+
+/**
+ * @template [T=FunctionValueReturn]
* @callback FunctionValue
* @param {Target} [target] - The animated target
* @param {Number} [index] - The target index
* @param {TargetsArray} [targets] - The array of all animated targets
* @param {Tween|null} [prevTween] - The previous sibling tween for the same target and property
- * @return {Number|String|TweenObjectValue|EasingParam|Array.<Number|String|TweenObjectValue>}
+ * @return {T}
*/
/**
@@ -207,7 +222,7 @@
* @property {JSAnimation} parent
* @property {String} property
* @property {Target} target
- * @property {String|Number} _value
+ * @property {String|Number|Object} _value
* @property {Function|null} _toFunc
* @property {Function|null} _fromFunc
* @property {EasingFunction} _ease
@@ -226,7 +241,11 @@
* @property {Number} _startTime
* @property {Number} _changeDuration
* @property {Number} _absoluteStartTime
+ * @property {Number} _absoluteUpdateStartTime
+ * @property {Number} _absoluteEndTime
+ * @property {Number} _hasFromValue
* @property {tweenTypes} _tweenType
+ * @property {((target: any, value: number, tween: Tween) => void) | null} _setter
* @property {valueTypes} _valueType
* @property {Number} _composition
* @property {Number} _isOverlapped
@@ -247,8 +266,8 @@
* @property {Number} n - Single number value
* @property {String} u - Value unit
* @property {String} o - Value operator
- * @property {Array.<Number>} d - Array of Numbers (in case of complex value type)
- * @property {Array.<String>} s - Strings (in case of complex value type)
+ * @property {Array.<Number>} d - Array of Numbers (complex / color value type)
+ * @property {Array.<String>} s - Strings (complex value type)
*/
/** @typedef {{_head: null|Tween, _tail: null|Tween}} TweenPropertySiblings */
@@ -259,7 +278,7 @@
// JSAnimation types
/**
- * @typedef {Number|String|FunctionValue|EasingParam} TweenParamValue
+ * @typedef {Number|String|FunctionValue|EasingParam|TweakRegister} TweenParamValue
*/
/**
@@ -452,7 +471,7 @@
*/
/**
- * @typedef {Record<String, TweenParamValue | EasingParam | TweenModifier | TweenComposition | AnimatablePropertyParamsOptions> & AnimatablePropertyParamsOptions} AnimatableParams
+ * @typedef {Record<String, TweenParamValue | EasingParam | TweenModifier | TweenComposition | AnimatablePropertyParamsOptions | Callback<JSAnimation>> & AnimatablePropertyParamsOptions & TickableCallbacks<JSAnimation> & RenderableCallbacks<JSAnimation>} AnimatableParams
*/
// Scope types
@@ -495,7 +514,7 @@
/**
* @callback ScopeMethod
* @param {...*} args
- * @return {ScopeCleanupCallback|void}
+ * @return {*}
*/
// Scroll types
@@ -725,6 +744,11 @@ const maxFps = 240;
const emptyString = '';
const cssVarPrefix = 'var(';
+// Arrays
+
+// Shared sentinel for tween slots that don't hold array data. Never mutated, only read; COMPLEX and COLOR tweens always replace the slot before writing.
+const emptyArray = [];
+
const shortTransforms = /*#__PURE__*/ (() => {
const map = new Map();
map.set('x', 'translateX');
@@ -758,6 +782,13 @@ const transformsFragmentStrings = /*#__PURE__*/ validTransforms.reduce((a, v) =>
/** @return {void} */
const noop = () => {};
+/**
+ * @template T
+ * @param {T} v
+ * @return {T}
+ */
+const noopModifier = v => v;
+
// Regex
const validRgbHslRgx = /\)\s*[-.\d]/;
@@ -779,10 +810,13 @@ const cssVariableMatchRgx = /var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/;
/**
* @typedef {Object} EditorGlobals
* @property {boolean} showPanel
- * @property {boolean} synced
* @property {Function} addAnimation
+ * @property {Function} addSet
* @property {Function} addTimeline
* @property {Function} addTimelineChild
+ * @property {Function} addTimelineLabel
+ * @property {Function} addTimelineCall
+ * @property {Function} addTimelineSync
* @property {Function} resolveStagger
* @property {Object|null} _head
* @property {Object|null} _tail
@@ -805,7 +839,7 @@ const defaults = {
loopDelay: 0,
ease: 'out(2)',
composition: compositionTypes.replace,
- modifier: v => v,
+ modifier: noopModifier,
onBegin: noop,
onBeforeUpdate: noop,
onUpdate: noop,
@@ -835,7 +869,7 @@ const globals = {
editor: null,
};
-const globalVersions = { version: '4.4.1', engine: null };
+const globalVersions = { version: '4.5.0', engine: null };
if (isBrowser) {
if (!win.AnimeJS) win.AnimeJS = [];
@@ -982,7 +1016,7 @@ const snap$1 = (v, increment) => isArr(increment) ? increment.reduce((closest, c
* @param {Number} factor - Interpolation factor in the range [0, 1]
* @return {Number} The interpolated value
*/
-const lerp$1 = (start, end, factor) => start + (end - start) * factor;
+const lerp$1 = (start, end, factor) => factor === 1 ? end : factor === 0 ? start : start + (end - start) * factor;
/**
* Replaces infinity with maximum safe value
@@ -1231,6 +1265,61 @@ const buildTransformString = (props) => {
return str;
};
+/**
+ * Anime.js adapter API. Each library or class group that wants to extend `animate()` and `utils.set()` calls `registerAdapter()` to create its own `Adapter`. The returned `Adapter` exposes `registerTargetAdapter(detect)` for per-class detection and `registerPropertyResolver(fn)` for global Color / Vector / pattern-based fallbacks.
+ *
+ * import { registerAdapter } from 'animejs/adapters';
+ *
+ * const myAdapter = registerAdapter();
+ * const widget = myAdapter.registerTargetAdapter((t) => t instanceof MyWidget);
+ * widget.registerProperty('value',
+ * (t) => t.getValue(),
+ * (target, value) => target.setValue(value),
+ * );
+ *
+ * For scalar tweens, `value` is the interpolated number. For color and complex tweens it is `undefined`; read `tween._numbers` instead. `gate(target)` scopes the prop to a subset of matching targets.
+ *
+ * Resolution order: every Adapter's target adapters in registration order (first match wins) then every Adapter's property resolvers (first non-null wins) then engine direct property path.
+ */
+
+
+const adapters = /** @type {Adapter[]} */([]);
+
+/**
+ * Internal resolution. Tries every Adapter's target adapters first (in registration order, first match wins), then every Adapter's property resolvers.
+ *
+ * @param {any} target
+ * @param {string} name
+ * @return {TargetAdapterEntry | null}
+ */
+function resolveAdapterEntry(target, name) {
+ if (!target) return null;
+ const al = adapters.length;
+ outer: for (let i = 0; i < al; i++) {
+ const a = adapters[i];
+ if (a.detect && !a.detect(target)) continue;
+ const tas = a.targetAdapters;
+ for (let j = 0, m = tas.length; j < m; j++) {
+ const ta = tas[j];
+ if (ta.detect(target)) {
+ const entry = ta.props[name];
+ if (entry && (!entry.gate || entry.gate(target))) return entry;
+ break outer;
+ }
+ }
+ }
+ for (let i = 0; i < al; i++) {
+ const a = adapters[i];
+ if (a.detect && !a.detect(target)) continue;
+ const rs = a.propertyResolvers;
+ for (let j = 0, m = rs.length; j < m; j++) {
+ const entry = rs[j](target, name);
+ if (entry) return entry;
+ }
+ }
+ return null;
+}
+
/**
@@ -1328,6 +1417,21 @@ const setValue = (targetValue, defaultValue) => {
return isUnd(targetValue) ? defaultValue : targetValue;
};
+/**
+ * Resolve against the target when it's a DOM element, otherwise fall back to :root so non-DOM targets like three.js meshes and custom adapters still pick up CSS variables defined on the document.
+ *
+ * @param {String} value
+ * @param {Target} target
+ * @return {String|Number}
+ */
+const resolveCssVar = (value, target) => {
+ const match = value.match(cssVariableMatchRgx);
+ const el = target[isDomSymbol] ? target : document.documentElement;
+ let computed = getComputedStyle(/** @type {HTMLElement} */(el))?.getPropertyValue(match[1]);
+ if ((!computed || computed.trim() === emptyString) && match[2]) computed = match[2].trim();
+ return computed || 0;
+};
+
/**
* @param {TweenPropValue} value
* @param {Target} target
@@ -1338,30 +1442,26 @@ const setValue = (targetValue, defaultValue) => {
* @return {any}
*/
const getFunctionValue = (value, target, index, targets, store, prevTween) => {
- let func;
if (isFnc(value)) {
- func = () => {
+ if (!store) {
+ const computed = /** @type {Function} */(value)(target, index, targets, prevTween);
+ // Fallback to 0 if the function returns undefined, NaN, null, false or 0
+ return !isNaN(+computed) ? +computed : computed || 0;
+ }
+ const func = () => {
const computed = /** @type {Function} */(value)(target, index, targets, prevTween);
- // Fallback to 0 if the function returns undefined / NaN / null / false / 0
return !isNaN(+computed) ? +computed : computed || 0;
};
- } else if (isStr(value) && stringStartsWith(value, cssVarPrefix)) {
- func = () => {
- const match = value.match(cssVariableMatchRgx);
- const cssVarName = match[1];
- const fallbackValue = match[2];
- let computed = getComputedStyle(/** @type {HTMLElement} */(target))?.getPropertyValue(cssVarName);
- // Use fallback if CSS variable is not set or empty
- if ((!computed || computed.trim() === emptyString) && fallbackValue) {
- computed = fallbackValue.trim();
- }
- return computed || 0;
- };
- } else {
- return value;
+ store.func = func;
+ return func();
}
- if (store) store.func = func;
- return func();
+ if (isStr(value) && stringStartsWith(value, cssVarPrefix)) {
+ if (!store) return resolveCssVar(/** @type {String} */(value), target);
+ const func = () => resolveCssVar(/** @type {String} */(value), target);
+ store.func = func;
+ return func();
+ }
+ return value;
};
/**
@@ -1408,6 +1508,12 @@ const getCSSValue = (target, propName, animationInlineStyles) => {
*/
const getOriginalAnimatableValue = (target, propName, tweenType, animationInlineStyles) => {
const type = !isUnd(tweenType) ? tweenType : getTweenType(target, propName);
+ const adapterProp = resolveAdapterEntry(target, propName);
+ if (adapterProp) {
+ const value = adapterProp.get(target);
+ if (value && animationInlineStyles) animationInlineStyles[propName] = value;
+ return value == null ? 0 : value;
+ }
if (type === tweenTypes.OBJECT) {
const value = target[propName];
if (value && animationInlineStyles) animationInlineStyles[propName] = value;
@@ -1449,7 +1555,7 @@ const createDecomposedValueTargetObject = () => {
};
/**
- * @param {String|Number} rawValue
+ * @param {String|Number|Object} rawValue
* @param {TweenDecomposedValue} targetObject
* @return {TweenDecomposedValue}
*/
@@ -1467,39 +1573,38 @@ const decomposeRawValue = (rawValue, targetObject) => {
// It's a number
targetObject.n = num;
return targetObject;
+ }
+ // let str = /** @type {String} */(rawValue).trim();
+ let str = /** @type {String} */(rawValue);
+ // Parsing operators (+=, -=, *=) manually is much faster than using regex here
+ if (str[1] === '=') {
+ targetObject.o = str[0];
+ str = str.slice(2);
+ }
+ // Skip exec regex if the value type is complex or color to avoid long regex backtracking
+ const unitMatch = str.includes(' ') ? false : unitsExecRgx.exec(str);
+ if (unitMatch) {
+ // Has a number and a unit
+ targetObject.t = valueTypes.UNIT;
+ targetObject.n = +unitMatch[1];
+ targetObject.u = unitMatch[2];
+ return targetObject;
+ } else if (targetObject.o) {
+ // Has an operator (+=, -=, *=)
+ targetObject.n = +str;
+ return targetObject;
+ } else if (isCol(str)) {
+ // Color string
+ targetObject.t = valueTypes.COLOR;
+ targetObject.d = convertColorStringValuesToRgbaArray(str);
+ return targetObject;
} else {
- // let str = /** @type {String} */(rawValue).trim();
- let str = /** @type {String} */(rawValue);
- // Parsing operators (+=, -=, *=) manually is much faster than using regex here
- if (str[1] === '=') {
- targetObject.o = str[0];
- str = str.slice(2);
- }
- // Skip exec regex if the value type is complex or color to avoid long regex backtracking
- const unitMatch = str.includes(' ') ? false : unitsExecRgx.exec(str);
- if (unitMatch) {
- // Has a number and a unit
- targetObject.t = valueTypes.UNIT;
- targetObject.n = +unitMatch[1];
- targetObject.u = unitMatch[2];
- return targetObject;
- } else if (targetObject.o) {
- // Has an operator (+=, -=, *=)
- targetObject.n = +str;
- return targetObject;
- } else if (isCol(str)) {
- // Is a color
- targetObject.t = valueTypes.COLOR;
- targetObject.d = convertColorStringValuesToRgbaArray(str);
- return targetObject;
- } else {
- // Is a more complex string (generally svg coords, calc() or filters CSS values)
- const matchedNumbers = str.match(digitWithExponentRgx);
- targetObject.t = valueTypes.COMPLEX;
- targetObject.d = matchedNumbers ? matchedNumbers.map(Number) : [];
- targetObject.s = str.split(digitWithExponentRgx) || [];
- return targetObject;
- }
+ // Is a more complex string (generally svg coords, calc() or filters CSS values)
+ const matchedNumbers = str.match(digitWithExponentRgx);
+ targetObject.t = valueTypes.COMPLEX;
+ targetObject.d = matchedNumbers ? matchedNumbers.map(Number) : [];
+ targetObject.s = str.split(digitWithExponentRgx) || [];
+ return targetObject;
}
};
@@ -1520,30 +1625,6 @@ const decomposeTweenValue = (tween, targetObject) => {
const decomposedOriginalValue = createDecomposedValueTargetObject();
-/**
- * @param {Tween} tween
- * @param {Number} progress
- * @param {Number} precision
- * @return {String}
- */
-const composeColorValue = (tween, progress, precision) => {
- const mod = tween._modifier;
- const fn = tween._fromNumbers;
- const tn = tween._toNumbers;
- const r = round$1(clamp$1(/** @type {Number} */(mod(lerp$1(fn[0], tn[0], progress))), 0, 255), 0);
- const g = round$1(clamp$1(/** @type {Number} */(mod(lerp$1(fn[1], tn[1], progress))), 0, 255), 0);
- const b = round$1(clamp$1(/** @type {Number} */(mod(lerp$1(fn[2], tn[2], progress))), 0, 255), 0);
- const a = clamp$1(/** @type {Number} */(mod(round$1(lerp$1(fn[3], tn[3], progress), precision))), 0, 1);
- if (tween._composition !== compositionTypes.none) {
- const ns = tween._numbers;
- ns[0] = r;
- ns[1] = g;
- ns[2] = b;
- ns[3] = a;
- }
- return `rgba(${r},${g},${b},${a})`;
-};
-
/**
* @param {Tween} tween
* @param {Number} progress
@@ -1555,15 +1636,14 @@ const composeComplexValue = (tween, progress, precision) => {
const fn = tween._fromNumbers;
const tn = tween._toNumbers;
const ts = tween._strings;
- const hasComposition = tween._composition !== compositionTypes.none;
let v = ts[0];
for (let j = 0, l = tn.length; j < l; j++) {
const n = /** @type {Number} */(mod(round$1(lerp$1(fn[j], tn[j], progress), precision)));
const s = ts[j + 1];
v += `${s ? n + s : n}`;
- if (hasComposition) {
- tween._numbers[j] = n;
- }
+ // Keep _numbers fresh for every tween, not only composed ones, so a non-composition setter that reads the lerped triplet such as three transformOrigin still animates.
+ // Potential optimization, skip the write when nothing reads it: if (hasComposition || tween._setter) tween._numbers[j] = n;
+ tween._numbers[j] = n;
}
return v;
};
@@ -1615,12 +1695,14 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
// Execute the "expensive" iterations calculations only when necessary
if (iterationCount > 1) {
// bitwise NOT operator seems to be generally faster than Math.floor() across browsers
- const currentIteration = ~~(tickableCurrentTime / (iterationDuration + (isCurrentTimeEqualOrAboveDuration ? 0 : _loopDelay)));
+ const period = iterationDuration + (isCurrentTimeEqualOrAboveDuration ? 0 : _loopDelay);
+ const currentIteration = ~~(tickableCurrentTime / period);
tickable._currentIteration = clamp$1(currentIteration, 0, iterationCount);
// Prevent the iteration count to go above the max iterations when reaching the end of the animation
if (isCurrentTimeEqualOrAboveDuration) tickable._currentIteration--;
isOdd = tickable._currentIteration % 2;
- iterationElapsedTime = tickableCurrentTime % (iterationDuration + _loopDelay) || 0;
+ // Derive elapsed from the same `~~` truncation that gave currentIteration. Using `% period` here can disagree with `~~(/period)` under float drift at iteration boundaries and write the wrong end of the tween for one frame.
+ iterationElapsedTime = tickableCurrentTime - currentIteration * period || 0;
}
// Checks if exactly one of _reversed and (_alternate && isOdd) is true
@@ -1652,12 +1734,14 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
if (
forcedTick ||
tickMode === tickModes.AUTO && (
- time >= tickableDelay && time <= tickableEndTime || // Normal render
+ // Timeline children render from their offset instead of their delay so the gap left by a truncated sibling is covered on seek.
+ time >= (parent && tickableDelay > 0 ? 0 : tickableDelay) && time <= tickableEndTime || // Normal render
time <= tickableDelay && tickablePrevTime > tickableDelay || // Playhead is before the animation start time so make sure the animation is at its initial state
time >= tickableEndTime && tickablePrevTime !== duration // Playhead is after the animation end time so make sure the animation is at its end state
) ||
iterationTime >= tickableEndTime && tickablePrevTime !== duration ||
- iterationTime <= tickableDelay && tickablePrevTime > 0 ||
+ // iterationTime is per-iteration, compared to the delay to catch a backward seek into a looped iteration's delay region. Exclude the final settled end, where iterationTime clamps to duration and would falsely match the delay region when the delay exceeds the duration.
+ iterationTime <= tickableDelay && tickablePrevTime > 0 && !isCurrentTimeEqualOrAboveDuration ||
time <= tickablePrevTime && tickablePrevTime === duration && completed || // Force a render if a seek occurs on an completed animation
isCurrentTimeEqualOrAboveDuration && !completed && isSetter // This prevents 0 duration tickables to be skipped
) {
@@ -1673,7 +1757,8 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
// Time has jumped more than globals.tickThreshold so consider this tick manual
const forcedRender = forcedTick || (isRunningBackwards ? deltaTime * -1 : deltaTime) >= globals.tickThreshold;
- const absoluteTime = tickable._offset + (parent ? parent._offset : 0) + tickableDelay + iterationTime;
+ // Round to match the precision of tween._absoluteStartTime so equal-time boundary checks compare cleanly without floating point drift from the unrounded _offset.
+ const absoluteTime = round$1(tickable._offset + (parent ? parent._offset : 0) + tickableDelay + iterationTime, 12);
// Only Animation can have tweens, Timer returns undefined
let tween = /** @type {Tween} */(/** @type {JSAnimation} */(tickable)._head);
@@ -1692,15 +1777,38 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
const tweenNextRep = tween._nextRep;
const tweenPrevRep = tween._prevRep;
const tweenHasComposition = tweenComposition !== compositionTypes.none;
+ // The previous sibling stops writing at its truncated end, so this tween takes over the hold from that point.
+ const tweenPrevRepEndTime = tweenPrevRep ? tweenPrevRep._absoluteStartTime + tweenPrevRep._changeDuration : 0;
+ const tweenPrevRepIsCrossParent = tweenPrevRep && tweenPrevRep.parent !== tween.parent;
+ // Same parent keyframes take over at their own start, end plus delay equals the next start by construction.
+ // Cross parent siblings take over at their update start.
+ // Negative delay siblings take over at their own start instead.
+ const tweenNextRepTakeover = !tweenNextRep || tweenNextRep._isOverridden ? tweenAbsEndTime :
+ tweenNextRep.parent === tween.parent ? tweenAbsEndTime + tweenNextRep._delay :
+ tweenNextRep._absoluteStartTime < tweenNextRep._absoluteUpdateStartTime ? tweenNextRep._absoluteStartTime : tweenNextRep._absoluteUpdateStartTime;
if ((forcedRender || (
- (tweenCurrentTime !== tweenChangeDuration || absoluteTime <= tweenAbsEndTime + (tweenNextRep ? tweenNextRep._delay : 0)) &&
- (tweenCurrentTime !== 0 || absoluteTime >= tween._absoluteStartTime)
- )) && (!tweenHasComposition || (
+ // Tail keyframes always re-evaluate the gate so an earlier keyframe cannot leave the target stale by writing past its own range after a backward seek.
+ (tweenCurrentTime !== tweenChangeDuration || absoluteTime <= tweenNextRepTakeover ||
+ (tweenPrevRep && !tweenPrevRepIsCrossParent && (!tweenNextRep || tweenNextRep.parent !== tween.parent))) &&
+ // A cross parent tween re-renders its from value from the previous sibling truncated end so the handoff gap holds.
+ // A keyframe re-renders its from revert while the next keyframe time is stale so a backward jump over its range cannot leave the next value in place.
+ (tweenCurrentTime !== 0 || absoluteTime >= tween._absoluteStartTime ||
+ (tweenPrevRepIsCrossParent && !tween._hasFromValue && !tweenPrevRep._isOverridden && absoluteTime >= tweenPrevRepEndTime) ||
+ (tweenNextRep && !tweenNextRep._isOverridden && tweenNextRep.parent === tween.parent && tweenNextRep._currentTime !== 0 && iterationTime < tweenNextRep._startTime))
+ )) &&
+ // Non-first keyframes wait until the iteration reaches their own start before rendering, so the previous keyframe can handle the from-revert when scrubbed backward past this tween's range.
+ (!tweenPrevRep || tweenPrevRepIsCrossParent || iterationTime >= tween._startTime) &&
+ (!tweenHasComposition || (
!tween._isOverridden &&
(!tween._isOverlapped || absoluteTime <= tweenAbsEndTime) &&
- (!tweenNextRep || (tweenNextRep._isOverridden || absoluteTime <= tweenNextRep._absoluteStartTime)) &&
- (!tweenPrevRep || (tweenPrevRep._isOverridden || (absoluteTime >= (tweenPrevRep._absoluteStartTime + tweenPrevRep._changeDuration) + tween._delay)))
+ // The next sibling owns the value past its takeover point, so yielding there keeps writes single owner in both directions.
+ (!tweenNextRep || tweenNextRep._isOverridden || absoluteTime <= tweenNextRepTakeover) &&
+ // The previous sibling owns the value up to its truncated end.
+ // Cross parent tweens take over the hold from that point, explicit from values wait for their own start.
+ (!tweenPrevRep || (tweenPrevRep._isOverridden || (!tweenPrevRepIsCrossParent ?
+ absoluteTime >= tweenPrevRepEndTime + tween._delay :
+ absoluteTime >= tween._absoluteStartTime || (!tween._hasFromValue && absoluteTime >= tweenPrevRepEndTime))))
))
) {
@@ -1711,7 +1819,7 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
const tweenType = tween._tweenType;
const tweenIsObject = tweenType === tweenTypes.OBJECT;
const tweenIsNumber = tweenValueType === valueTypes.NUMBER;
- // Only round the in-between frames values if the final value is a string
+ // Only round the in-between frames values if the final value is a string. Object targets consume raw numbers, so rounding is dead work there.
const tweenPrecision = (tweenIsNumber && tweenIsObject) || tweenProgress === 0 || tweenProgress === 1 ? -1 : globals.precision;
// Recompose tween value
@@ -1727,7 +1835,22 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
number = /** @type {Number} */(tweenModifier(round$1(lerp$1(tween._fromNumber, tween._toNumber, tweenProgress), tweenPrecision)));
value = `${number}${tween._unit}`;
} else if (tweenValueType === valueTypes.COLOR) {
- value = composeColorValue(tween, tweenProgress, tweenPrecision);
+ const ns = tween._numbers;
+ const fn = tween._fromNumbers;
+ const tn = tween._toNumbers;
+ const omt = 1 - tweenProgress;
+ const fr = fn[0], fg = fn[1], fb = fn[2];
+ const tr = tn[0], tg = tn[1], tb = tn[2];
+ // RGB channels lerp in pseudo-linear space (square inputs, sqrt result) to approximate gamma-correct blending.
+ // See https://developer.nvidia.com/gpugems/gpugems3/part-iv-image-effects/chapter-24-importance-being-linear.
+ ns[0] = /** @type {Number} */(tweenModifier(Math.sqrt(fr * fr * omt + tr * tr * tweenProgress)));
+ ns[1] = /** @type {Number} */(tweenModifier(Math.sqrt(fg * fg * omt + tg * tg * tweenProgress)));
+ ns[2] = /** @type {Number} */(tweenModifier(Math.sqrt(fb * fb * omt + tb * tb * tweenProgress)));
+ ns[3] = /** @type {Number} */(tweenModifier(lerp$1(fn[3], tn[3], tweenProgress)));
+ // The rgba string is built only for the dispatch path or the internalRender composition tick (setters handles the color comp)
+ if (!tween._setter || internalRender) {
+ value = `rgba(${round$1(ns[0], 0)},${round$1(ns[1], 0)},${round$1(ns[2], 0)},${ns[3]})`;
+ }
} else if (tweenValueType === valueTypes.COMPLEX) {
value = composeComplexValue(tween, tweenProgress, tweenPrecision);
}
@@ -1742,7 +1865,9 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
const tweenProperty = tween.property;
tweenTarget = tween.target;
- if (tweenIsObject) {
+ if (tween._setter) {
+ tween._setter(tweenTarget, number, tween);
+ } else if (tweenIsObject) {
tweenTarget[tweenProperty] = value;
} else if (tweenType === tweenTypes.ATTRIBUTE) {
/** @type {DOMTarget} */(tweenTarget).setAttribute(tweenProperty, /** @type {String} */(value));
@@ -1770,6 +1895,9 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
tween._value = value;
}
+ } else if (tweenCurrentTime && tweenPrevRep && !tweenPrevRepIsCrossParent && iterationTime < tween._startTime) {
+ // Mark the keyframe as reverted when the playhead moves before its start, the previous keyframe owns the from revert and writes it once.
+ tween._currentTime = 0;
}
if (tweenTransformsNeedUpdate && tween._renderTransforms) {
@@ -1877,6 +2005,8 @@ const tick = (tickable, time, muteCallbacks, internalRender, tickMode) => {
forEachChildren(tl, (/** @type {JSAnimation} */child) => {
const childTime = round$1((tlChildrenTime - child._offset) * child._speed, 12); // Rounding is needed when using seconds
+ // Skip past-end siblings on backward iteration so their progress=1 to-values don't render last and overwrite the active sibling's write. Compare against _delay + duration so children with a normalized delay are not skipped while still inside their active range.
+ if (tlIsRunningBackwards && childTime > child._delay + child.duration) return;
const childTickMode = child._fps < tl._fps ? child.requestTick(tlCildrenTickTime) : tickMode;
tlChildrenHasRendered += render(child, childTime, muteCallbacks, internalRender, childTickMode);
if (!child.completed && tlChildrenHaveCompleted) tlChildrenHaveCompleted = false;
@@ -1953,7 +2083,20 @@ const revertValues = (renderable, inlineStylesOnly = false) => {
const tweenType = tween._tweenType;
const originalInlinedValue = tween._inlineValue;
const tweenHadNoInlineValue = isNil(originalInlinedValue) || originalInlinedValue === emptyString;
- if (tweenType === tweenTypes.OBJECT) {
+ if (tween._setter) {
+ if (!inlineStylesOnly && !tweenHadNoInlineValue) {
+ // Re-seed the original value to the _number / _numbers props so the setter can write the original state instead of re-applying the current frame.
+ decomposeRawValue(originalInlinedValue, decomposedOriginalValue);
+ if (decomposedOriginalValue.d) {
+ const src = decomposedOriginalValue.d;
+ const dst = tween._numbers;
+ for (let i = 0, l = src.length; i < l; i++) dst[i] = src[i];
+ } else {
+ tween._number = decomposedOriginalValue.n;
+ }
+ tween._setter(tween.target, tween._number, tween);
+ }
+ } else if (tweenType === tweenTypes.OBJECT) {
if (!inlineStylesOnly && !tweenHadNoInlineValue) {
tweenTarget[tweenProperty] = originalInlinedValue;
}
@@ -2030,8 +2173,6 @@ class Clock {
/** @type {Number} */
this._lastTime = initTime;
/** @type {Number} */
- this._scheduledTime = 0;
- /** @type {Number} */
this._frameDuration = K / maxFps;
/** @type {Number} */
this._fps = maxFps;
@@ -2050,14 +2191,12 @@ class Clock {
}
set fps(frameRate) {
- const previousFrameDuration = this._frameDuration;
const fr = +frameRate;
const fps = fr < minValue ? minValue : fr;
const frameDuration = K / fps;
if (fps > defaults.frameRate) defaults.frameRate = fps;
this._fps = fps;
this._frameDuration = frameDuration;
- this._scheduledTime += frameDuration - previousFrameDuration;
}
get speed() {
@@ -2074,17 +2213,17 @@ class Clock {
* @return {tickModes}
*/
requestTick(time) {
- const scheduledTime = this._scheduledTime;
- this._lastTickTime = time;
- // If the current time is lower than the scheduled time
- // this means not enough time has passed to hit one frameDuration
- // so skip that frame
- if (time < scheduledTime) return tickModes.NONE;
const frameDuration = this._frameDuration;
- const frameDelta = time - scheduledTime;
- // Ensures that _scheduledTime progresses in steps of at least 1 frameDuration.
- // Skips ahead if the actual elapsed time is higher.
- this._scheduledTime += frameDelta < frameDuration ? frameDuration : frameDelta;
+ const elapsed = time - this._lastTickTime;
+ const scaled = frameDuration * .25;
+ const tolerance = scaled < 4 ? scaled : 4;
+ // Tolerance prevents dropping frames that arrive a bit early due to RAF jitter
+ // typically <= ~25% of frame duration and capped at 4ms so it doesn't dominate at high fps.
+ // e.g. at 60fps (frameDuration=16.667ms) a frame arriving after 15ms:
+ // - without tolerance: 15 < 16.667 -> skip
+ // - with tolerance: 15 + 4 >= 16.667 -> tick
+ if (elapsed + tolerance < frameDuration) return tickModes.NONE;
+ this._lastTickTime = elapsed >= frameDuration ? time - (elapsed % frameDuration) : time;
return tickModes.AUTO;
}
@@ -2244,7 +2383,9 @@ class Engine extends Clock {
}
set speed(playbackRate) {
- this._speed = playbackRate * globals.timeScale;
+ const speed = playbackRate * globals.timeScale;
+ if (this._speed === speed) return;
+ this._speed = speed;
forEachChildren(this, (/** @type {Tickable} */child) => child.speed = child._speed);
}
@@ -2377,7 +2518,7 @@ const composeTween = (tween, siblings) => {
if (prevSibling) {
const prevParent = prevSibling.parent;
- const prevAbsEndTime = prevSibling._absoluteStartTime + prevSibling._changeDuration;
+ const prevAbsEndTime = prevSibling._absoluteEndTime;
// Handle looped animations tween
@@ -2403,7 +2544,8 @@ const composeTween = (tween, siblings) => {
}
- const absoluteUpdateStartTime = tweenAbsStartTime - tween._delay;
+ // Read the precision-matched update-start instead of subtracting tween._delay live so sequential keyframes touching at a boundary don't trigger a phantom overlap from float drift.
+ const absoluteUpdateStartTime = tween._absoluteUpdateStartTime;
if (prevAbsEndTime > absoluteUpdateStartTime) {
@@ -2423,37 +2565,41 @@ const composeTween = (tween, siblings) => {
}
}
- // Pause (and cancel) the parent if it only contains overlapped tweens
+ // Skip the cancel cascade when both tweens share the same parent timeline, a timeline cannot replace itself.
+ const tweenParentTL = tween.parent.parent;
+ if (!tweenParentTL || tweenParentTL !== prevParent.parent) {
- let pausePrevParentAnimation = true;
+ let pausePrevParentAnimation = true;
- forEachChildren(prevParent, (/** @type Tween */t) => {
- if (!t._isOverlapped) pausePrevParentAnimation = false;
- });
+ forEachChildren(prevParent, (/** @type Tween */t) => {
+ if (!t._isOverlapped) pausePrevParentAnimation = false;
+ });
- if (pausePrevParentAnimation) {
- const prevParentTL = prevParent.parent;
- if (prevParentTL) {
- let pausePrevParentTL = true;
- forEachChildren(prevParentTL, (/** @type JSAnimation */a) => {
- if (a !== prevParent) {
- forEachChildren(a, (/** @type Tween */t) => {
- if (!t._isOverlapped) pausePrevParentTL = false;
- });
+ if (pausePrevParentAnimation) {
+ const prevParentTL = prevParent.parent;
+ if (prevParentTL) {
+ let pausePrevParentTL = true;
+ forEachChildren(prevParentTL, (/** @type JSAnimation */a) => {
+ if (a !== prevParent) {
+ forEachChildren(a, (/** @type Tween */t) => {
+ if (!t._isOverlapped) pausePrevParentTL = false;
+ });
+ }
+ });
+ if (pausePrevParentTL) {
+ prevParentTL.cancel();
}
- });
- if (pausePrevParentTL) {
- prevParentTL.cancel();
+ } else {
+ prevParent.cancel();
+ // Previously, calling .cancel() on a timeline child would affect the render order of other children
+ // Worked around this by marking it as .completed and using .pause() for safe removal in the engine loop
+ // This is no longer needed since timeline tween composition is now handled separately
+ // Keeping this here for reference
+ // prevParent.completed = true;
+ // prevParent.pause();
}
- } else {
- prevParent.cancel();
- // Previously, calling .cancel() on a timeline child would affect the render order of other children
- // Worked around this by marking it as .completed and using .pause() for safe removal in the engine loop
- // This is no longer needed since timeline tween composition is now handled separately
- // Keeping this here for reference
- // prevParent.completed = true;
- // prevParent.pause();
}
+
}
}
@@ -2508,14 +2654,12 @@ const composeTween = (tween, siblings) => {
tween._number = 0;
lookupTween._fromNumber = toNumber;
- if (tween._toNumbers) {
+ if (tween._toNumbers.length) {
const toNumbers = cloneArray(tween._toNumbers);
- if (toNumbers) {
- toNumbers.forEach((value, i) => {
- tween._fromNumbers[i] = lookupTween._fromNumbers[i] - value;
- tween._toNumbers[i] = 0;
- });
- }
+ toNumbers.forEach((value, i) => {
+ tween._fromNumbers[i] = lookupTween._fromNumbers[i] - value;
+ tween._toNumbers[i] = 0;
+ });
lookupTween._fromNumbers = toNumbers;
}
@@ -3216,18 +3360,16 @@ function parseTargets(targets) {
function registerTargets(targets) {
const parsedTargetsArray = parseTargets(targets);
const parsedTargetsLength = parsedTargetsArray.length;
- if (parsedTargetsLength) {
- for (let i = 0; i < parsedTargetsLength; i++) {
- const target = parsedTargetsArray[i];
- if (!target[isRegisteredTargetSymbol]) {
- target[isRegisteredTargetSymbol] = true;
- const isSvgType = isSvg(target);
- const isDom = /** @type {DOMTarget} */(target).nodeType || isSvgType;
- if (isDom) {
- target[isDomSymbol] = true;
- target[isSvgSymbol] = isSvgType;
- target[transformsSymbol] = {};
- }
+ for (let i = 0; i < parsedTargetsLength; i++) {
+ const target = parsedTargetsArray[i];
+ if (!target[isRegisteredTargetSymbol]) {
+ target[isRegisteredTargetSymbol] = true;
+ const isSvgType = isSvg(target);
+ const isDom = /** @type {DOMTarget} */(target).nodeType || isSvgType;
+ if (isDom) {
+ target[isDomSymbol] = true;
+ target[isSvgSymbol] = isSvgType;
+ target[transformsSymbol] = {};
}
}
}
@@ -3349,8 +3491,8 @@ const easeInFunctions = {
/**
* @typedef {Object} EasesFunctions
- * @property {typeof none} linear
- * @property {typeof none} none
+ * @property {EasingFunction} linear
+ * @property {EasingFunction} none
* @property {PowerEasing} in
* @property {PowerEasing} out
* @property {PowerEasing} inOut
@@ -3582,6 +3724,11 @@ class JSAnimation extends Timer {
super(/** @type {TimerParams & AnimationParams} */(parameters), parent, parentPosition);
+ /** @type {Tween} */
+ this._head;
+ /** @type {Tween} */
+ this._tail;
+
++JSAnimationId;
const parsedTargets = registerTargets(targets);
@@ -3638,6 +3785,7 @@ class JSAnimation extends Timer {
if (isKey(p)) {
const tweenType = getTweenType(target, p);
+ const adapterProp = resolveAdapterEntry(target, p);
const propName = sanitizePropertyName(p, target, tweenType);
@@ -3721,7 +3869,7 @@ class JSAnimation extends Timer {
} else {
tweenToValue = computedToValue;
}
- const tweenFromValue = getFunctionValue(key.from, target, ti, tl, null, prevSiblingTween);
+ const tweenFromValue = getFunctionValue(key.from, target, ti, tl, fromFunctionStore, prevSiblingTween);
const easeToParse = key.ease || tEasing;
const easeFunctionResult = getFunctionValue(easeToParse, target, ti, tl, null, prevSiblingTween);
@@ -3739,9 +3887,13 @@ class JSAnimation extends Timer {
const hasToValue = !isUnd(tweenToValue);
const isFromToArray = isArr(tweenToValue);
const isFromToValue = isFromToArray || (hasFromvalue && hasToValue);
+ // Capture the update-start in local time, the previous sibling's end for keyframes after the first, zero for the first keyframe. Used to derive a precision-matched _absoluteUpdateStartTime below.
+ const tweenUpdateStartLocal = prevTween ? lastTweenChangeEndTime : 0;
const tweenStartTime = prevTween ? lastTweenChangeEndTime + tweenDelay : tweenDelay;
// Rounding is necessary here to minimize floating point errors when working in seconds
const absoluteStartTime = round$1(absoluteOffsetTime + tweenStartTime, 12);
+ // Match the rounding pattern of prevSibling._absoluteEndTime so the composition overlap check compares cleanly when keyframes touch at a boundary.
+ const absoluteUpdateStartTime = round$1(absoluteOffsetTime + tweenUpdateStartLocal, 12);
// Force a onRender callback if the animation contains at least one from value and autoplay is set to false
if (!shouldTriggerRender && (hasFromvalue || isFromToArray)) shouldTriggerRender = 1;
@@ -3750,9 +3902,9 @@ class JSAnimation extends Timer {
if (tweenComposition !== compositionTypes.none) {
let nextSibling = siblings._head;
- // Iterate trough all the next siblings until we find a sibling with an equal or inferior start time
- while (nextSibling && !nextSibling._isOverridden && nextSibling._absoluteStartTime <= absoluteStartTime) {
- prevSibling = nextSibling;
+ // Walk prior siblings up to the new tween, skipping overridden ones so the chain resolves to the latest live value instead of stopping at the first override.
+ while (nextSibling && nextSibling._absoluteStartTime <= absoluteStartTime) {
+ if (!nextSibling._isOverridden) prevSibling = nextSibling;
nextSibling = nextSibling._nextRep;
// Overrides all the next siblings if the next sibling starts at the same time of after as the new tween start time
if (nextSibling && nextSibling._absoluteStartTime >= absoluteStartTime) {
@@ -3806,8 +3958,8 @@ class JSAnimation extends Timer {
if (prevTween) {
decomposeTweenValue(prevTween, fromTargetObject);
} else {
- decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
// No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
+ decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), fromTargetObject);
}
}
@@ -3846,8 +3998,7 @@ class JSAnimation extends Timer {
const colorValue = fromTargetObject.t === valueTypes.COLOR ? fromTargetObject : toTargetObject;
const notColorValue = fromTargetObject.t === valueTypes.COLOR ? toTargetObject : fromTargetObject;
notColorValue.t = valueTypes.COLOR;
- notColorValue.s = colorValue.s;
- notColorValue.d = [0, 0, 0, 1];
+ notColorValue.d = colorValue.d.map(() => 0);
}
}
@@ -3877,6 +4028,16 @@ class JSAnimation extends Timer {
let inlineValue = inlineStylesStore[propName];
if (!isNil(inlineValue)) inlineStylesStore[propName] = null;
+ // Resolve the adapter setter once so render skips the lookup per frame.
+ const tweenSetter = adapterProp ? adapterProp.set : null;
+
+ // Rounding is necessary here to minimize floating point errors when working in seconds
+ lastTweenChangeEndTime = round$1(tweenStartTime + tweenUpdateDuration, 12);
+
+ const fromD = fromTargetObject.d;
+ const toD = toTargetObject.d;
+ const toS = toTargetObject.s;
+
/** @type {Tween} */
const tween = {
parent: this,
@@ -3887,12 +4048,12 @@ class JSAnimation extends Timer {
_toFunc: toFunctionStore.func,
_fromFunc: fromFunctionStore.func,
_ease: parseEase(tweenEasing),
- _fromNumbers: cloneArray(fromTargetObject.d),
- _toNumbers: cloneArray(toTargetObject.d),
- _strings: cloneArray(toTargetObject.s),
+ _fromNumbers: fromD ? cloneArray(fromD) : emptyArray,
+ _toNumbers: toD ? cloneArray(toD) : emptyArray,
+ _strings: toS ? cloneArray(toS) : emptyArray,
_fromNumber: fromTargetObject.n,
_toNumber: toTargetObject.n,
- _numbers: cloneArray(fromTargetObject.d), // For additive tween and animatables
+ _numbers: fromD ? cloneArray(fromD) : emptyArray, // For additive tween and animatables
_number: fromTargetObject.n, // For additive tween and animatables
_unit: toTargetObject.u,
_modifier: tweenModifier,
@@ -3902,8 +4063,12 @@ class JSAnimation extends Timer {
_updateDuration: tweenUpdateDuration,
_changeDuration: tweenUpdateDuration,
_absoluteStartTime: absoluteStartTime,
+ _absoluteUpdateStartTime: absoluteUpdateStartTime,
+ _absoluteEndTime: round$1(absoluteOffsetTime + lastTweenChangeEndTime, 12),
+ _hasFromValue: hasFromvalue || isFromToArray ? 1 : 0,
// NOTE: Investigate bit packing to stores ENUM / BOOL
_tweenType: tweenType,
+ _setter: tweenSetter,
_valueType: toTargetObject.t,
_composition: tweenComposition,
_isOverlapped: 0,
@@ -3926,10 +4091,11 @@ class JSAnimation extends Timer {
const vt = tween._valueType;
if (vt === valueTypes.COMPLEX) {
tween._value = composeComplexValue(tween, 1, -1);
- } else if (vt === valueTypes.COLOR) {
- tween._value = composeColorValue(tween, 1, -1);
} else if (vt === valueTypes.UNIT) {
tween._value = `${tweenModifier(tween._toNumber)}${tween._unit}`;
+ } else if (vt === valueTypes.COLOR) {
+ const d = toTargetObject.d;
+ tween._value = `rgba(${round$1(d[0], 0)},${round$1(d[1], 0)},${round$1(d[2], 0)},${d[3]})`;
} else {
tween._value = tweenModifier(tween._toNumber);
}
@@ -3937,8 +4103,7 @@ class JSAnimation extends Timer {
if (isNaN(firstTweenChangeStartTime)) {
firstTweenChangeStartTime = tween._startTime;
}
- // Rounding is necessary here to minimize floating point errors when working in seconds
- lastTweenChangeEndTime = round$1(tweenStartTime + tweenUpdateDuration, 12);
+
prevTween = tween;
animationAnimationLength++;
@@ -4044,8 +4209,11 @@ class JSAnimation extends Timer {
tween._updateDuration = normalizeTime(tween._updateDuration * timeScale);
tween._changeDuration = normalizeTime(tween._changeDuration * timeScale);
tween._currentTime *= timeScale;
+ tween._delay *= timeScale;
tween._startTime *= timeScale;
tween._absoluteStartTime *= timeScale;
+ tween._absoluteUpdateStartTime *= timeScale;
+ tween._absoluteEndTime *= timeScale;
});
return super.stretch(newDuration);
}
@@ -4174,8 +4342,6 @@ const parseTimelinePosition = (timeline, timePosition) => {
-
-
/**
* @param {Timeline} tl
* @return {Number}
@@ -4368,13 +4534,21 @@ class Timeline extends Timer {
if (!isUnd(synced) && !isUnd(/** @type {WAAPIAnimation} */(synced).persist)) {
/** @type {WAAPIAnimation} */(synced).persist = true;
}
- return this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
+ const editor = globals.editor;
+ const childHook = editor && editor.addTimelineChild;
+ if (editor && editor.addTimelineSync) {
+ position = editor.addTimelineSync(synced, position, this.id);
+ editor.addTimelineChild = null; // Suppress the per-child hook for the internal .add, sync already registered.
+ }
+ const result = this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
+ if (editor) editor.addTimelineChild = childHook;
+ return result;
}
/**
* @param {TargetsParam} targets
* @param {AnimationParams} parameters
- * @param {TimelinePosition} [position]
+ * @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [position]
* @return {this}
*/
set(targets, parameters, position) {
@@ -4391,6 +4565,7 @@ class Timeline extends Timer {
*/
call(callback, position) {
if (isUnd(callback) || callback && !isFnc(callback)) return this;
+ if (globals.editor && globals.editor.addTimelineCall) position = globals.editor.addTimelineCall(callback, position, this.id);
return this.add({ duration: 0, delay: 0, onComplete: () => callback(this) }, position);
}
@@ -4402,6 +4577,7 @@ class Timeline extends Timer {
*/
label(labelName, position) {
if (isUnd(labelName) || labelName && !isStr(labelName)) return this;
+ if (globals.editor && globals.editor.addTimelineLabel) position = globals.editor.addTimelineLabel(labelName, position, this.id);
this.labels[labelName] = parseTimelinePosition(this, position);
return this;
}
@@ -4510,6 +4686,7 @@ class Animatable {
const callbacksAnimationParams = { v: 1, autoplay: false };
const properties = {};
this.targets = [];
+ /** @type {Record<String, JSAnimation>} */
this.animations = {};
/** @type {JSAnimation|null} */
this.callbacks = null;
@@ -5048,6 +5225,9 @@ function get(targetSelector, propName, unit) {
*/
const set = (targets, parameters) => {
if (isUnd(parameters)) return;
+ if (globals.editor && globals.editor.addSet) {
+ return globals.editor.addSet(targets, parameters);
+ }
parameters.duration = minValue;
// Do not overrides currently active tweens by default
parameters.composition = setValue(parameters.composition, compositionTypes.none);
@@ -6284,13 +6464,14 @@ const sync = (callback = noop) => {
};
/**
- * @param {(...args: any[]) => Tickable | ((...args: any[]) => void) | void} constructor
- * @return {(...args: any[]) => Tickable | ((...args: any[]) => void)}
+ * @template {Tickable | ((...args: any[]) => void) | void} T
+ * @param {(...args: any[]) => T} constructor
+ * @return {(...args: any[]) => T extends void ? () => void : T}
*/
const keepTime = constructor => {
/** @type {Tickable} */
let tracked;
- return (...args) => {
+ return /** @type {(...args: any[]) => T extends void ? () => void : T} */(/** @type {*} */((...args) => {
let currentIteration, currentIterationProgress, reversed, alternate, startTime;
if (tracked) {
currentIteration = tracked.currentIteration;
@@ -6308,7 +6489,7 @@ const keepTime = constructor => {
/** @type {Tickable} */(tracked)._startTime = startTime;
}
return cleanup || noop;
- }
+ }));
};
@@ -6706,12 +6887,14 @@ class ScrollContainer {
refreshScrollObservers() {
forEachChildren(this, (/** @type {ScrollObserver} */child) => {
+ if (!child.ready) return;
if (child._debug) {
child.removeDebug();
}
});
this.updateBounds();
forEachChildren(this, (/** @type {ScrollObserver} */child) => {
+ if (!child.ready) return;
child.refresh();
child.onResize(child);
if (child._debug) {
@@ -9809,11 +9992,12 @@ const randomPick = items => items[random(0, items.length - 1)];
* Adapted from https://bost.ocks.org/mike/shuffle/
*
* @param {Array} items - The array to shuffle (will be modified in-place)
+ * @param {RandomNumberGenerator} [rnd] - Optional RNG matching the random() signature (defaults to random)
* @return {Array} The same array reference, now shuffled
*/
-const shuffle = items => {
+const shuffle = (items, rnd = random) => {
let m = items.length, t, i;
- while (m) { i = random(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
+ while (m) { i = rnd(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
return items;
};
@@ -9858,6 +10042,7 @@ const stagger = (val, params = {}) => {
let values = [];
let maxValue = 0;
let cachedOffset;
+ let jitterSamples = null;
const from = params.from;
const reversed = params.reversed;
const ease = params.ease;
@@ -9879,27 +10064,42 @@ const stagger = (val, params = {}) => {
const val2 = isRange ? parseNumber(val[1]) : 0;
const unitMatch = unitsExecRgx.exec((isRange ? val[1] : val) + emptyString);
const start = params.start || 0 + (isRange ? val1 : 0);
+ const seed = params.seed;
+ const hasSeed = !isUnd(seed) && seed !== false;
+ const rng = hasSeed ? createSeededRandom(seed === true ? 0 : /** @type {Number} */(seed)) : random;
+ const jitter = params.jitter;
+ const hasJitter = !isUnd(jitter);
+ const jitterIsArr = isArr(jitter);
+ const jitterStart = jitterIsArr ? /** @type {[Number,Number]} */(jitter)[0] : /** @type {Number} */(jitter) || 0;
+ const jitterEnd = jitterIsArr ? /** @type {[Number,Number]} */(jitter)[1] : /** @type {Number} */(jitter) || 0;
let fromIndex = fromFirst ? 0 : isNum(from) ? from : 0;
return (target, i, t, _, tl) => {
const [ registeredTarget ] = registerTargets(target);
const total = isUnd(customTotal) ? t.length : customTotal;
const customIndex = !isUnd(useProp) ? isFnc(useProp) ? useProp(registeredTarget, i, total) : getOriginalAnimatableValue(registeredTarget, useProp) : false;
- const staggerIndex = isNum(customIndex) || isStr(customIndex) && isNum(+customIndex) ? +customIndex : i;
+ const customIdx = isNum(customIndex) || isStr(customIndex) && isNum(+customIndex) ? +customIndex : i;
+ // Fall back to the natural index when the resolved value lands outside [0, total) so values[staggerIndex] never reads undefined.
+ const staggerIndex = customIdx >= 0 && customIdx < total ? customIdx : i;
if (fromCenter) fromIndex = (total - 1) / 2;
if (fromLast) fromIndex = total - 1;
if (!values.length) {
if (autoGrid) {
let hasPositions = true;
+ let has3D = false;
let minPosX = Infinity;
let minPosY = Infinity;
+ let minPosZ = Infinity;
let maxPosX = -Infinity;
let maxPosY = -Infinity;
+ let maxPosZ = -Infinity;
const pxArr = [];
const pyArr = [];
+ const pzArr = [];
for (let index = 0; index < total; index++) {
const el = t[index];
let px = 0;
let py = 0;
+ let pz = 0;
let found = false;
if (el && isFnc(el.getBoundingClientRect)) {
const rect = el.getBoundingClientRect();
@@ -9911,6 +10111,10 @@ const stagger = (val, params = {}) => {
if (obj && isNum(obj.x) && isNum(obj.y)) {
px = obj.x;
py = obj.y;
+ if (isNum(obj.z)) {
+ pz = obj.z;
+ has3D = true;
+ }
found = true;
}
}
@@ -9920,42 +10124,52 @@ const stagger = (val, params = {}) => {
}
pxArr.push(px);
pyArr.push(py);
+ pzArr.push(pz);
if (px < minPosX) minPosX = px;
if (py < minPosY) minPosY = py;
+ if (pz < minPosZ) minPosZ = pz;
if (px > maxPosX) maxPosX = px;
if (py > maxPosY) maxPosY = py;
+ if (pz > maxPosZ) maxPosZ = pz;
}
if (hasPositions) {
let fX = pxArr[0];
let fY = pyArr[0];
+ let fZ = pzArr[0];
if (fromArr) {
fX = minPosX + from[0] * (maxPosX - minPosX);
fY = minPosY + from[1] * (maxPosY - minPosY);
+ fZ = has3D ? minPosZ + (from.length >= 3 ? from[2] : 0.5) * (maxPosZ - minPosZ) : 0;
} else if (fromCenter) {
fX = (minPosX + maxPosX) / 2;
fY = (minPosY + maxPosY) / 2;
+ fZ = (minPosZ + maxPosZ) / 2;
} else if (fromLast) {
fX = pxArr[total - 1];
fY = pyArr[total - 1];
+ fZ = pzArr[total - 1];
} else if (isNum(from)) {
fX = pxArr[from];
fY = pyArr[from];
+ fZ = pzArr[from];
}
for (let index = 0; index < total; index++) {
const distanceX = fX - pxArr[index];
const distanceY = fY - pyArr[index];
- let value = sqrt(distanceX * distanceX + distanceY * distanceY);
+ const distanceZ = fZ - pzArr[index];
+ let value = sqrt(distanceX * distanceX + distanceY * distanceY + (has3D ? distanceZ * distanceZ : 0));
if (axis === 'x') value = -distanceX;
if (axis === 'y') value = -distanceY;
+ if (axis === 'z') value = -distanceZ;
values.push(value);
}
let minDist = Infinity;
- for (let index = 0, l = values.length; index < l; index++) {
+ for (let index = 0; index < total; index++) {
const absVal = abs(values[index]);
if (absVal > 0 && absVal < minDist) minDist = absVal;
}
if (minDist > 0 && minDist < Infinity) {
- for (let index = 0, l = values.length; index < l; index++) {
+ for (let index = 0; index < total; index++) {
values[index] = values[index] / minDist;
}
}
@@ -9969,32 +10183,51 @@ const stagger = (val, params = {}) => {
if (!grid) {
values.push(abs(fromIndex - index));
} else {
- let fromX, fromY;
+ const dims = grid.length;
+ const wh = grid[0] * grid[1];
+ let fromX, fromY, fromZ;
if (fromArr) {
fromX = from[0] * (grid[0] - 1);
fromY = from[1] * (grid[1] - 1);
+ fromZ = dims === 3 ? (from.length >= 3 ? from[2] : 0.5) * (grid[2] - 1) : 0;
} else if (fromCenter) {
fromX = (grid[0] - 1) / 2;
fromY = (grid[1] - 1) / 2;
+ fromZ = dims === 3 ? (grid[2] - 1) / 2 : 0;
} else {
fromX = fromIndex % grid[0];
- fromY = floor(fromIndex / grid[0]);
+ fromY = floor(fromIndex / grid[0]) % grid[1];
+ fromZ = dims === 3 ? floor(fromIndex / wh) : 0;
}
const toX = index % grid[0];
- const toY = floor(index / grid[0]);
+ const toY = floor(index / grid[0]) % grid[1];
+ const toZ = dims === 3 ? floor(index / wh) : 0;
const distanceX = fromX - toX;
const distanceY = fromY - toY;
- let value = sqrt(distanceX * distanceX + distanceY * distanceY);
+ const distanceZ = fromZ - toZ;
+ let value = sqrt(distanceX * distanceX + distanceY * distanceY + (dims === 3 ? distanceZ * distanceZ : 0));
if (axis === 'x') value = -distanceX;
if (axis === 'y') value = -distanceY;
+ if (axis === 'z') value = -distanceZ;
values.push(value);
}
}
}
- maxValue = max(...values);
- if (staggerEase) values = values.map(val => staggerEase(val / maxValue) * maxValue);
- if (reversed) values = values.map(val => axis ? (val < 0) ? val * -1 : -val : abs(maxValue - val));
- if (fromRandom) values = shuffle(values);
+ maxValue = values[0];
+ for (let k = 1; k < total; k++) if (values[k] > maxValue) maxValue = values[k];
+ if (staggerEase || reversed) {
+ for (let k = 0; k < total; k++) {
+ let v = values[k];
+ if (staggerEase) v = staggerEase(v / maxValue) * maxValue;
+ if (reversed) v = axis ? -v : abs(maxValue - v);
+ values[k] = v;
+ }
+ }
+ if (hasJitter) {
+ jitterSamples = new Array(total);
+ for (let k = 0; k < total; k++) jitterSamples[k] = rng(-1, 1, 4);
+ }
+ if (fromRandom) values = shuffle(values, rng);
}
const spacing = isRange ? (val2 - val1) / maxValue : val1;
if (isUnd(cachedOffset)) {
@@ -10002,6 +10235,11 @@ const stagger = (val, params = {}) => {
}
/** @type {String|Number} */
let output = cachedOffset + ((spacing * round$1(values[staggerIndex], 2)) || 0);
+ if (hasJitter) {
+ const progress = maxValue ? values[staggerIndex] / maxValue : 0;
+ const mag = jitterStart + (jitterEnd - jitterStart) * progress;
+ output = /** @type {Number} */(output) + jitterSamples[staggerIndex] * mag;
+ }
if (params.modifier) output = params.modifier(/** @type {Number} */(output));
if (unitMatch) output = `${output}${unitMatch[2]}`;
return output;
@@ -10371,6 +10609,7 @@ const filterLineElements = ($el, lineIndex, bin) => {
*/
const generateTemplate = (type, params = {}) => {
let template = ``;
+ if (!params) params = {};
const classString = isStr(params.class) ? ` class="${params.class}"` : '';
const cloneType = setValue(params.clone, false);
const wrapType = setValue(params.wrap, false);
@@ -10752,6 +10991,16 @@ const split = (target, parameters) => {
+/**
+ * @typedef {Object} ScrambleTextTween
+ * @property {Number} from
+ * @property {Number} to
+ * @property {Number} duration
+ * @property {Number} delay
+ * @property {String} ease
+ * @property {(v: Number) => String} modifier
+ */
+
/**
* '-' is the range operator; place it at the start or end of the string to use it as a literal (e.g. '-abc' or 'abc-')
* @param {String} str
@@ -10789,7 +11038,7 @@ const originalTexts = new WeakMap();
* progressively revealing the original text.
*
* @param {ScrambleTextParams} [params]
- * @return {FunctionValue}
+ * @return {FunctionValue<ScrambleTextTween>}
*/
const scrambleText = (params = {}) => {
if (!params) params = {};
diff --git a/dist/bundles/anime.esm.min.js b/dist/bundles/anime.esm.min.js
index 7390679e..c278b156 100644
--- a/dist/bundles/anime.esm.min.js
+++ b/dist/bundles/anime.esm.min.js
@@ -1,7 +1,7 @@
/**
* Anime.js - ESM minified bundle
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
-const t="undefined"!=typeof window,e=t?window:null,s=t?document:null,i={OBJECT:0,ATTRIBUTE:1,CSS:2,TRANSFORM:3,CSS_VAR:4},r={NUMBER:0,UNIT:1,COLOR:2,COMPLEX:3},n={NONE:0,AUTO:1,FORCE:2},o={replace:0,none:1,blend:2},a=Symbol(),l=Symbol(),h=Symbol(),d=Symbol(),c=Symbol(),u=1e-11,p=1e12,m=1e3,f=240,g="",y="var(",v=(()=>{const t=new Map;return t.set("x","translateX"),t.set("y","translateY"),t.set("z","translateZ"),t})(),_=["perspective","translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY"],b=_.reduce((t,e)=>({...t,[e]:e+"("}),{}),T=()=>{},x=/\)\s*[-.\d]/,S=/(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i,w=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i,C=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,$=/hsl\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*\)/i,E=/hsla\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,N=/[-+]?\d*\.?\d+(?:e[-+]?\d)?/gi,k=/^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i,R=/([a-z])([A-Z])/g,A=/(\*=|\+=|-=)/,D=/var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/,O={id:null,keyframes:null,playbackEase:null,playbackRate:1,frameRate:f,loop:0,reversed:!1,alternate:!1,autoplay:!0,persist:!1,duration:m,delay:0,loopDelay:0,ease:"out(2)",composition:o.replace,modifier:t=>t,onBegin:T,onBeforeUpdate:T,onUpdate:T,onLoop:T,onPause:T,onComplete:T,onRender:T},I={current:null,root:s},L={defaults:O,precision:4,timeScale:1,tickThreshold:200,editor:null},B={version:"4.4.1",engine:null};t&&(e.AnimeJS||(e.AnimeJS=[]),e.AnimeJS.push(B));const M=t=>t.replace(R,"$1-$2").toLowerCase(),P=(t,e)=>0===t.indexOf(e),F=Date.now,V=Array.isArray,X=t=>t&&t.constructor===Object,z=t=>"number"==typeof t&&!isNaN(t),H=t=>"string"==typeof t,Y=t=>"function"==typeof t,U=t=>void 0===t,W=t=>U(t)||null===t,q=e=>t&&e instanceof SVGElement,j=t=>S.test(t),G=t=>P(t,"rgb"),Z=t=>P(t,"hsl"),Q=t=>j(t)||(G(t)||Z(t))&&(")"===t[t.length-1]||!x.test(t)),J=t=>!L.defaults.hasOwnProperty(t),K=["opacity","rotate","overflow","color"],tt=(t,e)=>{if(K.includes(e))return!1;if(t.getAttribute(e)||e in t){if("scale"===e){const e=t.parentNode;return e&&"filter"===e.tagName}return!0}},et=t=>H(t)?parseFloat(t):t,st=Math.pow,it=Math.sqrt,rt=Math.sin,nt=Math.cos,ot=Math.abs,at=Math.exp,lt=Math.ceil,ht=Math.floor,dt=Math.asin,ct=Math.max,ut=Math.atan2,pt=Math.PI,mt=Math.round,ft=(t,e,s)=>t<e?e:t>s?s:t,gt=(t,e)=>{if(e<0)return t;if(!e)return mt(t);const s=10**e;return mt(t*s)/s},yt=(t,e)=>V(e)?e.reduce((e,s)=>ot(s-t)<ot(e-t)?s:e):e?mt(t/e)*e:t,vt=(t,e,s)=>t+(e-t)*s,_t=t=>t===1/0?p:t===-1/0?-p:t,bt=t=>t<=u?u:_t(gt(t,11)),Tt=t=>V(t)?[...t]:t,xt=(t,e)=>{const s={...t};for(let i in e){const r=t[i];s[i]=U(r)?e[i]:r}return s},St=(t,e,s,i="_prev",r="_next")=>{let n=t._head,o=r;for(s&&(n=t._tail,o=i);n;){const t=n[o];e(n),n=t}},wt=(t,e,s="_prev",i="_next")=>{const r=e[s],n=e[i];r?r[i]=n:t._head=n,n?n[s]=r:t._tail=r,e[s]=null,e[i]=null},Ct=(t,e,s,i="_prev",r="_next")=>{let n=t._tail;for(;n&&s&&s(n,e);)n=n[i];const o=n?n[r]:t._head;n?n[r]=e:t._head=e,o?o[i]=e:t._tail=e,e[i]=n,e[r]=o},$t=(t,e,s)=>{const i=t.style.transform;if(i){const r=t[d];let n=0;const o=i.length;let a;for(;n<o;){for(;n<o&&32===i.charCodeAt(n);)n++;if(n>=o)break;const t=n;for(;n<o&&40!==i.charCodeAt(n);)n++;if(n>=o)break;const e=i.substring(t,n);let s=1;const l=n+1;let h=-1,d=-1;for(n++;n<o&&s>0;){const t=i.charCodeAt(n);40===t?s++:41===t?s--:44===t&&1===s&&(-1===h?h=n:-1===d&&(d=n)),n++}const c=n-1;"translate"===e||"translate3d"===e?(-1===h?r.translateX=i.substring(l,c).trim():(r.translateX=i.substring(l,h).trim(),-1===d?r.translateY=i.substring(h+1,c).trim():(r.translateY=i.substring(h+1,d).trim(),r.translateZ=i.substring(d+1,c).trim())),a=i.substring(l,c)):"scale"===e||"scale3d"===e?-1===h?r.scale=i.substring(l,c).trim():(r.scaleX=i.substring(l,h).trim(),-1===d?r.scaleY=i.substring(h+1,c).trim():(r.scaleY=i.substring(h+1,d).trim(),r.scaleZ=i.substring(d+1,c).trim())):r[e]=i.substring(l,c)}if("translate3d"===e&&a)return s&&(s[e]=a),a;const l=r[e];if(!U(l))return s&&(s[e]=l),l}return"translate3d"===e?"0px, 0px, 0px":"rotate3d"===e?"0, 0, 0, 0deg":P(e,"scale")?"1":P(e,"rotate")||P(e,"skew")?"0deg":"0px"},Et=t=>{let e=g;for(let s=0,i=_.length;s<i;s++){const i=_[s],r=t[i];if(void 0!==r){if("translateX"===i){const i=t.translateY;if(void 0!==i){const n=t.translateZ;void 0!==n?(e+=`translate3d(${r},${i},${n}) `,s+=2):(e+=`translate(${r},${i}) `,s+=1);continue}}if("scaleX"===i&&void 0===t.scale){const i=t.scaleY;if(void 0!==i){const n=t.scaleZ;void 0!==n?(e+=`scale3d(${r},${i},${n}) `,s+=2):(e+=`scale(${r},${i}) `,s+=1);continue}}e+=`${b[i]}${r}) `}"rotateZ"===i&&void 0!==t.rotate3d&&(e+=`rotate3d(${t.rotate3d}) `)}return void 0!==t.matrix&&(e+=`matrix(${t.matrix}) `),void 0!==t.matrix3d&&(e+=`matrix3d(${t.matrix3d}) `),e},Nt=t=>{const e=w.exec(t)||C.exec(t),s=U(e[4])?1:+e[4];return[+e[1],+e[2],+e[3],s]},kt=t=>{const e=t.length,s=4===e||5===e;return[+("0x"+t[1]+t[s?1:2]),+("0x"+t[s?2:3]+t[s?2:4]),+("0x"+t[s?3:5]+t[s?3:6]),5===e||9===e?+(+("0x"+t[s?4:7]+t[s?4:8])/255).toFixed(3):1]},Rt=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t),At=t=>{const e=$.exec(t)||E.exec(t),s=+e[1]/360,i=+e[2]/100,r=+e[3]/100,n=U(e[4])?1:+e[4];let o,a,l;if(0===i)o=a=l=r;else{const t=r<.5?r*(1+i):r+i-r*i,e=2*r-t;o=gt(255*Rt(e,t,s+1/3),0),a=gt(255*Rt(e,t,s),0),l=gt(255*Rt(e,t,s-1/3),0)}return[o,a,l,n]},Dt=t=>G(t)?Nt(t):j(t)?kt(t):Z(t)?At(t):[0,0,0,1],Ot=(t,e)=>U(t)?e:t,It=(t,e,s,i,r,n)=>{let o;if(Y(t))o=()=>{const r=t(e,s,i,n);return isNaN(+r)?r||0:+r};else{if(!H(t)||!P(t,y))return t;o=()=>{const s=t.match(D),i=s[1],r=s[2];let n=getComputedStyle(e)?.getPropertyValue(i);return n&&n.trim()!==g||!r||(n=r.trim()),n||0}}return r&&(r.func=o),o()},Lt=(t,e)=>t[l]?t[h]&&tt(t,e)?i.ATTRIBUTE:_.includes(e)||v.get(e)?i.TRANSFORM:P(e,"--")?i.CSS_VAR:e in t.style?i.CSS:e in t?i.OBJECT:i.ATTRIBUTE:i.OBJECT,Bt=(t,e,s)=>{const i=t.style[e];i&&s&&(s[e]=i);const r=i||getComputedStyle(t[c]||t).getPropertyValue(e);return"auto"===r?"0":r},Mt=(t,e,s,r)=>{const n=U(s)?Lt(t,e):s;if(n===i.OBJECT){const s=t[e];return s&&r&&(r[e]=s),s||0}if(n===i.ATTRIBUTE){const s=t.getAttribute(e);return s&&r&&(r[e]=s),s}return n===i.TRANSFORM?$t(t,e,r):n===i.CSS_VAR?Bt(t,e,r).trimStart():Bt(t,e,r)},Pt=(t,e,s)=>"-"===s?t-e:"+"===s?t+e:t*e,Ft=()=>({t:r.NUMBER,n:0,u:null,o:null,d:null,s:null}),Vt=(t,e)=>{if(e.t=r.NUMBER,e.n=0,e.u=null,e.o=null,e.d=null,e.s=null,!t)return e;const s=+t;if(isNaN(s)){let s=t;"="===s[1]&&(e.o=s[0],s=s.slice(2));const i=!s.includes(" ")&&k.exec(s);if(i)return e.t=r.UNIT,e.n=+i[1],e.u=i[2],e;if(e.o)return e.n=+s,e;if(Q(s))return e.t=r.COLOR,e.d=Dt(s),e;{const t=s.match(N);return e.t=r.COMPLEX,e.d=t?t.map(Number):[],e.s=s.split(N)||[],e}}return e.n=s,e},Xt=(t,e)=>(e.t=t._valueType,e.n=t._toNumber,e.u=t._unit,e.o=null,e.d=Tt(t._toNumbers),e.s=Tt(t._strings),e),zt=Ft(),Ht=(t,e,s)=>{const i=t._modifier,r=t._fromNumbers,n=t._toNumbers,a=gt(ft(i(vt(r[0],n[0],e)),0,255),0),l=gt(ft(i(vt(r[1],n[1],e)),0,255),0),h=gt(ft(i(vt(r[2],n[2],e)),0,255),0),d=ft(i(gt(vt(r[3],n[3],e),s)),0,1);if(t._composition!==o.none){const e=t._numbers;e[0]=a,e[1]=l,e[2]=h,e[3]=d}return`rgba(${a},${l},${h},${d})`},Yt=(t,e,s)=>{const i=t._modifier,r=t._fromNumbers,n=t._toNumbers,a=t._strings,l=t._composition!==o.none;let h=a[0];for(let o=0,d=n.length;o<d;o++){const d=i(gt(vt(r[o],n[o],e),s)),c=a[o+1];h+=`${c?d+c:d}`,l&&(t._numbers[o]=d)}return h},Ut=(t,e,s,a,l)=>{const h=t.parent,c=t.duration,p=t.completed,m=t.iterationDuration,f=t.iterationCount,g=t._currentIteration,y=t._loopDelay,v=t._reversed,_=t._alternate,b=t._hasChildren,T=t._delay,x=t._currentTime,S=T+m,w=e-T,C=ft(x,-T,c),$=ft(w,-T,c),E=w-x,N=$>0,k=$>=c,R=c<=u,A=l===n.FORCE;let D=0,O=w,I=0;if(f>1){const e=~~($/(m+(k?0:y)));t._currentIteration=ft(e,0,f),k&&t._currentIteration--,D=t._currentIteration%2,O=$%(m+y)||0}const B=v^(_&&D),M=t._ease;let P=k?B?0:c:B?m-O:O;M&&(P=m*M(P/m)||0);const F=(h?h.backwards:w<x)?!B:!!B;if(t._currentTime=w,t._iterationTime=P,t.backwards=F,N&&!t.began?(t.began=!0,s||h&&(F||!h.began)||t.onBegin(t)):w<=0&&(t.began=!1),s||b||!N||t._currentIteration===g||t.onLoop(t),A||l===n.AUTO&&(e>=T&&e<=S||e<=T&&C>T||e>=S&&C!==c)||P>=S&&C!==c||P<=T&&C>0||e<=C&&C===c&&p||k&&!p&&R){if(N&&(t.computeDeltaTime(C),s||t.onBeforeUpdate(t)),!b){const e=A||(F?-1*E:E)>=L.tickThreshold,n=t._offset+(h?h._offset:0)+T+P;let l,c,u,p,m=t._head,f=0;for(;m;){const t=m._composition,s=m._currentTime,h=m._changeDuration,g=m._absoluteStartTime+m._changeDuration,y=m._nextRep,v=m._prevRep,_=t!==o.none;if((e||(s!==h||n<=g+(y?y._delay:0))&&(0!==s||n>=m._absoluteStartTime))&&(!_||!m._isOverridden&&(!m._isOverlapped||n<=g)&&(!y||y._isOverridden||n<=y._absoluteStartTime)&&(!v||v._isOverridden||n>=v._absoluteStartTime+v._changeDuration+m._delay))){const e=m._currentTime=ft(P-m._startTime,0,h),s=m._ease(e/m._updateDuration),n=m._modifier,g=m._valueType,y=m._tweenType,v=y===i.OBJECT,b=g===r.NUMBER,T=b&&v||0===s||1===s?-1:L.precision;let x,S;if(b?x=S=n(gt(vt(m._fromNumber,m._toNumber,s),T)):g===r.UNIT?(S=n(gt(vt(m._fromNumber,m._toNumber,s),T)),x=`${S}${m._unit}`):g===r.COLOR?x=Ht(m,s,T):g===r.COMPLEX&&(x=Yt(m,s,T)),_&&(m._number=S),a||t===o.blend)m._value=x;else{const t=m.property;l=m.target,v?l[t]=x:y===i.ATTRIBUTE?l.setAttribute(t,x):(c=l.style,y===i.TRANSFORM?(l!==u&&(u=l,p=l[d]),p[t]=x,f=1):y===i.CSS?c[t]=x:y===i.CSS_VAR&&c.setProperty(t,x)),N&&(I=1)}}f&&m._renderTransforms&&(c.transform=Et(p),f=0),m=m._next}!s&&I&&t.onRender(t)}!s&&N&&t.onUpdate(t)}return h&&R?!s&&(h.began&&!F&&w>0&&!p||F&&w<=u&&p)&&(t.onComplete(t),t.completed=!F):N&&k?f===1/0?t._startTime+=t.duration:t._currentIteration>=f-1&&(t.paused=!0,p||b||(t.completed=!0,s||h&&(F||!h.began)||(t.onComplete(t),t._resolve(t)))):t.completed=!1,I},Wt=(t,e,s,i,r)=>{const o=t._currentIteration;if(Ut(t,e,s,i,r),t._hasChildren){const a=t,l=a.backwards,h=i?e:a._iterationTime,d=F();let c=0,p=!0;if(!i&&a._currentIteration!==o){const t=a.iterationDuration;St(a,e=>{if(l){const i=e.duration,r=e._offset+e._delay;s||!(i<=u)||r&&r+i!==t||e.onComplete(e)}else!e.completed&&!e.backwards&&e._currentTime<e.iterationDuration&&Ut(e,t,s,1,n.FORCE),e.began=!1,e.completed=!1}),s||a.onLoop(a)}St(a,t=>{const e=gt((h-t._offset)*t._speed,12),n=t._fps<a._fps?t.requestTick(d):r;c+=Ut(t,e,s,i,n),!t.completed&&p&&(p=!1)},l),!s&&c&&a.onRender(a),(p||l)&&a._currentTime>=a.duration&&(a.paused=!0,a.completed||(a.completed=!0,s||(a.onComplete(a),a._resolve(a))))}},qt={},jt=(t,e,s)=>{if(s===i.TRANSFORM)return v.get(t)||t;if(s===i.CSS||s===i.ATTRIBUTE&&q(e)&&t in e.style){const e=qt[t];if(e)return e;{const e=t?M(t):t;return qt[t]=e,e}}return t},Gt=(t,e=!1)=>{if(t._hasChildren)St(t,t=>Gt(t,e),!0);else{const s=t;s.pause(),St(s,t=>{const r=t.property,n=t.target,o=t._tweenType,a=t._inlineValue,h=W(a)||a===g;if(o===i.OBJECT)e||h||(n[r]=a);else if(n[l])if(o===i.ATTRIBUTE)e||(h?n.removeAttribute(r):n.setAttribute(r,a));else{const e=n.style;if(o===i.TRANSFORM){const s=n[d];h?delete s[r]:s[r]=a,t._renderTransforms&&(Object.keys(s).length?e.transform=Et(s):e.removeProperty("transform"))}else h?e.removeProperty(M(r)):e[r]=a}n[l]&&s._tail===t&&s.targets.forEach(t=>{t.getAttribute&&t.getAttribute("style")===g&&t.removeAttribute("style")})})}return t},Zt=t=>Gt(t,!0);class Qt{constructor(t=0){this.deltaTime=0,this._currentTime=t,this._lastTickTime=t,this._startTime=t,this._lastTime=t,this._scheduledTime=0,this._frameDuration=m/f,this._fps=f,this._speed=1,this._hasChildren=!1,this._head=null,this._tail=null}get fps(){return this._fps}set fps(t){const e=this._frameDuration,s=+t,i=s<u?u:s,r=m/i;i>O.frameRate&&(O.frameRate=i),this._fps=i,this._frameDuration=r,this._scheduledTime+=r-e}get speed(){return this._speed}set speed(t){const e=+t;this._speed=e<u?u:e}requestTick(t){const e=this._scheduledTime;if(this._lastTickTime=t,t<e)return n.NONE;const s=this._frameDuration,i=t-e;return this._scheduledTime+=i<s?s:i,n.AUTO}computeDeltaTime(t){const e=t-this._lastTime;return this.deltaTime=e,this._lastTime=t,e}}const Jt={animation:null,update:T},Kt=t=>{let e=Jt.animation;return e||(e={duration:u,computeDeltaTime:T,_offset:0,_delay:0,_head:null,_tail:null},Jt.animation=e,Jt.update=()=>{t.forEach(t=>{for(let e in t){const s=t[e],i=s._head;if(i){const t=i._valueType,e=t===r.COMPLEX||t===r.COLOR?Tt(i._fromNumbers):null;let n=i._fromNumber,o=s._tail;for(;o&&o!==i;){if(e)for(let t=0,s=o._numbers.length;t<s;t++)e[t]+=o._numbers[t];else n+=o._number;o=o._prevAdd}i._toNumber=n,i._toNumbers=e}}}),Ut(e,1,1,0,n.FORCE)}),e},te=(()=>t?requestAnimationFrame:setImmediate)(),ee=(()=>t?cancelAnimationFrame:clearImmediate)();class se extends Qt{constructor(t){super(t),this.useDefaultMainLoop=!0,this.pauseOnDocumentHidden=!0,this.defaults=O,this.paused=!0,this.reqId=0}update(){const t=this._currentTime=F();if(this.requestTick(t)){this.computeDeltaTime(t);const e=this._speed,s=this._fps;let i=this._head;for(;i;){const r=i._next;i.paused?(wt(this,i),this._hasChildren=!!this._tail,i._running=!1,i.completed&&!i._cancelled&&i.cancel()):Wt(i,(t-i._startTime)*i._speed*e,0,0,i._fps<s?i.requestTick(t):n.AUTO),i=r}Jt.update()}}wake(){return this.useDefaultMainLoop&&!this.reqId&&(this.requestTick(F()),this.reqId=te(re)),this}pause(){if(this.reqId)return this.paused=!0,ne()}resume(){if(this.paused)return this.paused=!1,St(this,t=>t.resetTime()),this.wake()}get speed(){return this._speed*(1===L.timeScale?1:m)}set speed(t){this._speed=t*L.timeScale,St(this,t=>t.speed=t._speed)}get timeUnit(){return 1===L.timeScale?"ms":"s"}set timeUnit(t){const e="s"===t,s=e?.001:1;if(L.timeScale!==s){L.timeScale=s,L.tickThreshold=200*s;const t=e?.001:m;this.defaults.duration*=t,this._speed*=t}}get precision(){return L.precision}set precision(t){L.precision=t}}const ie=(()=>{const e=new se(F());return t&&(B.engine=e,s.addEventListener("visibilitychange",()=>{e.pauseOnDocumentHidden&&(s.hidden?e.pause():e.resume())})),e})(),re=()=>{ie._head?(ie.reqId=te(re),ie.update()):ie.reqId=0},ne=()=>(ee(ie.reqId),ie.reqId=0,ie),oe={_rep:new WeakMap,_add:new Map},ae=(t,e,s="_rep")=>{const i=oe[s];let r=i.get(t);return r||(r={},i.set(t,r)),r[e]?r[e]:r[e]={_head:null,_tail:null}},le=(t,e)=>t._isOverridden||t._absoluteStartTime>e._absoluteStartTime,he=t=>{t._isOverlapped=1,t._isOverridden=1,t._changeDuration=u,t._currentTime=u},de=(t,e)=>{const s=t._composition;if(s===o.replace){const s=t._absoluteStartTime;Ct(e,t,le,"_prevRep","_nextRep");const i=t._prevRep;if(i){const e=i.parent,r=i._absoluteStartTime+i._changeDuration;if(t.parent.id!==e.id&&e.iterationCount>1&&r+(e.duration-e.iterationDuration)>s){he(i);let t=i._prevRep;for(;t&&t.parent.id===e.id;)he(t),t=t._prevRep}const n=s-t._delay;if(r>n){const t=i._startTime,e=r-(t+i._updateDuration),s=gt(n-e-t,12);i._changeDuration=s,i._currentTime=s,i._isOverlapped=1,s<u&&he(i)}let o=!0;if(St(e,t=>{t._isOverlapped||(o=!1)}),o){const t=e.parent;if(t){let s=!0;St(t,t=>{t!==e&&St(t,t=>{t._isOverlapped||(s=!1)})}),s&&t.cancel()}else e.cancel()}}}else if(s===o.blend){const e=ae(t.target,t.property,"_add"),s=Kt(oe._add);let i=e._head;i||(i={...t},i._composition=o.replace,i._updateDuration=u,i._startTime=0,i._numbers=Tt(t._fromNumbers),i._number=0,i._next=null,i._prev=null,Ct(e,i),Ct(s,i));const r=t._toNumber;if(t._fromNumber=i._fromNumber-r,t._toNumber=0,t._numbers=Tt(t._fromNumbers),t._number=0,i._fromNumber=r,t._toNumbers){const e=Tt(t._toNumbers);e&&e.forEach((e,s)=>{t._fromNumbers[s]=i._fromNumbers[s]-e,t._toNumbers[s]=0}),i._fromNumbers=e}Ct(e,t,null,"_prevAdd","_nextAdd")}return t},ce=t=>{const e=t._composition;if(e!==o.none){const s=t.target,i=t.property,r=oe._rep.get(s)[i];if(wt(r,t,"_prevRep","_nextRep"),e===o.blend){const e=oe._add,r=e.get(s);if(!r)return;const n=r[i],o=Jt.animation;wt(n,t,"_prevAdd","_nextAdd");const a=n._head;if(a&&a===n._tail){wt(n,a,"_prevAdd","_nextAdd"),wt(o,a);let t=!0;for(let e in r)if(r[e]._head){t=!1;break}t&&e.delete(s)}}}return t},ue=(t,e,s)=>{let r=!1;return St(e,n=>{const o=n.target;if(t.includes(o)){const t=n.property,a=n._tweenType,l=jt(s,o,a);(!l||l&&l===t)&&(n.parent._tail===n&&n._tweenType===i.TRANSFORM&&n._prev&&n._prev._tweenType===i.TRANSFORM&&(n._prev._renderTransforms=1),wt(e,n),ce(n),r=!0)}},!0),r},pe=(t,e,s)=>{const i=e||ie;let r;if(i._hasChildren){let e=0;St(i,n=>{if(!n._hasChildren)if(r=ue(t,n,s),r&&!n._head)n.cancel(),wt(i,n);else{const t=n._offset+n._delay+n.duration;t>e&&(e=t)}n._head?pe(t,n,s):n._hasChildren=!1},!0),U(i.iterationDuration)||(i.iterationDuration=e)}else r=ue(t,i,s);r&&!i._head&&(i._hasChildren=!1,i.cancel&&i.cancel())},me=t=>(t.paused=!0,t.began=!1,t.completed=!1,t),fe=t=>t._cancelled?(t._hasChildren?St(t,fe):St(t,t=>{t._composition!==o.none&&de(t,ae(t.target,t.property))}),t._cancelled=0,t):t;let ge=0;const ye=(t,e)=>t._priority>e._priority;class ve extends Qt{constructor(t={},e=null,s=0){super(0),++ge;const{id:i,delay:r,duration:n,reversed:o,alternate:a,loop:l,loopDelay:h,autoplay:d,frameRate:c,playbackRate:p,priority:m,onComplete:f,onLoop:g,onPause:y,onBegin:v,onBeforeUpdate:_,onUpdate:b}=t;I.current&&I.current.register(this);const x=e?0:ie._lastTickTime,S=e?e.defaults:L.defaults,w=Y(r)||U(r)?S.delay:+r,C=Y(n)||U(n)?1/0:+n,$=Ot(l,S.loop),E=Ot(h,S.loopDelay);let N=!0===$||$===1/0||$<0?1/0:$+1,k=0;e?k=s:(ie.reqId||ie.requestTick(F()),k=(ie._lastTickTime-ie._startTime)*L.timeScale),this.id=U(i)?ge:i,this.parent=e,this.duration=_t((C+E)*N-E)||u,this.backwards=!1,this.paused=!0,this.began=!1,this.completed=!1,this.onBegin=v||S.onBegin,this.onBeforeUpdate=_||S.onBeforeUpdate,this.onUpdate=b||S.onUpdate,this.onLoop=g||S.onLoop,this.onPause=y||S.onPause,this.onComplete=f||S.onComplete,this.iterationDuration=C,this.iterationCount=N,this._autoplay=!e&&Ot(d,S.autoplay),this._offset=k,this._delay=w,this._loopDelay=E,this._iterationTime=0,this._currentIteration=0,this._resolve=T,this._running=!1,this._reversed=+Ot(o,S.reversed),this._reverse=this._reversed,this._cancelled=0,this._alternate=Ot(a,S.alternate),this._prev=null,this._next=null,this._lastTickTime=x,this._startTime=x,this._lastTime=x,this._fps=Ot(c,S.frameRate),this._speed=Ot(p,S.playbackRate),this._priority=+Ot(m,1)}get cancelled(){return!!this._cancelled}set cancelled(t){t?this.cancel():this.reset(!0).play()}get currentTime(){return ft(gt(this._currentTime,L.precision),-this._delay,this.duration)}set currentTime(t){const e=this.paused;this.pause().seek(+t),e||this.resume()}get iterationCurrentTime(){return ft(gt(this._iterationTime,L.precision),0,this.iterationDuration)}set iterationCurrentTime(t){this.currentTime=this.iterationDuration*this._currentIteration+t}get progress(){return ft(gt(this._currentTime/this.duration,10),0,1)}set progress(t){this.currentTime=this.duration*t}get iterationProgress(){return ft(gt(this._iterationTime/this.iterationDuration,10),0,1)}set iterationProgress(t){const e=this.iterationDuration;this.currentTime=e*this._currentIteration+e*t}get currentIteration(){return this._currentIteration}set currentIteration(t){this.currentTime=this.iterationDuration*ft(+t,0,this.iterationCount-1)}get reversed(){return!!this._reversed}set reversed(t){t?this.reverse():this.play()}get speed(){return super.speed}set speed(t){super.speed=t,this.resetTime()}reset(t=!1){return fe(this),this._reversed&&!this._reverse&&(this.reversed=!1),this._iterationTime=this.iterationDuration,Wt(this,0,1,~~t,n.FORCE),me(this),this._hasChildren&&St(this,me),this}init(t=!1){this.fps=this._fps,this.speed=this._speed,!t&&this._hasChildren&&Wt(this,this.duration,1,~~t,n.FORCE),this.reset(t);const e=this._autoplay;return!0===e?this.resume():e&&!U(e.linked)&&e.link(this),this}resetTime(){const t=1/(this._speed*ie._speed);return this._startTime=F()-(this._currentTime+this._delay)*t,this}pause(){return this.paused||(this.paused=!0,this.onPause(this)),this}resume(){return this.paused?(this.paused=!1,this.duration<=u&&!this._hasChildren?Wt(this,u,0,0,n.FORCE):(this._running||(Ct(ie,this,ye),ie._hasChildren=!0,this._running=!0),this.resetTime(),this._startTime-=12,ie.wake()),this):this}restart(){return this.reset().resume()}seek(t,e=0,s=0){fe(this),this.completed=!1;const i=this.paused;return this.paused=!0,Wt(this,t+this._delay,~~e,~~s,n.AUTO),i?this:this.resume()}alternate(){const t=this._reversed,e=this.iterationCount,s=this.iterationDuration,i=e===1/0?ht(p/s):e;return this._reversed=+(!this._alternate||i%2?!t:t),e===1/0?this.iterationProgress=this._reversed?1-this.iterationProgress:this.iterationProgress:this.seek(s*i-this._currentTime),this.resetTime(),this}play(){return this._reversed&&this.alternate(),this.resume()}reverse(){return this._reversed||this.alternate(),this.resume()}cancel(){return this._hasChildren?St(this,t=>t.cancel(),!0):St(this,ce),this._cancelled=1,this.pause()}stretch(t){const e=this.duration,s=bt(t);if(e===s)return this;const i=t/e,r=t<=u;return this.duration=r?u:s,this.iterationDuration=r?u:bt(this.iterationDuration*i),this._offset*=i,this._delay*=i,this._loopDelay*=i,this}revert(){Wt(this,0,1,0,n.AUTO);const t=this._autoplay;return t&&t.linked&&t.linked===this&&t.revert(),this.cancel()}complete(t=0){return this.seek(this.duration,t).cancel()}then(t=T){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=T};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const _e=t=>new ve(t,null,0).init();function be(t){const e=H(t)?I.root.querySelectorAll(t):t;if(e instanceof NodeList||e instanceof HTMLCollection)return e}function Te(e){if(W(e))return[];if(!t)return V(e)&&e.flat(1/0)||[e];if(V(e)){const t=e.flat(1/0),s=[];for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!W(i)){const t=be(i);if(t)for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!W(i)){let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}else{let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}}return s}const s=be(e);return s?Array.from(s):[e]}function xe(t){const e=Te(t),s=e.length;if(s)for(let t=0;t<s;t++){const s=e[t];if(!s[a]){s[a]=!0;const t=q(s);(s.nodeType||t)&&(s[l]=!0,s[h]=t,s[d]={})}}return e}const Se={deg:1,rad:180/pt,turn:360},we={},Ce=(t,e,i,n=!1)=>{const o=e.u,a=e.n;if(e.t===r.UNIT&&o===i)return e;const l=a+o+i,h=we[l];if(U(h)||n){let r;if(o in Se)r=a*Se[o]/Se[i];else{const e=100,n=t.cloneNode(),l=t.parentNode,h=l&&l!==s?l:s.body;h.appendChild(n);const d=n.style;d.width=e+o;const c=n.offsetWidth||e;d.width=e+i;const u=c/(n.offsetWidth||e);h.removeChild(n),r=u*a}e.n=r,we[l]=r}else e.n=h;return e.t,e.u=i,e},$e=t=>t,Ee=(t=1.68)=>e=>st(e,+t),Ne={in:t=>e=>t(e),out:t=>e=>1-t(1-e),inOut:t=>e=>e<.5?t(2*e)/2:1-t(-2*e+2)/2,outIn:t=>e=>e<.5?(1-t(1-2*e))/2:(t(2*e-1)+1)/2},ke=pt/2,Re=2*pt,Ae={[g]:Ee,Quad:Ee(2),Cubic:Ee(3),Quart:Ee(4),Quint:Ee(5),Sine:t=>1-nt(t*ke),Circ:t=>1-it(1-t*t),Expo:t=>t?st(2,10*t-10):0,Bounce:t=>{let e,s=4;for(;t<((e=st(2,--s))-1)/11;);return 1/st(4,3-s)-7.5625*st((3*e-2)/22-t,2)},Back:(t=1.7)=>e=>(+t+1)*e*e*e-+t*e*e,Elastic:(t=1,e=.3)=>{const s=ft(+t,1,10),i=ft(+e,u,2),r=i/Re*dt(1/s),n=Re/i;return t=>0===t||1===t?t:-s*st(2,-10*(1-t))*rt((1-t-r)*n)}},De=(()=>{const t={linear:$e,none:$e};for(let e in Ne)for(let s in Ae){const i=Ae[s],r=Ne[e];t[e+s]=s===g||"Back"===s||"Elastic"===s?(t,e)=>r(i(t,e)):r(i)}return t})(),Oe={linear:$e,none:$e},Ie=t=>{if(Oe[t])return Oe[t];if(t.indexOf("(")<=-1){const e=Ne[t]||t.includes("Back")||t.includes("Elastic")?De[t]():De[t];return e?Oe[t]=e:$e}{const e=t.slice(0,-1).split("("),s=De[e[0]];return s?Oe[t]=s(...e[1].split(",")):$e}},Le=["steps(","irregular(","linear(","cubicBezier("],Be=t=>{if(H(t))for(let e=0,s=Le.length;e<s;e++)if(P(t,Le[e]))return console.warn(`String syntax for \`ease: "${t}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${t}\``),$e;return Y(t)?t:H(t)?Ie(t):$e},Me=Ft(),Pe=Ft(),Fe={},Ve={func:null},Xe={func:null},ze=[null],He=[null,null],Ye={to:null};let Ue,We,qe=0,je=0;const Ge=(t,e)=>{const s={};if(V(t)){const e=[].concat(...t.map(t=>Object.keys(t))).filter(J);for(let i=0,r=e.length;i<r;i++){const r=e[i],n=t.map(t=>{const e={};for(let s in t){const i=t[s];J(s)?s===r&&(e.to=i):e[s]=i}return e});s[r]=n}}else{const i=Ot(e.duration,L.defaults.duration),r=Object.keys(t).map(e=>({o:parseFloat(e)/100,p:t[e]})).sort((t,e)=>t.o-e.o);r.forEach(t=>{const e=t.o,r=t.p;for(let t in r)if(J(t)){let n=s[t];n||(n=s[t]=[]);const o=e*i;let a=n.length,l=n[a-1];const h={to:r[t]};let d=0;for(let t=0;t<a;t++)d+=n[t].duration;1===a&&(h.from=l.to),r.ease&&(h.ease=r.ease),h.duration=o-(a?d:0),n.push(h)}return t});for(let t in s){const e=s[t];let i;for(let t=0,s=e.length;t<s;t++){const s=e[t],r=s.ease;s.ease=i||void 0,i=r}e[0].duration||e.shift()}}return s};class Ze extends ve{constructor(t,e,s,n,a=!1,l=0,h){super(e,s,n),++je;const d=xe(t),c=d.length,p=e.keyframes,f=p?xt(Ge(p,e),e):e,{id:g,delay:y,duration:v,ease:_,playbackEase:b,modifier:T,composition:x,onRender:S}=f,w=s?s.defaults:L.defaults,C=Ot(_,w.ease),$=Ot(b,w.playbackEase),E=$?Be($):null,N=!U(C.ease),k=N?C.ease:Ot(_,E?"linear":w.ease),R=N?C.settlingDuration:Ot(v,w.duration),A=Ot(y,w.delay),D=T||w.modifier,O=U(x)&&c>=m?o.none:U(x)?w.composition:x,I=this._offset+(s?s._offset:0);N&&(C.parent=this);let B=NaN,M=NaN,P=0,F=0;for(let t=0;t<c;t++){const e=d[t],n=l||t,c=h||d;let p=NaN,m=NaN;for(let t in f)if(J(t)){const l=Lt(e,t),h=jt(t,e,l);let d=f[t];const g=V(d);if(a&&!g&&(He[0]=d,He[1]=d,d=He),g){const t=d.length,e=!X(d[0]);2===t&&e?(Ye.to=d,ze[0]=Ye,Ue=ze):t>2&&e?(Ue=[],d.forEach((t,e)=>{e?1===e?(He[1]=t,Ue.push(He)):Ue.push(t):He[0]=t})):Ue=d}else ze[0]=d,Ue=ze;let y=null,v=null,_=NaN,b=0,T=0;for(let t=Ue.length;T<t;T++){const i=Ue[T];X(i)?We=i:(Ye.to=i,We=Ye),Ve.func=null,Xe.func=null;const a=It(Ot(We.composition,O),e,n,c,null,null),d=z(a)?a:o[a];y||d===o.none||(y=ae(e,h));const p=y?y._tail:null,m=s&&p&&p.parent.parent===s?p:v,f=It(We.to,e,n,c,Ve,m);let g;X(f)&&!U(f.to)?(We=f,g=f.to):g=f;const x=It(We.from,e,n,c,null,m),S=We.ease||k,w=It(S,e,n,c,null,m),C=Y(w)||H(w)?w:S,$=!U(C)&&!U(C.ease),E=$?C.ease:C,N=$?C.settlingDuration:It(Ot(We.duration,t>1?It(R,e,n,c,null,m)/t:R),e,n,c,null,m),L=It(Ot(We.delay,T?0:A),e,n,c,null,m),B=We.modifier||D,M=!U(x),q=!U(g),j=V(g),G=j||M&&q,Z=v?b+L:L,Q=gt(I+Z,12);F||!M&&!j||(F=1);let J=v;if(d!==o.none){let t=y._head;for(;t&&!t._isOverridden&&t._absoluteStartTime<=Q;)if(J=t,t=t._nextRep,t&&t._absoluteStartTime>=Q)for(;t;)he(t),t=t._nextRep}if(G){Vt(j?It(g[0],e,n,c,Xe,m):x,Me),Vt(j?It(g[1],e,n,c,Ve,m):g,Pe);const t=Mt(e,h,l,Fe);Me.t===r.NUMBER&&(J?J._valueType===r.UNIT&&(Me.t=r.UNIT,Me.u=J._unit):(Vt(t,zt),zt.t===r.UNIT&&(Me.t=r.UNIT,Me.u=zt.u)))}else q?Vt(g,Pe):v?Xt(v,Pe):Vt(s&&J&&J.parent.parent===s?J._value:Mt(e,h,l,Fe),Pe),M?Vt(x,Me):v?Xt(v,Me):Vt(s&&J&&J.parent.parent===s?J._value:Mt(e,h,l,Fe),Me);if(Me.o&&(Me.n=Pt(J?J._toNumber:Vt(Mt(e,h,l,Fe),zt).n,Me.n,Me.o)),Pe.o&&(Pe.n=Pt(Me.n,Pe.n,Pe.o)),Me.t!==Pe.t)if(Me.t===r.COMPLEX||Pe.t===r.COMPLEX){const t=Me.t===r.COMPLEX?Me:Pe,e=Me.t===r.COMPLEX?Pe:Me;e.t=r.COMPLEX,e.s=Tt(t.s),e.d=t.d.map(()=>e.n)}else if(Me.t===r.UNIT||Pe.t===r.UNIT){const t=Me.t===r.UNIT?Me:Pe,e=Me.t===r.UNIT?Pe:Me;e.t=r.UNIT,e.u=t.u}else if(Me.t===r.COLOR||Pe.t===r.COLOR){const t=Me.t===r.COLOR?Me:Pe,e=Me.t===r.COLOR?Pe:Me;e.t=r.COLOR,e.s=t.s,e.d=[0,0,0,1]}if(Me.u!==Pe.u){let t=Pe.u?Me:Pe;t=Ce(e,t,Pe.u?Pe.u:Me.u,!1)}if(Pe.d&&Me.d&&Pe.d.length!==Me.d.length){const t=Me.d.length>Pe.d.length?Me:Pe,e=t===Me?Pe:Me;e.d=t.d.map((t,s)=>U(e.d[s])?0:e.d[s]),e.s=Tt(t.s)}const K=gt(+N||u,12);let tt=Fe[h];W(tt)||(Fe[h]=null);const et={parent:this,id:qe++,property:h,target:e,_value:null,_toFunc:Ve.func,_fromFunc:Xe.func,_ease:Be(E),_fromNumbers:Tt(Me.d),_toNumbers:Tt(Pe.d),_strings:Tt(Pe.s),_fromNumber:Me.n,_toNumber:Pe.n,_numbers:Tt(Me.d),_number:Me.n,_unit:Pe.u,_modifier:B,_currentTime:0,_startTime:Z,_delay:+L,_updateDuration:K,_changeDuration:K,_absoluteStartTime:Q,_tweenType:l,_valueType:Pe.t,_composition:d,_isOverlapped:0,_isOverridden:0,_renderTransforms:0,_inlineValue:tt,_prevRep:null,_nextRep:null,_prevAdd:null,_nextAdd:null,_prev:null,_next:null};d!==o.none&&de(et,y);const st=et._valueType;et._value=st===r.COMPLEX?Yt(et,1,-1):st===r.COLOR?Ht(et,1,-1):st===r.UNIT?`${B(et._toNumber)}${et._unit}`:B(et._toNumber),isNaN(_)&&(_=et._startTime),b=gt(Z+K,12),v=et,P++,Ct(this,et)}(isNaN(M)||_<M)&&(M=_),(isNaN(B)||b>B)&&(B=b),l===i.TRANSFORM&&(p=P-T,m=P)}if(!isNaN(p)){let t=0;St(this,e=>{t>=p&&t<m&&(e._renderTransforms=1,e._composition===o.blend&&St(Jt.animation,t=>{t.id===e.id&&(t._renderTransforms=1)})),t++})}}c||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation."),M?(St(this,t=>{t._startTime-t._delay||(t._delay-=M),t._startTime-=M}),B-=M):M=0,B||(B=u,this.iterationCount=0),this.targets=d,this.id=U(g)?je:g,this.duration=B===u?u:_t((B+this._loopDelay)*this.iterationCount-this._loopDelay)||u,this.onRender=S||w.onRender,this._ease=E,this._delay=M,this.iterationDuration=B,!this._autoplay&&F&&this.onRender(this)}stretch(t){const e=this.duration;if(e===bt(t))return this;const s=t/e;return St(this,t=>{t._updateDuration=bt(t._updateDuration*s),t._changeDuration=bt(t._changeDuration*s),t._currentTime*=s,t._startTime*=s,t._absoluteStartTime*=s}),super.stretch(t)}refresh(){return St(this,t=>{const e=t._toFunc,s=t._fromFunc;(e||s)&&(s?(Vt(s(),Me),Me.u!==t._unit&&t.target[l]&&Ce(t.target,Me,t._unit,!0),t._fromNumbers=Tt(Me.d),t._fromNumber=Me.n):e&&(Vt(Mt(t.target,t.property,t._tweenType),zt),t._fromNumbers=Tt(zt.d),t._fromNumber=zt.n),e&&(Vt(e(),Pe),t._toNumbers=Tt(Pe.d),t._strings=Tt(Pe.s),t._toNumber=Pe.o?Pt(t._fromNumber,Pe.n,Pe.o):Pe.n))}),this.duration===u&&this.restart(),this}revert(){return super.revert(),Gt(this)}then(t){return super.then(t)}}const Qe=(t,e)=>L.editor?L.editor.addAnimation(t,e):new Ze(t,e,null,0,!1).init(),Je=(t,e)=>{if(P(e,"<")){const s="<"===e[1],i=t._tail,r=i?i._offset+i._delay:0;return s?r:r+i.duration}},Ke=(t,e)=>{let s=t.iterationDuration;if(s===u&&(s=0),U(e))return s;if(z(+e))return+e;const i=e,r=t?t.labels:null,n=!W(r),o=Je(t,i),a=!U(o),l=A.exec(i);if(l){const t=l[0],e=i.split(t),h=n&&e[0]?r[e[0]]:s,d=a?o:n?h:s,c=+e[1];return Pt(d,c,t[0])}return a?o:n?U(r[i])?s:r[i]:s};function ts(t){return _t((t.iterationDuration+t._loopDelay)*t.iterationCount-t._loopDelay)||u}function es(t,e,s,i,r,o){const a=z(t.duration)&&t.duration<=u?s-u:s;e.composition&&Wt(e,a,1,1,n.AUTO);const l=i?new Ze(i,t,e,a,!1,r,o):new ve(t,e,a);return e.composition&&l.init(!0),Ct(e,l),St(e,t=>{const s=t._offset+t._delay+t.duration;s>e.iterationDuration&&(e.iterationDuration=s)}),e.duration=ts(e),e}let ss=0;class is extends ve{constructor(t={}){super(t,null,0),++ss,this.id=U(t.id)?ss:t.id,this.duration=0,this.labels={};const e=t.defaults,s=L.defaults;this.defaults=e?xt(e,s):s,this.composition=Ot(t.composition,!0),this.onRender=t.onRender||s.onRender;const i=Ot(t.playbackEase,s.playbackEase);this._ease=i?Be(i):null,this.iterationDuration=0}add(t,e,s){const i=X(e),r=X(t);if(i||r){if(this._hasChildren=!0,i){const i=e,r=L.editor&&L.editor.addTimelineChild,n=s&&"Stagger"===s.type&&L.editor,o=Y(s)?s:null;if(o||n){const e=Te(t),n=this.duration,a=this.iterationDuration,l=i.id;let h=0;const d=e.length,c=r?r(t,i,this.id,s,d):null,u=o||L.editor.resolveStagger(s.defaultValue);e.forEach(t=>{const s={...c||i};this.duration=n,this.iterationDuration=a,U(l)||(s.id=l+"-"+h),es(s,this,Ke(this,u(t,h,e,null,this)),t,h,e),h++})}else{const e=r?r(t,i,this.id,s):i,n=s&&s.type?s.defaultValue:s;es(e,this,Ke(this,n),t)}}else es(t,this,Ke(this,e));return this.composition&&this.init(!0),this}}sync(t,e){if(U(t)||t&&U(t.pause))return this;t.pause();const s=+(t.effect?t.effect.getTiming().duration:t.duration);return U(t)||U(t.persist)||(t.persist=!0),this.add(t,{currentTime:[0,s],duration:s,delay:0,ease:"linear",playbackEase:"linear"},e)}set(t,e,s){return U(e)?this:(e.duration=u,e.composition=o.replace,this.add(t,e,s))}call(t,e){return U(t)||t&&!Y(t)?this:this.add({duration:0,delay:0,onComplete:()=>t(this)},e)}label(t,e){return U(t)||t&&!H(t)||(this.labels[t]=Ke(this,e)),this}remove(t,e){return pe(Te(t),this,e),this}stretch(t){const e=this.duration;if(e===bt(t))return this;const s=t/e,i=this.labels;St(this,t=>t.stretch(t.duration*s));for(let t in i)i[t]*=s;return super.stretch(t)}refresh(){return St(this,t=>{t.refresh&&t.refresh()}),this}revert(){return super.revert(),St(this,t=>t.revert,!0),Gt(this)}then(t){return super.then(t)}}const rs=t=>L.editor?L.editor.addTimeline(t):new is(t).init();class ns{constructor(t,e){I.current&&I.current.register(this);const s=()=>{if(this.callbacks.completed)return;let t=!0;for(let e in this.animations)if(!this.animations[e].paused&&t){t=!1;break}t&&this.callbacks.complete()},i={onBegin:()=>{this.callbacks.completed&&this.callbacks.reset(),this.callbacks.play()},onComplete:s,onPause:s},r={v:1,autoplay:!1},n={};if(this.targets=[],this.animations={},this.callbacks=null,!U(t)&&!U(e)){for(let t in e){const s=e[t];J(t)?n[t]=s:P(t,"on")?r[t]=s:i[t]=s}this.callbacks=new Ze({v:0},r);for(let e in n){const s=n[e],r=X(s);let a={},l="+=0";if(r){const t=s.unit;H(t)&&(l+=t)}else a.duration=s;a[e]=r?xt({to:l},s):l;const h=xt(i,a);h.composition=o.replace,h.autoplay=!1;const d=this.animations[e]=new Ze(t,h,null,0,!1).init();this.targets.length||this.targets.push(...d.targets),this[e]=(t,e,s)=>{const i=d._head;if(U(t)&&i){const t=i._numbers;return t&&t.length?t:i._modifier(i._number)}return St(d,e=>{if(V(t))for(let s=0,i=t.length;s<i;s++)U(e._numbers[s])||(e._fromNumbers[s]=e._modifier(e._numbers[s]),e._toNumbers[s]=t[s]);else e._fromNumber=e._modifier(e._number),e._toNumber=t;U(s)||(e._ease=Be(s)),e._currentTime=0}),U(e)||d.stretch(e),d.reset(!0).resume(),this}}}}revert(){for(let t in this.animations)this[t]=T,this.animations[t].revert();return this.animations={},this.targets.length=0,this.callbacks&&this.callbacks.revert(),this}}const os=(t,e)=>new ns(t,e),as=(t,e)=>(+t).toFixed(e),ls=(t,e,s)=>`${t}`.padStart(e,s),hs=(t,e,s)=>`${t}`.padEnd(e,s),ds=(t,e,s)=>((t-e)%(s-e)+(s-e))%(s-e)+e,cs=(t,e,s,i,r)=>i+(t-e)/(s-e)*(r-i),us=t=>t*Math.PI/180,ps=t=>180*t/Math.PI,ms=(t,e,s,i)=>i?1===i?e:vt(t,e,1-Math.exp(-i*s*.1)):t;var fs=Object.freeze({__proto__:null,clamp:ft,damp:ms,degToRad:us,lerp:vt,mapRange:cs,padEnd:hs,padStart:ls,radToDeg:ps,round:gt,roundPad:as,snap:yt,wrap:ds});const gs=10*m;class ys{constructor(t={}){const e=!U(t.bounce)||!U(t.duration);this.timeStep=.02,this.restThreshold=5e-4,this.restDuration=200,this.maxDuration=6e4,this.maxRestSteps=this.restDuration/this.timeStep/m,this.maxIterations=this.maxDuration/this.timeStep/m,this.bn=ft(Ot(t.bounce,.5),-1,1),this.pd=ft(Ot(t.duration,628),10*L.timeScale,gs*L.timeScale),this.m=ft(Ot(t.mass,1),1,gs),this.s=ft(Ot(t.stiffness,100),u,gs),this.d=ft(Ot(t.damping,10),u,gs),this.v=ft(Ot(t.velocity,0),-1e4,gs),this.w0=0,this.zeta=0,this.wd=0,this.b=0,this.completed=!1,this.solverDuration=0,this.settlingDuration=0,this.parent=null,this.onComplete=t.onComplete||T,e&&this.calculateSDFromBD(),this.compute(),this.ease=t=>{const e=t*this.settlingDuration,s=this.completed,i=this.pd;return e>=i&&!s&&(this.completed=!0,this.onComplete(this.parent)),e<i&&s&&(this.completed=!1),0===t||1===t?t:this.solve(t*this.solverDuration)}}solve(t){const{zeta:e,w0:s,wd:i,b:r}=this;let n=t;return n=e<1?at(-n*e*s)*(1*nt(i*n)+r*rt(i*n)):1===e?(1+r*n)*at(-n*s):((1+r)*at((-e*s+i)*n)+(1-r)*at((-e*s-i)*n))/2,1-n}calculateSDFromBD(){const t=1===L.timeScale?this.pd/m:this.pd;this.m=1,this.v=0,this.s=st(2*pt/t,2),this.bn>=0?this.d=4*(1-this.bn)*pt/t:this.d=4*pt/(t*(1+this.bn)),this.s=gt(ft(this.s,u,gs),3),this.d=gt(ft(this.d,u,300),3)}calculateBDFromSD(){const t=2*pt/it(this.s);this.pd=t*(1===L.timeScale?m:1);const e=this.d/(2*it(this.s));this.bn=e<=1?1-this.d*t/(4*pt):4*pt/(this.d*t)-1,this.bn=gt(ft(this.bn,-1,1),3),this.pd=gt(ft(this.pd,10*L.timeScale,gs*L.timeScale),3)}compute(){const{maxRestSteps:t,maxIterations:e,restThreshold:s,timeStep:i,m:r,d:n,s:o,v:a}=this,l=this.w0=ft(it(o/r),u,m),h=this.zeta=n/(2*it(o*r));h<1?(this.wd=l*it(1-h*h),this.b=(h*l-a)/this.wd):1===h?(this.wd=0,this.b=-a+l):(this.wd=l*it(h*h-1),this.b=(h*l-a)/this.wd);let d=0,c=0,p=0;for(;c<=t&&p<=e;)ot(1-this.solve(d))<s?c++:c=0,this.solverDuration=d,d+=i,p++;this.settlingDuration=gt(this.solverDuration*m,0)*L.timeScale}get bounce(){return this.bn}set bounce(t){this.bn=ft(Ot(t,1),-1,1),this.calculateSDFromBD(),this.compute()}get duration(){return this.pd}set duration(t){this.pd=ft(Ot(t,1),10*L.timeScale,gs*L.timeScale),this.calculateSDFromBD(),this.compute()}get stiffness(){return this.s}set stiffness(t){this.s=ft(Ot(t,100),u,gs),this.calculateBDFromSD(),this.compute()}get damping(){return this.d}set damping(t){this.d=ft(Ot(t,10),u,gs),this.calculateBDFromSD(),this.compute()}get mass(){return this.m}set mass(t){this.m=ft(Ot(t,1),1,gs),this.compute()}get velocity(){return this.v}set velocity(t){this.v=ft(Ot(t,0),-1e4,gs),this.compute()}}const vs=t=>new ys(t),_s=t=>(console.warn("createSpring() is deprecated use spring() instead"),new ys(t)),bs={_head:null,_tail:null},Ts=(t,e,s)=>{let i,r=bs._head;for(;r;){const n=r._next,o=r.$el===t,a=!e||r.property===e,l=!s||r.parent===s;if(o&&a&&l){i=r.animation;try{i.commitStyles()}catch{}i.cancel(),wt(bs,r);const t=r.parent;t&&(t._completed++,t.animations.length===t._completed&&(t.completed=!0,t.paused=!0,t.muteCallbacks||(t.onComplete(t),t._resolve(t))))}r=n}return i},xs=(t,e,s,i,r)=>{const n=e.animate(i,r),o=r.delay+ +r.duration*r.iterations;n.playbackRate=t._speed,t.paused&&n.pause(),t.duration<o&&(t.duration=o,t.controlAnimation=n),t.animations.push(n),Ts(e,s),Ct(bs,{parent:t,animation:n,$el:e,property:s,_next:null,_prev:null});const a=()=>Ts(e,s,t);return n.oncancel=a,n.onremove=a,t.persist||(n.onfinish=a),n};function Ss(t,e,s){const i=xe(t);if(!i.length)return;const[n]=i,o=Lt(n,e),a=jt(e,n,o);let l=Mt(n,a);if(U(s))return l;if(Vt(l,zt),zt.t===r.NUMBER||zt.t===r.UNIT){if(!1===s)return zt.n;{const t=Ce(n,zt,s,!1);return`${gt(t.n,L.precision)}${t.u}`}}}const ws=(t,e)=>{if(!U(e))return e.duration=u,e.composition=Ot(e.composition,o.none),new Ze(t,e,null,0,!0).resume()},Cs=(t,e,s)=>{const i=Te(t);for(let t=0,r=i.length;t<r;t++)Ts(i[t],s,e&&e.controlAnimation&&e);return pe(i,e,s),i},$s=t=>{t.cancelable&&t.preventDefault()};class Es{constructor(t){this.el=t,this.zIndex=0,this.parentElement=null,this.classList={add:T,remove:T}}get x(){return this.el.x||0}set x(t){this.el.x=t}get y(){return this.el.y||0}set y(t){this.el.y=t}get width(){return this.el.width||0}set width(t){this.el.width=t}get height(){return this.el.height||0}set height(t){this.el.height=t}getBoundingClientRect(){return{top:this.y,right:this.x,bottom:this.y+this.height,left:this.x+this.width}}}class Ns{constructor(t){this.$el=t,this.inlineTransforms=[],this.point=new DOMPoint,this.inversedMatrix=this.getMatrix().inverse()}normalizePoint(t,e){return this.point.x=t,this.point.y=e,this.point.matrixTransform(this.inversedMatrix)}traverseUp(t){let e=this.$el.parentElement,i=0;for(;e&&e!==s;)t(e,i),e=e.parentElement,i++}getMatrix(){const t=new DOMMatrix;return this.traverseUp(e=>{const s=getComputedStyle(e).transform;if(s){const e=new DOMMatrix(s);t.preMultiplySelf(e)}}),t}remove(){this.traverseUp((t,e)=>{this.inlineTransforms[e]=t.style.transform,t.style.transform="none"})}revert(){this.traverseUp((t,e)=>{const s=this.inlineTransforms[e];""===s?t.style.removeProperty("transform"):t.style.transform=s})}}const ks=(t,e)=>t&&Y(t)?t(e):t;let Rs=0;class As{constructor(t,i={}){if(!t)return;I.current&&I.current.register(this);const r=i.x,n=i.y,o=i.trigger,a=i.modifier,l=i.releaseEase,h=l&&Be(l),d=!U(l)&&!U(l.ease),c=X(r)&&!U(r.mapTo)?r.mapTo:"translateX",u=X(n)&&!U(n.mapTo)?n.mapTo:"translateY",m=ks(i.container,this);this.containerArray=V(m)?m:null,this.$container=m&&!this.containerArray?Te(m)[0]:s.body,this.useWin=this.$container===s.body,this.$scrollContainer=this.useWin?e:this.$container,this.$target=X(t)?new Es(t):Te(t)[0],this.$trigger=Te(o||t)[0],this.fixed="fixed"===Ss(this.$target,"position"),this.isFinePointer=!0,this.containerPadding=[0,0,0,0],this.containerFriction=0,this.releaseContainerFriction=0,this.snapX=0,this.snapY=0,this.scrollSpeed=0,this.scrollThreshold=0,this.dragSpeed=0,this.dragThreshold=3,this.maxVelocity=0,this.minVelocity=0,this.velocityMultiplier=0,this.cursor=!1,this.releaseXSpring=d?l:vs({mass:Ot(i.releaseMass,1),stiffness:Ot(i.releaseStiffness,80),damping:Ot(i.releaseDamping,20)}),this.releaseYSpring=d?l:vs({mass:Ot(i.releaseMass,1),stiffness:Ot(i.releaseStiffness,80),damping:Ot(i.releaseDamping,20)}),this.releaseEase=h||De.outQuint,this.hasReleaseSpring=d,this.onGrab=i.onGrab||T,this.onDrag=i.onDrag||T,this.onRelease=i.onRelease||T,this.onUpdate=i.onUpdate||T,this.onSettle=i.onSettle||T,this.onSnap=i.onSnap||T,this.onResize=i.onResize||T,this.onAfterResize=i.onAfterResize||T,this.disabled=[0,0];const f={};if(a&&(f.modifier=a),U(r)||!0===r)f[c]=0;else if(X(r)){const t=r,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[c]=e}else!1===r&&(f[c]=0,this.disabled[0]=1);if(U(n)||!0===n)f[u]=0;else if(X(n)){const t=n,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[u]=e}else!1===n&&(f[u]=0,this.disabled[1]=1);this.animate=new ns(this.$target,f),this.xProp=c,this.yProp=u,this.destX=0,this.destY=0,this.deltaX=0,this.deltaY=0,this.scroll={x:0,y:0},this.coords=[this.x,this.y,0,0],this.snapped=[0,0],this.pointer=[0,0,0,0,0,0,0,0],this.scrollView=[0,0],this.dragArea=[0,0,0,0],this.containerBounds=[-p,p,p,-p],this.scrollBounds=[0,0,0,0],this.targetBounds=[0,0,0,0],this.window=[0,0],this.velocityStack=[0,0,0],this.velocityStackIndex=0,this.velocityTime=F(),this.velocity=0,this.angle=0,this.cursorStyles=null,this.triggerStyles=null,this.bodyStyles=null,this.targetStyles=null,this.touchActionStyles=null,this.transforms=new Ns(this.$target),this.overshootCoords={x:0,y:0},this.overshootTicker=new ve({autoplay:!1,onUpdate:()=>{this.updated=!0,this.manual=!0,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,1),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,1)},onComplete:()=>{this.manual=!1,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,0),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,0)}},null,0).init(),this.updateTicker=new ve({autoplay:!1,onUpdate:()=>this.update()},null,0).init(),this.contained=!U(m),this.manual=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.enabled=!1,this.initialized=!1,this.activeProp=this.disabled[1]?c:u,this.animate.callbacks.onRender=()=>{const t=this.updated,e=!(this.grabbed&&t)&&this.released,s=this.x,i=this.y,r=s-this.coords[2],n=i-this.coords[3];this.deltaX=r,this.deltaY=n,this.coords[2]=s,this.coords[3]=i,t&&(r||n)&&this.onUpdate(this),e?(this.computeVelocity(r,n),this.angle=ut(n,r)):this.updated=!1},this.animate.callbacks.onComplete=()=>{!this.grabbed&&this.released&&(this.released=!1),this.manual||(this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.onSettle(this))},this.resizeTicker=new ve({autoplay:!1,duration:150*L.timeScale,onComplete:()=>{this.onResize(this),this.refresh(),this.onAfterResize(this)}}).init(),this.parameters=i,this.resizeObserver=new ResizeObserver(()=>{this.initialized?this.resizeTicker.restart():this.initialized=!0}),this.enable(),this.refresh(),this.resizeObserver.observe(this.$container),X(t)||this.resizeObserver.observe(this.$target)}computeVelocity(t,e){const s=this.velocityTime,i=F(),r=i-s;if(r<17)return this.velocity;this.velocityTime=i;const n=this.velocityStack,o=this.velocityMultiplier,a=this.minVelocity,l=this.maxVelocity,h=this.velocityStackIndex;n[h]=gt(ft(it(t*t+e*e)/r*o,a,l),5);const d=ct(n[0],n[1],n[2]);return this.velocity=d,this.velocityStackIndex=(h+1)%3,d}setX(t,e=!1){if(this.disabled[0])return;const s=gt(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destX=s,this.snapped[0]=yt(s,this.snapX),this.animate[this.xProp](s,0),this.manual=!1,this}setY(t,e=!1){if(this.disabled[1])return;const s=gt(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destY=s,this.snapped[1]=yt(s,this.snapY),this.animate[this.yProp](s,0),this.manual=!1,this}get x(){return gt(this.animate[this.xProp](),L.precision)}set x(t){this.setX(t,!1)}get y(){return gt(this.animate[this.yProp](),L.precision)}set y(t){this.setY(t,!1)}get progressX(){return cs(this.x,this.containerBounds[3],this.containerBounds[1],0,1)}set progressX(t){this.setX(cs(t,0,1,this.containerBounds[3],this.containerBounds[1]),!1)}get progressY(){return cs(this.y,this.containerBounds[0],this.containerBounds[2],0,1)}set progressY(t){this.setY(cs(t,0,1,this.containerBounds[0],this.containerBounds[2]),!1)}updateScrollCoords(){const t=gt(this.useWin?e.scrollX:this.$container.scrollLeft,0),s=gt(this.useWin?e.scrollY:this.$container.scrollTop,0),[i,r,n,o]=this.containerPadding,a=this.scrollThreshold;this.scroll.x=t,this.scroll.y=s,this.scrollBounds[0]=s-this.targetBounds[0]+i-a,this.scrollBounds[1]=t-this.targetBounds[1]-r+a,this.scrollBounds[2]=s-this.targetBounds[2]-n+a,this.scrollBounds[3]=t-this.targetBounds[3]+o-a}updateBoundingValues(){const t=this.$container;if(!t)return;const i=this.x,r=this.y,n=this.coords[2],o=this.coords[3];this.coords[2]=0,this.coords[3]=0,this.setX(0,!0),this.setY(0,!0),this.transforms.remove();const a=this.window[0]=e.innerWidth,l=this.window[1]=e.innerHeight,h=this.useWin,d=t.scrollWidth,c=t.scrollHeight,u=this.fixed,p=t.getBoundingClientRect(),[m,f,g,y]=this.containerPadding;this.dragArea[0]=h?0:p.left,this.dragArea[1]=h?0:p.top,this.scrollView[0]=h?ft(d,a,d):d,this.scrollView[1]=h?ft(c,l,c):c,this.updateScrollCoords();const{width:v,height:_,left:b,top:T,right:x,bottom:S}=t.getBoundingClientRect();this.dragArea[2]=gt(h?ft(v,a,a):v,0),this.dragArea[3]=gt(h?ft(_,l,l):_,0);const w=Ss(t,"overflow"),C="visible"===w,$="hidden"===w;if(this.canScroll=!u&&this.contained&&(t===s.body&&C||!$&&!C)&&(d>this.dragArea[2]+y-f||c>this.dragArea[3]+m-g)&&(!this.containerArray||this.containerArray&&!V(this.containerArray)),this.contained){const e=this.scroll.x,s=this.scroll.y,i=this.canScroll,r=this.$target.getBoundingClientRect(),n=i?h?0:t.scrollLeft:0,o=i?h?0:t.scrollTop:0,d=i?this.scrollView[0]-n-v:0,c=i?this.scrollView[1]-o-_:0;this.targetBounds[0]=gt(r.top+s-(h?0:T),0),this.targetBounds[1]=gt(r.right+e-(h?a:x),0),this.targetBounds[2]=gt(r.bottom+s-(h?l:S),0),this.targetBounds[3]=gt(r.left+e-(h?0:b),0),this.containerArray?(this.containerBounds[0]=this.containerArray[0]+m,this.containerBounds[1]=this.containerArray[1]-f,this.containerBounds[2]=this.containerArray[2]-g,this.containerBounds[3]=this.containerArray[3]+y):(this.containerBounds[0]=-gt(r.top-(u?ft(T,0,l):T)+o-m,0),this.containerBounds[1]=-gt(r.right-(u?ft(x,0,a):x)-d+f,0),this.containerBounds[2]=-gt(r.bottom-(u?ft(S,0,l):S)-c+g,0),this.containerBounds[3]=-gt(r.left-(u?ft(b,0,a):b)+n-y,0))}this.transforms.revert(),this.coords[2]=n,this.coords[3]=o,this.setX(i,!0),this.setY(r,!0)}isOutOfBounds(t,e,s){if(!this.contained)return 0;const[i,r,n,o]=t,[a,l]=this.disabled,h=!a&&e<o||!a&&e>r,d=!l&&s<i||!l&&s>n;return h&&!d?1:!h&&d?2:h&&d?3:0}refresh(){const t=this.parameters,i=t.x,r=t.y,n=ks(t.container,this),o=ks(t.containerPadding,this)||0,a=V(o)?o:[o,o,o,o],l=this.x,h=this.y,d=ks(t.cursor,this),c={onHover:"grab",onGrab:"grabbing"};if(d){const{onHover:t,onGrab:e}=d;t&&(c.onHover=t),e&&(c.onGrab=e)}const u=ks(t.dragThreshold,this),p={mouse:3,touch:7};if(z(u))p.mouse=u,p.touch=u;else if(u){const{mouse:t,touch:e}=u;U(t)||(p.mouse=t),U(e)||(p.touch=e)}this.containerArray=V(n)?n:null,this.$container=n&&!this.containerArray?Te(n)[0]:s.body,this.useWin=this.$container===s.body,this.$scrollContainer=this.useWin?e:this.$container,this.isFinePointer=matchMedia("(pointer:fine)").matches,this.containerPadding=Ot(a,[0,0,0,0]),this.containerFriction=ft(Ot(ks(t.containerFriction,this),.8),0,1),this.releaseContainerFriction=ft(Ot(ks(t.releaseContainerFriction,this),this.containerFriction),0,1),this.snapX=ks(X(i)&&!U(i.snap)?i.snap:t.snap,this),this.snapY=ks(X(r)&&!U(r.snap)?r.snap:t.snap,this),this.scrollSpeed=Ot(ks(t.scrollSpeed,this),1.5),this.scrollThreshold=Ot(ks(t.scrollThreshold,this),20),this.dragSpeed=Ot(ks(t.dragSpeed,this),1),this.dragThreshold=this.isFinePointer?p.mouse:p.touch,this.minVelocity=Ot(ks(t.minVelocity,this),0),this.maxVelocity=Ot(ks(t.maxVelocity,this),50),this.velocityMultiplier=Ot(ks(t.velocityMultiplier,this),1),this.cursor=!1!==d&&c,this.updateBoundingValues();const[m,f,g,y]=this.containerBounds;this.setX(ft(l,y,f),!0),this.setY(ft(h,m,g),!0)}update(){if(this.updateScrollCoords(),this.canScroll){const[t,e,s,i]=this.containerPadding,[r,n]=this.scrollView,o=this.dragArea[2],a=this.dragArea[3],l=this.scroll.x,h=this.scroll.y,d=this.$container.scrollWidth,c=this.$container.scrollHeight,u=this.useWin?ft(d,this.window[0],d):d,p=this.useWin?ft(c,this.window[1],c):c,m=r-u,f=n-p;this.dragged&&m>0&&(this.coords[0]-=m,this.scrollView[0]=u),this.dragged&&f>0&&(this.coords[1]-=f,this.scrollView[1]=p);const g=10*this.scrollSpeed,y=this.scrollThreshold,[v,_]=this.coords,[b,T,x,S]=this.scrollBounds,w=gt(ft((_-b+t)/y,-1,0)*g,0),C=gt(ft((v-T-e)/y,0,1)*g,0),$=gt(ft((_-x-s)/y,0,1)*g,0),E=gt(ft((v-S+i)/y,-1,0)*g,0);if(w||$||E||C){const[t,e]=this.disabled;let s=l,i=h;t||(s=gt(ft(l+(E||C),0,r-o),0),this.coords[0]-=l-s),e||(i=gt(ft(h+(w||$),0,n-a),0),this.coords[1]-=h-i),this.useWin?this.$scrollContainer.scrollBy(-(l-s),-(h-i)):this.$scrollContainer.scrollTo(s,i)}}const[t,e,s,i]=this.containerBounds,[r,n,o,a,l,h]=this.pointer;this.coords[0]+=(r-l)*this.dragSpeed,this.coords[1]+=(n-h)*this.dragSpeed,this.pointer[4]=r,this.pointer[5]=n;const[d,c]=this.coords,[u,p]=this.snapped,m=(1-this.containerFriction)*this.dragSpeed;this.setX(d>e?e+(d-e)*m:d<i?i+(d-i)*m:d,!1),this.setY(c>s?s+(c-s)*m:c<t?t+(c-t)*m:c,!1),this.computeVelocity(r-l,n-h),this.angle=ut(n-a,r-o);const[f,g]=this.snapped;(f!==u&&this.snapX||g!==p&&this.snapY)&&this.onSnap(this)}stop(){this.updateTicker.pause(),this.overshootTicker.pause();for(let t in this.animate.animations)this.animate.animations[t].pause();return pe([this],null,"x"),pe([this],null,"y"),pe([this],null,"progressX"),pe([this],null,"progressY"),pe([this.scroll]),pe([this.overshootCoords]),this}scrollInView(t,e=0,s=De.inOutQuad){this.updateScrollCoords();const i=this.destX,r=this.destY,n=this.scroll,o=this.scrollBounds,a=this.canScroll;if(!this.containerArray&&this.isOutOfBounds(o,i,r)){const[l,h,d,c]=o,u=gt(ft(r-l,-p,0),0),m=gt(ft(i-h,0,p),0),f=gt(ft(r-d,0,p),0),g=gt(ft(i-c,-p,0),0);new Ze(n,{x:gt(n.x+(g?g-e:m?m+e:0),0),y:gt(n.y+(u?u-e:f?f+e:0),0),duration:U(t)?350*L.timeScale:t,ease:s,onUpdate:()=>{this.canScroll=!1,this.$scrollContainer.scrollTo(n.x,n.y)}}).init().then(()=>{this.canScroll=a})}return this}handleHover(){this.isFinePointer&&this.cursor&&!this.cursorStyles&&(this.cursorStyles=ws(this.$trigger,{cursor:this.cursor.onHover}))}animateInView(t,e=0,s=De.inOutQuad){this.stop(),this.updateBoundingValues();const i=this.x,r=this.y,[n,o,a,l]=this.containerPadding,h=this.scroll.y-this.targetBounds[0]+n+e,d=this.scroll.x-this.targetBounds[1]-o-e,c=this.scroll.y-this.targetBounds[2]-a-e,u=this.scroll.x-this.targetBounds[3]+l+e,p=this.isOutOfBounds([h,d,c,u],i,r);if(p){const[e,n]=this.disabled,o=ft(yt(i,this.snapX),u,d),a=ft(yt(r,this.snapY),h,c),l=U(t)?350*L.timeScale:t;e||1!==p&&3!==p||this.animate[this.xProp](o,l,s),n||2!==p&&3!==p||this.animate[this.yProp](a,l,s)}return this}handleDown(t){const e=t.target;if(this.grabbed||"range"===e.type)return;t.stopPropagation(),this.grabbed=!0,this.released=!1,this.stop(),this.updateBoundingValues();const i=t.changedTouches,r=i?i[0].clientX:t.clientX,n=i?i[0].clientY:t.clientY,{x:o,y:a}=this.transforms.normalizePoint(r,n),[l,h,d,c]=this.containerBounds,u=(1-this.containerFriction)*this.dragSpeed,p=this.x,m=this.y;this.coords[0]=this.coords[2]=u?p>h?h+(p-h)/u:p<c?c+(p-c)/u:p:p,this.coords[1]=this.coords[3]=u?m>d?d+(m-d)/u:m<l?l+(m-l)/u:m:m,this.pointer[0]=o,this.pointer[1]=a,this.pointer[2]=o,this.pointer[3]=a,this.pointer[4]=o,this.pointer[5]=a,this.pointer[6]=o,this.pointer[7]=a,this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null);const f=Ss(this.$target,"zIndex",!1);Rs=(f>Rs?f:Rs)+1,this.targetStyles=ws(this.$target,{zIndex:Rs}),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.isFinePointer&&this.cursor&&(this.bodyStyles=ws(s.body,{cursor:this.cursor.onGrab})),this.scrollInView(100,0,De.out(3)),this.onGrab(this),s.addEventListener("touchmove",this),s.addEventListener("touchend",this),s.addEventListener("touchcancel",this),s.addEventListener("mousemove",this),s.addEventListener("mouseup",this),s.addEventListener("selectstart",this)}handleMove(t){if(!this.grabbed)return;const e=t.changedTouches,s=e?e[0].clientX:t.clientX,i=e?e[0].clientY:t.clientY,{x:r,y:n}=this.transforms.normalizePoint(s,i),o=r-this.pointer[6],a=n-this.pointer[7];let l=t.target,h=!1,d=!1,c=!1;for(;e&&l&&l!==this.$trigger;){const t=Ss(l,"overflow-y");if("hidden"!==t&&"visible"!==t){const{scrollTop:t,scrollHeight:e,clientHeight:s}=l;if(e>s){c=!0,h=t<=3,d=t>=e-s-3;break}}l=l.parentElement}c&&(!h&&!d||h&&a<0||d&&a>0)?(this.pointer[0]=r,this.pointer[1]=n,this.pointer[2]=r,this.pointer[3]=n,this.pointer[4]=r,this.pointer[5]=n,this.pointer[6]=r,this.pointer[7]=n):($s(t),this.triggerStyles||(this.triggerStyles=ws(this.$trigger,{pointerEvents:"none"})),this.$trigger.addEventListener("touchstart",$s,{passive:!1}),this.$trigger.addEventListener("touchmove",$s,{passive:!1}),this.$trigger.addEventListener("touchend",$s),(this.dragged||!this.disabled[0]&&ot(o)>this.dragThreshold||!this.disabled[1]&&ot(a)>this.dragThreshold)&&(this.updateTicker.resume(),this.pointer[2]=this.pointer[0],this.pointer[3]=this.pointer[1],this.pointer[0]=r,this.pointer[1]=n,this.dragged=!0,this.released=!1,this.onDrag(this)))}handleUp(){if(!this.grabbed)return;this.updateTicker.pause(),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null);const[t,e]=this.disabled,[i,r,n,a,l,h]=this.pointer,[d,c,u,p]=this.containerBounds,[m,f]=this.snapped,g=this.releaseXSpring,y=this.releaseYSpring,v=this.releaseEase,_=this.hasReleaseSpring,b=this.overshootCoords,T=this.x,x=this.y,S=this.computeVelocity(i-l,r-h),w=this.angle=ut(r-a,i-n),C=150*S,$=(1-this.releaseContainerFriction)*this.dragSpeed,E=T+nt(w)*C,N=x+rt(w)*C,k=E>c?c+(E-c)*$:E<p?p+(E-p)*$:E,R=N>u?u+(N-u)*$:N<d?d+(N-d)*$:N,A=this.destX=ft(gt(yt(k,this.snapX),5),p,c),D=this.destY=ft(gt(yt(R,this.snapY),5),d,u),O=this.isOutOfBounds(this.containerBounds,E,N);let I=0,B=0,M=v,P=v,F=0;if(b.x=T,b.y=x,!t){const t=A===c?T>c?-1:1:T<p?-1:1,s=gt(T-A,0);g.velocity=e&&_?s?C*t/ot(s):0:S;const{ease:i,settlingDuration:r,restDuration:n}=g;I=T===A?0:_?r:r-n*L.timeScale,_&&(M=i),I>F&&(F=I)}if(!e){const e=D===u?x>u?-1:1:x<d?-1:1,s=gt(x-D,0);y.velocity=t&&_?s?C*e/ot(s):0:S;const{ease:i,settlingDuration:r,restDuration:n}=y;B=x===D?0:_?r:r-n*L.timeScale,_&&(P=i),B>F&&(F=B)}if(!_&&O&&$&&(I||B)){const t=o.blend;new Ze(b,{x:{to:k,duration:.65*I},y:{to:R,duration:.65*B},ease:v,composition:t}).init(),new Ze(b,{x:{to:A,duration:I},y:{to:D,duration:B},ease:v,composition:t}).init(),this.overshootTicker.stretch(ct(I,B)).restart()}else t||this.animate[this.xProp](A,I,M),e||this.animate[this.yProp](D,B,P);this.scrollInView(F,this.scrollThreshold,v);let V=!1;A!==m&&(this.snapped[0]=A,this.snapX&&(V=!0)),D!==f&&this.snapY&&(this.snapped[1]=D,this.snapY&&(V=!0)),V&&this.onSnap(this),this.grabbed=!1,this.dragged=!1,this.updated=!0,this.released=!0,this.onRelease(this),this.$trigger.removeEventListener("touchstart",$s),this.$trigger.removeEventListener("touchmove",$s),this.$trigger.removeEventListener("touchend",$s),s.removeEventListener("touchmove",this),s.removeEventListener("touchend",this),s.removeEventListener("touchcancel",this),s.removeEventListener("mousemove",this),s.removeEventListener("mouseup",this),s.removeEventListener("selectstart",this)}reset(){return this.stop(),this.resizeTicker.pause(),this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.setX(0,!0),this.setY(0,!0),this.coords[0]=0,this.coords[1]=0,this.pointer[0]=0,this.pointer[1]=0,this.pointer[2]=0,this.pointer[3]=0,this.pointer[4]=0,this.pointer[5]=0,this.pointer[6]=0,this.pointer[7]=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this}enable(){return this.enabled||(this.enabled=!0,this.$target.classList.remove("is-disabled"),this.touchActionStyles=ws(this.$trigger,{touchAction:this.disabled[0]?"pan-x":this.disabled[1]?"pan-y":"none"}),this.$trigger.addEventListener("touchstart",this,{passive:!0}),this.$trigger.addEventListener("mousedown",this,{passive:!0}),this.$trigger.addEventListener("mouseenter",this)),this}disable(){return this.enabled=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.touchActionStyles.revert(),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null),this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null),this.$target.classList.add("is-disabled"),this.$trigger.removeEventListener("touchstart",this),this.$trigger.removeEventListener("mousedown",this),this.$trigger.removeEventListener("mouseenter",this),s.removeEventListener("touchmove",this),s.removeEventListener("touchend",this),s.removeEventListener("touchcancel",this),s.removeEventListener("mousemove",this),s.removeEventListener("mouseup",this),s.removeEventListener("selectstart",this),this}revert(){return this.reset(),this.disable(),this.$target.classList.remove("is-disabled"),this.updateTicker.revert(),this.overshootTicker.revert(),this.resizeTicker.revert(),this.animate.revert(),this.resizeObserver.disconnect(),this}handleEvent(t){switch(t.type){case"mousedown":case"touchstart":this.handleDown(t);break;case"mousemove":case"touchmove":this.handleMove(t);break;case"mouseup":case"touchend":case"touchcancel":this.handleUp();break;case"mouseenter":this.handleHover();break;case"selectstart":$s(t)}}}const Ds=(t,e)=>new As(t,e),Os=(t=T)=>new ve({duration:1*L.timeScale,onComplete:t},null,0).resume(),Is=t=>{let e;return(...s)=>{let i,r,n,o,a;e&&(i=e.currentIteration,r=e.iterationProgress,n=e.reversed,o=e._alternate,a=e._startTime,e.revert());const l=t(...s);return l&&!Y(l)&&l.revert&&(e=l),U(r)||(e.currentIteration=i,e.iterationProgress=(o&&i%2?!n:n)?1-r:r,e._startTime=a),l||T}};class Ls{constructor(t={}){I.current&&I.current.register(this);const i=t.root;let r=s;i&&(r=i.current||i.nativeElement||Te(i)[0]||s);const n=t.defaults,o=L.defaults,a=t.mediaQueries;if(this.defaults=n?xt(n,o):o,this.root=r,this.constructors=[],this.revertConstructors=[],this.revertibles=[],this.constructorsOnce=[],this.revertConstructorsOnce=[],this.revertiblesOnce=[],this.once=!1,this.onceIndex=0,this.methods={},this.matches={},this.mediaQueryLists={},this.data={},a)for(let t in a){const s=e.matchMedia(a[t]);this.mediaQueryLists[t]=s,s.addEventListener("change",this)}}register(t){(this.once?this.revertiblesOnce:this.revertibles).push(t)}execute(t){let e=I.current,s=I.root,i=L.defaults;I.current=this,I.root=this.root,L.defaults=this.defaults;const r=this.mediaQueryLists;for(let t in r)this.matches[t]=r[t].matches;const n=t(this);return I.current=e,I.root=s,L.defaults=i,n}refresh(){return this.onceIndex=0,this.execute(()=>{let t=this.revertibles.length,e=this.revertConstructors.length;for(;t--;)this.revertibles[t].revert();for(;e--;)this.revertConstructors[e](this);this.revertibles.length=0,this.revertConstructors.length=0,this.constructors.forEach(t=>{const e=t(this);Y(e)&&this.revertConstructors.push(e)})}),this}add(t,e){if(this.once=!1,Y(t)){const e=t;this.constructors.push(e),this.execute(()=>{const t=e(this);Y(t)&&this.revertConstructors.push(t)})}else this.methods[t]=(...t)=>this.execute(()=>e(...t));return this}addOnce(t){if(this.once=!0,Y(t)){const e=this.onceIndex++;if(this.constructorsOnce[e])return this;const s=t;this.constructorsOnce[e]=s,this.execute(()=>{const t=s(this);Y(t)&&this.revertConstructorsOnce.push(t)})}return this}keepTime(t){this.once=!0;const e=this.onceIndex++,s=this.constructorsOnce[e];if(Y(s))return s(this);const i=Is(t);let r;return this.constructorsOnce[e]=i,this.execute(()=>{r=i(this)}),r}handleEvent(t){"change"===t.type&&this.refresh()}revert(){const t=this.revertibles,e=this.revertConstructors,s=this.revertiblesOnce,i=this.revertConstructorsOnce,r=this.mediaQueryLists;let n=t.length,o=e.length,a=s.length,l=i.length;for(;n--;)t[n].revert();for(;o--;)e[o](this);for(;a--;)s[a].revert();for(;l--;)i[l](this);for(let t in r)r[t].removeEventListener("change",this);t.length=0,e.length=0,this.constructors.length=0,s.length=0,i.length=0,this.constructorsOnce.length=0,this.onceIndex=0,this.matches={},this.methods={},this.mediaQueryLists={},this.data={}}}const Bs=t=>new Ls(t),Ms=()=>{const t=s.createElement("div");s.body.appendChild(t),t.style.height="100lvh";const e=t.offsetHeight;return s.body.removeChild(t),e},Ps=(t,e)=>t&&Y(t)?t(e):t,Fs=new Map;class Vs{constructor(t){this.element=t,this.useWin=this.element===s.body,this.winWidth=0,this.winHeight=0,this.width=0,this.height=0,this.left=0,this.top=0,this.scale=1,this.zIndex=0,this.scrollX=0,this.scrollY=0,this.prevScrollX=0,this.prevScrollY=0,this.scrollWidth=0,this.scrollHeight=0,this.velocity=0,this.backwardX=!1,this.backwardY=!1,this.scrollTicker=new ve({autoplay:!1,onBegin:()=>this.dataTimer.resume(),onUpdate:()=>{const t=this.backwardX||this.backwardY;St(this,t=>t.handleScroll(),t)},onComplete:()=>this.dataTimer.pause()}).init(),this.dataTimer=new ve({autoplay:!1,frameRate:30,onUpdate:t=>{const e=t.deltaTime,s=this.prevScrollX,i=this.prevScrollY,r=this.scrollX,n=this.scrollY,o=s-r,a=i-n;this.prevScrollX=r,this.prevScrollY=n,o&&(this.backwardX=s>r),a&&(this.backwardY=i>n),this.velocity=gt(e>0?Math.sqrt(o*o+a*a)/e:0,5)}}).init(),this.resizeTicker=new ve({autoplay:!1,duration:250*L.timeScale,onComplete:()=>{this.updateWindowBounds(),this.refreshScrollObservers(),this.handleScroll()}}).init(),this.wakeTicker=new ve({autoplay:!1,duration:500*L.timeScale,onBegin:()=>{this.scrollTicker.resume()},onComplete:()=>{this.scrollTicker.pause()}}).init(),this._head=null,this._tail=null,this.updateScrollCoords(),this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll(),this.resizeObserver=new ResizeObserver(()=>this.resizeTicker.restart()),this.resizeObserver.observe(this.element),(this.useWin?e:this.element).addEventListener("scroll",this,!1)}updateScrollCoords(){const t=this.useWin,s=this.element;this.scrollX=gt(t?e.scrollX:s.scrollLeft,0),this.scrollY=gt(t?e.scrollY:s.scrollTop,0)}updateWindowBounds(){this.winWidth=e.innerWidth,this.winHeight=Ms()}updateBounds(){const t=getComputedStyle(this.element),e=this.element;let s,i;if(this.scrollWidth=e.scrollWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),this.scrollHeight=e.scrollHeight+parseFloat(t.marginTop)+parseFloat(t.marginBottom),this.updateWindowBounds(),this.useWin)s=this.winWidth,i=this.winHeight;else{const t=e.getBoundingClientRect();s=e.clientWidth,i=e.clientHeight,this.top=t.top,this.left=t.left,this.scale=t.width?s/t.width:t.height?i/t.height:1}this.width=s,this.height=i}refreshScrollObservers(){St(this,t=>{t._debug&&t.removeDebug()}),this.updateBounds(),St(this,t=>{t.refresh(),t.onResize(t),t._debug&&t.debug()})}refresh(){this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll()}handleScroll(){this.updateScrollCoords(),this.wakeTicker.restart()}handleEvent(t){"scroll"===t.type&&this.handleScroll()}revert(){this.scrollTicker.cancel(),this.dataTimer.cancel(),this.resizeTicker.cancel(),this.wakeTicker.cancel(),this.resizeObserver.disconnect(),(this.useWin?e:this.element).removeEventListener("scroll",this),Fs.delete(this.element)}}const Xs=t=>{const e=t&&Te(t)[0]||s.body;let i=Fs.get(e);return i||(i=new Vs(e),Fs.set(e,i)),i},zs=(t,e,s,i,r)=>{const n="min"===e,o="max"===e,a="top"===e||"left"===e||"start"===e||n?0:"bottom"===e||"right"===e||"end"===e||o?"100%":"center"===e?"50%":e,{n:l,u:h}=Vt(a,zt);let d=l;return"%"===h?d=l/100*s:h&&(d=Ce(t,zt,"px",!0).n),o&&i<0&&(d+=i),n&&r>0&&(d+=r),d},Hs=(t,e,s,i,r)=>{let n;if(H(e)){const o=A.exec(e);if(o){const a=o[0],l=a[0],h=e.split(a),d="min"===h[0],c="max"===h[0],u=zs(t,h[0],s,i,r),p=zs(t,h[1],s,i,r);if(d){const e=Pt(zs(t,"min",s),p,l);n=e<u?u:e}else if(c){const e=Pt(zs(t,"max",s),p,l);n=e>u?u:e}else n=Pt(u,p,l)}else n=zs(t,e,s,i,r)}else n=e;return gt(n,0)},Ys=t=>{let e;const s=t.targets;for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i[l]){e=i;break}}return e};let Us=0;const Ws=["#FF4B4B","#FF971B","#FFC730","#F9F640","#7AFF5A","#18FF74","#17E09B","#3CFFEC","#05DBE9","#33B3F1","#638CF9","#C563FE","#FF4FCF","#F93F8A"];class qs{constructor(t={}){I.current&&I.current.register(this);const e=Ot(t.sync,"play pause"),i=e?Be(e):null,r=e&&("linear"===e||e===$e),n=e&&!(i===$e&&!r),o=e&&(z(e)||!0===e||r),a=e&&H(e)&&!n&&!o,l=a?e.split(" ").map(t=>()=>{const e=this.linked;return e&&e[t]?e[t]():null}):null,h=a&&l.length>2;this.index=Us++,this.id=U(t.id)?this.index:t.id,this.container=Xs(t.container),this.target=null,this.linked=null,this.repeat=null,this.horizontal=null,this.enter=null,this.leave=null,this.sync=n||o||!!l,this.syncEase=n?i:null,this.syncSmooth=o?!0===e||r?1:e:null,this.onSyncEnter=l&&!h&&l[0]?l[0]:T,this.onSyncLeave=l&&!h&&l[1]?l[1]:T,this.onSyncEnterForward=l&&h&&l[0]?l[0]:T,this.onSyncLeaveForward=l&&h&&l[1]?l[1]:T,this.onSyncEnterBackward=l&&h&&l[2]?l[2]:T,this.onSyncLeaveBackward=l&&h&&l[3]?l[3]:T,this.onEnter=t.onEnter||T,this.onLeave=t.onLeave||T,this.onEnterForward=t.onEnterForward||T,this.onLeaveForward=t.onLeaveForward||T,this.onEnterBackward=t.onEnterBackward||T,this.onLeaveBackward=t.onLeaveBackward||T,this.onUpdate=t.onUpdate||T,this.onResize=t.onResize||T,this.onSyncComplete=t.onSyncComplete||T,this.reverted=!1,this.ready=!1,this.completed=!1,this.began=!1,this.isInView=!1,this.forceEnter=!1,this.hasEntered=!1,this.offset=0,this.offsetStart=0,this.offsetEnd=0,this.distance=0,this.prevProgress=0,this.thresholds=["start","end","end","start"],this.coords=[0,0,0,0],this.debugStyles=null,this.$debug=null,this._params=t,this._debug=Ot(t.debug,!1),this._next=null,this._prev=null,Ct(this.container,this),Os(()=>{if(!this.reverted){if(!this.target){const e=Te(t.target)[0];this.target=e||s.body,this.refresh()}this._debug&&this.debug()}})}link(t){if(t&&(t.pause(),this.linked=t,U(t)||U(t.persist)||(t.persist=!0),!this._params.target)){let e;U(t.targets)?St(t,t=>{t.targets&&!e&&(e=Ys(t))}):e=Ys(t),this.target=e||s.body,this.refresh()}return this}get velocity(){return this.container.velocity}get backward(){return this.horizontal?this.container.backwardX:this.container.backwardY}get scroll(){return this.horizontal?this.container.scrollX:this.container.scrollY}get progress(){const t=(this.scroll-this.offsetStart)/this.distance;return t===1/0||isNaN(t)?0:gt(ft(t,0,1),6)}refresh(){this.ready=!0,this.reverted=!1;const t=this._params;return this.repeat=Ot(Ps(t.repeat,this),!0),this.horizontal="x"===Ot(Ps(t.axis,this),"y"),this.enter=Ot(Ps(t.enter,this),"end start"),this.leave=Ot(Ps(t.leave,this),"start end"),this.updateBounds(),this.handleScroll(),this}removeDebug(){return this.$debug&&(this.$debug.parentNode.removeChild(this.$debug),this.$debug=null),this.debugStyles&&(this.debugStyles.revert(),this.$debug=null),this}debug(){this.removeDebug();const t=this.container,e=this.horizontal,i=t.element.querySelector(":scope > .animejs-onscroll-debug"),r=s.createElement("div"),n=s.createElement("div"),o=s.createElement("div"),a=Ws[this.index%Ws.length],l=t.useWin,h=l?t.winWidth:t.width,d=l?t.winHeight:t.height,c=t.scrollWidth,u=t.scrollHeight,p=this.container.width>360?320:260,m=e?0:10,f=e?10:0,g=e?24:p/2,y=e?g:15,v=e?60:g,_=e?v:y,b=e?"repeat-x":"repeat-y",T=t=>e?"0px "+t+"px":t+"px 2px",x=t=>`linear-gradient(${e?90:0}deg, ${t} 2px, transparent 1px)`,S=(t,e,s,i,r)=>`position:${t};left:${e}px;top:${s}px;width:${i}px;height:${r}px;`;r.style.cssText=`${S("absolute",m,f,e?c:p,e?p:u)}\n pointer-events: none;\n z-index: ${this.container.zIndex++};\n display: flex;\n flex-direction: ${e?"column":"row"};\n filter: drop-shadow(0px 1px 0px rgba(0,0,0,.75));\n `,n.style.cssText=`${S("sticky",0,0,e?h:g,e?g:d)}`,i||(n.style.cssText+=`background:\n ${x("#FFFF")}${T(g-10)} / 100px 100px ${b},\n ${x("#FFF8")}${T(g-10)} / 10px 10px ${b};\n `),o.style.cssText=`${S("relative",0,0,e?c:g,e?g:u)}`,i||(o.style.cssText+=`background:\n ${x("#FFFF")}${T(0)} / ${e?"100px 10px":"10px 100px"} ${b},\n ${x("#FFF8")}${T(0)} / ${e?"10px 0px":"0px 10px"} ${b};\n `);const w=[" enter: "," leave: "];this.coords.forEach((t,i)=>{const r=i>1,l=(r?0:this.offset)+t,m=i%2,f=l<_,g=l>(r?e?h:d:e?c:u)-_,b=(r?m&&!f:!m&&!f)||g,T=s.createElement("div"),x=s.createElement("div"),C=e?b?"right":"left":b?"bottom":"top",$=b?(e?v:y)+(r?e?-1:g?0:-2:e?-1:-2):e?1:0;x.innerHTML=`${this.id}${w[m]}${this.thresholds[i]}`,T.style.cssText=`${S("absolute",0,0,v,y)}\n display: flex;\n flex-direction: ${e?"column":"row"};\n justify-content: flex-${r?"start":"end"};\n align-items: flex-${b?"end":"start"};\n border-${C}: 2px solid ${a};\n `,x.style.cssText=`\n overflow: hidden;\n max-width: ${p/2-10}px;\n height: ${y};\n margin-${e?b?"right":"left":b?"bottom":"top"}: -2px;\n padding: 1px;\n font-family: ui-monospace, monospace;\n font-size: 10px;\n letter-spacing: -.025em;\n line-height: 9px;\n font-weight: 600;\n text-align: ${e&&b||!e&&!r?"right":"left"};\n white-space: pre;\n text-overflow: ellipsis;\n color: ${m?a:"rgba(0,0,0,.75)"};\n background-color: ${m?"rgba(0,0,0,.65)":a};\n border: 2px solid ${m?a:"transparent"};\n border-${e?b?"top-left":"top-right":b?"top-left":"bottom-left"}-radius: 5px;\n border-${e?b?"bottom-left":"bottom-right":b?"top-right":"bottom-right"}-radius: 5px;\n `,T.appendChild(x);let E=l-$+(e?1:0);T.style[e?"left":"top"]=`${E}px`,(r?n:o).appendChild(T)}),r.appendChild(n),r.appendChild(o),t.element.appendChild(r),i||r.classList.add("animejs-onscroll-debug"),this.$debug=r,"static"===Ss(t.element,"position")&&(this.debugStyles=ws(t.element,{position:"relative "}))}updateBounds(){let t;this._debug&&this.removeDebug();const e=this.target,i=this.container,r=this.horizontal,n=this.linked;let o,a=e;for(n&&(o=n.currentTime,n.seek(0,!0));a&&a!==i.element&&a!==s.body;){const e="sticky"===Ss(a,"position")&&ws(a,{position:"static"});a=a.parentElement,e&&(t||(t=[]),t.push(e))}const l=e.getBoundingClientRect(),h=i.scale,d=(r?l.left+i.scrollX-i.left:l.top+i.scrollY-i.top)*h,c=(r?l.width:l.height)*h,u=r?i.width:i.height,p=(r?i.scrollWidth:i.scrollHeight)-u,m=this.enter,f=this.leave;let g="start",y="end",v="end",_="start";if(H(m)){const t=m.split(" ");v=t[0],g=t.length>1?t[1]:g}else if(X(m)){const t=m;U(t.container)||(v=t.container),U(t.target)||(g=t.target)}else z(m)&&(v=m);if(H(f)){const t=f.split(" ");_=t[0],y=t.length>1?t[1]:y}else if(X(f)){const t=f;U(t.container)||(_=t.container),U(t.target)||(y=t.target)}else z(f)&&(_=f);const b=Hs(e,g,c),T=Hs(e,y,c),x=b+d-u,S=T+d-p,w=Hs(e,v,u,x,S),C=Hs(e,_,u,x,S),$=b+d-w,E=T+d-C,N=E-$;this.offset=d,this.offsetStart=$,this.offsetEnd=E,this.distance=N<=0?0:N,this.thresholds=[g,y,v,_],this.coords=[b,T,w,C],t&&t.forEach(t=>t.revert()),n&&n.seek(o,!0),this._debug&&this.debug()}handleScroll(){if(!this.ready)return;const t=this.linked,e=this.sync,s=this.syncEase,i=this.syncSmooth,r=t&&(s||i),n=this.horizontal,o=this.container,a=this.scroll,l=a<=this.offsetStart,h=a>=this.offsetEnd,d=!l&&!h,c=a===this.offsetStart||a===this.offsetEnd,u=!this.hasEntered&&c,p=this._debug&&this.$debug;let m=!1,f=!1,g=this.progress;if(l&&this.began&&(this.began=!1),g>0&&!this.began&&(this.began=!0),r){const e=t.progress;if(i&&z(i)){if(i<1){const t=1e-4,s=e<g&&1===g?t:e>g&&!g?-t:0;g=gt(vt(e,g,vt(.01,.2,i))+s,6)}}else s&&(g=s(g));m=g!==this.prevProgress,f=1===e,m&&!f&&i&&e&&o.wakeTicker.restart()}if(p){const t=n?o.scrollY:o.scrollX;p.style[n?"top":"left"]=t+10+"px"}(d&&!this.isInView||u&&!this.forceEnter&&!this.hasEntered)&&(d&&(this.isInView=!0),this.forceEnter&&this.hasEntered?d&&(this.forceEnter=!1):(p&&d&&(p.style.zIndex=""+this.container.zIndex++),this.onSyncEnter(this),this.onEnter(this),this.backward?(this.onSyncEnterBackward(this),this.onEnterBackward(this)):(this.onSyncEnterForward(this),this.onEnterForward(this)),this.hasEntered=!0,u&&(this.forceEnter=!0))),(d||!d&&this.isInView)&&(m=!0),m&&(r&&t.seek(t.duration*g),this.onUpdate(this)),!d&&this.isInView&&(this.isInView=!1,this.onSyncLeave(this),this.onLeave(this),this.backward?(this.onSyncLeaveBackward(this),this.onLeaveBackward(this)):(this.onSyncLeaveForward(this),this.onLeaveForward(this)),e&&!i&&(f=!0)),g>=1&&this.began&&!this.completed&&(e&&f||!e)&&(e&&this.onSyncComplete(this),this.completed=!0,(!this.repeat&&!t||!this.repeat&&t&&t.completed)&&this.revert()),g<1&&this.completed&&(this.completed=!1),this.prevProgress=g}revert(){if(this.reverted)return;const t=this.container;return wt(t,this),t._head||t.revert(),this._debug&&this.removeDebug(),this.reverted=!0,this.ready=!1,this}}const js=(t={})=>new qs(t),Gs=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,Zs=(t,e,s)=>{let i,r,n=0,o=1,a=0;do{r=n+(o-n)/2,i=Gs(r,e,s)-t,i>0?o=r:n=r}while(ot(i)>1e-7&&++a<100);return r},Qs=(t=.5,e=0,s=.5,i=1)=>t===e&&s===i?$e:r=>0===r||1===r?r:Gs(Zs(r,t,s),e,i),Js=(t=10,e)=>{const s=e?lt:ht;return e=>s(ft(e,0,1)*t)*(1/t)},Ks=(...t)=>{const e=t.length;if(!e)return $e;const s=e-1,i=t[0],r=t[s],n=[0],o=[et(i)];for(let e=1;e<s;e++){const i=t[e],r=H(i)?i.trim().split(" "):[i],a=r[0],l=r[1];n.push(U(l)?e/s:et(l)/100),o.push(et(a))}return o.push(et(r)),n.push(1),function(t){for(let e=1,s=n.length;e<s;e++){const s=n[e];if(t<=s){const i=n[e-1],r=o[e-1];return r+(o[e]-r)*(t-i)/(s-i)}}return o[o.length-1]}},ti=(t=10,e=1)=>{const s=[0],i=t-1;for(let t=1;t<i;t++){const r=s[t-1],n=t/i,o=n*(1-e)+(n+((t+1)/i-n)*Math.random())*e;s.push(ft(o,r,1))}return s.push(1),Ks(...s)};var ei=Object.freeze({__proto__:null,Spring:ys,createSpring:_s,cubicBezier:Qs,eases:De,irregular:ti,linear:Ks,spring:vs,steps:Js});const si=(t,e=100)=>{const s=[];for(let i=0;i<=e;i++)s.push(gt(t(i/e),4));return`linear(${s.join(", ")})`},ii={},ri=t=>{let e=ii[t];if(e)return e;if(e="linear",H(t)){if(P(t,"linear")||P(t,"cubic-")||P(t,"steps")||P(t,"ease"))e=t;else if(P(t,"cubicB"))e=M(t);else{const s=Ie(t);Y(s)&&(e=s===$e?"linear":si(s))}ii[t]=e}else if(Y(t)){const s=si(t);s&&(e=s)}else t.ease&&(e=si(t.ease));return e},ni=["x","y","z"],oi=["perspective","width","height","margin","padding","top","right","bottom","left","borderWidth","fontSize","borderRadius",...ni],ai=(()=>[...ni,..._.filter(t=>["X","Y","Z"].some(e=>t.endsWith(e)))])();let li=null;const hi=(t,e,s,i,r)=>{let n=H(e)?e:It(e,s,i,r,null,null);return z(n)?oi.includes(t)||P(t,"translate")?`${n}px`:P(t,"rotate")||P(t,"skew")?`${n}deg`:`${n}`:n},di=(t,e,s,i,r,n)=>{let o="0";const a=U(i)?getComputedStyle(t)[e]:hi(e,i,t,r,n);return o=U(s)?V(i)?i.map(s=>hi(e,s,t,r,n)):a:[hi(e,s,t,r,n),a],o};class ci{constructor(e,s){I.current&&I.current.register(this),W(li)&&(!t||!U(CSS)&&Object.hasOwnProperty.call(CSS,"registerProperty")?(_.forEach(t=>{const e=P(t,"skew"),s=P(t,"scale"),i=P(t,"rotate"),r=P(t,"translate"),n=i||e,o=n?"<angle>":s?"<number>":r?"<length-percentage>":"*";try{CSS.registerProperty({name:"--"+t,syntax:o,inherits:!1,initialValue:r?"0px":n?"0deg":s?"1":"0"})}catch{}}),li=!0):li=!1);const i=xe(e);i.length||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation.");const r=Ot(s.autoplay,L.defaults.autoplay),n=!(!r||!r.link)&&r,o=s.alternate&&!0===s.alternate,a=s.reversed&&!0===s.reversed,l=Ot(s.loop,L.defaults.loop),h=!0===l||l===1/0?1/0:z(l)?l+1:1,c=o?a?"alternate-reverse":"alternate":a?"reverse":"normal",u=1===L.timeScale?1:m;this.targets=i,this.animations=[],this.controlAnimation=null,this.onComplete=s.onComplete||L.defaults.onComplete,this.duration=0,this.muteCallbacks=!1,this.completed=!1,this.paused=!r||!1!==n,this.reversed=a,this.persist=Ot(s.persist,L.defaults.persist),this.autoplay=r,this._speed=Ot(s.playbackRate,L.defaults.playbackRate),this._resolve=T,this._completed=0,this._inlineStyles=[],i.forEach((t,e)=>{const r=t[d],n=ai.some(t=>s.hasOwnProperty(t)),o=t.style,a=this._inlineStyles[e]={},l=Ot(s.ease,L.defaults.ease),p=It(l,t,e,i,null,null),m=Y(p)||H(p)?p:l,f=l.ease&&l,y=ri(m),T=(f?f.settlingDuration:It(Ot(s.duration,L.defaults.duration),t,e,i,null,null))*u,x=It(Ot(s.delay,L.defaults.delay),t,e,i,null,null)*u,S=Ot(s.composition,"replace");for(let l in s){if(!J(l))continue;const d={},p={iterations:h,direction:c,fill:"both",easing:y,duration:T,delay:x,composite:S},m=s[l],f=!!n&&(_.includes(l)?l:v.get(l)),g=f?"transform":l;let b;if(a[g]||(a[g]=o[g]),X(m)){const s=m,n=Ot(s.ease,y),a=n.ease&&n,h=s.to,c=s.from;if(p.duration=(a?a.settlingDuration:It(Ot(s.duration,T),t,e,i,null,null))*u,p.delay=It(Ot(s.delay,x),t,e,i,null,null)*u,p.composite=Ot(s.composition,S),p.easing=ri(n),b=di(t,l,c,h,e,i),f?(d[`--${f}`]=b,r[f]=b):d[l]=di(t,l,c,h,e,i),xs(this,t,l,d,p),!U(c))if(f){const t=`--${f}`;o.setProperty(t,d[t][0])}else o[l]=d[l][0]}else b=V(m)?m.map(s=>hi(l,s,t,e,i)):hi(l,m,t,e,i),f?(d[`--${f}`]=b,r[f]=b):d[l]=b,xs(this,t,l,d,p)}if(n){let t=g;for(let e in r)t+=`${b[e]}var(--${e})) `;o.transform=t}}),n&&this.autoplay.link(this)}forEach(t){try{const e=H(t)?e=>e[t]():t;this.animations.forEach(e)}catch{}return this}get speed(){return this._speed}set speed(t){this._speed=+t,this.forEach(e=>e.playbackRate=t)}get currentTime(){const t=this.controlAnimation,e=L.timeScale;return this.completed?this.duration:t?+t.currentTime*(1===e?1:e):0}set currentTime(t){const e=t*(1===L.timeScale?1:m);this.forEach(t=>{!this.persist&&e>=this.duration&&t.play(),t.currentTime=e})}get progress(){return this.currentTime/this.duration}set progress(t){this.forEach(e=>e.currentTime=t*this.duration||0)}resume(){return this.paused?(this.paused=!1,this.forEach("play")):this}pause(){return this.paused?this:(this.paused=!0,this.forEach("pause"))}alternate(){return this.reversed=!this.reversed,this.forEach("reverse"),this.paused&&this.forEach("pause"),this}play(){return this.reversed&&this.alternate(),this.resume()}reverse(){return this.reversed||this.alternate(),this.resume()}seek(t,e=!1){return e&&(this.muteCallbacks=!0),t<this.duration&&(this.completed=!1),this.currentTime=t,this.muteCallbacks=!1,this.paused&&this.pause(),this}restart(){return this.completed=!1,this.seek(0,!0).resume()}commitStyles(){return this.forEach("commitStyles")}complete(){return this.seek(this.duration)}cancel(){return this.muteCallbacks=!0,this.commitStyles().forEach("cancel"),this.animations.length=0,requestAnimationFrame(()=>{this.targets.forEach(t=>{"none"===t.style.transform&&t.style.removeProperty("transform")})}),this}revert(){return this.cancel().targets.forEach((t,e)=>{const s=t.style,i=this._inlineStyles[e];for(let e in i){const r=i[e];U(r)||r===g?s.removeProperty(M(e)):t.style[e]=r}t.getAttribute("style")===g&&t.removeAttribute("style")}),this}then(t=T){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=T};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const ui={animate:(t,e)=>new ci(t,e),convertEase:si};let pi=0,mi=0;const fi=(t,e)=>!(!t||!e)&&(t===e||t.contains(e)),gi=t=>{if(!t)return null;const e=t.style,s=e.transition||"";return e.setProperty("transition","none","important"),s},yi=(t,e)=>{if(!t)return;const s=t.style;e?s.transition=e:s.removeProperty("transition")},vi=t=>{const e=t.layout.transitionMuteStore,s=t.$el,i=t.$measure;s&&!e.has(s)&&e.set(s,gi(s)),i&&!e.has(i)&&e.set(i,gi(i))},_i=t=>{t.forEach((t,e)=>yi(e,t)),t.clear()},bi={display:"none",visibility:"hidden",opacity:"0",transform:"none",position:"static"},Ti=t=>{if(!t)return;const e=t.parentNode;e&&(e._head===t&&(e._head=t._next),e._tail===t&&(e._tail=t._prev),t._prev&&(t._prev._next=t._next),t._next&&(t._next._prev=t._prev),t._prev=null,t._next=null,t.parentNode=null)},xi=(t,e,s,i)=>{let r=t.dataset.layoutId;r||(r=t.dataset.layoutId="node-"+mi++);const n=i||{};return n.$el=t,n.$measure=t,n.id=r,n.index=0,n.targets=null,n.delay=0,n.duration=0,n.ease=null,n.state=s,n.layout=s.layout,n.parentNode=e||null,n.isTarget=!1,n.isEntering=!1,n.isLeaving=!1,n.isInlined=!1,n.hasTransform=!1,n.inlineStyles=[],n.inlineTransforms=null,n.inlineTransition=null,n.branchAdded=!1,n.branchRemoved=!1,n.branchNotRendered=!1,n.sizeChanged=!1,n.hasVisibilitySwap=!1,n.hasDisplayNone=!1,n.hasVisibilityHidden=!1,n.measuredInlineTransform=null,n.measuredInlineTransition=null,n.measuredDisplay=null,n.measuredVisibility=null,n.measuredPosition=null,n.measuredHasDisplayNone=!1,n.measuredHasVisibilityHidden=!1,n.measuredIsVisible=!1,n.measuredIsRemoved=!1,n.measuredIsInsideRoot=!1,n.properties={transform:"none",x:0,y:0,left:0,top:0,clientLeft:0,clientTop:0,width:0,height:0},n.layout.properties.forEach(t=>n.properties[t]=0),n._head=null,n._tail=null,n._prev=null,n._next=null,n},Si=(t,e,s,i)=>{const r=t.$el,n=t.layout.root,o=n===r,a=t.properties,l=t.state.rootNode,h=t.parentNode,d=s.transform,c=r.style.transform,u=!!h&&h.measuredIsRemoved,p=s.position;o&&(t.layout.absoluteCoords="fixed"===p||"absolute"===p),t.$measure=e,t.inlineTransforms=c,t.hasTransform=d&&"none"!==d,t.measuredIsInsideRoot=fi(n,e),t.measuredInlineTransform=null,t.measuredDisplay=s.display,t.measuredVisibility=s.visibility,t.measuredPosition=p,t.measuredHasDisplayNone="none"===s.display,t.measuredHasVisibilityHidden="hidden"===s.visibility,t.measuredIsVisible=!(t.measuredHasDisplayNone||t.measuredHasVisibilityHidden),t.measuredIsRemoved=t.measuredHasDisplayNone||t.measuredHasVisibilityHidden||u;let m=!1,f=r.previousSibling;for(;f&&(f.nodeType===Node.COMMENT_NODE||f.nodeType===Node.TEXT_NODE&&!f.textContent.trim());)f=f.previousSibling;if(f&&f.nodeType===Node.TEXT_NODE)m=!0;else{for(f=r.nextSibling;f&&(f.nodeType===Node.COMMENT_NODE||f.nodeType===Node.TEXT_NODE&&!f.textContent.trim());)f=f.nextSibling;m=null!==f&&f.nodeType===Node.TEXT_NODE}if(t.isInlined=m,t.hasTransform&&!i){const s=t.layout.transitionMuteStore;s.get(r)||(t.inlineTransition=gi(r)),e===r?r.style.transform="none":(s.get(e)||(t.measuredInlineTransition=gi(e)),t.measuredInlineTransform=e.style.transform,e.style.transform="none")}let g,y,v=0,_=0,b=0,T=0;if(!i){const t=e.getBoundingClientRect();v=t.left,_=t.top,b=t.width,T=t.height}for(let t in a){const e="transform"===t?d:s[t]||s.getPropertyValue&&s.getPropertyValue(t);U(e)||(a[t]=e)}if(a.left=v,a.top=_,a.clientLeft=i?0:e.clientLeft,a.clientTop=i?0:e.clientTop,o)t.layout.absoluteCoords?(g=v,y=_):(g=0,y=0);else{const e=h||l,s=e.properties.left,i=e.properties.top,r=e.properties.clientLeft,n=e.properties.clientTop;if(t.layout.absoluteCoords)g=v-s-r,y=_-i-n;else if(e===l){const t=l.properties.left,e=l.properties.top;g=v-t-l.properties.clientLeft,y=_-e-l.properties.clientTop}else g=v-s-r,y=_-i-n}return a.x=g,a.y=y,a.width=b,a.height=T,t},wi=(t,e)=>{if(e)for(let s in e)t.properties[s]=e[s]},Ci=(t,e)=>{const s=It(e.ease,t.$el,t.index,t.targets,null,null),i=Y(s)?s:e.ease,r=!U(i)&&!U(i.ease);t.ease=r?i.ease:i,t.duration=r?i.settlingDuration:It(e.duration,t.$el,t.index,t.targets,null,null),t.delay=It(e.delay,t.$el,t.index,t.targets,null,null)},$i=t=>{const e=t.$el.style,s=t.inlineStyles;s.length=0,t.layout.recordedProperties.forEach(t=>{s.push(t,e[t]||"")})},Ei=t=>{const e=t.$el.style,s=t.inlineStyles;for(let t=0,i=s.length;t<i;t+=2){const i=s[t],r=s[t+1];r&&""!==r?e[i]=r:(e[i]="",e.removeProperty(i))}},Ni=t=>{const e=t.inlineTransforms,s=t.$el.style;!t.hasTransform||!e||t.hasTransform&&"none"===s.transform||e&&"none"===e?s.removeProperty("transform"):e&&(s.transform=e);const i=t.$measure;if(t.hasTransform&&i!==t.$el){const e=i.style,s=t.measuredInlineTransform;s&&""!==s?e.transform=s:e.removeProperty("transform")}t.measuredInlineTransform=null,null!==t.inlineTransition&&(yi(t.$el,t.inlineTransition),t.inlineTransition=null),i!==t.$el&&null!==t.measuredInlineTransition&&(yi(i,t.measuredInlineTransition),t.measuredInlineTransition=null)},ki=t=>{(t.measuredIsRemoved||t.hasVisibilitySwap)&&(t.$el.style.removeProperty("display"),t.$el.style.removeProperty("visibility"),t.hasVisibilitySwap&&(t.$measure.style.removeProperty("display"),t.$measure.style.removeProperty("visibility"))),t.layout.pendingRemoval.delete(t.$el)},Ri=(t,e,s)=>(e.properties={...t.properties},e.state=s,e.isTarget=t.isTarget,e.hasTransform=t.hasTransform,e.inlineTransforms=t.inlineTransforms,e.measuredIsVisible=t.measuredIsVisible,e.measuredDisplay=t.measuredDisplay,e.measuredIsRemoved=t.measuredIsRemoved,e.measuredHasDisplayNone=t.measuredHasDisplayNone,e.measuredHasVisibilityHidden=t.measuredHasVisibilityHidden,e.hasDisplayNone=t.hasDisplayNone,e.isInlined=t.isInlined,e.hasVisibilityHidden=t.hasVisibilityHidden,e);class Ai{constructor(t){this.layout=t,this.rootNode=null,this.rootNodes=new Set,this.nodes=new Map,this.scrollX=0,this.scrollY=0}revert(){return this.forEachNode(t=>{this.layout.pendingRemoval.delete(t.$el),t.$el.removeAttribute("data-layout-id"),t.$measure.removeAttribute("data-layout-id")}),this.rootNode=null,this.rootNodes.clear(),this.nodes.clear(),this}getNode(t){if(t&&t.dataset)return this.nodes.get(t.dataset.layoutId)}getComputedValue(t,e){const s=this.getNode(t);if(s)return s.properties[e]}forEach(t,e){let s=t,i=0;for(;s;)if(e(s,i++),s._head)s=s._head;else if(s._next)s=s._next;else{for(;s&&!s._next;)s=s.parentNode;s&&(s=s._next)}}forEachRootNode(t){this.forEach(this.rootNode,t)}forEachNode(t){for(const e of this.rootNodes)this.forEach(e,t)}registerElement(t,e){if(!t||1!==t.nodeType)return null;this.layout.transitionMuteStore.has(t)||this.layout.transitionMuteStore.set(t,gi(t));const s=[t,e],i=this.layout.root;let r=null;for(;s.length;){const t=s.pop(),e=s.pop();if(!e||1!==e.nodeType||q(e))continue;const n=!!t&&t.measuredIsRemoved,o=n?bi:getComputedStyle(e),a=!!n||"none"===o.display,l=!!n||"hidden"===o.visibility,h=!a&&!l,d=e.dataset.layoutId,c=fi(i,e);let u=d?this.nodes.get(d):null;if(u&&u.$el!==e){const a=fi(i,u.$el),l=u.measuredIsVisible;if(a||!c&&(c||l||!h)){if(a&&!l&&h){Si(u,e,o,n);let t=e.lastElementChild;for(;t;)s.push(t,u),t=t.previousElementSibling;r||(r=u);continue}{let i=e.lastElementChild;for(;i;)s.push(i,t),i=i.previousElementSibling;r||(r=u);continue}}Ti(u),u=xi(e,t,this,u)}else u=xi(e,t,this,u);u.branchAdded=!1,u.branchRemoved=!1,u.branchNotRendered=!1,u.isTarget=!1,u.sizeChanged=!1,u.hasVisibilityHidden=l,u.hasDisplayNone=a,u.hasVisibilitySwap=l&&!u.measuredHasVisibilityHidden||a&&!u.measuredHasDisplayNone,this.nodes.set(u.id,u),u.parentNode=t||null,u._prev=null,u._next=null,t?(this.rootNodes.delete(u),t._head?(t._tail._next=u,u._prev=t._tail,t._tail=u):(t._head=u,t._tail=u)):this.rootNodes.add(u),Si(u,u.$el,o,n);let p=e.lastElementChild;for(;p;)s.push(p,u),p=p.previousElementSibling;r||(r=u)}return r}ensureDetachedNode(t,e){if(!t||t===this.layout.root)return null;const s=t.dataset.layoutId,i=s?this.nodes.get(s):null;if(i&&i.$el===t)return i;let r=null,n=t.parentElement;for(;n&&n!==this.layout.root;){if(e.has(n)){r=this.ensureDetachedNode(n,e);break}n=n.parentElement}return this.registerElement(t,r)}record(){const t=this.layout,e=t.children,s=t.root,i=V(e)?e:[e],r=[],n="*"===e?s:I.root,o=[];let a=s.parentElement;for(;a&&1===a.nodeType;){const t=getComputedStyle(a);if(t.transform&&"none"!==t.transform){const t=a.style.transform||"",e=gi(a);o.push(a,t,e),a.style.transform="none"}a=a.parentElement}for(let t=0,e=i.length;t<e;t++){const e=i[t];r[t]=H(e)?n.querySelectorAll(e):e}const l=xe(r);this.nodes.clear(),this.rootNodes.clear();const h=this.registerElement(s,null);h.isTarget=!0,this.rootNode=h;const d=new Set;let c=0;const u=[];this.nodes.forEach(t=>{u.push(t.$el)}),this.nodes.forEach((t,e)=>{t.index=c++,t.targets=u,t&&t.measuredIsInsideRoot&&d.add(e)});const p=new Set,m=[];for(let t=0,e=l.length;t<e;t++){const e=l[t];if(e&&1===e.nodeType&&e!==s){if(!fi(s,e)){const t=e.dataset.layoutId;if(!t||!d.has(t))continue}p.has(e)||(p.add(e),m.push(e))}}for(let t=0,e=m.length;t<e;t++)this.ensureDetachedNode(m[t],p);for(let t=0,e=l.length;t<e;t++){const e=l[t],s=this.getNode(e);if(s){let t=s;for(;t&&!t.isTarget;)t.isTarget=!0,t=t.parentNode}}this.scrollX=window.scrollX,this.scrollY=window.scrollY,this.forEachNode(Ni);for(let t=0,e=o.length;t<e;t+=3){const e=o[t],s=o[t+1],i=o[t+2];s&&""!==s?e.style.transform=s:e.style.removeProperty("transform"),yi(e,i)}return this}}function Di(t){const e={},s={};for(let i in t){const r=t[i];"duration"===i||"delay"===i||"ease"===i?s[i]=r:e[i]=r}return[e,s]}class Oi{constructor(t,e={}){I.current&&I.current.register(this);const s=Di(e.swapAt),i=Di(e.enterFrom),r=Di(e.leaveTo),n=e.properties;if(e.duration=Ot(e.duration,350),e.delay=Ot(e.delay,0),e.ease=Ot(e.ease,"inOut(3.5)"),this.params=e,this.root=xe(t)[0],this.id=e.id||pi++,this.children=e.children||"*",this.absoluteCoords=!1,this.swapAtParams=xt(e.swapAt||{opacity:0},{ease:"inOut(1.75)"}),this.enterFromParams=e.enterFrom||{opacity:0},this.leaveToParams=e.leaveTo||{opacity:0},this.properties=new Set(["opacity","fontSize","color","backgroundColor","borderRadius","border","filter","clipPath"]),s[0])for(let t in s[0])this.properties.add(t);if(i[0])for(let t in i[0])this.properties.add(t);if(r[0])for(let t in r[0])this.properties.add(t);if(n)for(let t=0,e=n.length;t<e;t++)this.properties.add(n[t]);this.recordedProperties=new Set(["display","visibility","translate","position","left","top","marginLeft","marginTop","width","height","maxWidth","maxHeight","minWidth","minHeight"]),this.properties.forEach(t=>this.recordedProperties.add(t)),this.pendingRemoval=new WeakSet,this.transitionMuteStore=new Map,this.oldState=new Ai(this),this.newState=new Ai(this),this.timeline=null,this.transformAnimation=null,this.animating=[],this.swapping=[],this.leaving=[],this.entering=[],this.oldState.record(),_i(this.transitionMuteStore)}revert(){return this.root.classList.remove("is-animated"),this.timeline&&(this.timeline.complete(),this.timeline=null),this.transformAnimation&&(this.transformAnimation.complete(),this.transformAnimation=null),this.animating.length=this.swapping.length=this.leaving.length=this.entering.length=0,this.oldState.revert(),this.newState.revert(),requestAnimationFrame(()=>_i(this.transitionMuteStore)),this}record(){return this.transformAnimation&&(this.transformAnimation.cancel(),this.transformAnimation=null),this.oldState.record(),this.timeline&&(this.timeline.cancel(),this.timeline=null),this.newState.forEachRootNode(Ei),this}animate(t={}){const e={ease:Ot(t.ease,this.params.ease),delay:Ot(t.delay,this.params.delay),duration:Ot(t.duration,this.params.duration)},s={id:this.id},i=Ot(t.onComplete,this.params.onComplete),r=Ot(t.onPause,this.params.onPause);for(let e in O)"ease"!==e&&"duration"!==e&&"delay"!==e&&(U(t[e])?U(this.params[e])||(s[e]=this.params[e]):s[e]=t[e]);s.onComplete=()=>{const e=t.autoplay,s=L.editor;if(e&&e.linked||s&&s.showPanel)i&&i(this.timeline);else{this.transformAnimation&&this.transformAnimation.cancel(),f.forEachRootNode(t=>{ki(t),Ei(t)});for(let t=0,e=S.length;t<e;t++){const e=S[t];e.style.transform=f.getComputedValue(e,"transform")}this.root.classList.contains("is-animated")&&(this.root.classList.remove("is-animated"),i&&i(this.timeline)),requestAnimationFrame(()=>{this.root.classList.contains("is-animated")||_i(this.transitionMuteStore)})}},s.onPause=()=>{const e=t.autoplay;if(e&&e.linked)return i&&i(this.timeline),void(r&&r(this.timeline));this.root.classList.contains("is-animated")&&(this.transformAnimation&&this.transformAnimation.cancel(),f.forEachRootNode(ki),this.root.classList.remove("is-animated"),i&&i(this.timeline),r&&r(this.timeline))},s.composition=!1;const n=xt(xt(t.swapAt||{},this.swapAtParams),e),o=xt(xt(t.enterFrom||{},this.enterFromParams),e),a=xt(xt(t.leaveTo||{},this.leaveToParams),e),[l,h]=Di(n),[d,c]=Di(o),[u,p]=Di(a),m=this.oldState,f=this.newState,g=this.animating,y=this.swapping,v=this.entering,_=this.leaving,b=this.pendingRemoval;g.length=y.length=v.length=_.length=0,m.forEachRootNode(vi),f.record(),f.forEachRootNode($i);const T=[],x=[],S=[],w=[],C=f.rootNode,$=C.$el;f.forEachRootNode(t=>{const e=t.$el,s=t.id,i=t.parentNode,r=!!i&&i.branchAdded,n=!!i&&i.branchRemoved,o=!!i&&i.branchNotRendered;let a=m.nodes.get(s);const l=!a;l?(a=Ri(t,{},m),m.nodes.set(s,a),a.measuredIsRemoved=!0):a.measuredIsRemoved&&!t.measuredIsRemoved&&(Ri(t,a,m),a.measuredIsRemoved=!0);const h=a.parentNode,c=(h?h.id:null)!==(i?i.id:null),p=a.$el!==t.$el,y=a.measuredIsRemoved,x=t.measuredIsRemoved;if(!a.measuredIsRemoved&&!x&&!l&&(c||p)){const t=a.properties.left,e=a.properties.top,s=i||f.rootNode,r=s.id?m.nodes.get(s.id):null,n=r?r.properties.left:s.properties.left,o=r?r.properties.top:s.properties.top,l=r?r.properties.clientLeft:s.properties.clientLeft,h=r?r.properties.clientTop:s.properties.clientTop;a.properties.x=t-n-l,a.properties.y=e-o-h}t.hasVisibilitySwap&&(t.hasVisibilityHidden&&(t.$el.style.visibility="visible",t.$measure.style.visibility="hidden"),t.hasDisplayNone&&(t.$el.style.display=a.measuredDisplay||t.measuredDisplay||"",t.$measure.style.visibility="hidden"));const S=b.has(e),w=a.measuredIsVisible,$=t.measuredIsVisible,E=!w&&$&&!o,N=!x&&(y||S)&&!r,k=x&&!y&&!n,R=k||x&&S&&!n;t.branchAdded=r||N,t.branchRemoved=n||R,t.branchNotRendered=o||x,x&&w&&(t.$el.style.display=a.measuredDisplay,t.$el.style.visibility="visible",Ri(a,t,f)),k?(t.isTarget&&(_.push(e),t.isLeaving=!0),b.add(e)):!x&&S&&b.delete(e),N&&!o||E?(wi(a,d),t.isTarget&&(v.push(e),t.isEntering=!0)):R&&!o&&wi(t,u),t===C||!t.isTarget||t.isEntering||t.isLeaving||g.push(e),T.push(e)});let E=0,N=0,k=0;f.forEachRootNode(t=>{const s=t.$el,i=t.parentNode,r=m.nodes.get(t.id),n=t.properties,o=r.properties;let a=i!==C&&i;for(;a&&!a.isTarget&&a!==C;)a=a.parentNode;t===C?(t.index=0,t.targets=g,Ci(t,e)):t.isEntering?(t.index=a?a.index:E,t.targets=a?g:v,Ci(t,c),E++):t.isLeaving?(t.index=a?a.index:N,t.targets=a?g:_,N++,Ci(t,p)):t.isTarget?(t.index=k++,t.targets=g,Ci(t,e)):(t.index=a?a.index:0,t.targets=g,Ci(t,h)),r.index=t.index,r.targets=t.targets;for(let e in n)n[e]=It(n[e],s,t.index,t.targets,null,null),o[e]=It(o[e],s,r.index,r.targets,null,null);const d=Math.abs(n.width-o.width)>1,u=Math.abs(n.height-o.height)>1;if(t.sizeChanged=d||u,t.isTarget&&(!t.measuredIsRemoved&&r.measuredIsVisible||t.measuredIsRemoved&&t.measuredIsVisible)){"none"===n.transform&&"none"===o.transform||(t.hasTransform=!0,S.push(s));for(let t in n)if("transform"!==t&&n[t]!==o[t]){x.push(s);break}}t.isTarget||(y.push(s),t.sizeChanged&&i&&i.isTarget&&i.sizeChanged&&(l.transform&&(t.hasTransform=!0,S.push(s)),w.push(s)))});const R={delay:t=>f.getNode(t).delay,duration:t=>f.getNode(t).duration,ease:t=>f.getNode(t).ease};if(s.defaults=R,this.timeline=rs(s),!x.length&&!S.length&&!y.length)return _i(this.transitionMuteStore),this.timeline.complete();if(T.length){this.root.classList.add("is-animated");for(let t=0,e=T.length;t<e;t++){const e=T[t],s=e.dataset.layoutId,i=m.nodes.get(s),r=f.nodes.get(s),n=i.properties;r.isInlined||("grid"!==i.measuredDisplay&&"grid"!==r.measuredDisplay||e.style.setProperty("display","block","important"),(e!==$||this.absoluteCoords)&&(e.style.position=this.absoluteCoords?"fixed":"absolute",e.style.left="0px",e.style.top="0px",e.style.marginLeft="0px",e.style.marginTop="0px",e.style.translate=`${n.x}px ${n.y}px`),e===$&&"static"===r.measuredPosition&&(e.style.position="relative",e.style.left="0px",e.style.top="0px")),e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none"}m.scrollX===window.scrollX&&m.scrollY===window.scrollY||requestAnimationFrame(()=>window.scrollTo(m.scrollX,m.scrollY));for(let t=0,e=x.length;t<e;t++){const e=x[t],s=e.dataset.layoutId,i=m.nodes.get(s),r=f.nodes.get(s),n=i.properties,o=r.properties;let a=!1;const l={composition:"none"};n.width!==o.width&&(l.width=[n.width,o.width],a=!0),n.height!==o.height&&(l.height=[n.height,o.height],a=!0),r.hasTransform||r.isInlined||(l.translate=[`${n.x}px ${n.y}px`,`${o.x}px ${o.y}px`],a=!0),this.properties.forEach(t=>{const e=n[t],s=o[t];"transform"!==t&&e!==s&&(l[t]=[e,s],a=!0)}),a&&this.timeline.add(e,l,0)}}if(y.length){for(let t=0,e=y.length;t<e;t++){const e=y[t],s=m.getNode(e),i=s.properties;e.style.width=`${i.width}px`,e.style.height=`${i.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none",s.isInlined||(e.style.translate=`${i.x}px ${i.y}px`),this.properties.forEach(t=>{"transform"!==t&&(e.style[t]=`${m.getComputedValue(e,t)}`)})}for(let t=0,e=y.length;t<e;t++){const e=y[t],s=f.getNode(e),i=s.properties;this.timeline.call(()=>{e.style.width=`${i.width}px`,e.style.height=`${i.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none",s.isInlined||(e.style.translate=`${i.x}px ${i.y}px`),this.properties.forEach(t=>{"transform"!==t&&(e.style[t]=`${f.getComputedValue(e,t)}`)})},s.delay+s.duration/2)}if(w.length){const t=Be(f.nodes.get(w[0].dataset.layoutId).ease),e=e=>1-t(1-e),s={};if(l)for(let t in l)"transform"!==t&&(s[t]=[{from:e=>m.getComputedValue(e,t),to:l[t]},{from:l[t],to:e=>f.getComputedValue(e,t),ease:e}]);this.timeline.add(w,s,0)}}const A=S.length;if(A){for(let t=0;t<A;t++){const e=S[t],s=f.getNode(e);s.isInlined||(e.style.translate=`${m.getComputedValue(e,"x")}px ${m.getComputedValue(e,"y")}px`),e.style.transform=m.getComputedValue(e,"transform"),w.includes(e)&&(s.ease=It(n.ease,e,s.index,s.targets,null,null),s.duration=It(n.duration,e,s.index,s.targets,null,null))}this.transformAnimation=ui.animate(S,{translate:t=>f.getNode(t).isInlined?"0px 0px":`${f.getComputedValue(t,"x")}px ${f.getComputedValue(t,"y")}px`,transform:t=>{const e=f.getComputedValue(t,"transform");if(!w.includes(t))return e;const s=m.getComputedValue(t,"transform"),i=f.getNode(t);return[s,It(l.transform,t,i.index,i.targets,null,null),e]},autoplay:!1,...R}),this.timeline.sync(this.transformAnimation,0)}return this.timeline.init()}update(t,e={}){return this.record(),t(this),this.animate(e)}}const Ii=(t,e)=>new Oi(t,e),Li=fs,Bi={},Mi=(t,e=0)=>(...s)=>e?e=>t(...s,e):e=>t(e,...s),Pi=t=>(...e)=>{const s=t(...e);return new Proxy(T,{apply:(t,e,[i])=>s(i),get:(t,e)=>{if(Bi[e])return Pi((...t)=>{const i=Bi[e](...t);return t=>i(s(t))})}})},Fi=(t,e,s=0)=>{const i=(...t)=>(t.length<e.length?Pi(Mi(e,s)):e)(...t);return Bi[t]||(Bi[t]=i),i},Vi=Fi("roundPad",Li.roundPad),Xi=Fi("padStart",Li.padStart),zi=Fi("padEnd",Li.padEnd),Hi=Fi("wrap",Li.wrap),Yi=Fi("mapRange",Li.mapRange),Ui=Fi("degToRad",Li.degToRad),Wi=Fi("radToDeg",Li.radToDeg),qi=Fi("snap",Li.snap),ji=Fi("clamp",Li.clamp),Gi=Fi("round",Li.round),Zi=Fi("lerp",Li.lerp,1),Qi=Fi("damp",Li.damp,1),Ji=(t=0,e=1,s=0)=>{const i=10**s;return Math.floor((Math.random()*(e-t+1/i)+t)*i)/i};let Ki=0;const tr=(t,e=0,s=1,i=0)=>{let r=void 0===t?Ki++:t;return(t=e,n=s,o=i)=>{r+=1831565813,r=Math.imul(r^r>>>15,1|r),r^=r+Math.imul(r^r>>>7,61|r);const a=10**o;return Math.floor((((r^r>>>14)>>>0)/4294967296*(n-t+1/a)+t)*a)/a}},er=t=>t[Ji(0,t.length-1)],sr=t=>{let e,s,i=t.length;for(;i;)s=Ji(0,--i),e=t[i],t[i]=t[s],t[s]=e;return t},ir=(t,e={})=>{let s,i=[],r=0;const n=e.from,o=e.reversed,a=e.ease,l=!U(a),h=l&&!U(a.ease)?a.ease:l?Be(a):null,d=e.grid,c=!0===d,u=e.axis,p=e.total,m=U(n)||0===n||"first"===n,f="center"===n,y="last"===n,v="random"===n,_=V(n),b=V(t),T=e.use,x=et(b?t[0]:t),S=b?et(t[1]):0,w=k.exec((b?t[1]:t)+g),C=e.start||0+(b?x:0);let $=m?0:z(n)?n:0;return(t,a,l,m,g)=>{const[E]=xe(t),N=U(p)?l.length:p,k=!U(T)&&(Y(T)?T(E,a,N):Mt(E,T)),R=z(k)||H(k)&&z(+k)?+k:a;if(f&&($=(N-1)/2),y&&($=N-1),!i.length){if(c){let t=!0,e=1/0,s=1/0,r=-1/0,o=-1/0;const a=[],h=[];for(let i=0;i<N;i++){const n=l[i];let d=0,c=0,u=!1;if(n&&Y(n.getBoundingClientRect)){const t=n.getBoundingClientRect();d=t.left+t.width/2,c=t.top+t.height/2,u=!0}else{const t=n;t&&z(t.x)&&z(t.y)&&(d=t.x,c=t.y,u=!0)}if(!u){t=!1;break}a.push(d),h.push(c),d<e&&(e=d),c<s&&(s=c),d>r&&(r=d),c>o&&(o=c)}if(t){let t=a[0],l=h[0];_?(t=e+n[0]*(r-e),l=s+n[1]*(o-s)):f?(t=(e+r)/2,l=(s+o)/2):y?(t=a[N-1],l=h[N-1]):z(n)&&(t=a[n],l=h[n]);for(let e=0;e<N;e++){const s=t-a[e],r=l-h[e];let n=it(s*s+r*r);"x"===u&&(n=-s),"y"===u&&(n=-r),i.push(n)}let d=1/0;for(let t=0,e=i.length;t<e;t++){const e=ot(i[t]);e>0&&e<d&&(d=e)}if(d>0&&d<1/0)for(let t=0,e=i.length;t<e;t++)i[t]=i[t]/d}else for(let t=0;t<N;t++)i.push(ot($-t))}else for(let t=0;t<N;t++)if(d){let e,s;_?(e=n[0]*(d[0]-1),s=n[1]*(d[1]-1)):f?(e=(d[0]-1)/2,s=(d[1]-1)/2):(e=$%d[0],s=ht($/d[0]));const r=e-t%d[0],o=s-ht(t/d[0]);let a=it(r*r+o*o);"x"===u&&(a=-r),"y"===u&&(a=-o),i.push(a)}else i.push(ot($-t));r=ct(...i),h&&(i=i.map(t=>h(t/r)*r)),o&&(i=i.map(t=>u?t<0?-1*t:-t:ot(r-t))),v&&(i=sr(i))}const A=b?(S-x)/r:x;U(s)&&(s=g?Ke(g,U(e.start)?g.iterationDuration:C):C);let D=s+(A*gt(i[R],2)||0);return e.modifier&&(D=e.modifier(D)),w&&(D=`${D}${w[2]}`),D}};var rr=Object.freeze({__proto__:null,$:xe,addChild:Ct,clamp:ji,cleanInlineStyles:Zt,createSeededRandom:tr,damp:Qi,degToRad:Ui,forEachChildren:St,get:Ss,keepTime:Is,lerp:Zi,mapRange:Yi,padEnd:zi,padStart:Xi,radToDeg:Wi,random:Ji,randomPick:er,remove:Cs,removeChild:wt,round:Gi,roundPad:Vi,set:ws,shuffle:sr,snap:qi,stagger:ir,sync:Os,wrap:Hi});const nr=t=>{const e=Te(t)[0];return e&&q(e)?e:console.warn(`${t} is not a valid SVGGeometryElement`)},or=(t,e,s,i,r)=>{const n=s+i,o=r?Math.max(0,Math.min(n,e)):(n%e+e)%e;return t.getPointAtLength(o)},ar=(t,e,s=0)=>i=>{const r=+t.getTotalLength(),n=i[h],o=t.getCTM(),a=0===s;return{from:0,to:r,modifier:i=>{const l=i+s*r;if("a"===e){const e=or(t,r,l,-1,a),s=or(t,r,l,1,a);return 180*ut(s.y-e.y,s.x-e.x)/pt}{const s=or(t,r,l,0,a);return"x"===e?n||!o?s.x:s.x*o.a+s.y*o.c+o.e:n||!o?s.y:s.x*o.b+s.y*o.d+o.f}}}},lr=(t,e=0)=>{const s=nr(t);if(s)return{translateX:ar(s,"x",e),translateY:ar(s,"y",e),rotate:ar(s,"a",e)}},hr=t=>{let e=1;if(t&&t.getCTM){const s=t.getCTM();s&&(e=(it(s.a*s.a+s.b*s.b)+it(s.c*s.c+s.d*s.d))/2)}return e},dr=(t,e,s)=>{const i=m,r=getComputedStyle(t),n=r.strokeLinecap,o="non-scaling-stroke"===r.vectorEffect?t:null;let a=n;const l=new Proxy(t,{get(t,e){const s=t[e];return e===c?t:"setAttribute"===e?(...e)=>{if("draw"===e[0]){const s=e[1].split(" "),r=+s[0],l=+s[1],h=hr(o),d=-1e3*r*h,c=l*i*h+d,u=i*h+(0===r&&1===l||1===r&&0===l?0:10*h)-c;if("butt"!==n){const e=r===l?"butt":n;a!==e&&(t.style.strokeLinecap=`${e}`,a=e)}t.setAttribute("stroke-dashoffset",`${d}`),t.setAttribute("stroke-dasharray",`${c} ${u}`)}return Reflect.apply(s,t,e)}:Y(s)?(...e)=>Reflect.apply(s,t,e):s}});return"1000"!==t.getAttribute("pathLength")&&(t.setAttribute("pathLength","1000"),l.setAttribute("draw",`${e} ${s}`)),l},cr=(t,e=0,s=0)=>Te(t).map(t=>dr(t,e,s)),ur=(t,e=.33)=>(s,i,r,n)=>{if(!(s.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${s.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const o=nr(t);if(!o)throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");if(!(o.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${o.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const a="path"===s.tagName,l=a?" ":",",h=n?n._value:null;h&&s.setAttribute(a?"d":"points",h);let d="",c="";if(e){const t=s.getTotalLength(),i=o.getTotalLength(),r=Math.max(Math.ceil(t*e),Math.ceil(i*e));for(let e=0;e<r;e++){const n=e/(r-1),h=s.getPointAtLength(t*n),u=o.getPointAtLength(i*n),p=a?0===e?"M":"L":"";d+=p+gt(h.x,3)+l+h.y+" ",c+=p+gt(u.x,3)+l+u.y+" "}}else d=s.getAttribute(a?"d":"points"),c=o.getAttribute(a?"d":"points");return[d,c]};var pr=Object.freeze({__proto__:null,createDrawable:cr,createMotionPath:lr,morphTo:ur});const mr="undefined"!=typeof Intl&&Intl.Segmenter,fr=/\{value\}/g,gr=/\{i\}/g,yr=/(\s+)/,vr=/^\s+$/,_r="line",br="word",Tr="char",xr="data-line";let Sr=null,wr=null,Cr=null;const $r=t=>t.isWordLike||" "===t.segment||z(+t.segment),Er=t=>t.setAttribute("aria-hidden","true"),Nr=(t,e)=>[...t.querySelectorAll(`[data-${e}]:not([data-${e}] [data-${e}])`)],kr={line:"#00D672",word:"#FF4B4B",char:"#5A87FF"},Rr=t=>{if(!t.childElementCount&&!t.textContent.trim()){const e=t.parentElement;t.remove(),e&&Rr(e)}},Ar=(t,e,s)=>{const i=t.getAttribute(xr);if(null!==i&&+i!==e||"BR"===t.tagName){s.add(t);const e=t.previousSibling,i=t.nextSibling;e&&3===e.nodeType&&vr.test(e.textContent)&&s.add(e),i&&3===i.nodeType&&vr.test(i.textContent)&&s.add(i)}let r=t.childElementCount;for(;r--;)Ar(t.children[r],e,s);return s},Dr=(t,e={})=>{let s="";const i=H(e.class)?` class="${e.class}"`:"",r=Ot(e.clone,!1),n=Ot(e.wrap,!1),o=n?!0===n?"clip":n:!!r&&"clip";return n&&(s+=`<span${o?` style="overflow:${o};"`:""}>`),s+=`<span${i}${r?' style="position:relative;"':""} data-${t}="{i}">`,r?(s+="<span>{value}</span>",s+=`<span inert style="position:absolute;top:${"top"===r?"-100%":"bottom"===r?"100%":"0"};left:${"left"===r?"-100%":"right"===r?"100%":"0"};white-space:nowrap;">{value}</span>`):s+="{value}",s+="</span>",n&&(s+="</span>"),s},Or=(t,e,s,i,r,n,o,a,l)=>{const h=r===_r,d=r===Tr,c=`_${r}_`,u=Y(t)?t(s):t,p=h?"block":"inline-block";Cr.innerHTML=u.replace(fr,`<i class="${c}"></i>`).replace(gr,`${d?l:h?o:a}`);const m=Cr.content,f=m.firstElementChild,g=m.querySelector(`[data-${r}]`)||f,y=m.querySelectorAll(`i.${c}`),v=y.length;if(v){f.style.display=p,g.style.display=p,g.setAttribute(xr,`${o}`),h||(g.setAttribute("data-word",`${a}`),d&&g.setAttribute("data-char",`${l}`));let t=v;for(;t--;){const e=y[t],i=e.parentElement;i.style.display=p,h?i.innerHTML=s.innerHTML:i.replaceChild(s.cloneNode(!0),e)}e.push(g),i.appendChild(m)}else console.warn('The expression "{value}" is missing from the provided template.');return n&&(f.style.outline=`1px dotted ${kr[r]}`),f};class Ir{constructor(e,i={}){Sr||(Sr=mr?new mr([],{granularity:br}):{segment:t=>{const e=[],s=t.split(yr);for(let t=0,i=s.length;t<i;t++){const i=s[t];e.push({segment:i,isWordLike:!vr.test(i)})}return e}}),wr||(wr=mr?new mr([],{granularity:"grapheme"}):{segment:t=>[...t].map(t=>({segment:t}))}),!Cr&&t&&(Cr=s.createElement("template")),I.current&&I.current.register(this);const{words:r,chars:n,lines:o,accessible:a,includeSpaces:l,debug:h}=i,d=(e=V(e)?e[0]:e)&&e.nodeType?e:(be(e)||[])[0],c=!0===o?{}:o,u=!0===r||U(r)?{}:r,p=!0===n?{}:n;this.debug=Ot(h,!1),this.includeSpaces=Ot(l,!1),this.accessible=Ot(a,!0),this.linesOnly=c&&!u&&!p,this.lineTemplate=X(c)?Dr(_r,c):c,this.wordTemplate=X(u)||this.linesOnly?Dr(br,u):u,this.charTemplate=X(p)?Dr(Tr,p):p,this.$target=d,this.html=d&&d.innerHTML,this.lines=[],this.words=[],this.chars=[],this.effects=[],this.effectsCleanups=[],this.cache=null,this.ready=!1,this.width=0,this.resizeTimeout=null;const m=()=>this.html&&(c||u||p)&&this.split();this.resizeObserver=new ResizeObserver(()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{const t=d.offsetWidth;t!==this.width&&(this.width=t,m())},150)}),this.lineTemplate&&!this.ready?s.fonts.ready.then(m):m(),d?this.resizeObserver.observe(d):console.warn("No Text Splitter target found.")}addEffect(t){if(!Y(t))return console.warn("Effect must return a function."),this;const e=Is(t);return this.effects.push(e),this.ready&&(this.effectsCleanups[this.effects.length-1]=e(this)),this}revert(){return clearTimeout(this.resizeTimeout),this.lines.length=this.words.length=this.chars.length=0,this.resizeObserver.disconnect(),this.effectsCleanups.forEach(t=>Y(t)?t(this):t.revert&&t.revert()),this.$target.innerHTML=this.html,this}splitNode(t){const e=this.wordTemplate,i=this.charTemplate,r=this.includeSpaces,n=this.debug,o=t.nodeType;if(3===o){const o=t.nodeValue;if(o.trim()){const a=[],l=this.words,h=this.chars,d=Sr.segment(o),c=s.createDocumentFragment();let u=null;for(const t of d){const e=t.segment,s=$r(t);if(!u||s&&u&&$r(u))a.push(e);else{const t=a.length-1,s=a[t];yr.test(s)||yr.test(e)?a.push(e):a[t]+=e}u=t}for(let t=0,o=a.length;t<o;t++){const o=a[t];if(o.trim()){const d=a[t+1],u=r&&d&&!d.trim(),p=o,m=i?wr.segment(p):null,f=i?s.createDocumentFragment():s.createTextNode(u?o+" ":o);if(i){const t=[...m];for(let e=0,r=t.length;e<r;e++){const o=t[e],a=e===r-1&&u?o.segment+" ":o.segment,d=s.createTextNode(a);Or(i,h,d,f,Tr,n,-1,l.length,h.length)}}e?Or(e,l,f,c,br,n,-1,l.length,h.length):i?c.appendChild(f):c.appendChild(s.createTextNode(o)),u&&t++}else{if(t&&r)continue;c.appendChild(s.createTextNode(o))}}t.parentNode.replaceChild(c,t)}}else if(1===o){const e=[...t.childNodes];for(let t=0,s=e.length;t<s;t++)this.splitNode(e[t])}}split(t=!1){const e=this.$target,i=!!this.cache&&!t,r=this.lineTemplate,n=this.wordTemplate,o=this.charTemplate,a="loading"!==s.fonts.status,l=r&&a;this.ready=!r||a,(l||t)&&this.effectsCleanups.forEach(t=>Y(t)&&t(this)),i||(t&&(e.innerHTML=this.html,this.words.length=this.chars.length=0),this.splitNode(e),this.cache=e.innerHTML),l&&(i&&(e.innerHTML=this.cache),this.lines.length=0,n&&(this.words=Nr(e,br))),o&&(l||n)&&(this.chars=Nr(e,Tr));const h=this.words.length?this.words:this.chars;let d,c=0;for(let t=0,e=h.length;t<e;t++){const e=h[t],{top:s,height:i}=e.getBoundingClientRect();!U(d)&&s-d>.5*i&&c++,e.setAttribute(xr,`${c}`);const r=e.querySelectorAll(`[${xr}]`);let n=r.length;for(;n--;)r[n].setAttribute(xr,`${c}`);d=s}if(l){const t=s.createDocumentFragment(),i=new Set,a=[];for(let t=0;t<c+1;t++){const s=e.cloneNode(!0);Ar(s,t,new Set).forEach(t=>{const e=t.parentNode;e&&(1===t.nodeType&&i.add(e),e.removeChild(t))}),a.push(s)}i.forEach(Rr);for(let e=0,s=a.length;e<s;e++)Or(r,this.lines,a[e],t,_r,this.debug,e);e.innerHTML="",e.appendChild(t),n&&(this.words=Nr(e,br)),o&&(this.chars=Nr(e,Tr))}if(this.linesOnly){const t=this.words;let e=t.length;for(;e--;){const s=t[e];s.replaceWith(s.textContent)}t.length=0}if(this.accessible&&(l||!i)){const t=s.createElement("span");t.style.cssText="position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;",t.innerHTML=this.html,e.insertBefore(t,e.firstChild),this.lines.forEach(Er),this.words.forEach(Er),this.chars.forEach(Er)}return this.width=e.offsetWidth,(l||t)&&this.effects.forEach((t,e)=>this.effectsCleanups[e]=t(this)),this}refresh(){this.split(!0)}}const Lr=(t,e)=>new Ir(t,e),Br=(t,e)=>(console.warn("text.split() is deprecated, import splitText() directly, or text.splitText()"),new Ir(t,e)),Mr=t=>{let e="";for(let s=0,i=t.length;s<i;s++)if(s+2<i&&"-"===t[s+1]&&t.charCodeAt(s)<t.charCodeAt(s+2)){const i=t.charCodeAt(s),r=t.charCodeAt(s+2);for(let t=i;t<=r;t++)e+=String.fromCharCode(t);s+=2}else e+=t[s];return e},Pr={lowercase:"a-z",uppercase:"A-Z",numbers:"0-9",symbols:"!%#_|*+=",braille:"⠀-⣿",blocks:"▀-▟",shades:"░-▓"},Fr=new WeakMap,Vr=(t={})=>{t||(t={});const e=t.chars,s=Be(t.ease||"linear"),i=t.text,r=t.from,n=t.reversed||!1,o=t.perturbation||0,a=t.cursor,l=!0===a?"_":"number"==typeof a?String.fromCharCode(a):"string"==typeof a?a:"",h=l.length,d=t.seed||0,c=void 0===t.override||t.override,u=t.revealRate||60,p=1e3*L.timeScale/u,m=t.settleDuration||300*L.timeScale,f=t.settleRate||30,g=t.duration,y=t.revealDelay,v=t.delay,_=t.onChange||T;return(t,a,u,b)=>{const T="function"==typeof e?e(t,a,u):e||"a-zA-Z0-9!%#_",x=Mr(Pr[T]||T),S=x.length-1,w="function"==typeof g?g(t,a,u):g,C="function"==typeof y?y(t,a,u):y||0,$="function"==typeof v?v(t,a,u):v||0,E=d?tr(d):tr();Fr.has(t)||Fr.set(t,t.textContent);const N=b?b._value:t.textContent,k=void 0!==i?"function"==typeof i?i(t,a,u):i:b?b._value:Fr.get(t),R=" "===k||"&nbsp;"===k?" ":k,A=" "===N?0:N.length,D=R.length,O=!0===c?x:"string"==typeof c&&c.length>0?Mr(Pr[c]||c):null,I=O?O.length-1:0,B=" "===c?" ":null,M=""===c?D:Math.max(A,D),P=w>0?w:(M-1)*p+m,F=gt((P+C)/L.timeScale,0)*L.timeScale,V=C>0?gt(C/F,12):0,X=void 0===r||"auto"===r?D<A?"right":"left":r,z=new Int32Array(M);if("random"===X){for(let t=0;t<M;t++)z[t]=t;for(let t=M-1;t>0;t--){const e=E(0,t),s=z[t];z[t]=z[e],z[e]=s}}else{const t="right"===X?(""!==c&&A?A:M)-1:"center"===X?((""!==c&&A?A:M)-1)/2:"number"==typeof X?X:0,e=Math.abs,s=new Array(M);for(let t=0;t<M;t++)s[t]=t;s.sort((s,i)=>e(s-t)-e(i-t));for(let t=0;t<M;t++)z[s[t]]=t}if(n){const t=M-1;for(let e=0;e<M;e++)z[e]=t-z[e]}const H=gt(m/P,12),Y=gt((1-H)/M,12),U=h*Y,W=gt(1e3*L.timeScale/(f*F),12),q=new Float32Array(M),j=new Float32Array(M),G=o>0?o*H:0;for(let t=0;t<M;t++){const e=G>0?(E(0,2e3)-1e3)/1e3*G:0,s=G>0?(E(0,2e3)-1e3)/1e3*G:0;q[t]=z[t]*Y+e,j[t]=Math.ceil((q[t]+H+s)/W)*W}if(D<M&&"left"!==X&&"right"!==X&&"random"!==X){let t=0;for(let e=D;e<M;e++)j[e]>t&&(t=j[e]);const e=new Array(D);for(let t=0;t<D;t++)e[t]=t;e.sort((t,e)=>z[t]-z[e]);const s=(1-t)/D;for(let i=0;i<D;i++){const r=t+i*s;r>j[e[i]]&&(j[e[i]]=r)}}const Z=new Array(M);for(let t=0;t<M;t++)Z[t]=x[E(0,S)];const Q=O?O===x?Z:new Array(M):null;if(Q&&Q!==Z)for(let t=0;t<M;t++)Q[t]=B||O[E(0,O.length-1)];let J=N;if(!b)if(""===c)J="";else if(O){J="";for(let t=0;t<A;t++)J+=" "===N[t]?" ":Q[t]}let K=-1,tt=-1,et="";const st=""!==c,it=!!O,rt=h>0;return{from:0,to:1,duration:F,delay:$,ease:"linear",modifier:t=>{if(t===K)return et;if(K=t,$>0&&t<=0)return et=N,N;if(t<=0)return et=J,J;if(t>=1)return et=R,R;et="";const e=t/W|0,i=e!==tt;i&&(tt=e);const r=V>0?(t-V)/(1-V):t,n=r>0?s(r):0;for(let t=0;t<M;t++){const e=q[t];n>=j[t]?t<D&&(et+=R[t]):n<=0||n<e?st&&t<A&&(it?" "===N[t]?et+=" ":(i&&(Q[t]=B||O[E(0,I)]),et+=Q[t]):et+=N[t]):t<D&&" "===R[t]||t<A&&" "===N[t]?et+=" ":rt&&n-e<U?et+=l[h-1-((n-e)/Y|0)]:(i&&(Z[t]=x[E(0,S)]),et+=Z[t])}return i&&_(et,n),et}}}};var Xr=Object.freeze({__proto__:null,TextSplitter:Ir,scrambleText:Vr,split:Br,splitText:Lr});export{xe as $,ns as Animatable,Oi as AutoLayout,As as Draggable,Ze as JSAnimation,Ls as Scope,qs as ScrollObserver,ys as Spring,Ir as TextSplitter,is as Timeline,ve as Timer,ci as WAAPIAnimation,Ct as addChild,Qe as animate,ji as clamp,Zt as cleanInlineStyles,os as createAnimatable,Ds as createDraggable,cr as createDrawable,Ii as createLayout,lr as createMotionPath,Bs as createScope,tr as createSeededRandom,_s as createSpring,rs as createTimeline,_e as createTimer,Qs as cubicBezier,Qi as damp,Ui as degToRad,De as eases,ei as easings,ie as engine,St as forEachChildren,Ss as get,L as globals,ti as irregular,Is as keepTime,Zi as lerp,Ks as linear,Yi as mapRange,ur as morphTo,js as onScroll,zi as padEnd,Xi as padStart,Wi as radToDeg,Ji as random,er as randomPick,Cs as remove,wt as removeChild,Gi as round,Vi as roundPad,Vr as scrambleText,Fs as scrollContainers,ws as set,sr as shuffle,qi as snap,Br as split,Lr as splitText,vs as spring,ir as stagger,Js as steps,pr as svg,Os as sync,Xr as text,rr as utils,ui as waapi,Hi as wrap};
+const t="undefined"!=typeof window,e=t?window:null,s=t?document:null,i={OBJECT:0,ATTRIBUTE:1,CSS:2,TRANSFORM:3,CSS_VAR:4},r={NUMBER:0,UNIT:1,COLOR:2,COMPLEX:3},n={NONE:0,AUTO:1,FORCE:2},o={replace:0,none:1,blend:2},a=Symbol(),l=Symbol(),h=Symbol(),d=Symbol(),c=Symbol(),u=1e-11,p=1e12,m=1e3,f=240,g="",y="var(",_=[],v=(()=>{const t=new Map;return t.set("x","translateX"),t.set("y","translateY"),t.set("z","translateZ"),t})(),b=["perspective","translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY"],T=b.reduce((t,e)=>({...t,[e]:e+"("}),{}),S=()=>{},x=t=>t,w=/\)\s*[-.\d]/,C=/(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i,$=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i,E=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,N=/hsl\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*\)/i,k=/hsla\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,R=/[-+]?\d*\.?\d+(?:e[-+]?\d)?/gi,A=/^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i,D=/([a-z])([A-Z])/g,O=/(\*=|\+=|-=)/,I=/var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/,L={id:null,keyframes:null,playbackEase:null,playbackRate:1,frameRate:f,loop:0,reversed:!1,alternate:!1,autoplay:!0,persist:!1,duration:m,delay:0,loopDelay:0,ease:"out(2)",composition:o.replace,modifier:x,onBegin:S,onBeforeUpdate:S,onUpdate:S,onLoop:S,onPause:S,onComplete:S,onRender:S},B={current:null,root:s},M={defaults:L,precision:4,timeScale:1,tickThreshold:200,editor:null},F={version:"4.5.0",engine:null};t&&(e.AnimeJS||(e.AnimeJS=[]),e.AnimeJS.push(F));const P=t=>t.replace(D,"$1-$2").toLowerCase(),V=(t,e)=>0===t.indexOf(e),z=Date.now,X=Array.isArray,U=t=>t&&t.constructor===Object,H=t=>"number"==typeof t&&!isNaN(t),Y=t=>"string"==typeof t,W=t=>"function"==typeof t,q=t=>void 0===t,j=t=>q(t)||null===t,G=e=>t&&e instanceof SVGElement,Z=t=>C.test(t),Q=t=>V(t,"rgb"),J=t=>V(t,"hsl"),K=t=>Z(t)||(Q(t)||J(t))&&(")"===t[t.length-1]||!w.test(t)),tt=t=>!M.defaults.hasOwnProperty(t),et=["opacity","rotate","overflow","color"],st=(t,e)=>{if(et.includes(e))return!1;if(t.getAttribute(e)||e in t){if("scale"===e){const e=t.parentNode;return e&&"filter"===e.tagName}return!0}},it=t=>Y(t)?parseFloat(t):t,rt=Math.pow,nt=Math.sqrt,ot=Math.sin,at=Math.cos,lt=Math.abs,ht=Math.exp,dt=Math.ceil,ct=Math.floor,ut=Math.asin,pt=Math.max,mt=Math.atan2,ft=Math.PI,gt=Math.round,yt=(t,e,s)=>t<e?e:t>s?s:t,_t=(t,e)=>{if(e<0)return t;if(!e)return gt(t);const s=10**e;return gt(t*s)/s},vt=(t,e)=>X(e)?e.reduce((e,s)=>lt(s-t)<lt(e-t)?s:e):e?gt(t/e)*e:t,bt=(t,e,s)=>1===s?e:0===s?t:t+(e-t)*s,Tt=t=>t===1/0?p:t===-1/0?-p:t,St=t=>t<=u?u:Tt(_t(t,11)),xt=t=>X(t)?[...t]:t,wt=(t,e)=>{const s={...t};for(let i in e){const r=t[i];s[i]=q(r)?e[i]:r}return s},Ct=(t,e,s,i="_prev",r="_next")=>{let n=t._head,o=r;for(s&&(n=t._tail,o=i);n;){const t=n[o];e(n),n=t}},$t=(t,e,s="_prev",i="_next")=>{const r=e[s],n=e[i];r?r[i]=n:t._head=n,n?n[s]=r:t._tail=r,e[s]=null,e[i]=null},Et=(t,e,s,i="_prev",r="_next")=>{let n=t._tail;for(;n&&s&&s(n,e);)n=n[i];const o=n?n[r]:t._head;n?n[r]=e:t._head=e,o?o[i]=e:t._tail=e,e[i]=n,e[r]=o},Nt=(t,e,s)=>{const i=t.style.transform;if(i){const r=t[d];let n=0;const o=i.length;let a;for(;n<o;){for(;n<o&&32===i.charCodeAt(n);)n++;if(n>=o)break;const t=n;for(;n<o&&40!==i.charCodeAt(n);)n++;if(n>=o)break;const e=i.substring(t,n);let s=1;const l=n+1;let h=-1,d=-1;for(n++;n<o&&s>0;){const t=i.charCodeAt(n);40===t?s++:41===t?s--:44===t&&1===s&&(-1===h?h=n:-1===d&&(d=n)),n++}const c=n-1;"translate"===e||"translate3d"===e?(-1===h?r.translateX=i.substring(l,c).trim():(r.translateX=i.substring(l,h).trim(),-1===d?r.translateY=i.substring(h+1,c).trim():(r.translateY=i.substring(h+1,d).trim(),r.translateZ=i.substring(d+1,c).trim())),a=i.substring(l,c)):"scale"===e||"scale3d"===e?-1===h?r.scale=i.substring(l,c).trim():(r.scaleX=i.substring(l,h).trim(),-1===d?r.scaleY=i.substring(h+1,c).trim():(r.scaleY=i.substring(h+1,d).trim(),r.scaleZ=i.substring(d+1,c).trim())):r[e]=i.substring(l,c)}if("translate3d"===e&&a)return s&&(s[e]=a),a;const l=r[e];if(!q(l))return s&&(s[e]=l),l}return"translate3d"===e?"0px, 0px, 0px":"rotate3d"===e?"0, 0, 0, 0deg":V(e,"scale")?"1":V(e,"rotate")||V(e,"skew")?"0deg":"0px"},kt=t=>{let e=g;for(let s=0,i=b.length;s<i;s++){const i=b[s],r=t[i];if(void 0!==r){if("translateX"===i){const i=t.translateY;if(void 0!==i){const n=t.translateZ;void 0!==n?(e+=`translate3d(${r},${i},${n}) `,s+=2):(e+=`translate(${r},${i}) `,s+=1);continue}}if("scaleX"===i&&void 0===t.scale){const i=t.scaleY;if(void 0!==i){const n=t.scaleZ;void 0!==n?(e+=`scale3d(${r},${i},${n}) `,s+=2):(e+=`scale(${r},${i}) `,s+=1);continue}}e+=`${T[i]}${r}) `}"rotateZ"===i&&void 0!==t.rotate3d&&(e+=`rotate3d(${t.rotate3d}) `)}return void 0!==t.matrix&&(e+=`matrix(${t.matrix}) `),void 0!==t.matrix3d&&(e+=`matrix3d(${t.matrix3d}) `),e},Rt=[];function At(t,e){if(!t)return null;const s=Rt.length;t:for(let i=0;i<s;i++){const s=Rt[i];if(s.detect&&!s.detect(t))continue;const r=s.targetAdapters;for(let s=0,i=r.length;s<i;s++){const i=r[s];if(i.detect(t)){const s=i.props[e];if(s&&(!s.gate||s.gate(t)))return s;break t}}}for(let i=0;i<s;i++){const s=Rt[i];if(s.detect&&!s.detect(t))continue;const r=s.propertyResolvers;for(let s=0,i=r.length;s<i;s++){const i=r[s](t,e);if(i)return i}}return null}const Dt=t=>{const e=$.exec(t)||E.exec(t),s=q(e[4])?1:+e[4];return[+e[1],+e[2],+e[3],s]},Ot=t=>{const e=t.length,s=4===e||5===e;return[+("0x"+t[1]+t[s?1:2]),+("0x"+t[s?2:3]+t[s?2:4]),+("0x"+t[s?3:5]+t[s?3:6]),5===e||9===e?+(+("0x"+t[s?4:7]+t[s?4:8])/255).toFixed(3):1]},It=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t),Lt=t=>{const e=N.exec(t)||k.exec(t),s=+e[1]/360,i=+e[2]/100,r=+e[3]/100,n=q(e[4])?1:+e[4];let o,a,l;if(0===i)o=a=l=r;else{const t=r<.5?r*(1+i):r+i-r*i,e=2*r-t;o=_t(255*It(e,t,s+1/3),0),a=_t(255*It(e,t,s),0),l=_t(255*It(e,t,s-1/3),0)}return[o,a,l,n]},Bt=t=>Q(t)?Dt(t):Z(t)?Ot(t):J(t)?Lt(t):[0,0,0,1],Mt=(t,e)=>q(t)?e:t,Ft=(t,e)=>{const s=t.match(I),i=e[l]?e:document.documentElement;let r=getComputedStyle(i)?.getPropertyValue(s[1]);return r&&r.trim()!==g||!s[2]||(r=s[2].trim()),r||0},Pt=(t,e,s,i,r,n)=>{if(W(t)){if(!r){const r=t(e,s,i,n);return isNaN(+r)?r||0:+r}const o=()=>{const r=t(e,s,i,n);return isNaN(+r)?r||0:+r};return r.func=o,o()}if(Y(t)&&V(t,y)){if(!r)return Ft(t,e);const s=()=>Ft(t,e);return r.func=s,s()}return t},Vt=(t,e)=>t[l]?t[h]&&st(t,e)?i.ATTRIBUTE:b.includes(e)||v.get(e)?i.TRANSFORM:V(e,"--")?i.CSS_VAR:e in t.style?i.CSS:e in t?i.OBJECT:i.ATTRIBUTE:i.OBJECT,zt=(t,e,s)=>{const i=t.style[e];i&&s&&(s[e]=i);const r=i||getComputedStyle(t[c]||t).getPropertyValue(e);return"auto"===r?"0":r},Xt=(t,e,s,r)=>{const n=q(s)?Vt(t,e):s,o=At(t,e);if(o){const s=o.get(t);return s&&r&&(r[e]=s),null==s?0:s}if(n===i.OBJECT){const s=t[e];return s&&r&&(r[e]=s),s||0}if(n===i.ATTRIBUTE){const s=t.getAttribute(e);return s&&r&&(r[e]=s),s}return n===i.TRANSFORM?Nt(t,e,r):n===i.CSS_VAR?zt(t,e,r).trimStart():zt(t,e,r)},Ut=(t,e,s)=>"-"===s?t-e:"+"===s?t+e:t*e,Ht=()=>({t:r.NUMBER,n:0,u:null,o:null,d:null,s:null}),Yt=(t,e)=>{if(e.t=r.NUMBER,e.n=0,e.u=null,e.o=null,e.d=null,e.s=null,!t)return e;const s=+t;if(!isNaN(s))return e.n=s,e;let i=t;"="===i[1]&&(e.o=i[0],i=i.slice(2));const n=!i.includes(" ")&&A.exec(i);if(n)return e.t=r.UNIT,e.n=+n[1],e.u=n[2],e;if(e.o)return e.n=+i,e;if(K(i))return e.t=r.COLOR,e.d=Bt(i),e;{const t=i.match(R);return e.t=r.COMPLEX,e.d=t?t.map(Number):[],e.s=i.split(R)||[],e}},Wt=(t,e)=>(e.t=t._valueType,e.n=t._toNumber,e.u=t._unit,e.o=null,e.d=xt(t._toNumbers),e.s=xt(t._strings),e),qt=Ht(),jt=(t,e,s)=>{const i=t._modifier,r=t._fromNumbers,n=t._toNumbers,o=t._strings;let a=o[0];for(let l=0,h=n.length;l<h;l++){const h=i(_t(bt(r[l],n[l],e),s)),d=o[l+1];a+=`${d?h+d:h}`,t._numbers[l]=h}return a},Gt=(t,e,s,a,l)=>{const h=t.parent,c=t.duration,p=t.completed,m=t.iterationDuration,f=t.iterationCount,g=t._currentIteration,y=t._loopDelay,_=t._reversed,v=t._alternate,b=t._hasChildren,T=t._delay,S=t._currentTime,x=T+m,w=e-T,C=yt(S,-T,c),$=yt(w,-T,c),E=w-S,N=$>0,k=$>=c,R=c<=u,A=l===n.FORCE;let D=0,O=w,I=0;if(f>1){const e=m+(k?0:y),s=~~($/e);t._currentIteration=yt(s,0,f),k&&t._currentIteration--,D=t._currentIteration%2,O=$-s*e||0}const L=_^(v&&D),B=t._ease;let F=k?L?0:c:L?m-O:O;B&&(F=m*B(F/m)||0);const P=(h?h.backwards:w<S)?!L:!!L;if(t._currentTime=w,t._iterationTime=F,t.backwards=P,N&&!t.began?(t.began=!0,s||h&&(P||!h.began)||t.onBegin(t)):w<=0&&(t.began=!1),s||b||!N||t._currentIteration===g||t.onLoop(t),A||l===n.AUTO&&(e>=(h&&T>0?0:T)&&e<=x||e<=T&&C>T||e>=x&&C!==c)||F>=x&&C!==c||F<=T&&C>0&&!k||e<=C&&C===c&&p||k&&!p&&R){if(N&&(t.computeDeltaTime(C),s||t.onBeforeUpdate(t)),!b){const e=A||(P?-1*E:E)>=M.tickThreshold,n=_t(t._offset+(h?h._offset:0)+T+F,12);let l,c,u,p,m=t._head,f=0;for(;m;){const t=m._composition,s=m._currentTime,h=m._changeDuration,g=m._absoluteStartTime+m._changeDuration,y=m._nextRep,_=m._prevRep,v=t!==o.none,b=_?_._absoluteStartTime+_._changeDuration:0,T=_&&_.parent!==m.parent,S=!y||y._isOverridden?g:y.parent===m.parent?g+y._delay:y._absoluteStartTime<y._absoluteUpdateStartTime?y._absoluteStartTime:y._absoluteUpdateStartTime;if((e||(s!==h||n<=S||_&&!T&&(!y||y.parent!==m.parent))&&(0!==s||n>=m._absoluteStartTime||T&&!m._hasFromValue&&!_._isOverridden&&n>=b||y&&!y._isOverridden&&y.parent===m.parent&&0!==y._currentTime&&F<y._startTime))&&(!_||T||F>=m._startTime)&&(!v||!m._isOverridden&&(!m._isOverlapped||n<=g)&&(!y||y._isOverridden||n<=S)&&(!_||_._isOverridden||(T?n>=m._absoluteStartTime||!m._hasFromValue&&n>=b:n>=b+m._delay)))){const e=m._currentTime=yt(F-m._startTime,0,h),s=m._ease(e/m._updateDuration),n=m._modifier,g=m._valueType,y=m._tweenType,_=y===i.OBJECT,b=g===r.NUMBER,T=b&&_||0===s||1===s?-1:M.precision;let S,x;if(b)S=x=n(_t(bt(m._fromNumber,m._toNumber,s),T));else if(g===r.UNIT)x=n(_t(bt(m._fromNumber,m._toNumber,s),T)),S=`${x}${m._unit}`;else if(g===r.COLOR){const t=m._numbers,e=m._fromNumbers,i=m._toNumbers,r=1-s,o=e[0],l=e[1],h=e[2],d=i[0],c=i[1],u=i[2];t[0]=n(Math.sqrt(o*o*r+d*d*s)),t[1]=n(Math.sqrt(l*l*r+c*c*s)),t[2]=n(Math.sqrt(h*h*r+u*u*s)),t[3]=n(bt(e[3],i[3],s)),m._setter&&!a||(S=`rgba(${_t(t[0],0)},${_t(t[1],0)},${_t(t[2],0)},${t[3]})`)}else g===r.COMPLEX&&(S=jt(m,s,T));if(v&&(m._number=x),a||t===o.blend)m._value=S;else{const t=m.property;l=m.target,m._setter?m._setter(l,x,m):_?l[t]=S:y===i.ATTRIBUTE?l.setAttribute(t,S):(c=l.style,y===i.TRANSFORM?(l!==u&&(u=l,p=l[d]),p[t]=S,f=1):y===i.CSS?c[t]=S:y===i.CSS_VAR&&c.setProperty(t,S)),N&&(I=1)}}else s&&_&&!T&&F<m._startTime&&(m._currentTime=0);f&&m._renderTransforms&&(c.transform=kt(p),f=0),m=m._next}!s&&I&&t.onRender(t)}!s&&N&&t.onUpdate(t)}return h&&R?!s&&(h.began&&!P&&w>0&&!p||P&&w<=u&&p)&&(t.onComplete(t),t.completed=!P):N&&k?f===1/0?t._startTime+=t.duration:t._currentIteration>=f-1&&(t.paused=!0,p||b||(t.completed=!0,s||h&&(P||!h.began)||(t.onComplete(t),t._resolve(t)))):t.completed=!1,I},Zt=(t,e,s,i,r)=>{const o=t._currentIteration;if(Gt(t,e,s,i,r),t._hasChildren){const a=t,l=a.backwards,h=i?e:a._iterationTime,d=z();let c=0,p=!0;if(!i&&a._currentIteration!==o){const t=a.iterationDuration;Ct(a,e=>{if(l){const i=e.duration,r=e._offset+e._delay;s||!(i<=u)||r&&r+i!==t||e.onComplete(e)}else!e.completed&&!e.backwards&&e._currentTime<e.iterationDuration&&Gt(e,t,s,1,n.FORCE),e.began=!1,e.completed=!1}),s||a.onLoop(a)}Ct(a,t=>{const e=_t((h-t._offset)*t._speed,12);if(l&&e>t._delay+t.duration)return;const n=t._fps<a._fps?t.requestTick(d):r;c+=Gt(t,e,s,i,n),!t.completed&&p&&(p=!1)},l),!s&&c&&a.onRender(a),(p||l)&&a._currentTime>=a.duration&&(a.paused=!0,a.completed||(a.completed=!0,s||(a.onComplete(a),a._resolve(a))))}},Qt={},Jt=(t,e,s)=>{if(s===i.TRANSFORM)return v.get(t)||t;if(s===i.CSS||s===i.ATTRIBUTE&&G(e)&&t in e.style){const e=Qt[t];if(e)return e;{const e=t?P(t):t;return Qt[t]=e,e}}return t},Kt=(t,e=!1)=>{if(t._hasChildren)Ct(t,t=>Kt(t,e),!0);else{const s=t;s.pause(),Ct(s,t=>{const r=t.property,n=t.target,o=t._tweenType,a=t._inlineValue,h=j(a)||a===g;if(t._setter){if(!e&&!h){if(Yt(a,qt),qt.d){const e=qt.d,s=t._numbers;for(let t=0,i=e.length;t<i;t++)s[t]=e[t]}else t._number=qt.n;t._setter(t.target,t._number,t)}}else if(o===i.OBJECT)e||h||(n[r]=a);else if(n[l])if(o===i.ATTRIBUTE)e||(h?n.removeAttribute(r):n.setAttribute(r,a));else{const e=n.style;if(o===i.TRANSFORM){const s=n[d];h?delete s[r]:s[r]=a,t._renderTransforms&&(Object.keys(s).length?e.transform=kt(s):e.removeProperty("transform"))}else h?e.removeProperty(P(r)):e[r]=a}n[l]&&s._tail===t&&s.targets.forEach(t=>{t.getAttribute&&t.getAttribute("style")===g&&t.removeAttribute("style")})})}return t},te=t=>Kt(t,!0);class ee{constructor(t=0){this.deltaTime=0,this._currentTime=t,this._lastTickTime=t,this._startTime=t,this._lastTime=t,this._frameDuration=m/f,this._fps=f,this._speed=1,this._hasChildren=!1,this._head=null,this._tail=null}get fps(){return this._fps}set fps(t){const e=+t,s=e<u?u:e,i=m/s;s>L.frameRate&&(L.frameRate=s),this._fps=s,this._frameDuration=i}get speed(){return this._speed}set speed(t){const e=+t;this._speed=e<u?u:e}requestTick(t){const e=this._frameDuration,s=t-this._lastTickTime,i=.25*e;return s+(i<4?i:4)<e?n.NONE:(this._lastTickTime=s>=e?t-s%e:t,n.AUTO)}computeDeltaTime(t){const e=t-this._lastTime;return this.deltaTime=e,this._lastTime=t,e}}const se={animation:null,update:S},ie=t=>{let e=se.animation;return e||(e={duration:u,computeDeltaTime:S,_offset:0,_delay:0,_head:null,_tail:null},se.animation=e,se.update=()=>{t.forEach(t=>{for(let e in t){const s=t[e],i=s._head;if(i){const t=i._valueType,e=t===r.COMPLEX||t===r.COLOR?xt(i._fromNumbers):null;let n=i._fromNumber,o=s._tail;for(;o&&o!==i;){if(e)for(let t=0,s=o._numbers.length;t<s;t++)e[t]+=o._numbers[t];else n+=o._number;o=o._prevAdd}i._toNumber=n,i._toNumbers=e}}}),Gt(e,1,1,0,n.FORCE)}),e},re=(()=>t?requestAnimationFrame:setImmediate)(),ne=(()=>t?cancelAnimationFrame:clearImmediate)();class oe extends ee{constructor(t){super(t),this.useDefaultMainLoop=!0,this.pauseOnDocumentHidden=!0,this.defaults=L,this.paused=!0,this.reqId=0}update(){const t=this._currentTime=z();if(this.requestTick(t)){this.computeDeltaTime(t);const e=this._speed,s=this._fps;let i=this._head;for(;i;){const r=i._next;i.paused?($t(this,i),this._hasChildren=!!this._tail,i._running=!1,i.completed&&!i._cancelled&&i.cancel()):Zt(i,(t-i._startTime)*i._speed*e,0,0,i._fps<s?i.requestTick(t):n.AUTO),i=r}se.update()}}wake(){return this.useDefaultMainLoop&&!this.reqId&&(this.requestTick(z()),this.reqId=re(le)),this}pause(){if(this.reqId)return this.paused=!0,he()}resume(){if(this.paused)return this.paused=!1,Ct(this,t=>t.resetTime()),this.wake()}get speed(){return this._speed*(1===M.timeScale?1:m)}set speed(t){const e=t*M.timeScale;this._speed!==e&&(this._speed=e,Ct(this,t=>t.speed=t._speed))}get timeUnit(){return 1===M.timeScale?"ms":"s"}set timeUnit(t){const e="s"===t,s=e?.001:1;if(M.timeScale!==s){M.timeScale=s,M.tickThreshold=200*s;const t=e?.001:m;this.defaults.duration*=t,this._speed*=t}}get precision(){return M.precision}set precision(t){M.precision=t}}const ae=(()=>{const e=new oe(z());return t&&(F.engine=e,s.addEventListener("visibilitychange",()=>{e.pauseOnDocumentHidden&&(s.hidden?e.pause():e.resume())})),e})(),le=()=>{ae._head?(ae.reqId=re(le),ae.update()):ae.reqId=0},he=()=>(ne(ae.reqId),ae.reqId=0,ae),de={_rep:new WeakMap,_add:new Map},ce=(t,e,s="_rep")=>{const i=de[s];let r=i.get(t);return r||(r={},i.set(t,r)),r[e]?r[e]:r[e]={_head:null,_tail:null}},ue=(t,e)=>t._isOverridden||t._absoluteStartTime>e._absoluteStartTime,pe=t=>{t._isOverlapped=1,t._isOverridden=1,t._changeDuration=u,t._currentTime=u},me=(t,e)=>{const s=t._composition;if(s===o.replace){const s=t._absoluteStartTime;Et(e,t,ue,"_prevRep","_nextRep");const i=t._prevRep;if(i){const e=i.parent,r=i._absoluteEndTime;if(t.parent.id!==e.id&&e.iterationCount>1&&r+(e.duration-e.iterationDuration)>s){pe(i);let t=i._prevRep;for(;t&&t.parent.id===e.id;)pe(t),t=t._prevRep}const n=t._absoluteUpdateStartTime;if(r>n){const t=i._startTime,e=r-(t+i._updateDuration),s=_t(n-e-t,12);i._changeDuration=s,i._currentTime=s,i._isOverlapped=1,s<u&&pe(i)}const o=t.parent.parent;if(!o||o!==e.parent){let t=!0;if(Ct(e,e=>{e._isOverlapped||(t=!1)}),t){const t=e.parent;if(t){let s=!0;Ct(t,t=>{t!==e&&Ct(t,t=>{t._isOverlapped||(s=!1)})}),s&&t.cancel()}else e.cancel()}}}}else if(s===o.blend){const e=ce(t.target,t.property,"_add"),s=ie(de._add);let i=e._head;i||(i={...t},i._composition=o.replace,i._updateDuration=u,i._startTime=0,i._numbers=xt(t._fromNumbers),i._number=0,i._next=null,i._prev=null,Et(e,i),Et(s,i));const r=t._toNumber;if(t._fromNumber=i._fromNumber-r,t._toNumber=0,t._numbers=xt(t._fromNumbers),t._number=0,i._fromNumber=r,t._toNumbers.length){const e=xt(t._toNumbers);e.forEach((e,s)=>{t._fromNumbers[s]=i._fromNumbers[s]-e,t._toNumbers[s]=0}),i._fromNumbers=e}Et(e,t,null,"_prevAdd","_nextAdd")}return t},fe=t=>{const e=t._composition;if(e!==o.none){const s=t.target,i=t.property,r=de._rep.get(s)[i];if($t(r,t,"_prevRep","_nextRep"),e===o.blend){const e=de._add,r=e.get(s);if(!r)return;const n=r[i],o=se.animation;$t(n,t,"_prevAdd","_nextAdd");const a=n._head;if(a&&a===n._tail){$t(n,a,"_prevAdd","_nextAdd"),$t(o,a);let t=!0;for(let e in r)if(r[e]._head){t=!1;break}t&&e.delete(s)}}}return t},ge=(t,e,s)=>{let r=!1;return Ct(e,n=>{const o=n.target;if(t.includes(o)){const t=n.property,a=n._tweenType,l=Jt(s,o,a);(!l||l&&l===t)&&(n.parent._tail===n&&n._tweenType===i.TRANSFORM&&n._prev&&n._prev._tweenType===i.TRANSFORM&&(n._prev._renderTransforms=1),$t(e,n),fe(n),r=!0)}},!0),r},ye=(t,e,s)=>{const i=e||ae;let r;if(i._hasChildren){let e=0;Ct(i,n=>{if(!n._hasChildren)if(r=ge(t,n,s),r&&!n._head)n.cancel(),$t(i,n);else{const t=n._offset+n._delay+n.duration;t>e&&(e=t)}n._head?ye(t,n,s):n._hasChildren=!1},!0),q(i.iterationDuration)||(i.iterationDuration=e)}else r=ge(t,i,s);r&&!i._head&&(i._hasChildren=!1,i.cancel&&i.cancel())},_e=t=>(t.paused=!0,t.began=!1,t.completed=!1,t),ve=t=>t._cancelled?(t._hasChildren?Ct(t,ve):Ct(t,t=>{t._composition!==o.none&&me(t,ce(t.target,t.property))}),t._cancelled=0,t):t;let be=0;const Te=(t,e)=>t._priority>e._priority;class Se extends ee{constructor(t={},e=null,s=0){super(0),++be;const{id:i,delay:r,duration:n,reversed:o,alternate:a,loop:l,loopDelay:h,autoplay:d,frameRate:c,playbackRate:p,priority:m,onComplete:f,onLoop:g,onPause:y,onBegin:_,onBeforeUpdate:v,onUpdate:b}=t;B.current&&B.current.register(this);const T=e?0:ae._lastTickTime,x=e?e.defaults:M.defaults,w=W(r)||q(r)?x.delay:+r,C=W(n)||q(n)?1/0:+n,$=Mt(l,x.loop),E=Mt(h,x.loopDelay);let N=!0===$||$===1/0||$<0?1/0:$+1,k=0;e?k=s:(ae.reqId||ae.requestTick(z()),k=(ae._lastTickTime-ae._startTime)*M.timeScale),this.id=q(i)?be:i,this.parent=e,this.duration=Tt((C+E)*N-E)||u,this.backwards=!1,this.paused=!0,this.began=!1,this.completed=!1,this.onBegin=_||x.onBegin,this.onBeforeUpdate=v||x.onBeforeUpdate,this.onUpdate=b||x.onUpdate,this.onLoop=g||x.onLoop,this.onPause=y||x.onPause,this.onComplete=f||x.onComplete,this.iterationDuration=C,this.iterationCount=N,this._autoplay=!e&&Mt(d,x.autoplay),this._offset=k,this._delay=w,this._loopDelay=E,this._iterationTime=0,this._currentIteration=0,this._resolve=S,this._running=!1,this._reversed=+Mt(o,x.reversed),this._reverse=this._reversed,this._cancelled=0,this._alternate=Mt(a,x.alternate),this._prev=null,this._next=null,this._lastTickTime=T,this._startTime=T,this._lastTime=T,this._fps=Mt(c,x.frameRate),this._speed=Mt(p,x.playbackRate),this._priority=+Mt(m,1)}get cancelled(){return!!this._cancelled}set cancelled(t){t?this.cancel():this.reset(!0).play()}get currentTime(){return yt(_t(this._currentTime,M.precision),-this._delay,this.duration)}set currentTime(t){const e=this.paused;this.pause().seek(+t),e||this.resume()}get iterationCurrentTime(){return yt(_t(this._iterationTime,M.precision),0,this.iterationDuration)}set iterationCurrentTime(t){this.currentTime=this.iterationDuration*this._currentIteration+t}get progress(){return yt(_t(this._currentTime/this.duration,10),0,1)}set progress(t){this.currentTime=this.duration*t}get iterationProgress(){return yt(_t(this._iterationTime/this.iterationDuration,10),0,1)}set iterationProgress(t){const e=this.iterationDuration;this.currentTime=e*this._currentIteration+e*t}get currentIteration(){return this._currentIteration}set currentIteration(t){this.currentTime=this.iterationDuration*yt(+t,0,this.iterationCount-1)}get reversed(){return!!this._reversed}set reversed(t){t?this.reverse():this.play()}get speed(){return super.speed}set speed(t){super.speed=t,this.resetTime()}reset(t=!1){return ve(this),this._reversed&&!this._reverse&&(this.reversed=!1),this._iterationTime=this.iterationDuration,Zt(this,0,1,~~t,n.FORCE),_e(this),this._hasChildren&&Ct(this,_e),this}init(t=!1){this.fps=this._fps,this.speed=this._speed,!t&&this._hasChildren&&Zt(this,this.duration,1,~~t,n.FORCE),this.reset(t);const e=this._autoplay;return!0===e?this.resume():e&&!q(e.linked)&&e.link(this),this}resetTime(){const t=1/(this._speed*ae._speed);return this._startTime=z()-(this._currentTime+this._delay)*t,this}pause(){return this.paused||(this.paused=!0,this.onPause(this)),this}resume(){return this.paused?(this.paused=!1,this.duration<=u&&!this._hasChildren?Zt(this,u,0,0,n.FORCE):(this._running||(Et(ae,this,Te),ae._hasChildren=!0,this._running=!0),this.resetTime(),this._startTime-=12,ae.wake()),this):this}restart(){return this.reset().resume()}seek(t,e=0,s=0){ve(this),this.completed=!1;const i=this.paused;return this.paused=!0,Zt(this,t+this._delay,~~e,~~s,n.AUTO),i?this:this.resume()}alternate(){const t=this._reversed,e=this.iterationCount,s=this.iterationDuration,i=e===1/0?ct(p/s):e;return this._reversed=+(!this._alternate||i%2?!t:t),e===1/0?this.iterationProgress=this._reversed?1-this.iterationProgress:this.iterationProgress:this.seek(s*i-this._currentTime),this.resetTime(),this}play(){return this._reversed&&this.alternate(),this.resume()}reverse(){return this._reversed||this.alternate(),this.resume()}cancel(){return this._hasChildren?Ct(this,t=>t.cancel(),!0):Ct(this,fe),this._cancelled=1,this.pause()}stretch(t){const e=this.duration,s=St(t);if(e===s)return this;const i=t/e,r=t<=u;return this.duration=r?u:s,this.iterationDuration=r?u:St(this.iterationDuration*i),this._offset*=i,this._delay*=i,this._loopDelay*=i,this}revert(){Zt(this,0,1,0,n.AUTO);const t=this._autoplay;return t&&t.linked&&t.linked===this&&t.revert(),this.cancel()}complete(t=0){return this.seek(this.duration,t).cancel()}then(t=S){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=S};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const xe=t=>new Se(t,null,0).init();function we(t){const e=Y(t)?B.root.querySelectorAll(t):t;if(e instanceof NodeList||e instanceof HTMLCollection)return e}function Ce(e){if(j(e))return[];if(!t)return X(e)&&e.flat(1/0)||[e];if(X(e)){const t=e.flat(1/0),s=[];for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!j(i)){const t=we(i);if(t)for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!j(i)){let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}else{let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}}return s}const s=we(e);return s?Array.from(s):[e]}function $e(t){const e=Ce(t),s=e.length;for(let t=0;t<s;t++){const s=e[t];if(!s[a]){s[a]=!0;const t=G(s);(s.nodeType||t)&&(s[l]=!0,s[h]=t,s[d]={})}}return e}const Ee={deg:1,rad:180/ft,turn:360},Ne={},ke=(t,e,i,n=!1)=>{const o=e.u,a=e.n;if(e.t===r.UNIT&&o===i)return e;const l=a+o+i,h=Ne[l];if(q(h)||n){let r;if(o in Ee)r=a*Ee[o]/Ee[i];else{const e=100,n=t.cloneNode(),l=t.parentNode,h=l&&l!==s?l:s.body;h.appendChild(n);const d=n.style;d.width=e+o;const c=n.offsetWidth||e;d.width=e+i;const u=c/(n.offsetWidth||e);h.removeChild(n),r=u*a}e.n=r,Ne[l]=r}else e.n=h;return e.t,e.u=i,e},Re=t=>t,Ae=(t=1.68)=>e=>rt(e,+t),De={in:t=>e=>t(e),out:t=>e=>1-t(1-e),inOut:t=>e=>e<.5?t(2*e)/2:1-t(-2*e+2)/2,outIn:t=>e=>e<.5?(1-t(1-2*e))/2:(t(2*e-1)+1)/2},Oe=ft/2,Ie=2*ft,Le={[g]:Ae,Quad:Ae(2),Cubic:Ae(3),Quart:Ae(4),Quint:Ae(5),Sine:t=>1-at(t*Oe),Circ:t=>1-nt(1-t*t),Expo:t=>t?rt(2,10*t-10):0,Bounce:t=>{let e,s=4;for(;t<((e=rt(2,--s))-1)/11;);return 1/rt(4,3-s)-7.5625*rt((3*e-2)/22-t,2)},Back:(t=1.7)=>e=>(+t+1)*e*e*e-+t*e*e,Elastic:(t=1,e=.3)=>{const s=yt(+t,1,10),i=yt(+e,u,2),r=i/Ie*ut(1/s),n=Ie/i;return t=>0===t||1===t?t:-s*rt(2,-10*(1-t))*ot((1-t-r)*n)}},Be=(()=>{const t={linear:Re,none:Re};for(let e in De)for(let s in Le){const i=Le[s],r=De[e];t[e+s]=s===g||"Back"===s||"Elastic"===s?(t,e)=>r(i(t,e)):r(i)}return t})(),Me={linear:Re,none:Re},Fe=t=>{if(Me[t])return Me[t];if(t.indexOf("(")<=-1){const e=De[t]||t.includes("Back")||t.includes("Elastic")?Be[t]():Be[t];return e?Me[t]=e:Re}{const e=t.slice(0,-1).split("("),s=Be[e[0]];return s?Me[t]=s(...e[1].split(",")):Re}},Pe=["steps(","irregular(","linear(","cubicBezier("],Ve=t=>{if(Y(t))for(let e=0,s=Pe.length;e<s;e++)if(V(t,Pe[e]))return console.warn(`String syntax for \`ease: "${t}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${t}\``),Re;return W(t)?t:Y(t)?Fe(t):Re},ze=Ht(),Xe=Ht(),Ue={},He={func:null},Ye={func:null},We=[null],qe=[null,null],je={to:null};let Ge,Ze,Qe=0,Je=0;const Ke=(t,e)=>{const s={};if(X(t)){const e=[].concat(...t.map(t=>Object.keys(t))).filter(tt);for(let i=0,r=e.length;i<r;i++){const r=e[i],n=t.map(t=>{const e={};for(let s in t){const i=t[s];tt(s)?s===r&&(e.to=i):e[s]=i}return e});s[r]=n}}else{const i=Mt(e.duration,M.defaults.duration),r=Object.keys(t).map(e=>({o:parseFloat(e)/100,p:t[e]})).sort((t,e)=>t.o-e.o);r.forEach(t=>{const e=t.o,r=t.p;for(let t in r)if(tt(t)){let n=s[t];n||(n=s[t]=[]);const o=e*i;let a=n.length,l=n[a-1];const h={to:r[t]};let d=0;for(let t=0;t<a;t++)d+=n[t].duration;1===a&&(h.from=l.to),r.ease&&(h.ease=r.ease),h.duration=o-(a?d:0),n.push(h)}return t});for(let t in s){const e=s[t];let i;for(let t=0,s=e.length;t<s;t++){const s=e[t],r=s.ease;s.ease=i||void 0,i=r}e[0].duration||e.shift()}}return s};class ts extends Se{constructor(t,e,s,n,a=!1,l=0,h){super(e,s,n),this._head,this._tail,++Je;const d=$e(t),c=d.length,p=e.keyframes,f=p?wt(Ke(p,e),e):e,{id:g,delay:y,duration:v,ease:b,playbackEase:T,modifier:S,composition:x,onRender:w}=f,C=s?s.defaults:M.defaults,$=Mt(b,C.ease),E=Mt(T,C.playbackEase),N=E?Ve(E):null,k=!q($.ease),R=k?$.ease:Mt(b,N?"linear":C.ease),A=k?$.settlingDuration:Mt(v,C.duration),D=Mt(y,C.delay),O=S||C.modifier,I=q(x)&&c>=m?o.none:q(x)?C.composition:x,L=this._offset+(s?s._offset:0);k&&($.parent=this);let B=NaN,F=NaN,P=0,V=0;for(let t=0;t<c;t++){const e=d[t],n=l||t,c=h||d;let p=NaN,m=NaN;for(let t in f)if(tt(t)){const l=Vt(e,t),h=At(e,t),d=Jt(t,e,l);let g=f[t];const y=X(g);if(a&&!y&&(qe[0]=g,qe[1]=g,g=qe),y){const t=g.length,e=!U(g[0]);2===t&&e?(je.to=g,We[0]=je,Ge=We):t>2&&e?(Ge=[],g.forEach((t,e)=>{e?1===e?(qe[1]=t,Ge.push(qe)):Ge.push(t):qe[0]=t})):Ge=g}else We[0]=g,Ge=We;let v=null,b=null,T=NaN,S=0,x=0;for(let t=Ge.length;x<t;x++){const i=Ge[x];U(i)?Ze=i:(je.to=i,Ze=je),He.func=null,Ye.func=null;const a=Pt(Mt(Ze.composition,I),e,n,c,null,null),p=H(a)?a:o[a];v||p===o.none||(v=ce(e,d));const m=v?v._tail:null,f=s&&m&&m.parent.parent===s?m:b,g=Pt(Ze.to,e,n,c,He,f);let y;U(g)&&!q(g.to)?(Ze=g,y=g.to):y=g;const w=Pt(Ze.from,e,n,c,Ye,f),C=Ze.ease||R,$=Pt(C,e,n,c,null,f),E=W($)||Y($)?$:C,N=!q(E)&&!q(E.ease),k=N?E.ease:E,B=N?E.settlingDuration:Pt(Mt(Ze.duration,t>1?Pt(A,e,n,c,null,f)/t:A),e,n,c,null,f),M=Pt(Mt(Ze.delay,x?0:D),e,n,c,null,f),F=Ze.modifier||O,z=!q(w),G=!q(y),Z=X(y),Q=Z||z&&G,J=b?S:0,K=b?S+M:M,tt=_t(L+K,12),et=_t(L+J,12);V||!z&&!Z||(V=1);let st=b;if(p!==o.none){let t=v._head;for(;t&&t._absoluteStartTime<=tt;)if(t._isOverridden||(st=t),t=t._nextRep,t&&t._absoluteStartTime>=tt)for(;t;)pe(t),t=t._nextRep}if(Q){Yt(Z?Pt(y[0],e,n,c,Ye,f):w,ze),Yt(Z?Pt(y[1],e,n,c,He,f):y,Xe);const t=Xt(e,d,l,Ue);ze.t===r.NUMBER&&(st?st._valueType===r.UNIT&&(ze.t=r.UNIT,ze.u=st._unit):(Yt(t,qt),qt.t===r.UNIT&&(ze.t=r.UNIT,ze.u=qt.u)))}else G?Yt(y,Xe):b?Wt(b,Xe):Yt(s&&st&&st.parent.parent===s?st._value:Xt(e,d,l,Ue),Xe),z?Yt(w,ze):b?Wt(b,ze):Yt(s&&st&&st.parent.parent===s?st._value:Xt(e,d,l,Ue),ze);if(ze.o&&(ze.n=Ut(st?st._toNumber:Yt(Xt(e,d,l,Ue),qt).n,ze.n,ze.o)),Xe.o&&(Xe.n=Ut(ze.n,Xe.n,Xe.o)),ze.t!==Xe.t)if(ze.t===r.COMPLEX||Xe.t===r.COMPLEX){const t=ze.t===r.COMPLEX?ze:Xe,e=ze.t===r.COMPLEX?Xe:ze;e.t=r.COMPLEX,e.s=xt(t.s),e.d=t.d.map(()=>e.n)}else if(ze.t===r.UNIT||Xe.t===r.UNIT){const t=ze.t===r.UNIT?ze:Xe,e=ze.t===r.UNIT?Xe:ze;e.t=r.UNIT,e.u=t.u}else if(ze.t===r.COLOR||Xe.t===r.COLOR){const t=ze.t===r.COLOR?ze:Xe,e=ze.t===r.COLOR?Xe:ze;e.t=r.COLOR,e.d=t.d.map(()=>0)}if(ze.u!==Xe.u){let t=Xe.u?ze:Xe;t=ke(e,t,Xe.u?Xe.u:ze.u,!1)}if(Xe.d&&ze.d&&Xe.d.length!==ze.d.length){const t=ze.d.length>Xe.d.length?ze:Xe,e=t===ze?Xe:ze;e.d=t.d.map((t,s)=>q(e.d[s])?0:e.d[s]),e.s=xt(t.s)}const it=_t(+B||u,12);let rt=Ue[d];j(rt)||(Ue[d]=null);const nt=h?h.set:null;S=_t(K+it,12);const ot=ze.d,at=Xe.d,lt=Xe.s,ht={parent:this,id:Qe++,property:d,target:e,_value:null,_toFunc:He.func,_fromFunc:Ye.func,_ease:Ve(k),_fromNumbers:ot?xt(ot):_,_toNumbers:at?xt(at):_,_strings:lt?xt(lt):_,_fromNumber:ze.n,_toNumber:Xe.n,_numbers:ot?xt(ot):_,_number:ze.n,_unit:Xe.u,_modifier:F,_currentTime:0,_startTime:K,_delay:+M,_updateDuration:it,_changeDuration:it,_absoluteStartTime:tt,_absoluteUpdateStartTime:et,_absoluteEndTime:_t(L+S,12),_hasFromValue:z||Z?1:0,_tweenType:l,_setter:nt,_valueType:Xe.t,_composition:p,_isOverlapped:0,_isOverridden:0,_renderTransforms:0,_inlineValue:rt,_prevRep:null,_nextRep:null,_prevAdd:null,_nextAdd:null,_prev:null,_next:null};p!==o.none&&me(ht,v);const dt=ht._valueType;if(dt===r.COMPLEX)ht._value=jt(ht,1,-1);else if(dt===r.UNIT)ht._value=`${F(ht._toNumber)}${ht._unit}`;else if(dt===r.COLOR){const t=Xe.d;ht._value=`rgba(${_t(t[0],0)},${_t(t[1],0)},${_t(t[2],0)},${t[3]})`}else ht._value=F(ht._toNumber);isNaN(T)&&(T=ht._startTime),b=ht,P++,Et(this,ht)}(isNaN(F)||T<F)&&(F=T),(isNaN(B)||S>B)&&(B=S),l===i.TRANSFORM&&(p=P-x,m=P)}if(!isNaN(p)){let t=0;Ct(this,e=>{t>=p&&t<m&&(e._renderTransforms=1,e._composition===o.blend&&Ct(se.animation,t=>{t.id===e.id&&(t._renderTransforms=1)})),t++})}}c||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation."),F?(Ct(this,t=>{t._startTime-t._delay||(t._delay-=F),t._startTime-=F}),B-=F):F=0,B||(B=u,this.iterationCount=0),this.targets=d,this.id=q(g)?Je:g,this.duration=B===u?u:Tt((B+this._loopDelay)*this.iterationCount-this._loopDelay)||u,this.onRender=w||C.onRender,this._ease=N,this._delay=F,this.iterationDuration=B,!this._autoplay&&V&&this.onRender(this)}stretch(t){const e=this.duration;if(e===St(t))return this;const s=t/e;return Ct(this,t=>{t._updateDuration=St(t._updateDuration*s),t._changeDuration=St(t._changeDuration*s),t._currentTime*=s,t._delay*=s,t._startTime*=s,t._absoluteStartTime*=s,t._absoluteUpdateStartTime*=s,t._absoluteEndTime*=s}),super.stretch(t)}refresh(){return Ct(this,t=>{const e=t._toFunc,s=t._fromFunc;(e||s)&&(s?(Yt(s(),ze),ze.u!==t._unit&&t.target[l]&&ke(t.target,ze,t._unit,!0),t._fromNumbers=xt(ze.d),t._fromNumber=ze.n):e&&(Yt(Xt(t.target,t.property,t._tweenType),qt),t._fromNumbers=xt(qt.d),t._fromNumber=qt.n),e&&(Yt(e(),Xe),t._toNumbers=xt(Xe.d),t._strings=xt(Xe.s),t._toNumber=Xe.o?Ut(t._fromNumber,Xe.n,Xe.o):Xe.n))}),this.duration===u&&this.restart(),this}revert(){return super.revert(),Kt(this)}then(t){return super.then(t)}}const es=(t,e)=>M.editor?M.editor.addAnimation(t,e):new ts(t,e,null,0,!1).init(),ss=(t,e)=>{if(V(e,"<")){const s="<"===e[1],i=t._tail,r=i?i._offset+i._delay:0;return s?r:r+i.duration}},is=(t,e)=>{let s=t.iterationDuration;if(s===u&&(s=0),q(e))return s;if(H(+e))return+e;const i=e,r=t?t.labels:null,n=!j(r),o=ss(t,i),a=!q(o),l=O.exec(i);if(l){const t=l[0],e=i.split(t),h=n&&e[0]?r[e[0]]:s,d=a?o:n?h:s,c=+e[1];return Ut(d,c,t[0])}return a?o:n?q(r[i])?s:r[i]:s};function rs(t){return Tt((t.iterationDuration+t._loopDelay)*t.iterationCount-t._loopDelay)||u}function ns(t,e,s,i,r,o){const a=H(t.duration)&&t.duration<=u?s-u:s;e.composition&&Zt(e,a,1,1,n.AUTO);const l=i?new ts(i,t,e,a,!1,r,o):new Se(t,e,a);return e.composition&&l.init(!0),Et(e,l),Ct(e,t=>{const s=t._offset+t._delay+t.duration;s>e.iterationDuration&&(e.iterationDuration=s)}),e.duration=rs(e),e}let os=0;class as extends Se{constructor(t={}){super(t,null,0),++os,this.id=q(t.id)?os:t.id,this.duration=0,this.labels={};const e=t.defaults,s=M.defaults;this.defaults=e?wt(e,s):s,this.composition=Mt(t.composition,!0),this.onRender=t.onRender||s.onRender;const i=Mt(t.playbackEase,s.playbackEase);this._ease=i?Ve(i):null,this.iterationDuration=0}add(t,e,s){const i=U(e),r=U(t);if(i||r){if(this._hasChildren=!0,i){const i=e,r=M.editor&&M.editor.addTimelineChild,n=s&&"Stagger"===s.type&&M.editor,o=W(s)?s:null;if(o||n){const e=Ce(t),n=this.duration,a=this.iterationDuration,l=i.id;let h=0;const d=e.length,c=r?r(t,i,this.id,s,d):null,u=o||M.editor.resolveStagger(s.defaultValue);e.forEach(t=>{const s={...c||i};this.duration=n,this.iterationDuration=a,q(l)||(s.id=l+"-"+h),ns(s,this,is(this,u(t,h,e,null,this)),t,h,e),h++})}else{const e=r?r(t,i,this.id,s):i,n=s&&s.type?s.defaultValue:s;ns(e,this,is(this,n),t)}}else ns(t,this,is(this,e));return this.composition&&this.init(!0),this}}sync(t,e){if(q(t)||t&&q(t.pause))return this;t.pause();const s=+(t.effect?t.effect.getTiming().duration:t.duration);q(t)||q(t.persist)||(t.persist=!0);const i=M.editor,r=i&&i.addTimelineChild;i&&i.addTimelineSync&&(e=i.addTimelineSync(t,e,this.id),i.addTimelineChild=null);const n=this.add(t,{currentTime:[0,s],duration:s,delay:0,ease:"linear",playbackEase:"linear"},e);return i&&(i.addTimelineChild=r),n}set(t,e,s){return q(e)?this:(e.duration=u,e.composition=o.replace,this.add(t,e,s))}call(t,e){return q(t)||t&&!W(t)?this:(M.editor&&M.editor.addTimelineCall&&(e=M.editor.addTimelineCall(t,e,this.id)),this.add({duration:0,delay:0,onComplete:()=>t(this)},e))}label(t,e){return q(t)||t&&!Y(t)||(M.editor&&M.editor.addTimelineLabel&&(e=M.editor.addTimelineLabel(t,e,this.id)),this.labels[t]=is(this,e)),this}remove(t,e){return ye(Ce(t),this,e),this}stretch(t){const e=this.duration;if(e===St(t))return this;const s=t/e,i=this.labels;Ct(this,t=>t.stretch(t.duration*s));for(let t in i)i[t]*=s;return super.stretch(t)}refresh(){return Ct(this,t=>{t.refresh&&t.refresh()}),this}revert(){return super.revert(),Ct(this,t=>t.revert,!0),Kt(this)}then(t){return super.then(t)}}const ls=t=>M.editor?M.editor.addTimeline(t):new as(t).init();class hs{constructor(t,e){B.current&&B.current.register(this);const s=()=>{if(this.callbacks.completed)return;let t=!0;for(let e in this.animations)if(!this.animations[e].paused&&t){t=!1;break}t&&this.callbacks.complete()},i={onBegin:()=>{this.callbacks.completed&&this.callbacks.reset(),this.callbacks.play()},onComplete:s,onPause:s},r={v:1,autoplay:!1},n={};if(this.targets=[],this.animations={},this.callbacks=null,!q(t)&&!q(e)){for(let t in e){const s=e[t];tt(t)?n[t]=s:V(t,"on")?r[t]=s:i[t]=s}this.callbacks=new ts({v:0},r);for(let e in n){const s=n[e],r=U(s);let a={},l="+=0";if(r){const t=s.unit;Y(t)&&(l+=t)}else a.duration=s;a[e]=r?wt({to:l},s):l;const h=wt(i,a);h.composition=o.replace,h.autoplay=!1;const d=this.animations[e]=new ts(t,h,null,0,!1).init();this.targets.length||this.targets.push(...d.targets),this[e]=(t,e,s)=>{const i=d._head;if(q(t)&&i){const t=i._numbers;return t&&t.length?t:i._modifier(i._number)}return Ct(d,e=>{if(X(t))for(let s=0,i=t.length;s<i;s++)q(e._numbers[s])||(e._fromNumbers[s]=e._modifier(e._numbers[s]),e._toNumbers[s]=t[s]);else e._fromNumber=e._modifier(e._number),e._toNumber=t;q(s)||(e._ease=Ve(s)),e._currentTime=0}),q(e)||d.stretch(e),d.reset(!0).resume(),this}}}}revert(){for(let t in this.animations)this[t]=S,this.animations[t].revert();return this.animations={},this.targets.length=0,this.callbacks&&this.callbacks.revert(),this}}const ds=(t,e)=>new hs(t,e),cs=(t,e)=>(+t).toFixed(e),us=(t,e,s)=>`${t}`.padStart(e,s),ps=(t,e,s)=>`${t}`.padEnd(e,s),ms=(t,e,s)=>((t-e)%(s-e)+(s-e))%(s-e)+e,fs=(t,e,s,i,r)=>i+(t-e)/(s-e)*(r-i),gs=t=>t*Math.PI/180,ys=t=>180*t/Math.PI,_s=(t,e,s,i)=>i?1===i?e:bt(t,e,1-Math.exp(-i*s*.1)):t;var vs=Object.freeze({__proto__:null,clamp:yt,damp:_s,degToRad:gs,lerp:bt,mapRange:fs,padEnd:ps,padStart:us,radToDeg:ys,round:_t,roundPad:cs,snap:vt,wrap:ms});const bs=10*m;class Ts{constructor(t={}){const e=!q(t.bounce)||!q(t.duration);this.timeStep=.02,this.restThreshold=5e-4,this.restDuration=200,this.maxDuration=6e4,this.maxRestSteps=this.restDuration/this.timeStep/m,this.maxIterations=this.maxDuration/this.timeStep/m,this.bn=yt(Mt(t.bounce,.5),-1,1),this.pd=yt(Mt(t.duration,628),10*M.timeScale,bs*M.timeScale),this.m=yt(Mt(t.mass,1),1,bs),this.s=yt(Mt(t.stiffness,100),u,bs),this.d=yt(Mt(t.damping,10),u,bs),this.v=yt(Mt(t.velocity,0),-1e4,bs),this.w0=0,this.zeta=0,this.wd=0,this.b=0,this.completed=!1,this.solverDuration=0,this.settlingDuration=0,this.parent=null,this.onComplete=t.onComplete||S,e&&this.calculateSDFromBD(),this.compute(),this.ease=t=>{const e=t*this.settlingDuration,s=this.completed,i=this.pd;return e>=i&&!s&&(this.completed=!0,this.onComplete(this.parent)),e<i&&s&&(this.completed=!1),0===t||1===t?t:this.solve(t*this.solverDuration)}}solve(t){const{zeta:e,w0:s,wd:i,b:r}=this;let n=t;return n=e<1?ht(-n*e*s)*(1*at(i*n)+r*ot(i*n)):1===e?(1+r*n)*ht(-n*s):((1+r)*ht((-e*s+i)*n)+(1-r)*ht((-e*s-i)*n))/2,1-n}calculateSDFromBD(){const t=1===M.timeScale?this.pd/m:this.pd;this.m=1,this.v=0,this.s=rt(2*ft/t,2),this.bn>=0?this.d=4*(1-this.bn)*ft/t:this.d=4*ft/(t*(1+this.bn)),this.s=_t(yt(this.s,u,bs),3),this.d=_t(yt(this.d,u,300),3)}calculateBDFromSD(){const t=2*ft/nt(this.s);this.pd=t*(1===M.timeScale?m:1);const e=this.d/(2*nt(this.s));this.bn=e<=1?1-this.d*t/(4*ft):4*ft/(this.d*t)-1,this.bn=_t(yt(this.bn,-1,1),3),this.pd=_t(yt(this.pd,10*M.timeScale,bs*M.timeScale),3)}compute(){const{maxRestSteps:t,maxIterations:e,restThreshold:s,timeStep:i,m:r,d:n,s:o,v:a}=this,l=this.w0=yt(nt(o/r),u,m),h=this.zeta=n/(2*nt(o*r));h<1?(this.wd=l*nt(1-h*h),this.b=(h*l-a)/this.wd):1===h?(this.wd=0,this.b=-a+l):(this.wd=l*nt(h*h-1),this.b=(h*l-a)/this.wd);let d=0,c=0,p=0;for(;c<=t&&p<=e;)lt(1-this.solve(d))<s?c++:c=0,this.solverDuration=d,d+=i,p++;this.settlingDuration=_t(this.solverDuration*m,0)*M.timeScale}get bounce(){return this.bn}set bounce(t){this.bn=yt(Mt(t,1),-1,1),this.calculateSDFromBD(),this.compute()}get duration(){return this.pd}set duration(t){this.pd=yt(Mt(t,1),10*M.timeScale,bs*M.timeScale),this.calculateSDFromBD(),this.compute()}get stiffness(){return this.s}set stiffness(t){this.s=yt(Mt(t,100),u,bs),this.calculateBDFromSD(),this.compute()}get damping(){return this.d}set damping(t){this.d=yt(Mt(t,10),u,bs),this.calculateBDFromSD(),this.compute()}get mass(){return this.m}set mass(t){this.m=yt(Mt(t,1),1,bs),this.compute()}get velocity(){return this.v}set velocity(t){this.v=yt(Mt(t,0),-1e4,bs),this.compute()}}const Ss=t=>new Ts(t),xs=t=>(console.warn("createSpring() is deprecated use spring() instead"),new Ts(t)),ws={_head:null,_tail:null},Cs=(t,e,s)=>{let i,r=ws._head;for(;r;){const n=r._next,o=r.$el===t,a=!e||r.property===e,l=!s||r.parent===s;if(o&&a&&l){i=r.animation;try{i.commitStyles()}catch{}i.cancel(),$t(ws,r);const t=r.parent;t&&(t._completed++,t.animations.length===t._completed&&(t.completed=!0,t.paused=!0,t.muteCallbacks||(t.onComplete(t),t._resolve(t))))}r=n}return i},$s=(t,e,s,i,r)=>{const n=e.animate(i,r),o=r.delay+ +r.duration*r.iterations;n.playbackRate=t._speed,t.paused&&n.pause(),t.duration<o&&(t.duration=o,t.controlAnimation=n),t.animations.push(n),Cs(e,s),Et(ws,{parent:t,animation:n,$el:e,property:s,_next:null,_prev:null});const a=()=>Cs(e,s,t);return n.oncancel=a,n.onremove=a,t.persist||(n.onfinish=a),n};function Es(t,e,s){const i=$e(t);if(!i.length)return;const[n]=i,o=Vt(n,e),a=Jt(e,n,o);let l=Xt(n,a);if(q(s))return l;if(Yt(l,qt),qt.t===r.NUMBER||qt.t===r.UNIT){if(!1===s)return qt.n;{const t=ke(n,qt,s,!1);return`${_t(t.n,M.precision)}${t.u}`}}}const Ns=(t,e)=>{if(!q(e))return M.editor&&M.editor.addSet?M.editor.addSet(t,e):(e.duration=u,e.composition=Mt(e.composition,o.none),new ts(t,e,null,0,!0).resume())},ks=(t,e,s)=>{const i=Ce(t);for(let t=0,r=i.length;t<r;t++)Cs(i[t],s,e&&e.controlAnimation&&e);return ye(i,e,s),i},Rs=t=>{t.cancelable&&t.preventDefault()};class As{constructor(t){this.el=t,this.zIndex=0,this.parentElement=null,this.classList={add:S,remove:S}}get x(){return this.el.x||0}set x(t){this.el.x=t}get y(){return this.el.y||0}set y(t){this.el.y=t}get width(){return this.el.width||0}set width(t){this.el.width=t}get height(){return this.el.height||0}set height(t){this.el.height=t}getBoundingClientRect(){return{top:this.y,right:this.x,bottom:this.y+this.height,left:this.x+this.width}}}class Ds{constructor(t){this.$el=t,this.inlineTransforms=[],this.point=new DOMPoint,this.inversedMatrix=this.getMatrix().inverse()}normalizePoint(t,e){return this.point.x=t,this.point.y=e,this.point.matrixTransform(this.inversedMatrix)}traverseUp(t){let e=this.$el.parentElement,i=0;for(;e&&e!==s;)t(e,i),e=e.parentElement,i++}getMatrix(){const t=new DOMMatrix;return this.traverseUp(e=>{const s=getComputedStyle(e).transform;if(s){const e=new DOMMatrix(s);t.preMultiplySelf(e)}}),t}remove(){this.traverseUp((t,e)=>{this.inlineTransforms[e]=t.style.transform,t.style.transform="none"})}revert(){this.traverseUp((t,e)=>{const s=this.inlineTransforms[e];""===s?t.style.removeProperty("transform"):t.style.transform=s})}}const Os=(t,e)=>t&&W(t)?t(e):t;let Is=0;class Ls{constructor(t,i={}){if(!t)return;B.current&&B.current.register(this);const r=i.x,n=i.y,o=i.trigger,a=i.modifier,l=i.releaseEase,h=l&&Ve(l),d=!q(l)&&!q(l.ease),c=U(r)&&!q(r.mapTo)?r.mapTo:"translateX",u=U(n)&&!q(n.mapTo)?n.mapTo:"translateY",m=Os(i.container,this);this.containerArray=X(m)?m:null,this.$container=m&&!this.containerArray?Ce(m)[0]:s.body,this.useWin=this.$container===s.body,this.$scrollContainer=this.useWin?e:this.$container,this.$target=U(t)?new As(t):Ce(t)[0],this.$trigger=Ce(o||t)[0],this.fixed="fixed"===Es(this.$target,"position"),this.isFinePointer=!0,this.containerPadding=[0,0,0,0],this.containerFriction=0,this.releaseContainerFriction=0,this.snapX=0,this.snapY=0,this.scrollSpeed=0,this.scrollThreshold=0,this.dragSpeed=0,this.dragThreshold=3,this.maxVelocity=0,this.minVelocity=0,this.velocityMultiplier=0,this.cursor=!1,this.releaseXSpring=d?l:Ss({mass:Mt(i.releaseMass,1),stiffness:Mt(i.releaseStiffness,80),damping:Mt(i.releaseDamping,20)}),this.releaseYSpring=d?l:Ss({mass:Mt(i.releaseMass,1),stiffness:Mt(i.releaseStiffness,80),damping:Mt(i.releaseDamping,20)}),this.releaseEase=h||Be.outQuint,this.hasReleaseSpring=d,this.onGrab=i.onGrab||S,this.onDrag=i.onDrag||S,this.onRelease=i.onRelease||S,this.onUpdate=i.onUpdate||S,this.onSettle=i.onSettle||S,this.onSnap=i.onSnap||S,this.onResize=i.onResize||S,this.onAfterResize=i.onAfterResize||S,this.disabled=[0,0];const f={};if(a&&(f.modifier=a),q(r)||!0===r)f[c]=0;else if(U(r)){const t=r,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[c]=e}else!1===r&&(f[c]=0,this.disabled[0]=1);if(q(n)||!0===n)f[u]=0;else if(U(n)){const t=n,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[u]=e}else!1===n&&(f[u]=0,this.disabled[1]=1);this.animate=new hs(this.$target,f),this.xProp=c,this.yProp=u,this.destX=0,this.destY=0,this.deltaX=0,this.deltaY=0,this.scroll={x:0,y:0},this.coords=[this.x,this.y,0,0],this.snapped=[0,0],this.pointer=[0,0,0,0,0,0,0,0],this.scrollView=[0,0],this.dragArea=[0,0,0,0],this.containerBounds=[-p,p,p,-p],this.scrollBounds=[0,0,0,0],this.targetBounds=[0,0,0,0],this.window=[0,0],this.velocityStack=[0,0,0],this.velocityStackIndex=0,this.velocityTime=z(),this.velocity=0,this.angle=0,this.cursorStyles=null,this.triggerStyles=null,this.bodyStyles=null,this.targetStyles=null,this.touchActionStyles=null,this.transforms=new Ds(this.$target),this.overshootCoords={x:0,y:0},this.overshootTicker=new Se({autoplay:!1,onUpdate:()=>{this.updated=!0,this.manual=!0,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,1),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,1)},onComplete:()=>{this.manual=!1,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,0),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,0)}},null,0).init(),this.updateTicker=new Se({autoplay:!1,onUpdate:()=>this.update()},null,0).init(),this.contained=!q(m),this.manual=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.enabled=!1,this.initialized=!1,this.activeProp=this.disabled[1]?c:u,this.animate.callbacks.onRender=()=>{const t=this.updated,e=!(this.grabbed&&t)&&this.released,s=this.x,i=this.y,r=s-this.coords[2],n=i-this.coords[3];this.deltaX=r,this.deltaY=n,this.coords[2]=s,this.coords[3]=i,t&&(r||n)&&this.onUpdate(this),e?(this.computeVelocity(r,n),this.angle=mt(n,r)):this.updated=!1},this.animate.callbacks.onComplete=()=>{!this.grabbed&&this.released&&(this.released=!1),this.manual||(this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.onSettle(this))},this.resizeTicker=new Se({autoplay:!1,duration:150*M.timeScale,onComplete:()=>{this.onResize(this),this.refresh(),this.onAfterResize(this)}}).init(),this.parameters=i,this.resizeObserver=new ResizeObserver(()=>{this.initialized?this.resizeTicker.restart():this.initialized=!0}),this.enable(),this.refresh(),this.resizeObserver.observe(this.$container),U(t)||this.resizeObserver.observe(this.$target)}computeVelocity(t,e){const s=this.velocityTime,i=z(),r=i-s;if(r<17)return this.velocity;this.velocityTime=i;const n=this.velocityStack,o=this.velocityMultiplier,a=this.minVelocity,l=this.maxVelocity,h=this.velocityStackIndex;n[h]=_t(yt(nt(t*t+e*e)/r*o,a,l),5);const d=pt(n[0],n[1],n[2]);return this.velocity=d,this.velocityStackIndex=(h+1)%3,d}setX(t,e=!1){if(this.disabled[0])return;const s=_t(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destX=s,this.snapped[0]=vt(s,this.snapX),this.animate[this.xProp](s,0),this.manual=!1,this}setY(t,e=!1){if(this.disabled[1])return;const s=_t(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destY=s,this.snapped[1]=vt(s,this.snapY),this.animate[this.yProp](s,0),this.manual=!1,this}get x(){return _t(this.animate[this.xProp](),M.precision)}set x(t){this.setX(t,!1)}get y(){return _t(this.animate[this.yProp](),M.precision)}set y(t){this.setY(t,!1)}get progressX(){return fs(this.x,this.containerBounds[3],this.containerBounds[1],0,1)}set progressX(t){this.setX(fs(t,0,1,this.containerBounds[3],this.containerBounds[1]),!1)}get progressY(){return fs(this.y,this.containerBounds[0],this.containerBounds[2],0,1)}set progressY(t){this.setY(fs(t,0,1,this.containerBounds[0],this.containerBounds[2]),!1)}updateScrollCoords(){const t=_t(this.useWin?e.scrollX:this.$container.scrollLeft,0),s=_t(this.useWin?e.scrollY:this.$container.scrollTop,0),[i,r,n,o]=this.containerPadding,a=this.scrollThreshold;this.scroll.x=t,this.scroll.y=s,this.scrollBounds[0]=s-this.targetBounds[0]+i-a,this.scrollBounds[1]=t-this.targetBounds[1]-r+a,this.scrollBounds[2]=s-this.targetBounds[2]-n+a,this.scrollBounds[3]=t-this.targetBounds[3]+o-a}updateBoundingValues(){const t=this.$container;if(!t)return;const i=this.x,r=this.y,n=this.coords[2],o=this.coords[3];this.coords[2]=0,this.coords[3]=0,this.setX(0,!0),this.setY(0,!0),this.transforms.remove();const a=this.window[0]=e.innerWidth,l=this.window[1]=e.innerHeight,h=this.useWin,d=t.scrollWidth,c=t.scrollHeight,u=this.fixed,p=t.getBoundingClientRect(),[m,f,g,y]=this.containerPadding;this.dragArea[0]=h?0:p.left,this.dragArea[1]=h?0:p.top,this.scrollView[0]=h?yt(d,a,d):d,this.scrollView[1]=h?yt(c,l,c):c,this.updateScrollCoords();const{width:_,height:v,left:b,top:T,right:S,bottom:x}=t.getBoundingClientRect();this.dragArea[2]=_t(h?yt(_,a,a):_,0),this.dragArea[3]=_t(h?yt(v,l,l):v,0);const w=Es(t,"overflow"),C="visible"===w,$="hidden"===w;if(this.canScroll=!u&&this.contained&&(t===s.body&&C||!$&&!C)&&(d>this.dragArea[2]+y-f||c>this.dragArea[3]+m-g)&&(!this.containerArray||this.containerArray&&!X(this.containerArray)),this.contained){const e=this.scroll.x,s=this.scroll.y,i=this.canScroll,r=this.$target.getBoundingClientRect(),n=i?h?0:t.scrollLeft:0,o=i?h?0:t.scrollTop:0,d=i?this.scrollView[0]-n-_:0,c=i?this.scrollView[1]-o-v:0;this.targetBounds[0]=_t(r.top+s-(h?0:T),0),this.targetBounds[1]=_t(r.right+e-(h?a:S),0),this.targetBounds[2]=_t(r.bottom+s-(h?l:x),0),this.targetBounds[3]=_t(r.left+e-(h?0:b),0),this.containerArray?(this.containerBounds[0]=this.containerArray[0]+m,this.containerBounds[1]=this.containerArray[1]-f,this.containerBounds[2]=this.containerArray[2]-g,this.containerBounds[3]=this.containerArray[3]+y):(this.containerBounds[0]=-_t(r.top-(u?yt(T,0,l):T)+o-m,0),this.containerBounds[1]=-_t(r.right-(u?yt(S,0,a):S)-d+f,0),this.containerBounds[2]=-_t(r.bottom-(u?yt(x,0,l):x)-c+g,0),this.containerBounds[3]=-_t(r.left-(u?yt(b,0,a):b)+n-y,0))}this.transforms.revert(),this.coords[2]=n,this.coords[3]=o,this.setX(i,!0),this.setY(r,!0)}isOutOfBounds(t,e,s){if(!this.contained)return 0;const[i,r,n,o]=t,[a,l]=this.disabled,h=!a&&e<o||!a&&e>r,d=!l&&s<i||!l&&s>n;return h&&!d?1:!h&&d?2:h&&d?3:0}refresh(){const t=this.parameters,i=t.x,r=t.y,n=Os(t.container,this),o=Os(t.containerPadding,this)||0,a=X(o)?o:[o,o,o,o],l=this.x,h=this.y,d=Os(t.cursor,this),c={onHover:"grab",onGrab:"grabbing"};if(d){const{onHover:t,onGrab:e}=d;t&&(c.onHover=t),e&&(c.onGrab=e)}const u=Os(t.dragThreshold,this),p={mouse:3,touch:7};if(H(u))p.mouse=u,p.touch=u;else if(u){const{mouse:t,touch:e}=u;q(t)||(p.mouse=t),q(e)||(p.touch=e)}this.containerArray=X(n)?n:null,this.$container=n&&!this.containerArray?Ce(n)[0]:s.body,this.useWin=this.$container===s.body,this.$scrollContainer=this.useWin?e:this.$container,this.isFinePointer=matchMedia("(pointer:fine)").matches,this.containerPadding=Mt(a,[0,0,0,0]),this.containerFriction=yt(Mt(Os(t.containerFriction,this),.8),0,1),this.releaseContainerFriction=yt(Mt(Os(t.releaseContainerFriction,this),this.containerFriction),0,1),this.snapX=Os(U(i)&&!q(i.snap)?i.snap:t.snap,this),this.snapY=Os(U(r)&&!q(r.snap)?r.snap:t.snap,this),this.scrollSpeed=Mt(Os(t.scrollSpeed,this),1.5),this.scrollThreshold=Mt(Os(t.scrollThreshold,this),20),this.dragSpeed=Mt(Os(t.dragSpeed,this),1),this.dragThreshold=this.isFinePointer?p.mouse:p.touch,this.minVelocity=Mt(Os(t.minVelocity,this),0),this.maxVelocity=Mt(Os(t.maxVelocity,this),50),this.velocityMultiplier=Mt(Os(t.velocityMultiplier,this),1),this.cursor=!1!==d&&c,this.updateBoundingValues();const[m,f,g,y]=this.containerBounds;this.setX(yt(l,y,f),!0),this.setY(yt(h,m,g),!0)}update(){if(this.updateScrollCoords(),this.canScroll){const[t,e,s,i]=this.containerPadding,[r,n]=this.scrollView,o=this.dragArea[2],a=this.dragArea[3],l=this.scroll.x,h=this.scroll.y,d=this.$container.scrollWidth,c=this.$container.scrollHeight,u=this.useWin?yt(d,this.window[0],d):d,p=this.useWin?yt(c,this.window[1],c):c,m=r-u,f=n-p;this.dragged&&m>0&&(this.coords[0]-=m,this.scrollView[0]=u),this.dragged&&f>0&&(this.coords[1]-=f,this.scrollView[1]=p);const g=10*this.scrollSpeed,y=this.scrollThreshold,[_,v]=this.coords,[b,T,S,x]=this.scrollBounds,w=_t(yt((v-b+t)/y,-1,0)*g,0),C=_t(yt((_-T-e)/y,0,1)*g,0),$=_t(yt((v-S-s)/y,0,1)*g,0),E=_t(yt((_-x+i)/y,-1,0)*g,0);if(w||$||E||C){const[t,e]=this.disabled;let s=l,i=h;t||(s=_t(yt(l+(E||C),0,r-o),0),this.coords[0]-=l-s),e||(i=_t(yt(h+(w||$),0,n-a),0),this.coords[1]-=h-i),this.useWin?this.$scrollContainer.scrollBy(-(l-s),-(h-i)):this.$scrollContainer.scrollTo(s,i)}}const[t,e,s,i]=this.containerBounds,[r,n,o,a,l,h]=this.pointer;this.coords[0]+=(r-l)*this.dragSpeed,this.coords[1]+=(n-h)*this.dragSpeed,this.pointer[4]=r,this.pointer[5]=n;const[d,c]=this.coords,[u,p]=this.snapped,m=(1-this.containerFriction)*this.dragSpeed;this.setX(d>e?e+(d-e)*m:d<i?i+(d-i)*m:d,!1),this.setY(c>s?s+(c-s)*m:c<t?t+(c-t)*m:c,!1),this.computeVelocity(r-l,n-h),this.angle=mt(n-a,r-o);const[f,g]=this.snapped;(f!==u&&this.snapX||g!==p&&this.snapY)&&this.onSnap(this)}stop(){this.updateTicker.pause(),this.overshootTicker.pause();for(let t in this.animate.animations)this.animate.animations[t].pause();return ye([this],null,"x"),ye([this],null,"y"),ye([this],null,"progressX"),ye([this],null,"progressY"),ye([this.scroll]),ye([this.overshootCoords]),this}scrollInView(t,e=0,s=Be.inOutQuad){this.updateScrollCoords();const i=this.destX,r=this.destY,n=this.scroll,o=this.scrollBounds,a=this.canScroll;if(!this.containerArray&&this.isOutOfBounds(o,i,r)){const[l,h,d,c]=o,u=_t(yt(r-l,-p,0),0),m=_t(yt(i-h,0,p),0),f=_t(yt(r-d,0,p),0),g=_t(yt(i-c,-p,0),0);new ts(n,{x:_t(n.x+(g?g-e:m?m+e:0),0),y:_t(n.y+(u?u-e:f?f+e:0),0),duration:q(t)?350*M.timeScale:t,ease:s,onUpdate:()=>{this.canScroll=!1,this.$scrollContainer.scrollTo(n.x,n.y)}}).init().then(()=>{this.canScroll=a})}return this}handleHover(){this.isFinePointer&&this.cursor&&!this.cursorStyles&&(this.cursorStyles=Ns(this.$trigger,{cursor:this.cursor.onHover}))}animateInView(t,e=0,s=Be.inOutQuad){this.stop(),this.updateBoundingValues();const i=this.x,r=this.y,[n,o,a,l]=this.containerPadding,h=this.scroll.y-this.targetBounds[0]+n+e,d=this.scroll.x-this.targetBounds[1]-o-e,c=this.scroll.y-this.targetBounds[2]-a-e,u=this.scroll.x-this.targetBounds[3]+l+e,p=this.isOutOfBounds([h,d,c,u],i,r);if(p){const[e,n]=this.disabled,o=yt(vt(i,this.snapX),u,d),a=yt(vt(r,this.snapY),h,c),l=q(t)?350*M.timeScale:t;e||1!==p&&3!==p||this.animate[this.xProp](o,l,s),n||2!==p&&3!==p||this.animate[this.yProp](a,l,s)}return this}handleDown(t){const e=t.target;if(this.grabbed||"range"===e.type)return;t.stopPropagation(),this.grabbed=!0,this.released=!1,this.stop(),this.updateBoundingValues();const i=t.changedTouches,r=i?i[0].clientX:t.clientX,n=i?i[0].clientY:t.clientY,{x:o,y:a}=this.transforms.normalizePoint(r,n),[l,h,d,c]=this.containerBounds,u=(1-this.containerFriction)*this.dragSpeed,p=this.x,m=this.y;this.coords[0]=this.coords[2]=u?p>h?h+(p-h)/u:p<c?c+(p-c)/u:p:p,this.coords[1]=this.coords[3]=u?m>d?d+(m-d)/u:m<l?l+(m-l)/u:m:m,this.pointer[0]=o,this.pointer[1]=a,this.pointer[2]=o,this.pointer[3]=a,this.pointer[4]=o,this.pointer[5]=a,this.pointer[6]=o,this.pointer[7]=a,this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null);const f=Es(this.$target,"zIndex",!1);Is=(f>Is?f:Is)+1,this.targetStyles=Ns(this.$target,{zIndex:Is}),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.isFinePointer&&this.cursor&&(this.bodyStyles=Ns(s.body,{cursor:this.cursor.onGrab})),this.scrollInView(100,0,Be.out(3)),this.onGrab(this),s.addEventListener("touchmove",this),s.addEventListener("touchend",this),s.addEventListener("touchcancel",this),s.addEventListener("mousemove",this),s.addEventListener("mouseup",this),s.addEventListener("selectstart",this)}handleMove(t){if(!this.grabbed)return;const e=t.changedTouches,s=e?e[0].clientX:t.clientX,i=e?e[0].clientY:t.clientY,{x:r,y:n}=this.transforms.normalizePoint(s,i),o=r-this.pointer[6],a=n-this.pointer[7];let l=t.target,h=!1,d=!1,c=!1;for(;e&&l&&l!==this.$trigger;){const t=Es(l,"overflow-y");if("hidden"!==t&&"visible"!==t){const{scrollTop:t,scrollHeight:e,clientHeight:s}=l;if(e>s){c=!0,h=t<=3,d=t>=e-s-3;break}}l=l.parentElement}c&&(!h&&!d||h&&a<0||d&&a>0)?(this.pointer[0]=r,this.pointer[1]=n,this.pointer[2]=r,this.pointer[3]=n,this.pointer[4]=r,this.pointer[5]=n,this.pointer[6]=r,this.pointer[7]=n):(Rs(t),this.triggerStyles||(this.triggerStyles=Ns(this.$trigger,{pointerEvents:"none"})),this.$trigger.addEventListener("touchstart",Rs,{passive:!1}),this.$trigger.addEventListener("touchmove",Rs,{passive:!1}),this.$trigger.addEventListener("touchend",Rs),(this.dragged||!this.disabled[0]&&lt(o)>this.dragThreshold||!this.disabled[1]&&lt(a)>this.dragThreshold)&&(this.updateTicker.resume(),this.pointer[2]=this.pointer[0],this.pointer[3]=this.pointer[1],this.pointer[0]=r,this.pointer[1]=n,this.dragged=!0,this.released=!1,this.onDrag(this)))}handleUp(){if(!this.grabbed)return;this.updateTicker.pause(),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null);const[t,e]=this.disabled,[i,r,n,a,l,h]=this.pointer,[d,c,u,p]=this.containerBounds,[m,f]=this.snapped,g=this.releaseXSpring,y=this.releaseYSpring,_=this.releaseEase,v=this.hasReleaseSpring,b=this.overshootCoords,T=this.x,S=this.y,x=this.computeVelocity(i-l,r-h),w=this.angle=mt(r-a,i-n),C=150*x,$=(1-this.releaseContainerFriction)*this.dragSpeed,E=T+at(w)*C,N=S+ot(w)*C,k=E>c?c+(E-c)*$:E<p?p+(E-p)*$:E,R=N>u?u+(N-u)*$:N<d?d+(N-d)*$:N,A=this.destX=yt(_t(vt(k,this.snapX),5),p,c),D=this.destY=yt(_t(vt(R,this.snapY),5),d,u),O=this.isOutOfBounds(this.containerBounds,E,N);let I=0,L=0,B=_,F=_,P=0;if(b.x=T,b.y=S,!t){const t=A===c?T>c?-1:1:T<p?-1:1,s=_t(T-A,0);g.velocity=e&&v?s?C*t/lt(s):0:x;const{ease:i,settlingDuration:r,restDuration:n}=g;I=T===A?0:v?r:r-n*M.timeScale,v&&(B=i),I>P&&(P=I)}if(!e){const e=D===u?S>u?-1:1:S<d?-1:1,s=_t(S-D,0);y.velocity=t&&v?s?C*e/lt(s):0:x;const{ease:i,settlingDuration:r,restDuration:n}=y;L=S===D?0:v?r:r-n*M.timeScale,v&&(F=i),L>P&&(P=L)}if(!v&&O&&$&&(I||L)){const t=o.blend;new ts(b,{x:{to:k,duration:.65*I},y:{to:R,duration:.65*L},ease:_,composition:t}).init(),new ts(b,{x:{to:A,duration:I},y:{to:D,duration:L},ease:_,composition:t}).init(),this.overshootTicker.stretch(pt(I,L)).restart()}else t||this.animate[this.xProp](A,I,B),e||this.animate[this.yProp](D,L,F);this.scrollInView(P,this.scrollThreshold,_);let V=!1;A!==m&&(this.snapped[0]=A,this.snapX&&(V=!0)),D!==f&&this.snapY&&(this.snapped[1]=D,this.snapY&&(V=!0)),V&&this.onSnap(this),this.grabbed=!1,this.dragged=!1,this.updated=!0,this.released=!0,this.onRelease(this),this.$trigger.removeEventListener("touchstart",Rs),this.$trigger.removeEventListener("touchmove",Rs),this.$trigger.removeEventListener("touchend",Rs),s.removeEventListener("touchmove",this),s.removeEventListener("touchend",this),s.removeEventListener("touchcancel",this),s.removeEventListener("mousemove",this),s.removeEventListener("mouseup",this),s.removeEventListener("selectstart",this)}reset(){return this.stop(),this.resizeTicker.pause(),this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.setX(0,!0),this.setY(0,!0),this.coords[0]=0,this.coords[1]=0,this.pointer[0]=0,this.pointer[1]=0,this.pointer[2]=0,this.pointer[3]=0,this.pointer[4]=0,this.pointer[5]=0,this.pointer[6]=0,this.pointer[7]=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this}enable(){return this.enabled||(this.enabled=!0,this.$target.classList.remove("is-disabled"),this.touchActionStyles=Ns(this.$trigger,{touchAction:this.disabled[0]?"pan-x":this.disabled[1]?"pan-y":"none"}),this.$trigger.addEventListener("touchstart",this,{passive:!0}),this.$trigger.addEventListener("mousedown",this,{passive:!0}),this.$trigger.addEventListener("mouseenter",this)),this}disable(){return this.enabled=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.touchActionStyles.revert(),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null),this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null),this.$target.classList.add("is-disabled"),this.$trigger.removeEventListener("touchstart",this),this.$trigger.removeEventListener("mousedown",this),this.$trigger.removeEventListener("mouseenter",this),s.removeEventListener("touchmove",this),s.removeEventListener("touchend",this),s.removeEventListener("touchcancel",this),s.removeEventListener("mousemove",this),s.removeEventListener("mouseup",this),s.removeEventListener("selectstart",this),this}revert(){return this.reset(),this.disable(),this.$target.classList.remove("is-disabled"),this.updateTicker.revert(),this.overshootTicker.revert(),this.resizeTicker.revert(),this.animate.revert(),this.resizeObserver.disconnect(),this}handleEvent(t){switch(t.type){case"mousedown":case"touchstart":this.handleDown(t);break;case"mousemove":case"touchmove":this.handleMove(t);break;case"mouseup":case"touchend":case"touchcancel":this.handleUp();break;case"mouseenter":this.handleHover();break;case"selectstart":Rs(t)}}}const Bs=(t,e)=>new Ls(t,e),Ms=(t=S)=>new Se({duration:1*M.timeScale,onComplete:t},null,0).resume(),Fs=t=>{let e;return(...s)=>{let i,r,n,o,a;e&&(i=e.currentIteration,r=e.iterationProgress,n=e.reversed,o=e._alternate,a=e._startTime,e.revert());const l=t(...s);return l&&!W(l)&&l.revert&&(e=l),q(r)||(e.currentIteration=i,e.iterationProgress=(o&&i%2?!n:n)?1-r:r,e._startTime=a),l||S}};class Ps{constructor(t={}){B.current&&B.current.register(this);const i=t.root;let r=s;i&&(r=i.current||i.nativeElement||Ce(i)[0]||s);const n=t.defaults,o=M.defaults,a=t.mediaQueries;if(this.defaults=n?wt(n,o):o,this.root=r,this.constructors=[],this.revertConstructors=[],this.revertibles=[],this.constructorsOnce=[],this.revertConstructorsOnce=[],this.revertiblesOnce=[],this.once=!1,this.onceIndex=0,this.methods={},this.matches={},this.mediaQueryLists={},this.data={},a)for(let t in a){const s=e.matchMedia(a[t]);this.mediaQueryLists[t]=s,s.addEventListener("change",this)}}register(t){(this.once?this.revertiblesOnce:this.revertibles).push(t)}execute(t){let e=B.current,s=B.root,i=M.defaults;B.current=this,B.root=this.root,M.defaults=this.defaults;const r=this.mediaQueryLists;for(let t in r)this.matches[t]=r[t].matches;const n=t(this);return B.current=e,B.root=s,M.defaults=i,n}refresh(){return this.onceIndex=0,this.execute(()=>{let t=this.revertibles.length,e=this.revertConstructors.length;for(;t--;)this.revertibles[t].revert();for(;e--;)this.revertConstructors[e](this);this.revertibles.length=0,this.revertConstructors.length=0,this.constructors.forEach(t=>{const e=t(this);W(e)&&this.revertConstructors.push(e)})}),this}add(t,e){if(this.once=!1,W(t)){const e=t;this.constructors.push(e),this.execute(()=>{const t=e(this);W(t)&&this.revertConstructors.push(t)})}else this.methods[t]=(...t)=>this.execute(()=>e(...t));return this}addOnce(t){if(this.once=!0,W(t)){const e=this.onceIndex++;if(this.constructorsOnce[e])return this;const s=t;this.constructorsOnce[e]=s,this.execute(()=>{const t=s(this);W(t)&&this.revertConstructorsOnce.push(t)})}return this}keepTime(t){this.once=!0;const e=this.onceIndex++,s=this.constructorsOnce[e];if(W(s))return s(this);const i=Fs(t);let r;return this.constructorsOnce[e]=i,this.execute(()=>{r=i(this)}),r}handleEvent(t){"change"===t.type&&this.refresh()}revert(){const t=this.revertibles,e=this.revertConstructors,s=this.revertiblesOnce,i=this.revertConstructorsOnce,r=this.mediaQueryLists;let n=t.length,o=e.length,a=s.length,l=i.length;for(;n--;)t[n].revert();for(;o--;)e[o](this);for(;a--;)s[a].revert();for(;l--;)i[l](this);for(let t in r)r[t].removeEventListener("change",this);t.length=0,e.length=0,this.constructors.length=0,s.length=0,i.length=0,this.constructorsOnce.length=0,this.onceIndex=0,this.matches={},this.methods={},this.mediaQueryLists={},this.data={}}}const Vs=t=>new Ps(t),zs=()=>{const t=s.createElement("div");s.body.appendChild(t),t.style.height="100lvh";const e=t.offsetHeight;return s.body.removeChild(t),e},Xs=(t,e)=>t&&W(t)?t(e):t,Us=new Map;class Hs{constructor(t){this.element=t,this.useWin=this.element===s.body,this.winWidth=0,this.winHeight=0,this.width=0,this.height=0,this.left=0,this.top=0,this.scale=1,this.zIndex=0,this.scrollX=0,this.scrollY=0,this.prevScrollX=0,this.prevScrollY=0,this.scrollWidth=0,this.scrollHeight=0,this.velocity=0,this.backwardX=!1,this.backwardY=!1,this.scrollTicker=new Se({autoplay:!1,onBegin:()=>this.dataTimer.resume(),onUpdate:()=>{const t=this.backwardX||this.backwardY;Ct(this,t=>t.handleScroll(),t)},onComplete:()=>this.dataTimer.pause()}).init(),this.dataTimer=new Se({autoplay:!1,frameRate:30,onUpdate:t=>{const e=t.deltaTime,s=this.prevScrollX,i=this.prevScrollY,r=this.scrollX,n=this.scrollY,o=s-r,a=i-n;this.prevScrollX=r,this.prevScrollY=n,o&&(this.backwardX=s>r),a&&(this.backwardY=i>n),this.velocity=_t(e>0?Math.sqrt(o*o+a*a)/e:0,5)}}).init(),this.resizeTicker=new Se({autoplay:!1,duration:250*M.timeScale,onComplete:()=>{this.updateWindowBounds(),this.refreshScrollObservers(),this.handleScroll()}}).init(),this.wakeTicker=new Se({autoplay:!1,duration:500*M.timeScale,onBegin:()=>{this.scrollTicker.resume()},onComplete:()=>{this.scrollTicker.pause()}}).init(),this._head=null,this._tail=null,this.updateScrollCoords(),this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll(),this.resizeObserver=new ResizeObserver(()=>this.resizeTicker.restart()),this.resizeObserver.observe(this.element),(this.useWin?e:this.element).addEventListener("scroll",this,!1)}updateScrollCoords(){const t=this.useWin,s=this.element;this.scrollX=_t(t?e.scrollX:s.scrollLeft,0),this.scrollY=_t(t?e.scrollY:s.scrollTop,0)}updateWindowBounds(){this.winWidth=e.innerWidth,this.winHeight=zs()}updateBounds(){const t=getComputedStyle(this.element),e=this.element;let s,i;if(this.scrollWidth=e.scrollWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),this.scrollHeight=e.scrollHeight+parseFloat(t.marginTop)+parseFloat(t.marginBottom),this.updateWindowBounds(),this.useWin)s=this.winWidth,i=this.winHeight;else{const t=e.getBoundingClientRect();s=e.clientWidth,i=e.clientHeight,this.top=t.top,this.left=t.left,this.scale=t.width?s/t.width:t.height?i/t.height:1}this.width=s,this.height=i}refreshScrollObservers(){Ct(this,t=>{t.ready&&t._debug&&t.removeDebug()}),this.updateBounds(),Ct(this,t=>{t.ready&&(t.refresh(),t.onResize(t),t._debug&&t.debug())})}refresh(){this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll()}handleScroll(){this.updateScrollCoords(),this.wakeTicker.restart()}handleEvent(t){"scroll"===t.type&&this.handleScroll()}revert(){this.scrollTicker.cancel(),this.dataTimer.cancel(),this.resizeTicker.cancel(),this.wakeTicker.cancel(),this.resizeObserver.disconnect(),(this.useWin?e:this.element).removeEventListener("scroll",this),Us.delete(this.element)}}const Ys=t=>{const e=t&&Ce(t)[0]||s.body;let i=Us.get(e);return i||(i=new Hs(e),Us.set(e,i)),i},Ws=(t,e,s,i,r)=>{const n="min"===e,o="max"===e,a="top"===e||"left"===e||"start"===e||n?0:"bottom"===e||"right"===e||"end"===e||o?"100%":"center"===e?"50%":e,{n:l,u:h}=Yt(a,qt);let d=l;return"%"===h?d=l/100*s:h&&(d=ke(t,qt,"px",!0).n),o&&i<0&&(d+=i),n&&r>0&&(d+=r),d},qs=(t,e,s,i,r)=>{let n;if(Y(e)){const o=O.exec(e);if(o){const a=o[0],l=a[0],h=e.split(a),d="min"===h[0],c="max"===h[0],u=Ws(t,h[0],s,i,r),p=Ws(t,h[1],s,i,r);if(d){const e=Ut(Ws(t,"min",s),p,l);n=e<u?u:e}else if(c){const e=Ut(Ws(t,"max",s),p,l);n=e>u?u:e}else n=Ut(u,p,l)}else n=Ws(t,e,s,i,r)}else n=e;return _t(n,0)},js=t=>{let e;const s=t.targets;for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i[l]){e=i;break}}return e};let Gs=0;const Zs=["#FF4B4B","#FF971B","#FFC730","#F9F640","#7AFF5A","#18FF74","#17E09B","#3CFFEC","#05DBE9","#33B3F1","#638CF9","#C563FE","#FF4FCF","#F93F8A"];class Qs{constructor(t={}){B.current&&B.current.register(this);const e=Mt(t.sync,"play pause"),i=e?Ve(e):null,r=e&&("linear"===e||e===Re),n=e&&!(i===Re&&!r),o=e&&(H(e)||!0===e||r),a=e&&Y(e)&&!n&&!o,l=a?e.split(" ").map(t=>()=>{const e=this.linked;return e&&e[t]?e[t]():null}):null,h=a&&l.length>2;this.index=Gs++,this.id=q(t.id)?this.index:t.id,this.container=Ys(t.container),this.target=null,this.linked=null,this.repeat=null,this.horizontal=null,this.enter=null,this.leave=null,this.sync=n||o||!!l,this.syncEase=n?i:null,this.syncSmooth=o?!0===e||r?1:e:null,this.onSyncEnter=l&&!h&&l[0]?l[0]:S,this.onSyncLeave=l&&!h&&l[1]?l[1]:S,this.onSyncEnterForward=l&&h&&l[0]?l[0]:S,this.onSyncLeaveForward=l&&h&&l[1]?l[1]:S,this.onSyncEnterBackward=l&&h&&l[2]?l[2]:S,this.onSyncLeaveBackward=l&&h&&l[3]?l[3]:S,this.onEnter=t.onEnter||S,this.onLeave=t.onLeave||S,this.onEnterForward=t.onEnterForward||S,this.onLeaveForward=t.onLeaveForward||S,this.onEnterBackward=t.onEnterBackward||S,this.onLeaveBackward=t.onLeaveBackward||S,this.onUpdate=t.onUpdate||S,this.onResize=t.onResize||S,this.onSyncComplete=t.onSyncComplete||S,this.reverted=!1,this.ready=!1,this.completed=!1,this.began=!1,this.isInView=!1,this.forceEnter=!1,this.hasEntered=!1,this.offset=0,this.offsetStart=0,this.offsetEnd=0,this.distance=0,this.prevProgress=0,this.thresholds=["start","end","end","start"],this.coords=[0,0,0,0],this.debugStyles=null,this.$debug=null,this._params=t,this._debug=Mt(t.debug,!1),this._next=null,this._prev=null,Et(this.container,this),Ms(()=>{if(!this.reverted){if(!this.target){const e=Ce(t.target)[0];this.target=e||s.body,this.refresh()}this._debug&&this.debug()}})}link(t){if(t&&(t.pause(),this.linked=t,q(t)||q(t.persist)||(t.persist=!0),!this._params.target)){let e;q(t.targets)?Ct(t,t=>{t.targets&&!e&&(e=js(t))}):e=js(t),this.target=e||s.body,this.refresh()}return this}get velocity(){return this.container.velocity}get backward(){return this.horizontal?this.container.backwardX:this.container.backwardY}get scroll(){return this.horizontal?this.container.scrollX:this.container.scrollY}get progress(){const t=(this.scroll-this.offsetStart)/this.distance;return t===1/0||isNaN(t)?0:_t(yt(t,0,1),6)}refresh(){this.ready=!0,this.reverted=!1;const t=this._params;return this.repeat=Mt(Xs(t.repeat,this),!0),this.horizontal="x"===Mt(Xs(t.axis,this),"y"),this.enter=Mt(Xs(t.enter,this),"end start"),this.leave=Mt(Xs(t.leave,this),"start end"),this.updateBounds(),this.handleScroll(),this}removeDebug(){return this.$debug&&(this.$debug.parentNode.removeChild(this.$debug),this.$debug=null),this.debugStyles&&(this.debugStyles.revert(),this.$debug=null),this}debug(){this.removeDebug();const t=this.container,e=this.horizontal,i=t.element.querySelector(":scope > .animejs-onscroll-debug"),r=s.createElement("div"),n=s.createElement("div"),o=s.createElement("div"),a=Zs[this.index%Zs.length],l=t.useWin,h=l?t.winWidth:t.width,d=l?t.winHeight:t.height,c=t.scrollWidth,u=t.scrollHeight,p=this.container.width>360?320:260,m=e?0:10,f=e?10:0,g=e?24:p/2,y=e?g:15,_=e?60:g,v=e?_:y,b=e?"repeat-x":"repeat-y",T=t=>e?"0px "+t+"px":t+"px 2px",S=t=>`linear-gradient(${e?90:0}deg, ${t} 2px, transparent 1px)`,x=(t,e,s,i,r)=>`position:${t};left:${e}px;top:${s}px;width:${i}px;height:${r}px;`;r.style.cssText=`${x("absolute",m,f,e?c:p,e?p:u)}\n pointer-events: none;\n z-index: ${this.container.zIndex++};\n display: flex;\n flex-direction: ${e?"column":"row"};\n filter: drop-shadow(0px 1px 0px rgba(0,0,0,.75));\n `,n.style.cssText=`${x("sticky",0,0,e?h:g,e?g:d)}`,i||(n.style.cssText+=`background:\n ${S("#FFFF")}${T(g-10)} / 100px 100px ${b},\n ${S("#FFF8")}${T(g-10)} / 10px 10px ${b};\n `),o.style.cssText=`${x("relative",0,0,e?c:g,e?g:u)}`,i||(o.style.cssText+=`background:\n ${S("#FFFF")}${T(0)} / ${e?"100px 10px":"10px 100px"} ${b},\n ${S("#FFF8")}${T(0)} / ${e?"10px 0px":"0px 10px"} ${b};\n `);const w=[" enter: "," leave: "];this.coords.forEach((t,i)=>{const r=i>1,l=(r?0:this.offset)+t,m=i%2,f=l<v,g=l>(r?e?h:d:e?c:u)-v,b=(r?m&&!f:!m&&!f)||g,T=s.createElement("div"),S=s.createElement("div"),C=e?b?"right":"left":b?"bottom":"top",$=b?(e?_:y)+(r?e?-1:g?0:-2:e?-1:-2):e?1:0;S.innerHTML=`${this.id}${w[m]}${this.thresholds[i]}`,T.style.cssText=`${x("absolute",0,0,_,y)}\n display: flex;\n flex-direction: ${e?"column":"row"};\n justify-content: flex-${r?"start":"end"};\n align-items: flex-${b?"end":"start"};\n border-${C}: 2px solid ${a};\n `,S.style.cssText=`\n overflow: hidden;\n max-width: ${p/2-10}px;\n height: ${y};\n margin-${e?b?"right":"left":b?"bottom":"top"}: -2px;\n padding: 1px;\n font-family: ui-monospace, monospace;\n font-size: 10px;\n letter-spacing: -.025em;\n line-height: 9px;\n font-weight: 600;\n text-align: ${e&&b||!e&&!r?"right":"left"};\n white-space: pre;\n text-overflow: ellipsis;\n color: ${m?a:"rgba(0,0,0,.75)"};\n background-color: ${m?"rgba(0,0,0,.65)":a};\n border: 2px solid ${m?a:"transparent"};\n border-${e?b?"top-left":"top-right":b?"top-left":"bottom-left"}-radius: 5px;\n border-${e?b?"bottom-left":"bottom-right":b?"top-right":"bottom-right"}-radius: 5px;\n `,T.appendChild(S);let E=l-$+(e?1:0);T.style[e?"left":"top"]=`${E}px`,(r?n:o).appendChild(T)}),r.appendChild(n),r.appendChild(o),t.element.appendChild(r),i||r.classList.add("animejs-onscroll-debug"),this.$debug=r,"static"===Es(t.element,"position")&&(this.debugStyles=Ns(t.element,{position:"relative "}))}updateBounds(){let t;this._debug&&this.removeDebug();const e=this.target,i=this.container,r=this.horizontal,n=this.linked;let o,a=e;for(n&&(o=n.currentTime,n.seek(0,!0));a&&a!==i.element&&a!==s.body;){const e="sticky"===Es(a,"position")&&Ns(a,{position:"static"});a=a.parentElement,e&&(t||(t=[]),t.push(e))}const l=e.getBoundingClientRect(),h=i.scale,d=(r?l.left+i.scrollX-i.left:l.top+i.scrollY-i.top)*h,c=(r?l.width:l.height)*h,u=r?i.width:i.height,p=(r?i.scrollWidth:i.scrollHeight)-u,m=this.enter,f=this.leave;let g="start",y="end",_="end",v="start";if(Y(m)){const t=m.split(" ");_=t[0],g=t.length>1?t[1]:g}else if(U(m)){const t=m;q(t.container)||(_=t.container),q(t.target)||(g=t.target)}else H(m)&&(_=m);if(Y(f)){const t=f.split(" ");v=t[0],y=t.length>1?t[1]:y}else if(U(f)){const t=f;q(t.container)||(v=t.container),q(t.target)||(y=t.target)}else H(f)&&(v=f);const b=qs(e,g,c),T=qs(e,y,c),S=b+d-u,x=T+d-p,w=qs(e,_,u,S,x),C=qs(e,v,u,S,x),$=b+d-w,E=T+d-C,N=E-$;this.offset=d,this.offsetStart=$,this.offsetEnd=E,this.distance=N<=0?0:N,this.thresholds=[g,y,_,v],this.coords=[b,T,w,C],t&&t.forEach(t=>t.revert()),n&&n.seek(o,!0),this._debug&&this.debug()}handleScroll(){if(!this.ready)return;const t=this.linked,e=this.sync,s=this.syncEase,i=this.syncSmooth,r=t&&(s||i),n=this.horizontal,o=this.container,a=this.scroll,l=a<=this.offsetStart,h=a>=this.offsetEnd,d=!l&&!h,c=a===this.offsetStart||a===this.offsetEnd,u=!this.hasEntered&&c,p=this._debug&&this.$debug;let m=!1,f=!1,g=this.progress;if(l&&this.began&&(this.began=!1),g>0&&!this.began&&(this.began=!0),r){const e=t.progress;if(i&&H(i)){if(i<1){const t=1e-4,s=e<g&&1===g?t:e>g&&!g?-t:0;g=_t(bt(e,g,bt(.01,.2,i))+s,6)}}else s&&(g=s(g));m=g!==this.prevProgress,f=1===e,m&&!f&&i&&e&&o.wakeTicker.restart()}if(p){const t=n?o.scrollY:o.scrollX;p.style[n?"top":"left"]=t+10+"px"}(d&&!this.isInView||u&&!this.forceEnter&&!this.hasEntered)&&(d&&(this.isInView=!0),this.forceEnter&&this.hasEntered?d&&(this.forceEnter=!1):(p&&d&&(p.style.zIndex=""+this.container.zIndex++),this.onSyncEnter(this),this.onEnter(this),this.backward?(this.onSyncEnterBackward(this),this.onEnterBackward(this)):(this.onSyncEnterForward(this),this.onEnterForward(this)),this.hasEntered=!0,u&&(this.forceEnter=!0))),(d||!d&&this.isInView)&&(m=!0),m&&(r&&t.seek(t.duration*g),this.onUpdate(this)),!d&&this.isInView&&(this.isInView=!1,this.onSyncLeave(this),this.onLeave(this),this.backward?(this.onSyncLeaveBackward(this),this.onLeaveBackward(this)):(this.onSyncLeaveForward(this),this.onLeaveForward(this)),e&&!i&&(f=!0)),g>=1&&this.began&&!this.completed&&(e&&f||!e)&&(e&&this.onSyncComplete(this),this.completed=!0,(!this.repeat&&!t||!this.repeat&&t&&t.completed)&&this.revert()),g<1&&this.completed&&(this.completed=!1),this.prevProgress=g}revert(){if(this.reverted)return;const t=this.container;return $t(t,this),t._head||t.revert(),this._debug&&this.removeDebug(),this.reverted=!0,this.ready=!1,this}}const Js=(t={})=>new Qs(t),Ks=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,ti=(t,e,s)=>{let i,r,n=0,o=1,a=0;do{r=n+(o-n)/2,i=Ks(r,e,s)-t,i>0?o=r:n=r}while(lt(i)>1e-7&&++a<100);return r},ei=(t=.5,e=0,s=.5,i=1)=>t===e&&s===i?Re:r=>0===r||1===r?r:Ks(ti(r,t,s),e,i),si=(t=10,e)=>{const s=e?dt:ct;return e=>s(yt(e,0,1)*t)*(1/t)},ii=(...t)=>{const e=t.length;if(!e)return Re;const s=e-1,i=t[0],r=t[s],n=[0],o=[it(i)];for(let e=1;e<s;e++){const i=t[e],r=Y(i)?i.trim().split(" "):[i],a=r[0],l=r[1];n.push(q(l)?e/s:it(l)/100),o.push(it(a))}return o.push(it(r)),n.push(1),function(t){for(let e=1,s=n.length;e<s;e++){const s=n[e];if(t<=s){const i=n[e-1],r=o[e-1];return r+(o[e]-r)*(t-i)/(s-i)}}return o[o.length-1]}},ri=(t=10,e=1)=>{const s=[0],i=t-1;for(let t=1;t<i;t++){const r=s[t-1],n=t/i,o=n*(1-e)+(n+((t+1)/i-n)*Math.random())*e;s.push(yt(o,r,1))}return s.push(1),ii(...s)};var ni=Object.freeze({__proto__:null,Spring:Ts,createSpring:xs,cubicBezier:ei,eases:Be,irregular:ri,linear:ii,spring:Ss,steps:si});const oi=(t,e=100)=>{const s=[];for(let i=0;i<=e;i++)s.push(_t(t(i/e),4));return`linear(${s.join(", ")})`},ai={},li=t=>{let e=ai[t];if(e)return e;if(e="linear",Y(t)){if(V(t,"linear")||V(t,"cubic-")||V(t,"steps")||V(t,"ease"))e=t;else if(V(t,"cubicB"))e=P(t);else{const s=Fe(t);W(s)&&(e=s===Re?"linear":oi(s))}ai[t]=e}else if(W(t)){const s=oi(t);s&&(e=s)}else t.ease&&(e=oi(t.ease));return e},hi=["x","y","z"],di=["perspective","width","height","margin","padding","top","right","bottom","left","borderWidth","fontSize","borderRadius",...hi],ci=(()=>[...hi,...b.filter(t=>["X","Y","Z"].some(e=>t.endsWith(e)))])();let ui=null;const pi=(t,e,s,i,r)=>{let n=Y(e)?e:Pt(e,s,i,r,null,null);return H(n)?di.includes(t)||V(t,"translate")?`${n}px`:V(t,"rotate")||V(t,"skew")?`${n}deg`:`${n}`:n},mi=(t,e,s,i,r,n)=>{let o="0";const a=q(i)?getComputedStyle(t)[e]:pi(e,i,t,r,n);return o=q(s)?X(i)?i.map(s=>pi(e,s,t,r,n)):a:[pi(e,s,t,r,n),a],o};class fi{constructor(e,s){B.current&&B.current.register(this),j(ui)&&(!t||!q(CSS)&&Object.hasOwnProperty.call(CSS,"registerProperty")?(b.forEach(t=>{const e=V(t,"skew"),s=V(t,"scale"),i=V(t,"rotate"),r=V(t,"translate"),n=i||e,o=n?"<angle>":s?"<number>":r?"<length-percentage>":"*";try{CSS.registerProperty({name:"--"+t,syntax:o,inherits:!1,initialValue:r?"0px":n?"0deg":s?"1":"0"})}catch{}}),ui=!0):ui=!1);const i=$e(e);i.length||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation.");const r=Mt(s.autoplay,M.defaults.autoplay),n=!(!r||!r.link)&&r,o=s.alternate&&!0===s.alternate,a=s.reversed&&!0===s.reversed,l=Mt(s.loop,M.defaults.loop),h=!0===l||l===1/0?1/0:H(l)?l+1:1,c=o?a?"alternate-reverse":"alternate":a?"reverse":"normal",u=1===M.timeScale?1:m;this.targets=i,this.animations=[],this.controlAnimation=null,this.onComplete=s.onComplete||M.defaults.onComplete,this.duration=0,this.muteCallbacks=!1,this.completed=!1,this.paused=!r||!1!==n,this.reversed=a,this.persist=Mt(s.persist,M.defaults.persist),this.autoplay=r,this._speed=Mt(s.playbackRate,M.defaults.playbackRate),this._resolve=S,this._completed=0,this._inlineStyles=[],i.forEach((t,e)=>{const r=t[d],n=ci.some(t=>s.hasOwnProperty(t)),o=t.style,a=this._inlineStyles[e]={},l=Mt(s.ease,M.defaults.ease),p=Pt(l,t,e,i,null,null),m=W(p)||Y(p)?p:l,f=l.ease&&l,y=li(m),_=(f?f.settlingDuration:Pt(Mt(s.duration,M.defaults.duration),t,e,i,null,null))*u,S=Pt(Mt(s.delay,M.defaults.delay),t,e,i,null,null)*u,x=Mt(s.composition,"replace");for(let l in s){if(!tt(l))continue;const d={},p={iterations:h,direction:c,fill:"both",easing:y,duration:_,delay:S,composite:x},m=s[l],f=!!n&&(b.includes(l)?l:v.get(l)),g=f?"transform":l;let T;if(a[g]||(a[g]=o[g]),U(m)){const s=m,n=Mt(s.ease,y),a=n.ease&&n,h=s.to,c=s.from;if(p.duration=(a?a.settlingDuration:Pt(Mt(s.duration,_),t,e,i,null,null))*u,p.delay=Pt(Mt(s.delay,S),t,e,i,null,null)*u,p.composite=Mt(s.composition,x),p.easing=li(n),T=mi(t,l,c,h,e,i),f?(d[`--${f}`]=T,r[f]=T):d[l]=mi(t,l,c,h,e,i),$s(this,t,l,d,p),!q(c))if(f){const t=`--${f}`;o.setProperty(t,d[t][0])}else o[l]=d[l][0]}else T=X(m)?m.map(s=>pi(l,s,t,e,i)):pi(l,m,t,e,i),f?(d[`--${f}`]=T,r[f]=T):d[l]=T,$s(this,t,l,d,p)}if(n){let t=g;for(let e in r)t+=`${T[e]}var(--${e})) `;o.transform=t}}),n&&this.autoplay.link(this)}forEach(t){try{const e=Y(t)?e=>e[t]():t;this.animations.forEach(e)}catch{}return this}get speed(){return this._speed}set speed(t){this._speed=+t,this.forEach(e=>e.playbackRate=t)}get currentTime(){const t=this.controlAnimation,e=M.timeScale;return this.completed?this.duration:t?+t.currentTime*(1===e?1:e):0}set currentTime(t){const e=t*(1===M.timeScale?1:m);this.forEach(t=>{!this.persist&&e>=this.duration&&t.play(),t.currentTime=e})}get progress(){return this.currentTime/this.duration}set progress(t){this.forEach(e=>e.currentTime=t*this.duration||0)}resume(){return this.paused?(this.paused=!1,this.forEach("play")):this}pause(){return this.paused?this:(this.paused=!0,this.forEach("pause"))}alternate(){return this.reversed=!this.reversed,this.forEach("reverse"),this.paused&&this.forEach("pause"),this}play(){return this.reversed&&this.alternate(),this.resume()}reverse(){return this.reversed||this.alternate(),this.resume()}seek(t,e=!1){return e&&(this.muteCallbacks=!0),t<this.duration&&(this.completed=!1),this.currentTime=t,this.muteCallbacks=!1,this.paused&&this.pause(),this}restart(){return this.completed=!1,this.seek(0,!0).resume()}commitStyles(){return this.forEach("commitStyles")}complete(){return this.seek(this.duration)}cancel(){return this.muteCallbacks=!0,this.commitStyles().forEach("cancel"),this.animations.length=0,requestAnimationFrame(()=>{this.targets.forEach(t=>{"none"===t.style.transform&&t.style.removeProperty("transform")})}),this}revert(){return this.cancel().targets.forEach((t,e)=>{const s=t.style,i=this._inlineStyles[e];for(let e in i){const r=i[e];q(r)||r===g?s.removeProperty(P(e)):t.style[e]=r}t.getAttribute("style")===g&&t.removeAttribute("style")}),this}then(t=S){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=S};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const gi={animate:(t,e)=>new fi(t,e),convertEase:oi};let yi=0,_i=0;const vi=(t,e)=>!(!t||!e)&&(t===e||t.contains(e)),bi=t=>{if(!t)return null;const e=t.style,s=e.transition||"";return e.setProperty("transition","none","important"),s},Ti=(t,e)=>{if(!t)return;const s=t.style;e?s.transition=e:s.removeProperty("transition")},Si=t=>{const e=t.layout.transitionMuteStore,s=t.$el,i=t.$measure;s&&!e.has(s)&&e.set(s,bi(s)),i&&!e.has(i)&&e.set(i,bi(i))},xi=t=>{t.forEach((t,e)=>Ti(e,t)),t.clear()},wi={display:"none",visibility:"hidden",opacity:"0",transform:"none",position:"static"},Ci=t=>{if(!t)return;const e=t.parentNode;e&&(e._head===t&&(e._head=t._next),e._tail===t&&(e._tail=t._prev),t._prev&&(t._prev._next=t._next),t._next&&(t._next._prev=t._prev),t._prev=null,t._next=null,t.parentNode=null)},$i=(t,e,s,i)=>{let r=t.dataset.layoutId;r||(r=t.dataset.layoutId="node-"+_i++);const n=i||{};return n.$el=t,n.$measure=t,n.id=r,n.index=0,n.targets=null,n.delay=0,n.duration=0,n.ease=null,n.state=s,n.layout=s.layout,n.parentNode=e||null,n.isTarget=!1,n.isEntering=!1,n.isLeaving=!1,n.isInlined=!1,n.hasTransform=!1,n.inlineStyles=[],n.inlineTransforms=null,n.inlineTransition=null,n.branchAdded=!1,n.branchRemoved=!1,n.branchNotRendered=!1,n.sizeChanged=!1,n.hasVisibilitySwap=!1,n.hasDisplayNone=!1,n.hasVisibilityHidden=!1,n.measuredInlineTransform=null,n.measuredInlineTransition=null,n.measuredDisplay=null,n.measuredVisibility=null,n.measuredPosition=null,n.measuredHasDisplayNone=!1,n.measuredHasVisibilityHidden=!1,n.measuredIsVisible=!1,n.measuredIsRemoved=!1,n.measuredIsInsideRoot=!1,n.properties={transform:"none",x:0,y:0,left:0,top:0,clientLeft:0,clientTop:0,width:0,height:0},n.layout.properties.forEach(t=>n.properties[t]=0),n._head=null,n._tail=null,n._prev=null,n._next=null,n},Ei=(t,e,s,i)=>{const r=t.$el,n=t.layout.root,o=n===r,a=t.properties,l=t.state.rootNode,h=t.parentNode,d=s.transform,c=r.style.transform,u=!!h&&h.measuredIsRemoved,p=s.position;o&&(t.layout.absoluteCoords="fixed"===p||"absolute"===p),t.$measure=e,t.inlineTransforms=c,t.hasTransform=d&&"none"!==d,t.measuredIsInsideRoot=vi(n,e),t.measuredInlineTransform=null,t.measuredDisplay=s.display,t.measuredVisibility=s.visibility,t.measuredPosition=p,t.measuredHasDisplayNone="none"===s.display,t.measuredHasVisibilityHidden="hidden"===s.visibility,t.measuredIsVisible=!(t.measuredHasDisplayNone||t.measuredHasVisibilityHidden),t.measuredIsRemoved=t.measuredHasDisplayNone||t.measuredHasVisibilityHidden||u;let m=!1,f=r.previousSibling;for(;f&&(f.nodeType===Node.COMMENT_NODE||f.nodeType===Node.TEXT_NODE&&!f.textContent.trim());)f=f.previousSibling;if(f&&f.nodeType===Node.TEXT_NODE)m=!0;else{for(f=r.nextSibling;f&&(f.nodeType===Node.COMMENT_NODE||f.nodeType===Node.TEXT_NODE&&!f.textContent.trim());)f=f.nextSibling;m=null!==f&&f.nodeType===Node.TEXT_NODE}if(t.isInlined=m,t.hasTransform&&!i){const s=t.layout.transitionMuteStore;s.get(r)||(t.inlineTransition=bi(r)),e===r?r.style.transform="none":(s.get(e)||(t.measuredInlineTransition=bi(e)),t.measuredInlineTransform=e.style.transform,e.style.transform="none")}let g,y,_=0,v=0,b=0,T=0;if(!i){const t=e.getBoundingClientRect();_=t.left,v=t.top,b=t.width,T=t.height}for(let t in a){const e="transform"===t?d:s[t]||s.getPropertyValue&&s.getPropertyValue(t);q(e)||(a[t]=e)}if(a.left=_,a.top=v,a.clientLeft=i?0:e.clientLeft,a.clientTop=i?0:e.clientTop,o)t.layout.absoluteCoords?(g=_,y=v):(g=0,y=0);else{const e=h||l,s=e.properties.left,i=e.properties.top,r=e.properties.clientLeft,n=e.properties.clientTop;if(t.layout.absoluteCoords)g=_-s-r,y=v-i-n;else if(e===l){const t=l.properties.left,e=l.properties.top;g=_-t-l.properties.clientLeft,y=v-e-l.properties.clientTop}else g=_-s-r,y=v-i-n}return a.x=g,a.y=y,a.width=b,a.height=T,t},Ni=(t,e)=>{if(e)for(let s in e)t.properties[s]=e[s]},ki=(t,e)=>{const s=Pt(e.ease,t.$el,t.index,t.targets,null,null),i=W(s)?s:e.ease,r=!q(i)&&!q(i.ease);t.ease=r?i.ease:i,t.duration=r?i.settlingDuration:Pt(e.duration,t.$el,t.index,t.targets,null,null),t.delay=Pt(e.delay,t.$el,t.index,t.targets,null,null)},Ri=t=>{const e=t.$el.style,s=t.inlineStyles;s.length=0,t.layout.recordedProperties.forEach(t=>{s.push(t,e[t]||"")})},Ai=t=>{const e=t.$el.style,s=t.inlineStyles;for(let t=0,i=s.length;t<i;t+=2){const i=s[t],r=s[t+1];r&&""!==r?e[i]=r:(e[i]="",e.removeProperty(i))}},Di=t=>{const e=t.inlineTransforms,s=t.$el.style;!t.hasTransform||!e||t.hasTransform&&"none"===s.transform||e&&"none"===e?s.removeProperty("transform"):e&&(s.transform=e);const i=t.$measure;if(t.hasTransform&&i!==t.$el){const e=i.style,s=t.measuredInlineTransform;s&&""!==s?e.transform=s:e.removeProperty("transform")}t.measuredInlineTransform=null,null!==t.inlineTransition&&(Ti(t.$el,t.inlineTransition),t.inlineTransition=null),i!==t.$el&&null!==t.measuredInlineTransition&&(Ti(i,t.measuredInlineTransition),t.measuredInlineTransition=null)},Oi=t=>{(t.measuredIsRemoved||t.hasVisibilitySwap)&&(t.$el.style.removeProperty("display"),t.$el.style.removeProperty("visibility"),t.hasVisibilitySwap&&(t.$measure.style.removeProperty("display"),t.$measure.style.removeProperty("visibility"))),t.layout.pendingRemoval.delete(t.$el)},Ii=(t,e,s)=>(e.properties={...t.properties},e.state=s,e.isTarget=t.isTarget,e.hasTransform=t.hasTransform,e.inlineTransforms=t.inlineTransforms,e.measuredIsVisible=t.measuredIsVisible,e.measuredDisplay=t.measuredDisplay,e.measuredIsRemoved=t.measuredIsRemoved,e.measuredHasDisplayNone=t.measuredHasDisplayNone,e.measuredHasVisibilityHidden=t.measuredHasVisibilityHidden,e.hasDisplayNone=t.hasDisplayNone,e.isInlined=t.isInlined,e.hasVisibilityHidden=t.hasVisibilityHidden,e);class Li{constructor(t){this.layout=t,this.rootNode=null,this.rootNodes=new Set,this.nodes=new Map,this.scrollX=0,this.scrollY=0}revert(){return this.forEachNode(t=>{this.layout.pendingRemoval.delete(t.$el),t.$el.removeAttribute("data-layout-id"),t.$measure.removeAttribute("data-layout-id")}),this.rootNode=null,this.rootNodes.clear(),this.nodes.clear(),this}getNode(t){if(t&&t.dataset)return this.nodes.get(t.dataset.layoutId)}getComputedValue(t,e){const s=this.getNode(t);if(s)return s.properties[e]}forEach(t,e){let s=t,i=0;for(;s;)if(e(s,i++),s._head)s=s._head;else if(s._next)s=s._next;else{for(;s&&!s._next;)s=s.parentNode;s&&(s=s._next)}}forEachRootNode(t){this.forEach(this.rootNode,t)}forEachNode(t){for(const e of this.rootNodes)this.forEach(e,t)}registerElement(t,e){if(!t||1!==t.nodeType)return null;this.layout.transitionMuteStore.has(t)||this.layout.transitionMuteStore.set(t,bi(t));const s=[t,e],i=this.layout.root;let r=null;for(;s.length;){const t=s.pop(),e=s.pop();if(!e||1!==e.nodeType||G(e))continue;const n=!!t&&t.measuredIsRemoved,o=n?wi:getComputedStyle(e),a=!!n||"none"===o.display,l=!!n||"hidden"===o.visibility,h=!a&&!l,d=e.dataset.layoutId,c=vi(i,e);let u=d?this.nodes.get(d):null;if(u&&u.$el!==e){const a=vi(i,u.$el),l=u.measuredIsVisible;if(a||!c&&(c||l||!h)){if(a&&!l&&h){Ei(u,e,o,n);let t=e.lastElementChild;for(;t;)s.push(t,u),t=t.previousElementSibling;r||(r=u);continue}{let i=e.lastElementChild;for(;i;)s.push(i,t),i=i.previousElementSibling;r||(r=u);continue}}Ci(u),u=$i(e,t,this,u)}else u=$i(e,t,this,u);u.branchAdded=!1,u.branchRemoved=!1,u.branchNotRendered=!1,u.isTarget=!1,u.sizeChanged=!1,u.hasVisibilityHidden=l,u.hasDisplayNone=a,u.hasVisibilitySwap=l&&!u.measuredHasVisibilityHidden||a&&!u.measuredHasDisplayNone,this.nodes.set(u.id,u),u.parentNode=t||null,u._prev=null,u._next=null,t?(this.rootNodes.delete(u),t._head?(t._tail._next=u,u._prev=t._tail,t._tail=u):(t._head=u,t._tail=u)):this.rootNodes.add(u),Ei(u,u.$el,o,n);let p=e.lastElementChild;for(;p;)s.push(p,u),p=p.previousElementSibling;r||(r=u)}return r}ensureDetachedNode(t,e){if(!t||t===this.layout.root)return null;const s=t.dataset.layoutId,i=s?this.nodes.get(s):null;if(i&&i.$el===t)return i;let r=null,n=t.parentElement;for(;n&&n!==this.layout.root;){if(e.has(n)){r=this.ensureDetachedNode(n,e);break}n=n.parentElement}return this.registerElement(t,r)}record(){const t=this.layout,e=t.children,s=t.root,i=X(e)?e:[e],r=[],n="*"===e?s:B.root,o=[];let a=s.parentElement;for(;a&&1===a.nodeType;){const t=getComputedStyle(a);if(t.transform&&"none"!==t.transform){const t=a.style.transform||"",e=bi(a);o.push(a,t,e),a.style.transform="none"}a=a.parentElement}for(let t=0,e=i.length;t<e;t++){const e=i[t];r[t]=Y(e)?n.querySelectorAll(e):e}const l=$e(r);this.nodes.clear(),this.rootNodes.clear();const h=this.registerElement(s,null);h.isTarget=!0,this.rootNode=h;const d=new Set;let c=0;const u=[];this.nodes.forEach(t=>{u.push(t.$el)}),this.nodes.forEach((t,e)=>{t.index=c++,t.targets=u,t&&t.measuredIsInsideRoot&&d.add(e)});const p=new Set,m=[];for(let t=0,e=l.length;t<e;t++){const e=l[t];if(e&&1===e.nodeType&&e!==s){if(!vi(s,e)){const t=e.dataset.layoutId;if(!t||!d.has(t))continue}p.has(e)||(p.add(e),m.push(e))}}for(let t=0,e=m.length;t<e;t++)this.ensureDetachedNode(m[t],p);for(let t=0,e=l.length;t<e;t++){const e=l[t],s=this.getNode(e);if(s){let t=s;for(;t&&!t.isTarget;)t.isTarget=!0,t=t.parentNode}}this.scrollX=window.scrollX,this.scrollY=window.scrollY,this.forEachNode(Di);for(let t=0,e=o.length;t<e;t+=3){const e=o[t],s=o[t+1],i=o[t+2];s&&""!==s?e.style.transform=s:e.style.removeProperty("transform"),Ti(e,i)}return this}}function Bi(t){const e={},s={};for(let i in t){const r=t[i];"duration"===i||"delay"===i||"ease"===i?s[i]=r:e[i]=r}return[e,s]}class Mi{constructor(t,e={}){B.current&&B.current.register(this);const s=Bi(e.swapAt),i=Bi(e.enterFrom),r=Bi(e.leaveTo),n=e.properties;if(e.duration=Mt(e.duration,350),e.delay=Mt(e.delay,0),e.ease=Mt(e.ease,"inOut(3.5)"),this.params=e,this.root=$e(t)[0],this.id=e.id||yi++,this.children=e.children||"*",this.absoluteCoords=!1,this.swapAtParams=wt(e.swapAt||{opacity:0},{ease:"inOut(1.75)"}),this.enterFromParams=e.enterFrom||{opacity:0},this.leaveToParams=e.leaveTo||{opacity:0},this.properties=new Set(["opacity","fontSize","color","backgroundColor","borderRadius","border","filter","clipPath"]),s[0])for(let t in s[0])this.properties.add(t);if(i[0])for(let t in i[0])this.properties.add(t);if(r[0])for(let t in r[0])this.properties.add(t);if(n)for(let t=0,e=n.length;t<e;t++)this.properties.add(n[t]);this.recordedProperties=new Set(["display","visibility","translate","position","left","top","marginLeft","marginTop","width","height","maxWidth","maxHeight","minWidth","minHeight"]),this.properties.forEach(t=>this.recordedProperties.add(t)),this.pendingRemoval=new WeakSet,this.transitionMuteStore=new Map,this.oldState=new Li(this),this.newState=new Li(this),this.timeline=null,this.transformAnimation=null,this.animating=[],this.swapping=[],this.leaving=[],this.entering=[],this.oldState.record(),xi(this.transitionMuteStore)}revert(){return this.root.classList.remove("is-animated"),this.timeline&&(this.timeline.complete(),this.timeline=null),this.transformAnimation&&(this.transformAnimation.complete(),this.transformAnimation=null),this.animating.length=this.swapping.length=this.leaving.length=this.entering.length=0,this.oldState.revert(),this.newState.revert(),requestAnimationFrame(()=>xi(this.transitionMuteStore)),this}record(){return this.transformAnimation&&(this.transformAnimation.cancel(),this.transformAnimation=null),this.oldState.record(),this.timeline&&(this.timeline.cancel(),this.timeline=null),this.newState.forEachRootNode(Ai),this}animate(t={}){const e={ease:Mt(t.ease,this.params.ease),delay:Mt(t.delay,this.params.delay),duration:Mt(t.duration,this.params.duration)},s={id:this.id},i=Mt(t.onComplete,this.params.onComplete),r=Mt(t.onPause,this.params.onPause);for(let e in L)"ease"!==e&&"duration"!==e&&"delay"!==e&&(q(t[e])?q(this.params[e])||(s[e]=this.params[e]):s[e]=t[e]);s.onComplete=()=>{const e=t.autoplay,s=M.editor;if(e&&e.linked||s&&s.showPanel)i&&i(this.timeline);else{this.transformAnimation&&this.transformAnimation.cancel(),f.forEachRootNode(t=>{Oi(t),Ai(t)});for(let t=0,e=x.length;t<e;t++){const e=x[t];e.style.transform=f.getComputedValue(e,"transform")}this.root.classList.contains("is-animated")&&(this.root.classList.remove("is-animated"),i&&i(this.timeline)),requestAnimationFrame(()=>{this.root.classList.contains("is-animated")||xi(this.transitionMuteStore)})}},s.onPause=()=>{const e=t.autoplay;if(e&&e.linked)return i&&i(this.timeline),void(r&&r(this.timeline));this.root.classList.contains("is-animated")&&(this.transformAnimation&&this.transformAnimation.cancel(),f.forEachRootNode(Oi),this.root.classList.remove("is-animated"),i&&i(this.timeline),r&&r(this.timeline))},s.composition=!1;const n=wt(wt(t.swapAt||{},this.swapAtParams),e),o=wt(wt(t.enterFrom||{},this.enterFromParams),e),a=wt(wt(t.leaveTo||{},this.leaveToParams),e),[l,h]=Bi(n),[d,c]=Bi(o),[u,p]=Bi(a),m=this.oldState,f=this.newState,g=this.animating,y=this.swapping,_=this.entering,v=this.leaving,b=this.pendingRemoval;g.length=y.length=_.length=v.length=0,m.forEachRootNode(Si),f.record(),f.forEachRootNode(Ri);const T=[],S=[],x=[],w=[],C=f.rootNode,$=C.$el;f.forEachRootNode(t=>{const e=t.$el,s=t.id,i=t.parentNode,r=!!i&&i.branchAdded,n=!!i&&i.branchRemoved,o=!!i&&i.branchNotRendered;let a=m.nodes.get(s);const l=!a;l?(a=Ii(t,{},m),m.nodes.set(s,a),a.measuredIsRemoved=!0):a.measuredIsRemoved&&!t.measuredIsRemoved&&(Ii(t,a,m),a.measuredIsRemoved=!0);const h=a.parentNode,c=(h?h.id:null)!==(i?i.id:null),p=a.$el!==t.$el,y=a.measuredIsRemoved,S=t.measuredIsRemoved;if(!a.measuredIsRemoved&&!S&&!l&&(c||p)){const t=a.properties.left,e=a.properties.top,s=i||f.rootNode,r=s.id?m.nodes.get(s.id):null,n=r?r.properties.left:s.properties.left,o=r?r.properties.top:s.properties.top,l=r?r.properties.clientLeft:s.properties.clientLeft,h=r?r.properties.clientTop:s.properties.clientTop;a.properties.x=t-n-l,a.properties.y=e-o-h}t.hasVisibilitySwap&&(t.hasVisibilityHidden&&(t.$el.style.visibility="visible",t.$measure.style.visibility="hidden"),t.hasDisplayNone&&(t.$el.style.display=a.measuredDisplay||t.measuredDisplay||"",t.$measure.style.visibility="hidden"));const x=b.has(e),w=a.measuredIsVisible,$=t.measuredIsVisible,E=!w&&$&&!o,N=!S&&(y||x)&&!r,k=S&&!y&&!n,R=k||S&&x&&!n;t.branchAdded=r||N,t.branchRemoved=n||R,t.branchNotRendered=o||S,S&&w&&(t.$el.style.display=a.measuredDisplay,t.$el.style.visibility="visible",Ii(a,t,f)),k?(t.isTarget&&(v.push(e),t.isLeaving=!0),b.add(e)):!S&&x&&b.delete(e),N&&!o||E?(Ni(a,d),t.isTarget&&(_.push(e),t.isEntering=!0)):R&&!o&&Ni(t,u),t===C||!t.isTarget||t.isEntering||t.isLeaving||g.push(e),T.push(e)});let E=0,N=0,k=0;f.forEachRootNode(t=>{const s=t.$el,i=t.parentNode,r=m.nodes.get(t.id),n=t.properties,o=r.properties;let a=i!==C&&i;for(;a&&!a.isTarget&&a!==C;)a=a.parentNode;t===C?(t.index=0,t.targets=g,ki(t,e)):t.isEntering?(t.index=a?a.index:E,t.targets=a?g:_,ki(t,c),E++):t.isLeaving?(t.index=a?a.index:N,t.targets=a?g:v,N++,ki(t,p)):t.isTarget?(t.index=k++,t.targets=g,ki(t,e)):(t.index=a?a.index:0,t.targets=g,ki(t,h)),r.index=t.index,r.targets=t.targets;for(let e in n)n[e]=Pt(n[e],s,t.index,t.targets,null,null),o[e]=Pt(o[e],s,r.index,r.targets,null,null);const d=Math.abs(n.width-o.width)>1,u=Math.abs(n.height-o.height)>1;if(t.sizeChanged=d||u,t.isTarget&&(!t.measuredIsRemoved&&r.measuredIsVisible||t.measuredIsRemoved&&t.measuredIsVisible)){"none"===n.transform&&"none"===o.transform||(t.hasTransform=!0,x.push(s));for(let t in n)if("transform"!==t&&n[t]!==o[t]){S.push(s);break}}t.isTarget||(y.push(s),t.sizeChanged&&i&&i.isTarget&&i.sizeChanged&&(l.transform&&(t.hasTransform=!0,x.push(s)),w.push(s)))});const R={delay:t=>f.getNode(t).delay,duration:t=>f.getNode(t).duration,ease:t=>f.getNode(t).ease};if(s.defaults=R,this.timeline=ls(s),!S.length&&!x.length&&!y.length)return xi(this.transitionMuteStore),this.timeline.complete();if(T.length){this.root.classList.add("is-animated");for(let t=0,e=T.length;t<e;t++){const e=T[t],s=e.dataset.layoutId,i=m.nodes.get(s),r=f.nodes.get(s),n=i.properties;r.isInlined||("grid"!==i.measuredDisplay&&"grid"!==r.measuredDisplay||e.style.setProperty("display","block","important"),(e!==$||this.absoluteCoords)&&(e.style.position=this.absoluteCoords?"fixed":"absolute",e.style.left="0px",e.style.top="0px",e.style.marginLeft="0px",e.style.marginTop="0px",e.style.translate=`${n.x}px ${n.y}px`),e===$&&"static"===r.measuredPosition&&(e.style.position="relative",e.style.left="0px",e.style.top="0px")),e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none"}m.scrollX===window.scrollX&&m.scrollY===window.scrollY||requestAnimationFrame(()=>window.scrollTo(m.scrollX,m.scrollY));for(let t=0,e=S.length;t<e;t++){const e=S[t],s=e.dataset.layoutId,i=m.nodes.get(s),r=f.nodes.get(s),n=i.properties,o=r.properties;let a=!1;const l={composition:"none"};n.width!==o.width&&(l.width=[n.width,o.width],a=!0),n.height!==o.height&&(l.height=[n.height,o.height],a=!0),r.hasTransform||r.isInlined||(l.translate=[`${n.x}px ${n.y}px`,`${o.x}px ${o.y}px`],a=!0),this.properties.forEach(t=>{const e=n[t],s=o[t];"transform"!==t&&e!==s&&(l[t]=[e,s],a=!0)}),a&&this.timeline.add(e,l,0)}}if(y.length){for(let t=0,e=y.length;t<e;t++){const e=y[t],s=m.getNode(e),i=s.properties;e.style.width=`${i.width}px`,e.style.height=`${i.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none",s.isInlined||(e.style.translate=`${i.x}px ${i.y}px`),this.properties.forEach(t=>{"transform"!==t&&(e.style[t]=`${m.getComputedValue(e,t)}`)})}for(let t=0,e=y.length;t<e;t++){const e=y[t],s=f.getNode(e),i=s.properties;this.timeline.call(()=>{e.style.width=`${i.width}px`,e.style.height=`${i.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none",s.isInlined||(e.style.translate=`${i.x}px ${i.y}px`),this.properties.forEach(t=>{"transform"!==t&&(e.style[t]=`${f.getComputedValue(e,t)}`)})},s.delay+s.duration/2)}if(w.length){const t=Ve(f.nodes.get(w[0].dataset.layoutId).ease),e=e=>1-t(1-e),s={};if(l)for(let t in l)"transform"!==t&&(s[t]=[{from:e=>m.getComputedValue(e,t),to:l[t]},{from:l[t],to:e=>f.getComputedValue(e,t),ease:e}]);this.timeline.add(w,s,0)}}const A=x.length;if(A){for(let t=0;t<A;t++){const e=x[t],s=f.getNode(e);s.isInlined||(e.style.translate=`${m.getComputedValue(e,"x")}px ${m.getComputedValue(e,"y")}px`),e.style.transform=m.getComputedValue(e,"transform"),w.includes(e)&&(s.ease=Pt(n.ease,e,s.index,s.targets,null,null),s.duration=Pt(n.duration,e,s.index,s.targets,null,null))}this.transformAnimation=gi.animate(x,{translate:t=>f.getNode(t).isInlined?"0px 0px":`${f.getComputedValue(t,"x")}px ${f.getComputedValue(t,"y")}px`,transform:t=>{const e=f.getComputedValue(t,"transform");if(!w.includes(t))return e;const s=m.getComputedValue(t,"transform"),i=f.getNode(t);return[s,Pt(l.transform,t,i.index,i.targets,null,null),e]},autoplay:!1,...R}),this.timeline.sync(this.transformAnimation,0)}return this.timeline.init()}update(t,e={}){return this.record(),t(this),this.animate(e)}}const Fi=(t,e)=>new Mi(t,e),Pi=vs,Vi={},zi=(t,e=0)=>(...s)=>e?e=>t(...s,e):e=>t(e,...s),Xi=t=>(...e)=>{const s=t(...e);return new Proxy(S,{apply:(t,e,[i])=>s(i),get:(t,e)=>{if(Vi[e])return Xi((...t)=>{const i=Vi[e](...t);return t=>i(s(t))})}})},Ui=(t,e,s=0)=>{const i=(...t)=>(t.length<e.length?Xi(zi(e,s)):e)(...t);return Vi[t]||(Vi[t]=i),i},Hi=Ui("roundPad",Pi.roundPad),Yi=Ui("padStart",Pi.padStart),Wi=Ui("padEnd",Pi.padEnd),qi=Ui("wrap",Pi.wrap),ji=Ui("mapRange",Pi.mapRange),Gi=Ui("degToRad",Pi.degToRad),Zi=Ui("radToDeg",Pi.radToDeg),Qi=Ui("snap",Pi.snap),Ji=Ui("clamp",Pi.clamp),Ki=Ui("round",Pi.round),tr=Ui("lerp",Pi.lerp,1),er=Ui("damp",Pi.damp,1),sr=(t=0,e=1,s=0)=>{const i=10**s;return Math.floor((Math.random()*(e-t+1/i)+t)*i)/i};let ir=0;const rr=(t,e=0,s=1,i=0)=>{let r=void 0===t?ir++:t;return(t=e,n=s,o=i)=>{r+=1831565813,r=Math.imul(r^r>>>15,1|r),r^=r+Math.imul(r^r>>>7,61|r);const a=10**o;return Math.floor((((r^r>>>14)>>>0)/4294967296*(n-t+1/a)+t)*a)/a}},nr=t=>t[sr(0,t.length-1)],or=(t,e=sr)=>{let s,i,r=t.length;for(;r;)i=e(0,--r),s=t[r],t[r]=t[i],t[i]=s;return t},ar=(t,e={})=>{let s,i=[],r=0,n=null;const o=e.from,a=e.reversed,l=e.ease,h=!q(l),d=h&&!q(l.ease)?l.ease:h?Ve(l):null,c=e.grid,u=!0===c,p=e.axis,m=e.total,f=q(o)||0===o||"first"===o,y="center"===o,_="last"===o,v="random"===o,b=X(o),T=X(t),S=e.use,x=it(T?t[0]:t),w=T?it(t[1]):0,C=A.exec((T?t[1]:t)+g),$=e.start||0+(T?x:0),E=e.seed,N=q(E)||!1===E?sr:rr(!0===E?0:E),k=e.jitter,R=!q(k),D=X(k),O=D?k[0]:k||0,I=D?k[1]:k||0;let L=f?0:H(o)?o:0;return(t,l,h,f,g)=>{const[E]=$e(t),k=q(m)?h.length:m,A=!q(S)&&(W(S)?S(E,l,k):Xt(E,S)),D=H(A)||Y(A)&&H(+A)?+A:l,B=D>=0&&D<k?D:l;if(y&&(L=(k-1)/2),_&&(L=k-1),!i.length){if(u){let t=!0,e=!1,s=1/0,r=1/0,n=1/0,a=-1/0,l=-1/0,d=-1/0;const c=[],u=[],m=[];for(let i=0;i<k;i++){const o=h[i];let p=0,f=0,g=0,y=!1;if(o&&W(o.getBoundingClientRect)){const t=o.getBoundingClientRect();p=t.left+t.width/2,f=t.top+t.height/2,y=!0}else{const t=o;t&&H(t.x)&&H(t.y)&&(p=t.x,f=t.y,H(t.z)&&(g=t.z,e=!0),y=!0)}if(!y){t=!1;break}c.push(p),u.push(f),m.push(g),p<s&&(s=p),f<r&&(r=f),g<n&&(n=g),p>a&&(a=p),f>l&&(l=f),g>d&&(d=g)}if(t){let t=c[0],h=u[0],f=m[0];b?(t=s+o[0]*(a-s),h=r+o[1]*(l-r),f=e?n+(o.length>=3?o[2]:.5)*(d-n):0):y?(t=(s+a)/2,h=(r+l)/2,f=(n+d)/2):_?(t=c[k-1],h=u[k-1],f=m[k-1]):H(o)&&(t=c[o],h=u[o],f=m[o]);for(let s=0;s<k;s++){const r=t-c[s],n=h-u[s],o=f-m[s];let a=nt(r*r+n*n+(e?o*o:0));"x"===p&&(a=-r),"y"===p&&(a=-n),"z"===p&&(a=-o),i.push(a)}let g=1/0;for(let t=0;t<k;t++){const e=lt(i[t]);e>0&&e<g&&(g=e)}if(g>0&&g<1/0)for(let t=0;t<k;t++)i[t]=i[t]/g}else for(let t=0;t<k;t++)i.push(lt(L-t))}else for(let t=0;t<k;t++)if(c){const e=c.length,s=c[0]*c[1];let r,n,a;b?(r=o[0]*(c[0]-1),n=o[1]*(c[1]-1),a=3===e?(o.length>=3?o[2]:.5)*(c[2]-1):0):y?(r=(c[0]-1)/2,n=(c[1]-1)/2,a=3===e?(c[2]-1)/2:0):(r=L%c[0],n=ct(L/c[0])%c[1],a=3===e?ct(L/s):0);const l=r-t%c[0],h=n-ct(t/c[0])%c[1],d=a-(3===e?ct(t/s):0);let u=nt(l*l+h*h+(3===e?d*d:0));"x"===p&&(u=-l),"y"===p&&(u=-h),"z"===p&&(u=-d),i.push(u)}else i.push(lt(L-t));r=i[0];for(let t=1;t<k;t++)i[t]>r&&(r=i[t]);if(d||a)for(let t=0;t<k;t++){let e=i[t];d&&(e=d(e/r)*r),a&&(e=p?-e:lt(r-e)),i[t]=e}if(R){n=new Array(k);for(let t=0;t<k;t++)n[t]=N(-1,1,4)}v&&(i=or(i,N))}const M=T?(w-x)/r:x;q(s)&&(s=g?is(g,q(e.start)?g.iterationDuration:$):$);let F=s+(M*_t(i[B],2)||0);if(R){const t=r?i[B]/r:0,e=O+(I-O)*t;F+=n[B]*e}return e.modifier&&(F=e.modifier(F)),C&&(F=`${F}${C[2]}`),F}};var lr=Object.freeze({__proto__:null,$:$e,addChild:Et,clamp:Ji,cleanInlineStyles:te,createSeededRandom:rr,damp:er,degToRad:Gi,forEachChildren:Ct,get:Es,keepTime:Fs,lerp:tr,mapRange:ji,padEnd:Wi,padStart:Yi,radToDeg:Zi,random:sr,randomPick:nr,remove:ks,removeChild:$t,round:Ki,roundPad:Hi,set:Ns,shuffle:or,snap:Qi,stagger:ar,sync:Ms,wrap:qi});const hr=t=>{const e=Ce(t)[0];return e&&G(e)?e:console.warn(`${t} is not a valid SVGGeometryElement`)},dr=(t,e,s,i,r)=>{const n=s+i,o=r?Math.max(0,Math.min(n,e)):(n%e+e)%e;return t.getPointAtLength(o)},cr=(t,e,s=0)=>i=>{const r=+t.getTotalLength(),n=i[h],o=t.getCTM(),a=0===s;return{from:0,to:r,modifier:i=>{const l=i+s*r;if("a"===e){const e=dr(t,r,l,-1,a),s=dr(t,r,l,1,a);return 180*mt(s.y-e.y,s.x-e.x)/ft}{const s=dr(t,r,l,0,a);return"x"===e?n||!o?s.x:s.x*o.a+s.y*o.c+o.e:n||!o?s.y:s.x*o.b+s.y*o.d+o.f}}}},ur=(t,e=0)=>{const s=hr(t);if(s)return{translateX:cr(s,"x",e),translateY:cr(s,"y",e),rotate:cr(s,"a",e)}},pr=t=>{let e=1;if(t&&t.getCTM){const s=t.getCTM();s&&(e=(nt(s.a*s.a+s.b*s.b)+nt(s.c*s.c+s.d*s.d))/2)}return e},mr=(t,e,s)=>{const i=m,r=getComputedStyle(t),n=r.strokeLinecap,o="non-scaling-stroke"===r.vectorEffect?t:null;let a=n;const l=new Proxy(t,{get(t,e){const s=t[e];return e===c?t:"setAttribute"===e?(...e)=>{if("draw"===e[0]){const s=e[1].split(" "),r=+s[0],l=+s[1],h=pr(o),d=-1e3*r*h,c=l*i*h+d,u=i*h+(0===r&&1===l||1===r&&0===l?0:10*h)-c;if("butt"!==n){const e=r===l?"butt":n;a!==e&&(t.style.strokeLinecap=`${e}`,a=e)}t.setAttribute("stroke-dashoffset",`${d}`),t.setAttribute("stroke-dasharray",`${c} ${u}`)}return Reflect.apply(s,t,e)}:W(s)?(...e)=>Reflect.apply(s,t,e):s}});return"1000"!==t.getAttribute("pathLength")&&(t.setAttribute("pathLength","1000"),l.setAttribute("draw",`${e} ${s}`)),l},fr=(t,e=0,s=0)=>Ce(t).map(t=>mr(t,e,s)),gr=(t,e=.33)=>(s,i,r,n)=>{if(!(s.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${s.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const o=hr(t);if(!o)throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");if(!(o.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${o.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const a="path"===s.tagName,l=a?" ":",",h=n?n._value:null;h&&s.setAttribute(a?"d":"points",h);let d="",c="";if(e){const t=s.getTotalLength(),i=o.getTotalLength(),r=Math.max(Math.ceil(t*e),Math.ceil(i*e));for(let e=0;e<r;e++){const n=e/(r-1),h=s.getPointAtLength(t*n),u=o.getPointAtLength(i*n),p=a?0===e?"M":"L":"";d+=p+_t(h.x,3)+l+h.y+" ",c+=p+_t(u.x,3)+l+u.y+" "}}else d=s.getAttribute(a?"d":"points"),c=o.getAttribute(a?"d":"points");return[d,c]};var yr=Object.freeze({__proto__:null,createDrawable:fr,createMotionPath:ur,morphTo:gr});const _r="undefined"!=typeof Intl&&Intl.Segmenter,vr=/\{value\}/g,br=/\{i\}/g,Tr=/(\s+)/,Sr=/^\s+$/,xr="line",wr="word",Cr="char",$r="data-line";let Er=null,Nr=null,kr=null;const Rr=t=>t.isWordLike||" "===t.segment||H(+t.segment),Ar=t=>t.setAttribute("aria-hidden","true"),Dr=(t,e)=>[...t.querySelectorAll(`[data-${e}]:not([data-${e}] [data-${e}])`)],Or={line:"#00D672",word:"#FF4B4B",char:"#5A87FF"},Ir=t=>{if(!t.childElementCount&&!t.textContent.trim()){const e=t.parentElement;t.remove(),e&&Ir(e)}},Lr=(t,e,s)=>{const i=t.getAttribute($r);if(null!==i&&+i!==e||"BR"===t.tagName){s.add(t);const e=t.previousSibling,i=t.nextSibling;e&&3===e.nodeType&&Sr.test(e.textContent)&&s.add(e),i&&3===i.nodeType&&Sr.test(i.textContent)&&s.add(i)}let r=t.childElementCount;for(;r--;)Lr(t.children[r],e,s);return s},Br=(t,e={})=>{let s="";e||(e={});const i=Y(e.class)?` class="${e.class}"`:"",r=Mt(e.clone,!1),n=Mt(e.wrap,!1),o=n?!0===n?"clip":n:!!r&&"clip";return n&&(s+=`<span${o?` style="overflow:${o};"`:""}>`),s+=`<span${i}${r?' style="position:relative;"':""} data-${t}="{i}">`,r?(s+="<span>{value}</span>",s+=`<span inert style="position:absolute;top:${"top"===r?"-100%":"bottom"===r?"100%":"0"};left:${"left"===r?"-100%":"right"===r?"100%":"0"};white-space:nowrap;">{value}</span>`):s+="{value}",s+="</span>",n&&(s+="</span>"),s},Mr=(t,e,s,i,r,n,o,a,l)=>{const h=r===xr,d=r===Cr,c=`_${r}_`,u=W(t)?t(s):t,p=h?"block":"inline-block";kr.innerHTML=u.replace(vr,`<i class="${c}"></i>`).replace(br,`${d?l:h?o:a}`);const m=kr.content,f=m.firstElementChild,g=m.querySelector(`[data-${r}]`)||f,y=m.querySelectorAll(`i.${c}`),_=y.length;if(_){f.style.display=p,g.style.display=p,g.setAttribute($r,`${o}`),h||(g.setAttribute("data-word",`${a}`),d&&g.setAttribute("data-char",`${l}`));let t=_;for(;t--;){const e=y[t],i=e.parentElement;i.style.display=p,h?i.innerHTML=s.innerHTML:i.replaceChild(s.cloneNode(!0),e)}e.push(g),i.appendChild(m)}else console.warn('The expression "{value}" is missing from the provided template.');return n&&(f.style.outline=`1px dotted ${Or[r]}`),f};class Fr{constructor(e,i={}){Er||(Er=_r?new _r([],{granularity:wr}):{segment:t=>{const e=[],s=t.split(Tr);for(let t=0,i=s.length;t<i;t++){const i=s[t];e.push({segment:i,isWordLike:!Sr.test(i)})}return e}}),Nr||(Nr=_r?new _r([],{granularity:"grapheme"}):{segment:t=>[...t].map(t=>({segment:t}))}),!kr&&t&&(kr=s.createElement("template")),B.current&&B.current.register(this);const{words:r,chars:n,lines:o,accessible:a,includeSpaces:l,debug:h}=i,d=(e=X(e)?e[0]:e)&&e.nodeType?e:(we(e)||[])[0],c=!0===o?{}:o,u=!0===r||q(r)?{}:r,p=!0===n?{}:n;this.debug=Mt(h,!1),this.includeSpaces=Mt(l,!1),this.accessible=Mt(a,!0),this.linesOnly=c&&!u&&!p,this.lineTemplate=U(c)?Br(xr,c):c,this.wordTemplate=U(u)||this.linesOnly?Br(wr,u):u,this.charTemplate=U(p)?Br(Cr,p):p,this.$target=d,this.html=d&&d.innerHTML,this.lines=[],this.words=[],this.chars=[],this.effects=[],this.effectsCleanups=[],this.cache=null,this.ready=!1,this.width=0,this.resizeTimeout=null;const m=()=>this.html&&(c||u||p)&&this.split();this.resizeObserver=new ResizeObserver(()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{const t=d.offsetWidth;t!==this.width&&(this.width=t,m())},150)}),this.lineTemplate&&!this.ready?s.fonts.ready.then(m):m(),d?this.resizeObserver.observe(d):console.warn("No Text Splitter target found.")}addEffect(t){if(!W(t))return console.warn("Effect must return a function."),this;const e=Fs(t);return this.effects.push(e),this.ready&&(this.effectsCleanups[this.effects.length-1]=e(this)),this}revert(){return clearTimeout(this.resizeTimeout),this.lines.length=this.words.length=this.chars.length=0,this.resizeObserver.disconnect(),this.effectsCleanups.forEach(t=>W(t)?t(this):t.revert&&t.revert()),this.$target.innerHTML=this.html,this}splitNode(t){const e=this.wordTemplate,i=this.charTemplate,r=this.includeSpaces,n=this.debug,o=t.nodeType;if(3===o){const o=t.nodeValue;if(o.trim()){const a=[],l=this.words,h=this.chars,d=Er.segment(o),c=s.createDocumentFragment();let u=null;for(const t of d){const e=t.segment,s=Rr(t);if(!u||s&&u&&Rr(u))a.push(e);else{const t=a.length-1,s=a[t];Tr.test(s)||Tr.test(e)?a.push(e):a[t]+=e}u=t}for(let t=0,o=a.length;t<o;t++){const o=a[t];if(o.trim()){const d=a[t+1],u=r&&d&&!d.trim(),p=o,m=i?Nr.segment(p):null,f=i?s.createDocumentFragment():s.createTextNode(u?o+" ":o);if(i){const t=[...m];for(let e=0,r=t.length;e<r;e++){const o=t[e],a=e===r-1&&u?o.segment+" ":o.segment,d=s.createTextNode(a);Mr(i,h,d,f,Cr,n,-1,l.length,h.length)}}e?Mr(e,l,f,c,wr,n,-1,l.length,h.length):i?c.appendChild(f):c.appendChild(s.createTextNode(o)),u&&t++}else{if(t&&r)continue;c.appendChild(s.createTextNode(o))}}t.parentNode.replaceChild(c,t)}}else if(1===o){const e=[...t.childNodes];for(let t=0,s=e.length;t<s;t++)this.splitNode(e[t])}}split(t=!1){const e=this.$target,i=!!this.cache&&!t,r=this.lineTemplate,n=this.wordTemplate,o=this.charTemplate,a="loading"!==s.fonts.status,l=r&&a;this.ready=!r||a,(l||t)&&this.effectsCleanups.forEach(t=>W(t)&&t(this)),i||(t&&(e.innerHTML=this.html,this.words.length=this.chars.length=0),this.splitNode(e),this.cache=e.innerHTML),l&&(i&&(e.innerHTML=this.cache),this.lines.length=0,n&&(this.words=Dr(e,wr))),o&&(l||n)&&(this.chars=Dr(e,Cr));const h=this.words.length?this.words:this.chars;let d,c=0;for(let t=0,e=h.length;t<e;t++){const e=h[t],{top:s,height:i}=e.getBoundingClientRect();!q(d)&&s-d>.5*i&&c++,e.setAttribute($r,`${c}`);const r=e.querySelectorAll(`[${$r}]`);let n=r.length;for(;n--;)r[n].setAttribute($r,`${c}`);d=s}if(l){const t=s.createDocumentFragment(),i=new Set,a=[];for(let t=0;t<c+1;t++){const s=e.cloneNode(!0);Lr(s,t,new Set).forEach(t=>{const e=t.parentNode;e&&(1===t.nodeType&&i.add(e),e.removeChild(t))}),a.push(s)}i.forEach(Ir);for(let e=0,s=a.length;e<s;e++)Mr(r,this.lines,a[e],t,xr,this.debug,e);e.innerHTML="",e.appendChild(t),n&&(this.words=Dr(e,wr)),o&&(this.chars=Dr(e,Cr))}if(this.linesOnly){const t=this.words;let e=t.length;for(;e--;){const s=t[e];s.replaceWith(s.textContent)}t.length=0}if(this.accessible&&(l||!i)){const t=s.createElement("span");t.style.cssText="position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;",t.innerHTML=this.html,e.insertBefore(t,e.firstChild),this.lines.forEach(Ar),this.words.forEach(Ar),this.chars.forEach(Ar)}return this.width=e.offsetWidth,(l||t)&&this.effects.forEach((t,e)=>this.effectsCleanups[e]=t(this)),this}refresh(){this.split(!0)}}const Pr=(t,e)=>new Fr(t,e),Vr=(t,e)=>(console.warn("text.split() is deprecated, import splitText() directly, or text.splitText()"),new Fr(t,e)),zr=t=>{let e="";for(let s=0,i=t.length;s<i;s++)if(s+2<i&&"-"===t[s+1]&&t.charCodeAt(s)<t.charCodeAt(s+2)){const i=t.charCodeAt(s),r=t.charCodeAt(s+2);for(let t=i;t<=r;t++)e+=String.fromCharCode(t);s+=2}else e+=t[s];return e},Xr={lowercase:"a-z",uppercase:"A-Z",numbers:"0-9",symbols:"!%#_|*+=",braille:"⠀-⣿",blocks:"▀-▟",shades:"░-▓"},Ur=new WeakMap,Hr=(t={})=>{t||(t={});const e=t.chars,s=Ve(t.ease||"linear"),i=t.text,r=t.from,n=t.reversed||!1,o=t.perturbation||0,a=t.cursor,l=!0===a?"_":"number"==typeof a?String.fromCharCode(a):"string"==typeof a?a:"",h=l.length,d=t.seed||0,c=void 0===t.override||t.override,u=t.revealRate||60,p=1e3*M.timeScale/u,m=t.settleDuration||300*M.timeScale,f=t.settleRate||30,g=t.duration,y=t.revealDelay,_=t.delay,v=t.onChange||S;return(t,a,u,b)=>{const T="function"==typeof e?e(t,a,u):e||"a-zA-Z0-9!%#_",S=zr(Xr[T]||T),x=S.length-1,w="function"==typeof g?g(t,a,u):g,C="function"==typeof y?y(t,a,u):y||0,$="function"==typeof _?_(t,a,u):_||0,E=d?rr(d):rr();Ur.has(t)||Ur.set(t,t.textContent);const N=b?b._value:t.textContent,k=void 0!==i?"function"==typeof i?i(t,a,u):i:b?b._value:Ur.get(t),R=" "===k||"&nbsp;"===k?" ":k,A=" "===N?0:N.length,D=R.length,O=!0===c?S:"string"==typeof c&&c.length>0?zr(Xr[c]||c):null,I=O?O.length-1:0,L=" "===c?" ":null,B=""===c?D:Math.max(A,D),F=w>0?w:(B-1)*p+m,P=_t((F+C)/M.timeScale,0)*M.timeScale,V=C>0?_t(C/P,12):0,z=void 0===r||"auto"===r?D<A?"right":"left":r,X=new Int32Array(B);if("random"===z){for(let t=0;t<B;t++)X[t]=t;for(let t=B-1;t>0;t--){const e=E(0,t),s=X[t];X[t]=X[e],X[e]=s}}else{const t="right"===z?(""!==c&&A?A:B)-1:"center"===z?((""!==c&&A?A:B)-1)/2:"number"==typeof z?z:0,e=Math.abs,s=new Array(B);for(let t=0;t<B;t++)s[t]=t;s.sort((s,i)=>e(s-t)-e(i-t));for(let t=0;t<B;t++)X[s[t]]=t}if(n){const t=B-1;for(let e=0;e<B;e++)X[e]=t-X[e]}const U=_t(m/F,12),H=_t((1-U)/B,12),Y=h*H,W=_t(1e3*M.timeScale/(f*P),12),q=new Float32Array(B),j=new Float32Array(B),G=o>0?o*U:0;for(let t=0;t<B;t++){const e=G>0?(E(0,2e3)-1e3)/1e3*G:0,s=G>0?(E(0,2e3)-1e3)/1e3*G:0;q[t]=X[t]*H+e,j[t]=Math.ceil((q[t]+U+s)/W)*W}if(D<B&&"left"!==z&&"right"!==z&&"random"!==z){let t=0;for(let e=D;e<B;e++)j[e]>t&&(t=j[e]);const e=new Array(D);for(let t=0;t<D;t++)e[t]=t;e.sort((t,e)=>X[t]-X[e]);const s=(1-t)/D;for(let i=0;i<D;i++){const r=t+i*s;r>j[e[i]]&&(j[e[i]]=r)}}const Z=new Array(B);for(let t=0;t<B;t++)Z[t]=S[E(0,x)];const Q=O?O===S?Z:new Array(B):null;if(Q&&Q!==Z)for(let t=0;t<B;t++)Q[t]=L||O[E(0,O.length-1)];let J=N;if(!b)if(""===c)J="";else if(O){J="";for(let t=0;t<A;t++)J+=" "===N[t]?" ":Q[t]}let K=-1,tt=-1,et="";const st=""!==c,it=!!O,rt=h>0;return{from:0,to:1,duration:P,delay:$,ease:"linear",modifier:t=>{if(t===K)return et;if(K=t,$>0&&t<=0)return et=N,N;if(t<=0)return et=J,J;if(t>=1)return et=R,R;et="";const e=t/W|0,i=e!==tt;i&&(tt=e);const r=V>0?(t-V)/(1-V):t,n=r>0?s(r):0;for(let t=0;t<B;t++){const e=q[t];n>=j[t]?t<D&&(et+=R[t]):n<=0||n<e?st&&t<A&&(it?" "===N[t]?et+=" ":(i&&(Q[t]=L||O[E(0,I)]),et+=Q[t]):et+=N[t]):t<D&&" "===R[t]||t<A&&" "===N[t]?et+=" ":rt&&n-e<Y?et+=l[h-1-((n-e)/H|0)]:(i&&(Z[t]=S[E(0,x)]),et+=Z[t])}return i&&v(et,n),et}}}};var Yr=Object.freeze({__proto__:null,TextSplitter:Fr,scrambleText:Hr,split:Vr,splitText:Pr});export{$e as $,hs as Animatable,Mi as AutoLayout,Ls as Draggable,ts as JSAnimation,Ps as Scope,Qs as ScrollObserver,Ts as Spring,Fr as TextSplitter,as as Timeline,Se as Timer,fi as WAAPIAnimation,Et as addChild,es as animate,Ji as clamp,te as cleanInlineStyles,ds as createAnimatable,Bs as createDraggable,fr as createDrawable,Fi as createLayout,ur as createMotionPath,Vs as createScope,rr as createSeededRandom,xs as createSpring,ls as createTimeline,xe as createTimer,ei as cubicBezier,er as damp,Gi as degToRad,Be as eases,ni as easings,ae as engine,Ct as forEachChildren,Es as get,M as globals,ri as irregular,Fs as keepTime,tr as lerp,ii as linear,ji as mapRange,gr as morphTo,Js as onScroll,Wi as padEnd,Yi as padStart,Zi as radToDeg,sr as random,nr as randomPick,ks as remove,$t as removeChild,Ki as round,Hi as roundPad,Hr as scrambleText,Us as scrollContainers,Ns as set,or as shuffle,Qi as snap,Vr as split,Pr as splitText,Ss as spring,ar as stagger,si as steps,yr as svg,Ms as sync,Yr as text,lr as utils,gi as waapi,qi as wrap};
diff --git a/dist/bundles/anime.umd.js b/dist/bundles/anime.umd.js
index 141f360d..240473cf 100644
--- a/dist/bundles/anime.umd.js
+++ b/dist/bundles/anime.umd.js
@@ -1,6 +1,6 @@
/**
* Anime.js - UMD bundle
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -39,6 +39,12 @@
/** @typedef {Timer&JSAnimation&Timeline} CallbackArgument */
/** @typedef {Animatable|Tickable|WAAPIAnimation|Draggable|ScrollObserver|TextSplitter|Scope|AutoLayout} Revertible */
+/**
+ * @typedef {Object} TweakRegister
+ * @property {String} type
+ * @property {*} defaultValue
+ */
+
// Stagger types
/**
@@ -58,11 +64,18 @@
* @property {Number|'first'|'center'|'last'|'random'|Array.<Number>} [from]
* @property {Boolean} [reversed]
* @property {Array.<Number>|Boolean} [grid]
- * @property {('x'|'y')} [axis]
- * @property {String|((target: Target, i: Number, length: Number) => Number)} [use]
+ * @property {('x'|'y'|'z')} [axis]
+ * @property {String | { method(target: Target, i: Number, length: Number): Number }['method']} [use]
* @property {Number} [total]
* @property {EasingParam} [ease]
* @property {TweenModifier} [modifier]
+ * @property {Number|[Number, Number]} [jitter] Additive uniform noise on the
+ * computed stagger value. Number form gives flat `+/-jitter`; tuple form
+ * ramps the magnitude `start -> end` across the from/axis/grid ordering
+ * and respects `ease`.
+ * @property {Boolean|Number} [seed] Seed for jitter draws and `from: 'random'`
+ * shuffling. `false` (default) uses Math.random. `true` seeds with `0`. A
+ * number is used directly as the seed.
*/
// Targets types
@@ -138,10 +151,7 @@
/**
* @template T
- * @callback Callback
- * @param {T} self - Returns itself
- * @param {PointerEvent} [e]
- * @return {*}
+ * @typedef {{ method(self: T): * }['method']} Callback
*/
/**
@@ -185,12 +195,17 @@
// Tween types
/**
+ * @typedef {Number|String|TweenKeyValue|EasingParam|Array.<Number|String|TweenKeyValue>} FunctionValueReturn
+ */
+
+/**
+ * @template [T=FunctionValueReturn]
* @callback FunctionValue
* @param {Target} [target] - The animated target
* @param {Number} [index] - The target index
* @param {TargetsArray} [targets] - The array of all animated targets
* @param {Tween|null} [prevTween] - The previous sibling tween for the same target and property
- * @return {Number|String|TweenObjectValue|EasingParam|Array.<Number|String|TweenObjectValue>}
+ * @return {T}
*/
/**
@@ -207,7 +222,7 @@
* @property {JSAnimation} parent
* @property {String} property
* @property {Target} target
- * @property {String|Number} _value
+ * @property {String|Number|Object} _value
* @property {Function|null} _toFunc
* @property {Function|null} _fromFunc
* @property {EasingFunction} _ease
@@ -226,7 +241,11 @@
* @property {Number} _startTime
* @property {Number} _changeDuration
* @property {Number} _absoluteStartTime
+ * @property {Number} _absoluteUpdateStartTime
+ * @property {Number} _absoluteEndTime
+ * @property {Number} _hasFromValue
* @property {tweenTypes} _tweenType
+ * @property {((target: any, value: number, tween: Tween) => void) | null} _setter
* @property {valueTypes} _valueType
* @property {Number} _composition
* @property {Number} _isOverlapped
@@ -247,8 +266,8 @@
* @property {Number} n - Single number value
* @property {String} u - Value unit
* @property {String} o - Value operator
- * @property {Array.<Number>} d - Array of Numbers (in case of complex value type)
- * @property {Array.<String>} s - Strings (in case of complex value type)
+ * @property {Array.<Number>} d - Array of Numbers (complex / color value type)
+ * @property {Array.<String>} s - Strings (complex value type)
*/
/** @typedef {{_head: null|Tween, _tail: null|Tween}} TweenPropertySiblings */
@@ -259,7 +278,7 @@
// JSAnimation types
/**
- * @typedef {Number|String|FunctionValue|EasingParam} TweenParamValue
+ * @typedef {Number|String|FunctionValue|EasingParam|TweakRegister} TweenParamValue
*/
/**
@@ -452,7 +471,7 @@
*/
/**
- * @typedef {Record<String, TweenParamValue | EasingParam | TweenModifier | TweenComposition | AnimatablePropertyParamsOptions> & AnimatablePropertyParamsOptions} AnimatableParams
+ * @typedef {Record<String, TweenParamValue | EasingParam | TweenModifier | TweenComposition | AnimatablePropertyParamsOptions | Callback<JSAnimation>> & AnimatablePropertyParamsOptions & TickableCallbacks<JSAnimation> & RenderableCallbacks<JSAnimation>} AnimatableParams
*/
// Scope types
@@ -495,7 +514,7 @@
/**
* @callback ScopeMethod
* @param {...*} args
- * @return {ScopeCleanupCallback|void}
+ * @return {*}
*/
// Scroll types
@@ -731,6 +750,11 @@
const emptyString = '';
const cssVarPrefix = 'var(';
+ // Arrays
+
+ // Shared sentinel for tween slots that don't hold array data. Never mutated, only read; COMPLEX and COLOR tweens always replace the slot before writing.
+ const emptyArray = [];
+
const shortTransforms = /*#__PURE__*/ (() => {
const map = new Map();
map.set('x', 'translateX');
@@ -764,6 +788,13 @@
/** @return {void} */
const noop = () => {};
+ /**
+ * @template T
+ * @param {T} v
+ * @return {T}
+ */
+ const noopModifier = v => v;
+
// Regex
const validRgbHslRgx = /\)\s*[-.\d]/;
@@ -785,10 +816,13 @@
/**
* @typedef {Object} EditorGlobals
* @property {boolean} showPanel
- * @property {boolean} synced
* @property {Function} addAnimation
+ * @property {Function} addSet
* @property {Function} addTimeline
* @property {Function} addTimelineChild
+ * @property {Function} addTimelineLabel
+ * @property {Function} addTimelineCall
+ * @property {Function} addTimelineSync
* @property {Function} resolveStagger
* @property {Object|null} _head
* @property {Object|null} _tail
@@ -811,7 +845,7 @@
loopDelay: 0,
ease: 'out(2)',
composition: compositionTypes.replace,
- modifier: v => v,
+ modifier: noopModifier,
onBegin: noop,
onBeforeUpdate: noop,
onUpdate: noop,
@@ -841,7 +875,7 @@
editor: null,
};
- const globalVersions = { version: '4.4.1', engine: null };
+ const globalVersions = { version: '4.5.0', engine: null };
if (isBrowser) {
if (!win.AnimeJS) win.AnimeJS = [];
@@ -988,7 +1022,7 @@
* @param {Number} factor - Interpolation factor in the range [0, 1]
* @return {Number} The interpolated value
*/
- const lerp$1 = (start, end, factor) => start + (end - start) * factor;
+ const lerp$1 = (start, end, factor) => factor === 1 ? end : factor === 0 ? start : start + (end - start) * factor;
/**
* Replaces infinity with maximum safe value
@@ -1237,6 +1271,61 @@
return str;
};
+ /**
+ * Anime.js adapter API. Each library or class group that wants to extend `animate()` and `utils.set()` calls `registerAdapter()` to create its own `Adapter`. The returned `Adapter` exposes `registerTargetAdapter(detect)` for per-class detection and `registerPropertyResolver(fn)` for global Color / Vector / pattern-based fallbacks.
+ *
+ * import { registerAdapter } from 'animejs/adapters';
+ *
+ * const myAdapter = registerAdapter();
+ * const widget = myAdapter.registerTargetAdapter((t) => t instanceof MyWidget);
+ * widget.registerProperty('value',
+ * (t) => t.getValue(),
+ * (target, value) => target.setValue(value),
+ * );
+ *
+ * For scalar tweens, `value` is the interpolated number. For color and complex tweens it is `undefined`; read `tween._numbers` instead. `gate(target)` scopes the prop to a subset of matching targets.
+ *
+ * Resolution order: every Adapter's target adapters in registration order (first match wins) then every Adapter's property resolvers (first non-null wins) then engine direct property path.
+ */
+
+
+ const adapters = /** @type {Adapter[]} */([]);
+
+ /**
+ * Internal resolution. Tries every Adapter's target adapters first (in registration order, first match wins), then every Adapter's property resolvers.
+ *
+ * @param {any} target
+ * @param {string} name
+ * @return {TargetAdapterEntry | null}
+ */
+ function resolveAdapterEntry(target, name) {
+ if (!target) return null;
+ const al = adapters.length;
+ outer: for (let i = 0; i < al; i++) {
+ const a = adapters[i];
+ if (a.detect && !a.detect(target)) continue;
+ const tas = a.targetAdapters;
+ for (let j = 0, m = tas.length; j < m; j++) {
+ const ta = tas[j];
+ if (ta.detect(target)) {
+ const entry = ta.props[name];
+ if (entry && (!entry.gate || entry.gate(target))) return entry;
+ break outer;
+ }
+ }
+ }
+ for (let i = 0; i < al; i++) {
+ const a = adapters[i];
+ if (a.detect && !a.detect(target)) continue;
+ const rs = a.propertyResolvers;
+ for (let j = 0, m = rs.length; j < m; j++) {
+ const entry = rs[j](target, name);
+ if (entry) return entry;
+ }
+ }
+ return null;
+ }
+
/**
@@ -1334,6 +1423,21 @@
return isUnd(targetValue) ? defaultValue : targetValue;
};
+ /**
+ * Resolve against the target when it's a DOM element, otherwise fall back to :root so non-DOM targets like three.js meshes and custom adapters still pick up CSS variables defined on the document.
+ *
+ * @param {String} value
+ * @param {Target} target
+ * @return {String|Number}
+ */
+ const resolveCssVar = (value, target) => {
+ const match = value.match(cssVariableMatchRgx);
+ const el = target[isDomSymbol] ? target : document.documentElement;
+ let computed = getComputedStyle(/** @type {HTMLElement} */(el))?.getPropertyValue(match[1]);
+ if ((!computed || computed.trim() === emptyString) && match[2]) computed = match[2].trim();
+ return computed || 0;
+ };
+
/**
* @param {TweenPropValue} value
* @param {Target} target
@@ -1344,30 +1448,26 @@
* @return {any}
*/
const getFunctionValue = (value, target, index, targets, store, prevTween) => {
- let func;
if (isFnc(value)) {
- func = () => {
+ if (!store) {
+ const computed = /** @type {Function} */(value)(target, index, targets, prevTween);
+ // Fallback to 0 if the function returns undefined, NaN, null, false or 0
+ return !isNaN(+computed) ? +computed : computed || 0;
+ }
+ const func = () => {
const computed = /** @type {Function} */(value)(target, index, targets, prevTween);
- // Fallback to 0 if the function returns undefined / NaN / null / false / 0
return !isNaN(+computed) ? +computed : computed || 0;
};
- } else if (isStr(value) && stringStartsWith(value, cssVarPrefix)) {
- func = () => {
- const match = value.match(cssVariableMatchRgx);
- const cssVarName = match[1];
- const fallbackValue = match[2];
- let computed = getComputedStyle(/** @type {HTMLElement} */(target))?.getPropertyValue(cssVarName);
- // Use fallback if CSS variable is not set or empty
- if ((!computed || computed.trim() === emptyString) && fallbackValue) {
- computed = fallbackValue.trim();
- }
- return computed || 0;
- };
- } else {
- return value;
+ store.func = func;
+ return func();
}
- if (store) store.func = func;
- return func();
+ if (isStr(value) && stringStartsWith(value, cssVarPrefix)) {
+ if (!store) return resolveCssVar(/** @type {String} */(value), target);
+ const func = () => resolveCssVar(/** @type {String} */(value), target);
+ store.func = func;
+ return func();
+ }
+ return value;
};
/**
@@ -1414,6 +1514,12 @@
*/
const getOriginalAnimatableValue = (target, propName, tweenType, animationInlineStyles) => {
const type = !isUnd(tweenType) ? tweenType : getTweenType(target, propName);
+ const adapterProp = resolveAdapterEntry(target, propName);
+ if (adapterProp) {
+ const value = adapterProp.get(target);
+ if (value && animationInlineStyles) animationInlineStyles[propName] = value;
+ return value == null ? 0 : value;
+ }
if (type === tweenTypes.OBJECT) {
const value = target[propName];
if (value && animationInlineStyles) animationInlineStyles[propName] = value;
@@ -1455,7 +1561,7 @@
};
/**
- * @param {String|Number} rawValue
+ * @param {String|Number|Object} rawValue
* @param {TweenDecomposedValue} targetObject
* @return {TweenDecomposedValue}
*/
@@ -1473,39 +1579,38 @@
// It's a number
targetObject.n = num;
return targetObject;
+ }
+ // let str = /** @type {String} */(rawValue).trim();
+ let str = /** @type {String} */(rawValue);
+ // Parsing operators (+=, -=, *=) manually is much faster than using regex here
+ if (str[1] === '=') {
+ targetObject.o = str[0];
+ str = str.slice(2);
+ }
+ // Skip exec regex if the value type is complex or color to avoid long regex backtracking
+ const unitMatch = str.includes(' ') ? false : unitsExecRgx.exec(str);
+ if (unitMatch) {
+ // Has a number and a unit
+ targetObject.t = valueTypes.UNIT;
+ targetObject.n = +unitMatch[1];
+ targetObject.u = unitMatch[2];
+ return targetObject;
+ } else if (targetObject.o) {
+ // Has an operator (+=, -=, *=)
+ targetObject.n = +str;
+ return targetObject;
+ } else if (isCol(str)) {
+ // Color string
+ targetObject.t = valueTypes.COLOR;
+ targetObject.d = convertColorStringValuesToRgbaArray(str);
+ return targetObject;
} else {
- // let str = /** @type {String} */(rawValue).trim();
- let str = /** @type {String} */(rawValue);
- // Parsing operators (+=, -=, *=) manually is much faster than using regex here
- if (str[1] === '=') {
- targetObject.o = str[0];
- str = str.slice(2);
- }
- // Skip exec regex if the value type is complex or color to avoid long regex backtracking
- const unitMatch = str.includes(' ') ? false : unitsExecRgx.exec(str);
- if (unitMatch) {
- // Has a number and a unit
- targetObject.t = valueTypes.UNIT;
- targetObject.n = +unitMatch[1];
- targetObject.u = unitMatch[2];
- return targetObject;
- } else if (targetObject.o) {
- // Has an operator (+=, -=, *=)
- targetObject.n = +str;
- return targetObject;
- } else if (isCol(str)) {
- // Is a color
- targetObject.t = valueTypes.COLOR;
- targetObject.d = convertColorStringValuesToRgbaArray(str);
- return targetObject;
- } else {
- // Is a more complex string (generally svg coords, calc() or filters CSS values)
- const matchedNumbers = str.match(digitWithExponentRgx);
- targetObject.t = valueTypes.COMPLEX;
- targetObject.d = matchedNumbers ? matchedNumbers.map(Number) : [];
- targetObject.s = str.split(digitWithExponentRgx) || [];
- return targetObject;
- }
+ // Is a more complex string (generally svg coords, calc() or filters CSS values)
+ const matchedNumbers = str.match(digitWithExponentRgx);
+ targetObject.t = valueTypes.COMPLEX;
+ targetObject.d = matchedNumbers ? matchedNumbers.map(Number) : [];
+ targetObject.s = str.split(digitWithExponentRgx) || [];
+ return targetObject;
}
};
@@ -1526,30 +1631,6 @@
const decomposedOriginalValue = createDecomposedValueTargetObject();
- /**
- * @param {Tween} tween
- * @param {Number} progress
- * @param {Number} precision
- * @return {String}
- */
- const composeColorValue = (tween, progress, precision) => {
- const mod = tween._modifier;
- const fn = tween._fromNumbers;
- const tn = tween._toNumbers;
- const r = round$1(clamp$1(/** @type {Number} */(mod(lerp$1(fn[0], tn[0], progress))), 0, 255), 0);
- const g = round$1(clamp$1(/** @type {Number} */(mod(lerp$1(fn[1], tn[1], progress))), 0, 255), 0);
- const b = round$1(clamp$1(/** @type {Number} */(mod(lerp$1(fn[2], tn[2], progress))), 0, 255), 0);
- const a = clamp$1(/** @type {Number} */(mod(round$1(lerp$1(fn[3], tn[3], progress), precision))), 0, 1);
- if (tween._composition !== compositionTypes.none) {
- const ns = tween._numbers;
- ns[0] = r;
- ns[1] = g;
- ns[2] = b;
- ns[3] = a;
- }
- return `rgba(${r},${g},${b},${a})`;
- };
-
/**
* @param {Tween} tween
* @param {Number} progress
@@ -1561,15 +1642,14 @@
const fn = tween._fromNumbers;
const tn = tween._toNumbers;
const ts = tween._strings;
- const hasComposition = tween._composition !== compositionTypes.none;
let v = ts[0];
for (let j = 0, l = tn.length; j < l; j++) {
const n = /** @type {Number} */(mod(round$1(lerp$1(fn[j], tn[j], progress), precision)));
const s = ts[j + 1];
v += `${s ? n + s : n}`;
- if (hasComposition) {
- tween._numbers[j] = n;
- }
+ // Keep _numbers fresh for every tween, not only composed ones, so a non-composition setter that reads the lerped triplet such as three transformOrigin still animates.
+ // Potential optimization, skip the write when nothing reads it: if (hasComposition || tween._setter) tween._numbers[j] = n;
+ tween._numbers[j] = n;
}
return v;
};
@@ -1621,12 +1701,14 @@
// Execute the "expensive" iterations calculations only when necessary
if (iterationCount > 1) {
// bitwise NOT operator seems to be generally faster than Math.floor() across browsers
- const currentIteration = ~~(tickableCurrentTime / (iterationDuration + (isCurrentTimeEqualOrAboveDuration ? 0 : _loopDelay)));
+ const period = iterationDuration + (isCurrentTimeEqualOrAboveDuration ? 0 : _loopDelay);
+ const currentIteration = ~~(tickableCurrentTime / period);
tickable._currentIteration = clamp$1(currentIteration, 0, iterationCount);
// Prevent the iteration count to go above the max iterations when reaching the end of the animation
if (isCurrentTimeEqualOrAboveDuration) tickable._currentIteration--;
isOdd = tickable._currentIteration % 2;
- iterationElapsedTime = tickableCurrentTime % (iterationDuration + _loopDelay) || 0;
+ // Derive elapsed from the same `~~` truncation that gave currentIteration. Using `% period` here can disagree with `~~(/period)` under float drift at iteration boundaries and write the wrong end of the tween for one frame.
+ iterationElapsedTime = tickableCurrentTime - currentIteration * period || 0;
}
// Checks if exactly one of _reversed and (_alternate && isOdd) is true
@@ -1658,12 +1740,14 @@
if (
forcedTick ||
tickMode === tickModes.AUTO && (
- time >= tickableDelay && time <= tickableEndTime || // Normal render
+ // Timeline children render from their offset instead of their delay so the gap left by a truncated sibling is covered on seek.
+ time >= (parent && tickableDelay > 0 ? 0 : tickableDelay) && time <= tickableEndTime || // Normal render
time <= tickableDelay && tickablePrevTime > tickableDelay || // Playhead is before the animation start time so make sure the animation is at its initial state
time >= tickableEndTime && tickablePrevTime !== duration // Playhead is after the animation end time so make sure the animation is at its end state
) ||
iterationTime >= tickableEndTime && tickablePrevTime !== duration ||
- iterationTime <= tickableDelay && tickablePrevTime > 0 ||
+ // iterationTime is per-iteration, compared to the delay to catch a backward seek into a looped iteration's delay region. Exclude the final settled end, where iterationTime clamps to duration and would falsely match the delay region when the delay exceeds the duration.
+ iterationTime <= tickableDelay && tickablePrevTime > 0 && !isCurrentTimeEqualOrAboveDuration ||
time <= tickablePrevTime && tickablePrevTime === duration && completed || // Force a render if a seek occurs on an completed animation
isCurrentTimeEqualOrAboveDuration && !completed && isSetter // This prevents 0 duration tickables to be skipped
) {
@@ -1679,7 +1763,8 @@
// Time has jumped more than globals.tickThreshold so consider this tick manual
const forcedRender = forcedTick || (isRunningBackwards ? deltaTime * -1 : deltaTime) >= globals.tickThreshold;
- const absoluteTime = tickable._offset + (parent ? parent._offset : 0) + tickableDelay + iterationTime;
+ // Round to match the precision of tween._absoluteStartTime so equal-time boundary checks compare cleanly without floating point drift from the unrounded _offset.
+ const absoluteTime = round$1(tickable._offset + (parent ? parent._offset : 0) + tickableDelay + iterationTime, 12);
// Only Animation can have tweens, Timer returns undefined
let tween = /** @type {Tween} */(/** @type {JSAnimation} */(tickable)._head);
@@ -1698,15 +1783,38 @@
const tweenNextRep = tween._nextRep;
const tweenPrevRep = tween._prevRep;
const tweenHasComposition = tweenComposition !== compositionTypes.none;
+ // The previous sibling stops writing at its truncated end, so this tween takes over the hold from that point.
+ const tweenPrevRepEndTime = tweenPrevRep ? tweenPrevRep._absoluteStartTime + tweenPrevRep._changeDuration : 0;
+ const tweenPrevRepIsCrossParent = tweenPrevRep && tweenPrevRep.parent !== tween.parent;
+ // Same parent keyframes take over at their own start, end plus delay equals the next start by construction.
+ // Cross parent siblings take over at their update start.
+ // Negative delay siblings take over at their own start instead.
+ const tweenNextRepTakeover = !tweenNextRep || tweenNextRep._isOverridden ? tweenAbsEndTime :
+ tweenNextRep.parent === tween.parent ? tweenAbsEndTime + tweenNextRep._delay :
+ tweenNextRep._absoluteStartTime < tweenNextRep._absoluteUpdateStartTime ? tweenNextRep._absoluteStartTime : tweenNextRep._absoluteUpdateStartTime;
if ((forcedRender || (
- (tweenCurrentTime !== tweenChangeDuration || absoluteTime <= tweenAbsEndTime + (tweenNextRep ? tweenNextRep._delay : 0)) &&
- (tweenCurrentTime !== 0 || absoluteTime >= tween._absoluteStartTime)
- )) && (!tweenHasComposition || (
+ // Tail keyframes always re-evaluate the gate so an earlier keyframe cannot leave the target stale by writing past its own range after a backward seek.
+ (tweenCurrentTime !== tweenChangeDuration || absoluteTime <= tweenNextRepTakeover ||
+ (tweenPrevRep && !tweenPrevRepIsCrossParent && (!tweenNextRep || tweenNextRep.parent !== tween.parent))) &&
+ // A cross parent tween re-renders its from value from the previous sibling truncated end so the handoff gap holds.
+ // A keyframe re-renders its from revert while the next keyframe time is stale so a backward jump over its range cannot leave the next value in place.
+ (tweenCurrentTime !== 0 || absoluteTime >= tween._absoluteStartTime ||
+ (tweenPrevRepIsCrossParent && !tween._hasFromValue && !tweenPrevRep._isOverridden && absoluteTime >= tweenPrevRepEndTime) ||
+ (tweenNextRep && !tweenNextRep._isOverridden && tweenNextRep.parent === tween.parent && tweenNextRep._currentTime !== 0 && iterationTime < tweenNextRep._startTime))
+ )) &&
+ // Non-first keyframes wait until the iteration reaches their own start before rendering, so the previous keyframe can handle the from-revert when scrubbed backward past this tween's range.
+ (!tweenPrevRep || tweenPrevRepIsCrossParent || iterationTime >= tween._startTime) &&
+ (!tweenHasComposition || (
!tween._isOverridden &&
(!tween._isOverlapped || absoluteTime <= tweenAbsEndTime) &&
- (!tweenNextRep || (tweenNextRep._isOverridden || absoluteTime <= tweenNextRep._absoluteStartTime)) &&
- (!tweenPrevRep || (tweenPrevRep._isOverridden || (absoluteTime >= (tweenPrevRep._absoluteStartTime + tweenPrevRep._changeDuration) + tween._delay)))
+ // The next sibling owns the value past its takeover point, so yielding there keeps writes single owner in both directions.
+ (!tweenNextRep || tweenNextRep._isOverridden || absoluteTime <= tweenNextRepTakeover) &&
+ // The previous sibling owns the value up to its truncated end.
+ // Cross parent tweens take over the hold from that point, explicit from values wait for their own start.
+ (!tweenPrevRep || (tweenPrevRep._isOverridden || (!tweenPrevRepIsCrossParent ?
+ absoluteTime >= tweenPrevRepEndTime + tween._delay :
+ absoluteTime >= tween._absoluteStartTime || (!tween._hasFromValue && absoluteTime >= tweenPrevRepEndTime))))
))
) {
@@ -1717,7 +1825,7 @@
const tweenType = tween._tweenType;
const tweenIsObject = tweenType === tweenTypes.OBJECT;
const tweenIsNumber = tweenValueType === valueTypes.NUMBER;
- // Only round the in-between frames values if the final value is a string
+ // Only round the in-between frames values if the final value is a string. Object targets consume raw numbers, so rounding is dead work there.
const tweenPrecision = (tweenIsNumber && tweenIsObject) || tweenProgress === 0 || tweenProgress === 1 ? -1 : globals.precision;
// Recompose tween value
@@ -1733,7 +1841,22 @@
number = /** @type {Number} */(tweenModifier(round$1(lerp$1(tween._fromNumber, tween._toNumber, tweenProgress), tweenPrecision)));
value = `${number}${tween._unit}`;
} else if (tweenValueType === valueTypes.COLOR) {
- value = composeColorValue(tween, tweenProgress, tweenPrecision);
+ const ns = tween._numbers;
+ const fn = tween._fromNumbers;
+ const tn = tween._toNumbers;
+ const omt = 1 - tweenProgress;
+ const fr = fn[0], fg = fn[1], fb = fn[2];
+ const tr = tn[0], tg = tn[1], tb = tn[2];
+ // RGB channels lerp in pseudo-linear space (square inputs, sqrt result) to approximate gamma-correct blending.
+ // See https://developer.nvidia.com/gpugems/gpugems3/part-iv-image-effects/chapter-24-importance-being-linear.
+ ns[0] = /** @type {Number} */(tweenModifier(Math.sqrt(fr * fr * omt + tr * tr * tweenProgress)));
+ ns[1] = /** @type {Number} */(tweenModifier(Math.sqrt(fg * fg * omt + tg * tg * tweenProgress)));
+ ns[2] = /** @type {Number} */(tweenModifier(Math.sqrt(fb * fb * omt + tb * tb * tweenProgress)));
+ ns[3] = /** @type {Number} */(tweenModifier(lerp$1(fn[3], tn[3], tweenProgress)));
+ // The rgba string is built only for the dispatch path or the internalRender composition tick (setters handles the color comp)
+ if (!tween._setter || internalRender) {
+ value = `rgba(${round$1(ns[0], 0)},${round$1(ns[1], 0)},${round$1(ns[2], 0)},${ns[3]})`;
+ }
} else if (tweenValueType === valueTypes.COMPLEX) {
value = composeComplexValue(tween, tweenProgress, tweenPrecision);
}
@@ -1748,7 +1871,9 @@
const tweenProperty = tween.property;
tweenTarget = tween.target;
- if (tweenIsObject) {
+ if (tween._setter) {
+ tween._setter(tweenTarget, number, tween);
+ } else if (tweenIsObject) {
tweenTarget[tweenProperty] = value;
} else if (tweenType === tweenTypes.ATTRIBUTE) {
/** @type {DOMTarget} */(tweenTarget).setAttribute(tweenProperty, /** @type {String} */(value));
@@ -1776,6 +1901,9 @@
tween._value = value;
}
+ } else if (tweenCurrentTime && tweenPrevRep && !tweenPrevRepIsCrossParent && iterationTime < tween._startTime) {
+ // Mark the keyframe as reverted when the playhead moves before its start, the previous keyframe owns the from revert and writes it once.
+ tween._currentTime = 0;
}
if (tweenTransformsNeedUpdate && tween._renderTransforms) {
@@ -1883,6 +2011,8 @@
forEachChildren(tl, (/** @type {JSAnimation} */child) => {
const childTime = round$1((tlChildrenTime - child._offset) * child._speed, 12); // Rounding is needed when using seconds
+ // Skip past-end siblings on backward iteration so their progress=1 to-values don't render last and overwrite the active sibling's write. Compare against _delay + duration so children with a normalized delay are not skipped while still inside their active range.
+ if (tlIsRunningBackwards && childTime > child._delay + child.duration) return;
const childTickMode = child._fps < tl._fps ? child.requestTick(tlCildrenTickTime) : tickMode;
tlChildrenHasRendered += render(child, childTime, muteCallbacks, internalRender, childTickMode);
if (!child.completed && tlChildrenHaveCompleted) tlChildrenHaveCompleted = false;
@@ -1959,7 +2089,20 @@
const tweenType = tween._tweenType;
const originalInlinedValue = tween._inlineValue;
const tweenHadNoInlineValue = isNil(originalInlinedValue) || originalInlinedValue === emptyString;
- if (tweenType === tweenTypes.OBJECT) {
+ if (tween._setter) {
+ if (!inlineStylesOnly && !tweenHadNoInlineValue) {
+ // Re-seed the original value to the _number / _numbers props so the setter can write the original state instead of re-applying the current frame.
+ decomposeRawValue(originalInlinedValue, decomposedOriginalValue);
+ if (decomposedOriginalValue.d) {
+ const src = decomposedOriginalValue.d;
+ const dst = tween._numbers;
+ for (let i = 0, l = src.length; i < l; i++) dst[i] = src[i];
+ } else {
+ tween._number = decomposedOriginalValue.n;
+ }
+ tween._setter(tween.target, tween._number, tween);
+ }
+ } else if (tweenType === tweenTypes.OBJECT) {
if (!inlineStylesOnly && !tweenHadNoInlineValue) {
tweenTarget[tweenProperty] = originalInlinedValue;
}
@@ -2036,8 +2179,6 @@
/** @type {Number} */
this._lastTime = initTime;
/** @type {Number} */
- this._scheduledTime = 0;
- /** @type {Number} */
this._frameDuration = K / maxFps;
/** @type {Number} */
this._fps = maxFps;
@@ -2056,14 +2197,12 @@
}
set fps(frameRate) {
- const previousFrameDuration = this._frameDuration;
const fr = +frameRate;
const fps = fr < minValue ? minValue : fr;
const frameDuration = K / fps;
if (fps > defaults.frameRate) defaults.frameRate = fps;
this._fps = fps;
this._frameDuration = frameDuration;
- this._scheduledTime += frameDuration - previousFrameDuration;
}
get speed() {
@@ -2080,17 +2219,17 @@
* @return {tickModes}
*/
requestTick(time) {
- const scheduledTime = this._scheduledTime;
- this._lastTickTime = time;
- // If the current time is lower than the scheduled time
- // this means not enough time has passed to hit one frameDuration
- // so skip that frame
- if (time < scheduledTime) return tickModes.NONE;
const frameDuration = this._frameDuration;
- const frameDelta = time - scheduledTime;
- // Ensures that _scheduledTime progresses in steps of at least 1 frameDuration.
- // Skips ahead if the actual elapsed time is higher.
- this._scheduledTime += frameDelta < frameDuration ? frameDuration : frameDelta;
+ const elapsed = time - this._lastTickTime;
+ const scaled = frameDuration * .25;
+ const tolerance = scaled < 4 ? scaled : 4;
+ // Tolerance prevents dropping frames that arrive a bit early due to RAF jitter
+ // typically <= ~25% of frame duration and capped at 4ms so it doesn't dominate at high fps.
+ // e.g. at 60fps (frameDuration=16.667ms) a frame arriving after 15ms:
+ // - without tolerance: 15 < 16.667 -> skip
+ // - with tolerance: 15 + 4 >= 16.667 -> tick
+ if (elapsed + tolerance < frameDuration) return tickModes.NONE;
+ this._lastTickTime = elapsed >= frameDuration ? time - (elapsed % frameDuration) : time;
return tickModes.AUTO;
}
@@ -2250,7 +2389,9 @@
}
set speed(playbackRate) {
- this._speed = playbackRate * globals.timeScale;
+ const speed = playbackRate * globals.timeScale;
+ if (this._speed === speed) return;
+ this._speed = speed;
forEachChildren(this, (/** @type {Tickable} */child) => child.speed = child._speed);
}
@@ -2383,7 +2524,7 @@
if (prevSibling) {
const prevParent = prevSibling.parent;
- const prevAbsEndTime = prevSibling._absoluteStartTime + prevSibling._changeDuration;
+ const prevAbsEndTime = prevSibling._absoluteEndTime;
// Handle looped animations tween
@@ -2409,7 +2550,8 @@
}
- const absoluteUpdateStartTime = tweenAbsStartTime - tween._delay;
+ // Read the precision-matched update-start instead of subtracting tween._delay live so sequential keyframes touching at a boundary don't trigger a phantom overlap from float drift.
+ const absoluteUpdateStartTime = tween._absoluteUpdateStartTime;
if (prevAbsEndTime > absoluteUpdateStartTime) {
@@ -2429,37 +2571,41 @@
}
}
- // Pause (and cancel) the parent if it only contains overlapped tweens
+ // Skip the cancel cascade when both tweens share the same parent timeline, a timeline cannot replace itself.
+ const tweenParentTL = tween.parent.parent;
+ if (!tweenParentTL || tweenParentTL !== prevParent.parent) {
- let pausePrevParentAnimation = true;
+ let pausePrevParentAnimation = true;
- forEachChildren(prevParent, (/** @type Tween */t) => {
- if (!t._isOverlapped) pausePrevParentAnimation = false;
- });
+ forEachChildren(prevParent, (/** @type Tween */t) => {
+ if (!t._isOverlapped) pausePrevParentAnimation = false;
+ });
- if (pausePrevParentAnimation) {
- const prevParentTL = prevParent.parent;
- if (prevParentTL) {
- let pausePrevParentTL = true;
- forEachChildren(prevParentTL, (/** @type JSAnimation */a) => {
- if (a !== prevParent) {
- forEachChildren(a, (/** @type Tween */t) => {
- if (!t._isOverlapped) pausePrevParentTL = false;
- });
+ if (pausePrevParentAnimation) {
+ const prevParentTL = prevParent.parent;
+ if (prevParentTL) {
+ let pausePrevParentTL = true;
+ forEachChildren(prevParentTL, (/** @type JSAnimation */a) => {
+ if (a !== prevParent) {
+ forEachChildren(a, (/** @type Tween */t) => {
+ if (!t._isOverlapped) pausePrevParentTL = false;
+ });
+ }
+ });
+ if (pausePrevParentTL) {
+ prevParentTL.cancel();
}
- });
- if (pausePrevParentTL) {
- prevParentTL.cancel();
+ } else {
+ prevParent.cancel();
+ // Previously, calling .cancel() on a timeline child would affect the render order of other children
+ // Worked around this by marking it as .completed and using .pause() for safe removal in the engine loop
+ // This is no longer needed since timeline tween composition is now handled separately
+ // Keeping this here for reference
+ // prevParent.completed = true;
+ // prevParent.pause();
}
- } else {
- prevParent.cancel();
- // Previously, calling .cancel() on a timeline child would affect the render order of other children
- // Worked around this by marking it as .completed and using .pause() for safe removal in the engine loop
- // This is no longer needed since timeline tween composition is now handled separately
- // Keeping this here for reference
- // prevParent.completed = true;
- // prevParent.pause();
}
+
}
}
@@ -2514,14 +2660,12 @@
tween._number = 0;
lookupTween._fromNumber = toNumber;
- if (tween._toNumbers) {
+ if (tween._toNumbers.length) {
const toNumbers = cloneArray(tween._toNumbers);
- if (toNumbers) {
- toNumbers.forEach((value, i) => {
- tween._fromNumbers[i] = lookupTween._fromNumbers[i] - value;
- tween._toNumbers[i] = 0;
- });
- }
+ toNumbers.forEach((value, i) => {
+ tween._fromNumbers[i] = lookupTween._fromNumbers[i] - value;
+ tween._toNumbers[i] = 0;
+ });
lookupTween._fromNumbers = toNumbers;
}
@@ -3222,18 +3366,16 @@
function registerTargets(targets) {
const parsedTargetsArray = parseTargets(targets);
const parsedTargetsLength = parsedTargetsArray.length;
- if (parsedTargetsLength) {
- for (let i = 0; i < parsedTargetsLength; i++) {
- const target = parsedTargetsArray[i];
- if (!target[isRegisteredTargetSymbol]) {
- target[isRegisteredTargetSymbol] = true;
- const isSvgType = isSvg(target);
- const isDom = /** @type {DOMTarget} */(target).nodeType || isSvgType;
- if (isDom) {
- target[isDomSymbol] = true;
- target[isSvgSymbol] = isSvgType;
- target[transformsSymbol] = {};
- }
+ for (let i = 0; i < parsedTargetsLength; i++) {
+ const target = parsedTargetsArray[i];
+ if (!target[isRegisteredTargetSymbol]) {
+ target[isRegisteredTargetSymbol] = true;
+ const isSvgType = isSvg(target);
+ const isDom = /** @type {DOMTarget} */(target).nodeType || isSvgType;
+ if (isDom) {
+ target[isDomSymbol] = true;
+ target[isSvgSymbol] = isSvgType;
+ target[transformsSymbol] = {};
}
}
}
@@ -3355,8 +3497,8 @@
/**
* @typedef {Object} EasesFunctions
- * @property {typeof none} linear
- * @property {typeof none} none
+ * @property {EasingFunction} linear
+ * @property {EasingFunction} none
* @property {PowerEasing} in
* @property {PowerEasing} out
* @property {PowerEasing} inOut
@@ -3588,6 +3730,11 @@
super(/** @type {TimerParams & AnimationParams} */(parameters), parent, parentPosition);
+ /** @type {Tween} */
+ this._head;
+ /** @type {Tween} */
+ this._tail;
+
++JSAnimationId;
const parsedTargets = registerTargets(targets);
@@ -3644,6 +3791,7 @@
if (isKey(p)) {
const tweenType = getTweenType(target, p);
+ const adapterProp = resolveAdapterEntry(target, p);
const propName = sanitizePropertyName(p, target, tweenType);
@@ -3727,7 +3875,7 @@
} else {
tweenToValue = computedToValue;
}
- const tweenFromValue = getFunctionValue(key.from, target, ti, tl, null, prevSiblingTween);
+ const tweenFromValue = getFunctionValue(key.from, target, ti, tl, fromFunctionStore, prevSiblingTween);
const easeToParse = key.ease || tEasing;
const easeFunctionResult = getFunctionValue(easeToParse, target, ti, tl, null, prevSiblingTween);
@@ -3745,9 +3893,13 @@
const hasToValue = !isUnd(tweenToValue);
const isFromToArray = isArr(tweenToValue);
const isFromToValue = isFromToArray || (hasFromvalue && hasToValue);
+ // Capture the update-start in local time, the previous sibling's end for keyframes after the first, zero for the first keyframe. Used to derive a precision-matched _absoluteUpdateStartTime below.
+ const tweenUpdateStartLocal = prevTween ? lastTweenChangeEndTime : 0;
const tweenStartTime = prevTween ? lastTweenChangeEndTime + tweenDelay : tweenDelay;
// Rounding is necessary here to minimize floating point errors when working in seconds
const absoluteStartTime = round$1(absoluteOffsetTime + tweenStartTime, 12);
+ // Match the rounding pattern of prevSibling._absoluteEndTime so the composition overlap check compares cleanly when keyframes touch at a boundary.
+ const absoluteUpdateStartTime = round$1(absoluteOffsetTime + tweenUpdateStartLocal, 12);
// Force a onRender callback if the animation contains at least one from value and autoplay is set to false
if (!shouldTriggerRender && (hasFromvalue || isFromToArray)) shouldTriggerRender = 1;
@@ -3756,9 +3908,9 @@
if (tweenComposition !== compositionTypes.none) {
let nextSibling = siblings._head;
- // Iterate trough all the next siblings until we find a sibling with an equal or inferior start time
- while (nextSibling && !nextSibling._isOverridden && nextSibling._absoluteStartTime <= absoluteStartTime) {
- prevSibling = nextSibling;
+ // Walk prior siblings up to the new tween, skipping overridden ones so the chain resolves to the latest live value instead of stopping at the first override.
+ while (nextSibling && nextSibling._absoluteStartTime <= absoluteStartTime) {
+ if (!nextSibling._isOverridden) prevSibling = nextSibling;
nextSibling = nextSibling._nextRep;
// Overrides all the next siblings if the next sibling starts at the same time of after as the new tween start time
if (nextSibling && nextSibling._absoluteStartTime >= absoluteStartTime) {
@@ -3812,8 +3964,8 @@
if (prevTween) {
decomposeTweenValue(prevTween, fromTargetObject);
} else {
- decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
// No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
+ decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), fromTargetObject);
}
}
@@ -3852,8 +4004,7 @@
const colorValue = fromTargetObject.t === valueTypes.COLOR ? fromTargetObject : toTargetObject;
const notColorValue = fromTargetObject.t === valueTypes.COLOR ? toTargetObject : fromTargetObject;
notColorValue.t = valueTypes.COLOR;
- notColorValue.s = colorValue.s;
- notColorValue.d = [0, 0, 0, 1];
+ notColorValue.d = colorValue.d.map(() => 0);
}
}
@@ -3883,6 +4034,16 @@
let inlineValue = inlineStylesStore[propName];
if (!isNil(inlineValue)) inlineStylesStore[propName] = null;
+ // Resolve the adapter setter once so render skips the lookup per frame.
+ const tweenSetter = adapterProp ? adapterProp.set : null;
+
+ // Rounding is necessary here to minimize floating point errors when working in seconds
+ lastTweenChangeEndTime = round$1(tweenStartTime + tweenUpdateDuration, 12);
+
+ const fromD = fromTargetObject.d;
+ const toD = toTargetObject.d;
+ const toS = toTargetObject.s;
+
/** @type {Tween} */
const tween = {
parent: this,
@@ -3893,12 +4054,12 @@
_toFunc: toFunctionStore.func,
_fromFunc: fromFunctionStore.func,
_ease: parseEase(tweenEasing),
- _fromNumbers: cloneArray(fromTargetObject.d),
- _toNumbers: cloneArray(toTargetObject.d),
- _strings: cloneArray(toTargetObject.s),
+ _fromNumbers: fromD ? cloneArray(fromD) : emptyArray,
+ _toNumbers: toD ? cloneArray(toD) : emptyArray,
+ _strings: toS ? cloneArray(toS) : emptyArray,
_fromNumber: fromTargetObject.n,
_toNumber: toTargetObject.n,
- _numbers: cloneArray(fromTargetObject.d), // For additive tween and animatables
+ _numbers: fromD ? cloneArray(fromD) : emptyArray, // For additive tween and animatables
_number: fromTargetObject.n, // For additive tween and animatables
_unit: toTargetObject.u,
_modifier: tweenModifier,
@@ -3908,8 +4069,12 @@
_updateDuration: tweenUpdateDuration,
_changeDuration: tweenUpdateDuration,
_absoluteStartTime: absoluteStartTime,
+ _absoluteUpdateStartTime: absoluteUpdateStartTime,
+ _absoluteEndTime: round$1(absoluteOffsetTime + lastTweenChangeEndTime, 12),
+ _hasFromValue: hasFromvalue || isFromToArray ? 1 : 0,
// NOTE: Investigate bit packing to stores ENUM / BOOL
_tweenType: tweenType,
+ _setter: tweenSetter,
_valueType: toTargetObject.t,
_composition: tweenComposition,
_isOverlapped: 0,
@@ -3932,10 +4097,11 @@
const vt = tween._valueType;
if (vt === valueTypes.COMPLEX) {
tween._value = composeComplexValue(tween, 1, -1);
- } else if (vt === valueTypes.COLOR) {
- tween._value = composeColorValue(tween, 1, -1);
} else if (vt === valueTypes.UNIT) {
tween._value = `${tweenModifier(tween._toNumber)}${tween._unit}`;
+ } else if (vt === valueTypes.COLOR) {
+ const d = toTargetObject.d;
+ tween._value = `rgba(${round$1(d[0], 0)},${round$1(d[1], 0)},${round$1(d[2], 0)},${d[3]})`;
} else {
tween._value = tweenModifier(tween._toNumber);
}
@@ -3943,8 +4109,7 @@
if (isNaN(firstTweenChangeStartTime)) {
firstTweenChangeStartTime = tween._startTime;
}
- // Rounding is necessary here to minimize floating point errors when working in seconds
- lastTweenChangeEndTime = round$1(tweenStartTime + tweenUpdateDuration, 12);
+
prevTween = tween;
animationAnimationLength++;
@@ -4050,8 +4215,11 @@
tween._updateDuration = normalizeTime(tween._updateDuration * timeScale);
tween._changeDuration = normalizeTime(tween._changeDuration * timeScale);
tween._currentTime *= timeScale;
+ tween._delay *= timeScale;
tween._startTime *= timeScale;
tween._absoluteStartTime *= timeScale;
+ tween._absoluteUpdateStartTime *= timeScale;
+ tween._absoluteEndTime *= timeScale;
});
return super.stretch(newDuration);
}
@@ -4180,8 +4348,6 @@
-
-
/**
* @param {Timeline} tl
* @return {Number}
@@ -4374,13 +4540,21 @@
if (!isUnd(synced) && !isUnd(/** @type {WAAPIAnimation} */(synced).persist)) {
/** @type {WAAPIAnimation} */(synced).persist = true;
}
- return this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
+ const editor = globals.editor;
+ const childHook = editor && editor.addTimelineChild;
+ if (editor && editor.addTimelineSync) {
+ position = editor.addTimelineSync(synced, position, this.id);
+ editor.addTimelineChild = null; // Suppress the per-child hook for the internal .add, sync already registered.
+ }
+ const result = this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
+ if (editor) editor.addTimelineChild = childHook;
+ return result;
}
/**
* @param {TargetsParam} targets
* @param {AnimationParams} parameters
- * @param {TimelinePosition} [position]
+ * @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [position]
* @return {this}
*/
set(targets, parameters, position) {
@@ -4397,6 +4571,7 @@
*/
call(callback, position) {
if (isUnd(callback) || callback && !isFnc(callback)) return this;
+ if (globals.editor && globals.editor.addTimelineCall) position = globals.editor.addTimelineCall(callback, position, this.id);
return this.add({ duration: 0, delay: 0, onComplete: () => callback(this) }, position);
}
@@ -4408,6 +4583,7 @@
*/
label(labelName, position) {
if (isUnd(labelName) || labelName && !isStr(labelName)) return this;
+ if (globals.editor && globals.editor.addTimelineLabel) position = globals.editor.addTimelineLabel(labelName, position, this.id);
this.labels[labelName] = parseTimelinePosition(this, position);
return this;
}
@@ -4516,6 +4692,7 @@
const callbacksAnimationParams = { v: 1, autoplay: false };
const properties = {};
this.targets = [];
+ /** @type {Record<String, JSAnimation>} */
this.animations = {};
/** @type {JSAnimation|null} */
this.callbacks = null;
@@ -5054,6 +5231,9 @@
*/
const set = (targets, parameters) => {
if (isUnd(parameters)) return;
+ if (globals.editor && globals.editor.addSet) {
+ return globals.editor.addSet(targets, parameters);
+ }
parameters.duration = minValue;
// Do not overrides currently active tweens by default
parameters.composition = setValue(parameters.composition, compositionTypes.none);
@@ -6290,13 +6470,14 @@
};
/**
- * @param {(...args: any[]) => Tickable | ((...args: any[]) => void) | void} constructor
- * @return {(...args: any[]) => Tickable | ((...args: any[]) => void)}
+ * @template {Tickable | ((...args: any[]) => void) | void} T
+ * @param {(...args: any[]) => T} constructor
+ * @return {(...args: any[]) => T extends void ? () => void : T}
*/
const keepTime = constructor => {
/** @type {Tickable} */
let tracked;
- return (...args) => {
+ return /** @type {(...args: any[]) => T extends void ? () => void : T} */(/** @type {*} */((...args) => {
let currentIteration, currentIterationProgress, reversed, alternate, startTime;
if (tracked) {
currentIteration = tracked.currentIteration;
@@ -6314,7 +6495,7 @@
/** @type {Tickable} */(tracked)._startTime = startTime;
}
return cleanup || noop;
- }
+ }));
};
@@ -6712,12 +6893,14 @@
refreshScrollObservers() {
forEachChildren(this, (/** @type {ScrollObserver} */child) => {
+ if (!child.ready) return;
if (child._debug) {
child.removeDebug();
}
});
this.updateBounds();
forEachChildren(this, (/** @type {ScrollObserver} */child) => {
+ if (!child.ready) return;
child.refresh();
child.onResize(child);
if (child._debug) {
@@ -9815,11 +9998,12 @@
* Adapted from https://bost.ocks.org/mike/shuffle/
*
* @param {Array} items - The array to shuffle (will be modified in-place)
+ * @param {RandomNumberGenerator} [rnd] - Optional RNG matching the random() signature (defaults to random)
* @return {Array} The same array reference, now shuffled
*/
- const shuffle = items => {
+ const shuffle = (items, rnd = random) => {
let m = items.length, t, i;
- while (m) { i = random(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
+ while (m) { i = rnd(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
return items;
};
@@ -9864,6 +10048,7 @@
let values = [];
let maxValue = 0;
let cachedOffset;
+ let jitterSamples = null;
const from = params.from;
const reversed = params.reversed;
const ease = params.ease;
@@ -9885,27 +10070,42 @@
const val2 = isRange ? parseNumber(val[1]) : 0;
const unitMatch = unitsExecRgx.exec((isRange ? val[1] : val) + emptyString);
const start = params.start || 0 + (isRange ? val1 : 0);
+ const seed = params.seed;
+ const hasSeed = !isUnd(seed) && seed !== false;
+ const rng = hasSeed ? createSeededRandom(seed === true ? 0 : /** @type {Number} */(seed)) : random;
+ const jitter = params.jitter;
+ const hasJitter = !isUnd(jitter);
+ const jitterIsArr = isArr(jitter);
+ const jitterStart = jitterIsArr ? /** @type {[Number,Number]} */(jitter)[0] : /** @type {Number} */(jitter) || 0;
+ const jitterEnd = jitterIsArr ? /** @type {[Number,Number]} */(jitter)[1] : /** @type {Number} */(jitter) || 0;
let fromIndex = fromFirst ? 0 : isNum(from) ? from : 0;
return (target, i, t, _, tl) => {
const [ registeredTarget ] = registerTargets(target);
const total = isUnd(customTotal) ? t.length : customTotal;
const customIndex = !isUnd(useProp) ? isFnc(useProp) ? useProp(registeredTarget, i, total) : getOriginalAnimatableValue(registeredTarget, useProp) : false;
- const staggerIndex = isNum(customIndex) || isStr(customIndex) && isNum(+customIndex) ? +customIndex : i;
+ const customIdx = isNum(customIndex) || isStr(customIndex) && isNum(+customIndex) ? +customIndex : i;
+ // Fall back to the natural index when the resolved value lands outside [0, total) so values[staggerIndex] never reads undefined.
+ const staggerIndex = customIdx >= 0 && customIdx < total ? customIdx : i;
if (fromCenter) fromIndex = (total - 1) / 2;
if (fromLast) fromIndex = total - 1;
if (!values.length) {
if (autoGrid) {
let hasPositions = true;
+ let has3D = false;
let minPosX = Infinity;
let minPosY = Infinity;
+ let minPosZ = Infinity;
let maxPosX = -Infinity;
let maxPosY = -Infinity;
+ let maxPosZ = -Infinity;
const pxArr = [];
const pyArr = [];
+ const pzArr = [];
for (let index = 0; index < total; index++) {
const el = t[index];
let px = 0;
let py = 0;
+ let pz = 0;
let found = false;
if (el && isFnc(el.getBoundingClientRect)) {
const rect = el.getBoundingClientRect();
@@ -9917,6 +10117,10 @@
if (obj && isNum(obj.x) && isNum(obj.y)) {
px = obj.x;
py = obj.y;
+ if (isNum(obj.z)) {
+ pz = obj.z;
+ has3D = true;
+ }
found = true;
}
}
@@ -9926,42 +10130,52 @@
}
pxArr.push(px);
pyArr.push(py);
+ pzArr.push(pz);
if (px < minPosX) minPosX = px;
if (py < minPosY) minPosY = py;
+ if (pz < minPosZ) minPosZ = pz;
if (px > maxPosX) maxPosX = px;
if (py > maxPosY) maxPosY = py;
+ if (pz > maxPosZ) maxPosZ = pz;
}
if (hasPositions) {
let fX = pxArr[0];
let fY = pyArr[0];
+ let fZ = pzArr[0];
if (fromArr) {
fX = minPosX + from[0] * (maxPosX - minPosX);
fY = minPosY + from[1] * (maxPosY - minPosY);
+ fZ = has3D ? minPosZ + (from.length >= 3 ? from[2] : 0.5) * (maxPosZ - minPosZ) : 0;
} else if (fromCenter) {
fX = (minPosX + maxPosX) / 2;
fY = (minPosY + maxPosY) / 2;
+ fZ = (minPosZ + maxPosZ) / 2;
} else if (fromLast) {
fX = pxArr[total - 1];
fY = pyArr[total - 1];
+ fZ = pzArr[total - 1];
} else if (isNum(from)) {
fX = pxArr[from];
fY = pyArr[from];
+ fZ = pzArr[from];
}
for (let index = 0; index < total; index++) {
const distanceX = fX - pxArr[index];
const distanceY = fY - pyArr[index];
- let value = sqrt(distanceX * distanceX + distanceY * distanceY);
+ const distanceZ = fZ - pzArr[index];
+ let value = sqrt(distanceX * distanceX + distanceY * distanceY + (has3D ? distanceZ * distanceZ : 0));
if (axis === 'x') value = -distanceX;
if (axis === 'y') value = -distanceY;
+ if (axis === 'z') value = -distanceZ;
values.push(value);
}
let minDist = Infinity;
- for (let index = 0, l = values.length; index < l; index++) {
+ for (let index = 0; index < total; index++) {
const absVal = abs(values[index]);
if (absVal > 0 && absVal < minDist) minDist = absVal;
}
if (minDist > 0 && minDist < Infinity) {
- for (let index = 0, l = values.length; index < l; index++) {
+ for (let index = 0; index < total; index++) {
values[index] = values[index] / minDist;
}
}
@@ -9975,32 +10189,51 @@
if (!grid) {
values.push(abs(fromIndex - index));
} else {
- let fromX, fromY;
+ const dims = grid.length;
+ const wh = grid[0] * grid[1];
+ let fromX, fromY, fromZ;
if (fromArr) {
fromX = from[0] * (grid[0] - 1);
fromY = from[1] * (grid[1] - 1);
+ fromZ = dims === 3 ? (from.length >= 3 ? from[2] : 0.5) * (grid[2] - 1) : 0;
} else if (fromCenter) {
fromX = (grid[0] - 1) / 2;
fromY = (grid[1] - 1) / 2;
+ fromZ = dims === 3 ? (grid[2] - 1) / 2 : 0;
} else {
fromX = fromIndex % grid[0];
- fromY = floor(fromIndex / grid[0]);
+ fromY = floor(fromIndex / grid[0]) % grid[1];
+ fromZ = dims === 3 ? floor(fromIndex / wh) : 0;
}
const toX = index % grid[0];
- const toY = floor(index / grid[0]);
+ const toY = floor(index / grid[0]) % grid[1];
+ const toZ = dims === 3 ? floor(index / wh) : 0;
const distanceX = fromX - toX;
const distanceY = fromY - toY;
- let value = sqrt(distanceX * distanceX + distanceY * distanceY);
+ const distanceZ = fromZ - toZ;
+ let value = sqrt(distanceX * distanceX + distanceY * distanceY + (dims === 3 ? distanceZ * distanceZ : 0));
if (axis === 'x') value = -distanceX;
if (axis === 'y') value = -distanceY;
+ if (axis === 'z') value = -distanceZ;
values.push(value);
}
}
}
- maxValue = max(...values);
- if (staggerEase) values = values.map(val => staggerEase(val / maxValue) * maxValue);
- if (reversed) values = values.map(val => axis ? (val < 0) ? val * -1 : -val : abs(maxValue - val));
- if (fromRandom) values = shuffle(values);
+ maxValue = values[0];
+ for (let k = 1; k < total; k++) if (values[k] > maxValue) maxValue = values[k];
+ if (staggerEase || reversed) {
+ for (let k = 0; k < total; k++) {
+ let v = values[k];
+ if (staggerEase) v = staggerEase(v / maxValue) * maxValue;
+ if (reversed) v = axis ? -v : abs(maxValue - v);
+ values[k] = v;
+ }
+ }
+ if (hasJitter) {
+ jitterSamples = new Array(total);
+ for (let k = 0; k < total; k++) jitterSamples[k] = rng(-1, 1, 4);
+ }
+ if (fromRandom) values = shuffle(values, rng);
}
const spacing = isRange ? (val2 - val1) / maxValue : val1;
if (isUnd(cachedOffset)) {
@@ -10008,6 +10241,11 @@
}
/** @type {String|Number} */
let output = cachedOffset + ((spacing * round$1(values[staggerIndex], 2)) || 0);
+ if (hasJitter) {
+ const progress = maxValue ? values[staggerIndex] / maxValue : 0;
+ const mag = jitterStart + (jitterEnd - jitterStart) * progress;
+ output = /** @type {Number} */(output) + jitterSamples[staggerIndex] * mag;
+ }
if (params.modifier) output = params.modifier(/** @type {Number} */(output));
if (unitMatch) output = `${output}${unitMatch[2]}`;
return output;
@@ -10377,6 +10615,7 @@
*/
const generateTemplate = (type, params = {}) => {
let template = ``;
+ if (!params) params = {};
const classString = isStr(params.class) ? ` class="${params.class}"` : '';
const cloneType = setValue(params.clone, false);
const wrapType = setValue(params.wrap, false);
@@ -10758,6 +10997,16 @@
+ /**
+ * @typedef {Object} ScrambleTextTween
+ * @property {Number} from
+ * @property {Number} to
+ * @property {Number} duration
+ * @property {Number} delay
+ * @property {String} ease
+ * @property {(v: Number) => String} modifier
+ */
+
/**
* '-' is the range operator; place it at the start or end of the string to use it as a literal (e.g. '-abc' or 'abc-')
* @param {String} str
@@ -10795,7 +11044,7 @@
* progressively revealing the original text.
*
* @param {ScrambleTextParams} [params]
- * @return {FunctionValue}
+ * @return {FunctionValue<ScrambleTextTween>}
*/
const scrambleText = (params = {}) => {
if (!params) params = {};
diff --git a/dist/bundles/anime.umd.min.js b/dist/bundles/anime.umd.min.js
index d4fcde89..6c1a3ca6 100644
--- a/dist/bundles/anime.umd.min.js
+++ b/dist/bundles/anime.umd.min.js
@@ -1,7 +1,7 @@
/**
* Anime.js - UMD minified bundle
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
-!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).anime={})}(this,function(t){"use strict";const e="undefined"!=typeof window,s=e?window:null,i=e?document:null,r={replace:0,none:1,blend:2},n=Symbol(),o=Symbol(),a=Symbol(),l=Symbol(),h=Symbol(),d=1e-11,c=1e12,u=1e3,p="",m=(()=>{const t=new Map;return t.set("x","translateX"),t.set("y","translateY"),t.set("z","translateZ"),t})(),f=["perspective","translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY"],g=f.reduce((t,e)=>({...t,[e]:e+"("}),{}),y=()=>{},v=/\)\s*[-.\d]/,b=/(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i,_=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i,T=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,x=/hsl\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*\)/i,w=/hsla\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,S=/[-+]?\d*\.?\d+(?:e[-+]?\d)?/gi,$=/^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i,C=/([a-z])([A-Z])/g,E=/(\*=|\+=|-=)/,k=/var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/,N={id:null,keyframes:null,playbackEase:null,playbackRate:1,frameRate:240,loop:0,reversed:!1,alternate:!1,autoplay:!0,persist:!1,duration:u,delay:0,loopDelay:0,ease:"out(2)",composition:r.replace,modifier:t=>t,onBegin:y,onBeforeUpdate:y,onUpdate:y,onLoop:y,onPause:y,onComplete:y,onRender:y},D={current:null,root:i},A={defaults:N,precision:4,timeScale:1,tickThreshold:200,editor:null},I={version:"4.4.1",engine:null};e&&(s.AnimeJS||(s.AnimeJS=[]),s.AnimeJS.push(I));const R=t=>t.replace(C,"$1-$2").toLowerCase(),L=(t,e)=>0===t.indexOf(e),B=Date.now,P=Array.isArray,F=t=>t&&t.constructor===Object,M=t=>"number"==typeof t&&!isNaN(t),V=t=>"string"==typeof t,O=t=>"function"==typeof t,z=t=>void 0===t,H=t=>z(t)||null===t,X=t=>e&&t instanceof SVGElement,Y=t=>b.test(t),W=t=>L(t,"rgb"),U=t=>L(t,"hsl"),q=t=>!A.defaults.hasOwnProperty(t),j=["opacity","rotate","overflow","color"],G=t=>V(t)?parseFloat(t):t,Z=Math.pow,Q=Math.sqrt,J=Math.sin,K=Math.cos,tt=Math.abs,et=Math.exp,st=Math.ceil,it=Math.floor,rt=Math.asin,nt=Math.max,ot=Math.atan2,at=Math.PI,lt=Math.round,ht=(t,e,s)=>t<e?e:t>s?s:t,dt=(t,e)=>{if(e<0)return t;if(!e)return lt(t);const s=10**e;return lt(t*s)/s},ct=(t,e)=>P(e)?e.reduce((e,s)=>tt(s-t)<tt(e-t)?s:e):e?lt(t/e)*e:t,ut=(t,e,s)=>t+(e-t)*s,pt=t=>t===1/0?c:t===-1/0?-c:t,mt=t=>t<=d?d:pt(dt(t,11)),ft=t=>P(t)?[...t]:t,gt=(t,e)=>{const s={...t};for(let i in e){const r=t[i];s[i]=z(r)?e[i]:r}return s},yt=(t,e,s,i="_prev",r="_next")=>{let n=t._head,o=r;for(s&&(n=t._tail,o=i);n;){const t=n[o];e(n),n=t}},vt=(t,e,s="_prev",i="_next")=>{const r=e[s],n=e[i];r?r[i]=n:t._head=n,n?n[s]=r:t._tail=r,e[s]=null,e[i]=null},bt=(t,e,s,i="_prev",r="_next")=>{let n=t._tail;for(;n&&s&&s(n,e);)n=n[i];const o=n?n[r]:t._head;n?n[r]=e:t._head=e,o?o[i]=e:t._tail=e,e[i]=n,e[r]=o},_t=t=>{let e=p;for(let s=0,i=f.length;s<i;s++){const i=f[s],r=t[i];if(void 0!==r){if("translateX"===i){const i=t.translateY;if(void 0!==i){const n=t.translateZ;void 0!==n?(e+=`translate3d(${r},${i},${n}) `,s+=2):(e+=`translate(${r},${i}) `,s+=1);continue}}if("scaleX"===i&&void 0===t.scale){const i=t.scaleY;if(void 0!==i){const n=t.scaleZ;void 0!==n?(e+=`scale3d(${r},${i},${n}) `,s+=2):(e+=`scale(${r},${i}) `,s+=1);continue}}e+=`${g[i]}${r}) `}"rotateZ"===i&&void 0!==t.rotate3d&&(e+=`rotate3d(${t.rotate3d}) `)}return void 0!==t.matrix&&(e+=`matrix(${t.matrix}) `),void 0!==t.matrix3d&&(e+=`matrix3d(${t.matrix3d}) `),e},Tt=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t),xt=(t,e)=>z(t)?e:t,wt=(t,e,s,i,r,n)=>{let o;if(O(t))o=()=>{const r=t(e,s,i,n);return isNaN(+r)?r||0:+r};else{if(!V(t)||!L(t,"var("))return t;o=()=>{const s=t.match(k),i=s[1],r=s[2];let n=getComputedStyle(e)?.getPropertyValue(i);return n&&n.trim()!==p||!r||(n=r.trim()),n||0}}return r&&(r.func=o),o()},St=(t,e)=>t[o]?t[a]&&((t,e)=>{if(j.includes(e))return!1;if(t.getAttribute(e)||e in t){if("scale"===e){const e=t.parentNode;return e&&"filter"===e.tagName}return!0}})(t,e)?1:f.includes(e)||m.get(e)?3:L(e,"--")?4:e in t.style?2:e in t?0:1:0,$t=(t,e,s)=>{const i=t.style[e];i&&s&&(s[e]=i);const r=i||getComputedStyle(t[h]||t).getPropertyValue(e);return"auto"===r?"0":r},Ct=(t,e,s,i)=>{const r=z(s)?St(t,e):s;if(0===r){const s=t[e];return s&&i&&(i[e]=s),s||0}if(1===r){const s=t.getAttribute(e);return s&&i&&(i[e]=s),s}return 3===r?((t,e,s)=>{const i=t.style.transform;if(i){const r=t[l];let n=0;const o=i.length;let a;for(;n<o;){for(;n<o&&32===i.charCodeAt(n);)n++;if(n>=o)break;const t=n;for(;n<o&&40!==i.charCodeAt(n);)n++;if(n>=o)break;const e=i.substring(t,n);let s=1;const l=n+1;let h=-1,d=-1;for(n++;n<o&&s>0;){const t=i.charCodeAt(n);40===t?s++:41===t?s--:44===t&&1===s&&(-1===h?h=n:-1===d&&(d=n)),n++}const c=n-1;"translate"===e||"translate3d"===e?(-1===h?r.translateX=i.substring(l,c).trim():(r.translateX=i.substring(l,h).trim(),-1===d?r.translateY=i.substring(h+1,c).trim():(r.translateY=i.substring(h+1,d).trim(),r.translateZ=i.substring(d+1,c).trim())),a=i.substring(l,c)):"scale"===e||"scale3d"===e?-1===h?r.scale=i.substring(l,c).trim():(r.scaleX=i.substring(l,h).trim(),-1===d?r.scaleY=i.substring(h+1,c).trim():(r.scaleY=i.substring(h+1,d).trim(),r.scaleZ=i.substring(d+1,c).trim())):r[e]=i.substring(l,c)}if("translate3d"===e&&a)return s&&(s[e]=a),a;const h=r[e];if(!z(h))return s&&(s[e]=h),h}return"translate3d"===e?"0px, 0px, 0px":"rotate3d"===e?"0, 0, 0, 0deg":L(e,"scale")?"1":L(e,"rotate")||L(e,"skew")?"0deg":"0px"})(t,e,i):4===r?$t(t,e,i).trimStart():$t(t,e,i)},Et=(t,e,s)=>"-"===s?t-e:"+"===s?t+e:t*e,kt=(t,e)=>{if(e.t=0,e.n=0,e.u=null,e.o=null,e.d=null,e.s=null,!t)return e;const s=+t;if(isNaN(s)){let s=t;"="===s[1]&&(e.o=s[0],s=s.slice(2));const n=!s.includes(" ")&&$.exec(s);if(n)return e.t=1,e.n=+n[1],e.u=n[2],e;if(e.o)return e.n=+s,e;if(Y(r=s)||(W(r)||U(r))&&(")"===r[r.length-1]||!v.test(r)))return e.t=2,e.d=W(i=s)?(t=>{const e=_.exec(t)||T.exec(t),s=z(e[4])?1:+e[4];return[+e[1],+e[2],+e[3],s]})(i):Y(i)?(t=>{const e=t.length,s=4===e||5===e;return[+("0x"+t[1]+t[s?1:2]),+("0x"+t[s?2:3]+t[s?2:4]),+("0x"+t[s?3:5]+t[s?3:6]),5===e||9===e?+(+("0x"+t[s?4:7]+t[s?4:8])/255).toFixed(3):1]})(i):U(i)?(t=>{const e=x.exec(t)||w.exec(t),s=+e[1]/360,i=+e[2]/100,r=+e[3]/100,n=z(e[4])?1:+e[4];let o,a,l;if(0===i)o=a=l=r;else{const t=r<.5?r*(1+i):r+i-r*i,e=2*r-t;o=dt(255*Tt(e,t,s+1/3),0),a=dt(255*Tt(e,t,s),0),l=dt(255*Tt(e,t,s-1/3),0)}return[o,a,l,n]})(i):[0,0,0,1],e;{const t=s.match(S);return e.t=3,e.d=t?t.map(Number):[],e.s=s.split(S)||[],e}}var i,r;return e.n=s,e},Nt=(t,e)=>(e.t=t._valueType,e.n=t._toNumber,e.u=t._unit,e.o=null,e.d=ft(t._toNumbers),e.s=ft(t._strings),e),Dt={t:0,n:0,u:null,o:null,d:null,s:null},At=(t,e,s)=>{const i=t._modifier,n=t._fromNumbers,o=t._toNumbers,a=dt(ht(i(ut(n[0],o[0],e)),0,255),0),l=dt(ht(i(ut(n[1],o[1],e)),0,255),0),h=dt(ht(i(ut(n[2],o[2],e)),0,255),0),d=ht(i(dt(ut(n[3],o[3],e),s)),0,1);if(t._composition!==r.none){const e=t._numbers;e[0]=a,e[1]=l,e[2]=h,e[3]=d}return`rgba(${a},${l},${h},${d})`},It=(t,e,s)=>{const i=t._modifier,n=t._fromNumbers,o=t._toNumbers,a=t._strings,l=t._composition!==r.none;let h=a[0];for(let r=0,d=o.length;r<d;r++){const d=i(dt(ut(n[r],o[r],e),s)),c=a[r+1];h+=`${c?d+c:d}`,l&&(t._numbers[r]=d)}return h},Rt=(t,e,s,i,n)=>{const o=t.parent,a=t.duration,h=t.completed,c=t.iterationDuration,u=t.iterationCount,p=t._currentIteration,m=t._loopDelay,f=t._reversed,g=t._alternate,y=t._hasChildren,v=t._delay,b=t._currentTime,_=v+c,T=e-v,x=ht(b,-v,a),w=ht(T,-v,a),S=T-b,$=w>0,C=w>=a,E=a<=d,k=2===n;let N=0,D=T,I=0;if(u>1){const e=~~(w/(c+(C?0:m)));t._currentIteration=ht(e,0,u),C&&t._currentIteration--,N=t._currentIteration%2,D=w%(c+m)||0}const R=f^(g&&N),L=t._ease;let B=C?R?0:a:R?c-D:D;L&&(B=c*L(B/c)||0);const P=(o?o.backwards:T<b)?!R:!!R;if(t._currentTime=T,t._iterationTime=B,t.backwards=P,$&&!t.began?(t.began=!0,s||o&&(P||!o.began)||t.onBegin(t)):T<=0&&(t.began=!1),s||y||!$||t._currentIteration===p||t.onLoop(t),k||1===n&&(e>=v&&e<=_||e<=v&&x>v||e>=_&&x!==a)||B>=_&&x!==a||B<=v&&x>0||e<=x&&x===a&&h||C&&!h&&E){if($&&(t.computeDeltaTime(x),s||t.onBeforeUpdate(t)),!y){const e=k||(P?-1*S:S)>=A.tickThreshold,n=t._offset+(o?o._offset:0)+v+B;let a,h,d,c,u=t._head,p=0;for(;u;){const t=u._composition,s=u._currentTime,o=u._changeDuration,m=u._absoluteStartTime+u._changeDuration,f=u._nextRep,g=u._prevRep,y=t!==r.none;if((e||(s!==o||n<=m+(f?f._delay:0))&&(0!==s||n>=u._absoluteStartTime))&&(!y||!u._isOverridden&&(!u._isOverlapped||n<=m)&&(!f||f._isOverridden||n<=f._absoluteStartTime)&&(!g||g._isOverridden||n>=g._absoluteStartTime+g._changeDuration+u._delay))){const e=u._currentTime=ht(B-u._startTime,0,o),s=u._ease(e/u._updateDuration),n=u._modifier,m=u._valueType,f=u._tweenType,g=0===f,v=0===m,b=v&&g||0===s||1===s?-1:A.precision;let _,T;if(v?_=T=n(dt(ut(u._fromNumber,u._toNumber,s),b)):1===m?(T=n(dt(ut(u._fromNumber,u._toNumber,s),b)),_=`${T}${u._unit}`):2===m?_=At(u,s,b):3===m&&(_=It(u,s,b)),y&&(u._number=T),i||t===r.blend)u._value=_;else{const t=u.property;a=u.target,g?a[t]=_:1===f?a.setAttribute(t,_):(h=a.style,3===f?(a!==d&&(d=a,c=a[l]),c[t]=_,p=1):2===f?h[t]=_:4===f&&h.setProperty(t,_)),$&&(I=1)}}p&&u._renderTransforms&&(h.transform=_t(c),p=0),u=u._next}!s&&I&&t.onRender(t)}!s&&$&&t.onUpdate(t)}return o&&E?!s&&(o.began&&!P&&T>0&&!h||P&&T<=d&&h)&&(t.onComplete(t),t.completed=!P):$&&C?u===1/0?t._startTime+=t.duration:t._currentIteration>=u-1&&(t.paused=!0,h||y||(t.completed=!0,s||o&&(P||!o.began)||(t.onComplete(t),t._resolve(t)))):t.completed=!1,I},Lt=(t,e,s,i,r)=>{const n=t._currentIteration;if(Rt(t,e,s,i,r),t._hasChildren){const o=t,a=o.backwards,l=i?e:o._iterationTime,h=B();let c=0,u=!0;if(!i&&o._currentIteration!==n){const t=o.iterationDuration;yt(o,e=>{if(a){const i=e.duration,r=e._offset+e._delay;s||!(i<=d)||r&&r+i!==t||e.onComplete(e)}else!e.completed&&!e.backwards&&e._currentTime<e.iterationDuration&&Rt(e,t,s,1,2),e.began=!1,e.completed=!1}),s||o.onLoop(o)}yt(o,t=>{const e=dt((l-t._offset)*t._speed,12),n=t._fps<o._fps?t.requestTick(h):r;c+=Rt(t,e,s,i,n),!t.completed&&u&&(u=!1)},a),!s&&c&&o.onRender(o),(u||a)&&o._currentTime>=o.duration&&(o.paused=!0,o.completed||(o.completed=!0,s||(o.onComplete(o),o._resolve(o))))}},Bt={},Pt=(t,e,s)=>{if(3===s)return m.get(t)||t;if(2===s||1===s&&X(e)&&t in e.style){const e=Bt[t];if(e)return e;{const e=t?R(t):t;return Bt[t]=e,e}}return t},Ft=(t,e=!1)=>{if(t._hasChildren)yt(t,t=>Ft(t,e),!0);else{const s=t;s.pause(),yt(s,t=>{const i=t.property,r=t.target,n=t._tweenType,a=t._inlineValue,h=H(a)||a===p;if(0===n)e||h||(r[i]=a);else if(r[o])if(1===n)e||(h?r.removeAttribute(i):r.setAttribute(i,a));else{const e=r.style;if(3===n){const s=r[l];h?delete s[i]:s[i]=a,t._renderTransforms&&(Object.keys(s).length?e.transform=_t(s):e.removeProperty("transform"))}else h?e.removeProperty(R(i)):e[i]=a}r[o]&&s._tail===t&&s.targets.forEach(t=>{t.getAttribute&&t.getAttribute("style")===p&&t.removeAttribute("style")})})}return t},Mt=t=>Ft(t,!0);class Vt{constructor(t=0){this.deltaTime=0,this._currentTime=t,this._lastTickTime=t,this._startTime=t,this._lastTime=t,this._scheduledTime=0,this._frameDuration=u/240,this._fps=240,this._speed=1,this._hasChildren=!1,this._head=null,this._tail=null}get fps(){return this._fps}set fps(t){const e=this._frameDuration,s=+t,i=s<d?d:s,r=u/i;i>N.frameRate&&(N.frameRate=i),this._fps=i,this._frameDuration=r,this._scheduledTime+=r-e}get speed(){return this._speed}set speed(t){const e=+t;this._speed=e<d?d:e}requestTick(t){const e=this._scheduledTime;if(this._lastTickTime=t,t<e)return 0;const s=this._frameDuration,i=t-e;return this._scheduledTime+=i<s?s:i,1}computeDeltaTime(t){const e=t-this._lastTime;return this.deltaTime=e,this._lastTime=t,e}}const Ot={animation:null,update:y},zt=(()=>e?requestAnimationFrame:setImmediate)(),Ht=(()=>e?cancelAnimationFrame:clearImmediate)();class Xt extends Vt{constructor(t){super(t),this.useDefaultMainLoop=!0,this.pauseOnDocumentHidden=!0,this.defaults=N,this.paused=!0,this.reqId=0}update(){const t=this._currentTime=B();if(this.requestTick(t)){this.computeDeltaTime(t);const e=this._speed,s=this._fps;let i=this._head;for(;i;){const r=i._next;i.paused?(vt(this,i),this._hasChildren=!!this._tail,i._running=!1,i.completed&&!i._cancelled&&i.cancel()):Lt(i,(t-i._startTime)*i._speed*e,0,0,i._fps<s?i.requestTick(t):1),i=r}Ot.update()}}wake(){return this.useDefaultMainLoop&&!this.reqId&&(this.requestTick(B()),this.reqId=zt(Wt)),this}pause(){if(this.reqId)return this.paused=!0,Ut()}resume(){if(this.paused)return this.paused=!1,yt(this,t=>t.resetTime()),this.wake()}get speed(){return this._speed*(1===A.timeScale?1:u)}set speed(t){this._speed=t*A.timeScale,yt(this,t=>t.speed=t._speed)}get timeUnit(){return 1===A.timeScale?"ms":"s"}set timeUnit(t){const e="s"===t,s=e?.001:1;if(A.timeScale!==s){A.timeScale=s,A.tickThreshold=200*s;const t=e?.001:u;this.defaults.duration*=t,this._speed*=t}}get precision(){return A.precision}set precision(t){A.precision=t}}const Yt=(()=>{const t=new Xt(B());return e&&(I.engine=t,i.addEventListener("visibilitychange",()=>{t.pauseOnDocumentHidden&&(i.hidden?t.pause():t.resume())})),t})(),Wt=()=>{Yt._head?(Yt.reqId=zt(Wt),Yt.update()):Yt.reqId=0},Ut=()=>(Ht(Yt.reqId),Yt.reqId=0,Yt),qt={_rep:new WeakMap,_add:new Map},jt=(t,e,s="_rep")=>{const i=qt[s];let r=i.get(t);return r||(r={},i.set(t,r)),r[e]?r[e]:r[e]={_head:null,_tail:null}},Gt=(t,e)=>t._isOverridden||t._absoluteStartTime>e._absoluteStartTime,Zt=t=>{t._isOverlapped=1,t._isOverridden=1,t._changeDuration=d,t._currentTime=d},Qt=(t,e)=>{const s=t._composition;if(s===r.replace){const s=t._absoluteStartTime;bt(e,t,Gt,"_prevRep","_nextRep");const i=t._prevRep;if(i){const e=i.parent,r=i._absoluteStartTime+i._changeDuration;if(t.parent.id!==e.id&&e.iterationCount>1&&r+(e.duration-e.iterationDuration)>s){Zt(i);let t=i._prevRep;for(;t&&t.parent.id===e.id;)Zt(t),t=t._prevRep}const n=s-t._delay;if(r>n){const t=i._startTime,e=r-(t+i._updateDuration),s=dt(n-e-t,12);i._changeDuration=s,i._currentTime=s,i._isOverlapped=1,s<d&&Zt(i)}let o=!0;if(yt(e,t=>{t._isOverlapped||(o=!1)}),o){const t=e.parent;if(t){let s=!0;yt(t,t=>{t!==e&&yt(t,t=>{t._isOverlapped||(s=!1)})}),s&&t.cancel()}else e.cancel()}}}else if(s===r.blend){const e=jt(t.target,t.property,"_add"),s=(t=>{let e=Ot.animation;return e||(e={duration:d,computeDeltaTime:y,_offset:0,_delay:0,_head:null,_tail:null},Ot.animation=e,Ot.update=()=>{t.forEach(t=>{for(let e in t){const s=t[e],i=s._head;if(i){const t=i._valueType,e=3===t||2===t?ft(i._fromNumbers):null;let r=i._fromNumber,n=s._tail;for(;n&&n!==i;){if(e)for(let t=0,s=n._numbers.length;t<s;t++)e[t]+=n._numbers[t];else r+=n._number;n=n._prevAdd}i._toNumber=r,i._toNumbers=e}}}),Rt(e,1,1,0,2)}),e})(qt._add);let i=e._head;i||(i={...t},i._composition=r.replace,i._updateDuration=d,i._startTime=0,i._numbers=ft(t._fromNumbers),i._number=0,i._next=null,i._prev=null,bt(e,i),bt(s,i));const n=t._toNumber;if(t._fromNumber=i._fromNumber-n,t._toNumber=0,t._numbers=ft(t._fromNumbers),t._number=0,i._fromNumber=n,t._toNumbers){const e=ft(t._toNumbers);e&&e.forEach((e,s)=>{t._fromNumbers[s]=i._fromNumbers[s]-e,t._toNumbers[s]=0}),i._fromNumbers=e}bt(e,t,null,"_prevAdd","_nextAdd")}return t},Jt=t=>{const e=t._composition;if(e!==r.none){const s=t.target,i=t.property,n=qt._rep.get(s)[i];if(vt(n,t,"_prevRep","_nextRep"),e===r.blend){const e=qt._add,r=e.get(s);if(!r)return;const n=r[i],o=Ot.animation;vt(n,t,"_prevAdd","_nextAdd");const a=n._head;if(a&&a===n._tail){vt(n,a,"_prevAdd","_nextAdd"),vt(o,a);let t=!0;for(let e in r)if(r[e]._head){t=!1;break}t&&e.delete(s)}}}return t},Kt=(t,e,s)=>{let i=!1;return yt(e,r=>{const n=r.target;if(t.includes(n)){const t=r.property,o=r._tweenType,a=Pt(s,n,o);(!a||a&&a===t)&&(r.parent._tail===r&&3===r._tweenType&&r._prev&&3===r._prev._tweenType&&(r._prev._renderTransforms=1),vt(e,r),Jt(r),i=!0)}},!0),i},te=(t,e,s)=>{const i=e||Yt;let r;if(i._hasChildren){let e=0;yt(i,n=>{if(!n._hasChildren)if(r=Kt(t,n,s),r&&!n._head)n.cancel(),vt(i,n);else{const t=n._offset+n._delay+n.duration;t>e&&(e=t)}n._head?te(t,n,s):n._hasChildren=!1},!0),z(i.iterationDuration)||(i.iterationDuration=e)}else r=Kt(t,i,s);r&&!i._head&&(i._hasChildren=!1,i.cancel&&i.cancel())},ee=t=>(t.paused=!0,t.began=!1,t.completed=!1,t),se=t=>t._cancelled?(t._hasChildren?yt(t,se):yt(t,t=>{t._composition!==r.none&&Qt(t,jt(t.target,t.property))}),t._cancelled=0,t):t;let ie=0;const re=(t,e)=>t._priority>e._priority;class ne extends Vt{constructor(t={},e=null,s=0){super(0),++ie;const{id:i,delay:r,duration:n,reversed:o,alternate:a,loop:l,loopDelay:h,autoplay:c,frameRate:u,playbackRate:p,priority:m,onComplete:f,onLoop:g,onPause:v,onBegin:b,onBeforeUpdate:_,onUpdate:T}=t;D.current&&D.current.register(this);const x=e?0:Yt._lastTickTime,w=e?e.defaults:A.defaults,S=O(r)||z(r)?w.delay:+r,$=O(n)||z(n)?1/0:+n,C=xt(l,w.loop),E=xt(h,w.loopDelay);let k=!0===C||C===1/0||C<0?1/0:C+1,N=0;e?N=s:(Yt.reqId||Yt.requestTick(B()),N=(Yt._lastTickTime-Yt._startTime)*A.timeScale),this.id=z(i)?ie:i,this.parent=e,this.duration=pt(($+E)*k-E)||d,this.backwards=!1,this.paused=!0,this.began=!1,this.completed=!1,this.onBegin=b||w.onBegin,this.onBeforeUpdate=_||w.onBeforeUpdate,this.onUpdate=T||w.onUpdate,this.onLoop=g||w.onLoop,this.onPause=v||w.onPause,this.onComplete=f||w.onComplete,this.iterationDuration=$,this.iterationCount=k,this._autoplay=!e&&xt(c,w.autoplay),this._offset=N,this._delay=S,this._loopDelay=E,this._iterationTime=0,this._currentIteration=0,this._resolve=y,this._running=!1,this._reversed=+xt(o,w.reversed),this._reverse=this._reversed,this._cancelled=0,this._alternate=xt(a,w.alternate),this._prev=null,this._next=null,this._lastTickTime=x,this._startTime=x,this._lastTime=x,this._fps=xt(u,w.frameRate),this._speed=xt(p,w.playbackRate),this._priority=+xt(m,1)}get cancelled(){return!!this._cancelled}set cancelled(t){t?this.cancel():this.reset(!0).play()}get currentTime(){return ht(dt(this._currentTime,A.precision),-this._delay,this.duration)}set currentTime(t){const e=this.paused;this.pause().seek(+t),e||this.resume()}get iterationCurrentTime(){return ht(dt(this._iterationTime,A.precision),0,this.iterationDuration)}set iterationCurrentTime(t){this.currentTime=this.iterationDuration*this._currentIteration+t}get progress(){return ht(dt(this._currentTime/this.duration,10),0,1)}set progress(t){this.currentTime=this.duration*t}get iterationProgress(){return ht(dt(this._iterationTime/this.iterationDuration,10),0,1)}set iterationProgress(t){const e=this.iterationDuration;this.currentTime=e*this._currentIteration+e*t}get currentIteration(){return this._currentIteration}set currentIteration(t){this.currentTime=this.iterationDuration*ht(+t,0,this.iterationCount-1)}get reversed(){return!!this._reversed}set reversed(t){t?this.reverse():this.play()}get speed(){return super.speed}set speed(t){super.speed=t,this.resetTime()}reset(t=!1){return se(this),this._reversed&&!this._reverse&&(this.reversed=!1),this._iterationTime=this.iterationDuration,Lt(this,0,1,~~t,2),ee(this),this._hasChildren&&yt(this,ee),this}init(t=!1){this.fps=this._fps,this.speed=this._speed,!t&&this._hasChildren&&Lt(this,this.duration,1,~~t,2),this.reset(t);const e=this._autoplay;return!0===e?this.resume():e&&!z(e.linked)&&e.link(this),this}resetTime(){const t=1/(this._speed*Yt._speed);return this._startTime=B()-(this._currentTime+this._delay)*t,this}pause(){return this.paused||(this.paused=!0,this.onPause(this)),this}resume(){return this.paused?(this.paused=!1,this.duration<=d&&!this._hasChildren?Lt(this,d,0,0,2):(this._running||(bt(Yt,this,re),Yt._hasChildren=!0,this._running=!0),this.resetTime(),this._startTime-=12,Yt.wake()),this):this}restart(){return this.reset().resume()}seek(t,e=0,s=0){se(this),this.completed=!1;const i=this.paused;return this.paused=!0,Lt(this,t+this._delay,~~e,~~s,1),i?this:this.resume()}alternate(){const t=this._reversed,e=this.iterationCount,s=this.iterationDuration,i=e===1/0?it(c/s):e;return this._reversed=+(!this._alternate||i%2?!t:t),e===1/0?this.iterationProgress=this._reversed?1-this.iterationProgress:this.iterationProgress:this.seek(s*i-this._currentTime),this.resetTime(),this}play(){return this._reversed&&this.alternate(),this.resume()}reverse(){return this._reversed||this.alternate(),this.resume()}cancel(){return this._hasChildren?yt(this,t=>t.cancel(),!0):yt(this,Jt),this._cancelled=1,this.pause()}stretch(t){const e=this.duration,s=mt(t);if(e===s)return this;const i=t/e,r=t<=d;return this.duration=r?d:s,this.iterationDuration=r?d:mt(this.iterationDuration*i),this._offset*=i,this._delay*=i,this._loopDelay*=i,this}revert(){Lt(this,0,1,0,1);const t=this._autoplay;return t&&t.linked&&t.linked===this&&t.revert(),this.cancel()}complete(t=0){return this.seek(this.duration,t).cancel()}then(t=y){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=y};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}function oe(t){const e=V(t)?D.root.querySelectorAll(t):t;if(e instanceof NodeList||e instanceof HTMLCollection)return e}function ae(t){if(H(t))return[];if(!e)return P(t)&&t.flat(1/0)||[t];if(P(t)){const e=t.flat(1/0),s=[];for(let t=0,i=e.length;t<i;t++){const i=e[t];if(!H(i)){const t=oe(i);if(t)for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!H(i)){let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}else{let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}}return s}const s=oe(t);return s?Array.from(s):[t]}function le(t){const e=ae(t),s=e.length;if(s)for(let t=0;t<s;t++){const s=e[t];if(!s[n]){s[n]=!0;const t=X(s);(s.nodeType||t)&&(s[o]=!0,s[a]=t,s[l]={})}}return e}const he={deg:1,rad:180/at,turn:360},de={},ce=(t,e,s,r=!1)=>{const n=e.u,o=e.n;if(1===e.t&&n===s)return e;const a=o+n+s,l=de[a];if(z(l)||r){let r;if(n in he)r=o*he[n]/he[s];else{const e=100,a=t.cloneNode(),l=t.parentNode,h=l&&l!==i?l:i.body;h.appendChild(a);const d=a.style;d.width=e+n;const c=a.offsetWidth||e;d.width=e+s;const u=c/(a.offsetWidth||e);h.removeChild(a),r=u*o}e.n=r,de[a]=r}else e.n=l;return e.t,e.u=s,e},ue=t=>t,pe=(t=1.68)=>e=>Z(e,+t),me={in:t=>e=>t(e),out:t=>e=>1-t(1-e),inOut:t=>e=>e<.5?t(2*e)/2:1-t(-2*e+2)/2,outIn:t=>e=>e<.5?(1-t(1-2*e))/2:(t(2*e-1)+1)/2},fe=at/2,ge=2*at,ye={[p]:pe,Quad:pe(2),Cubic:pe(3),Quart:pe(4),Quint:pe(5),Sine:t=>1-K(t*fe),Circ:t=>1-Q(1-t*t),Expo:t=>t?Z(2,10*t-10):0,Bounce:t=>{let e,s=4;for(;t<((e=Z(2,--s))-1)/11;);return 1/Z(4,3-s)-7.5625*Z((3*e-2)/22-t,2)},Back:(t=1.7)=>e=>(+t+1)*e*e*e-+t*e*e,Elastic:(t=1,e=.3)=>{const s=ht(+t,1,10),i=ht(+e,d,2),r=i/ge*rt(1/s),n=ge/i;return t=>0===t||1===t?t:-s*Z(2,-10*(1-t))*J((1-t-r)*n)}},ve=(()=>{const t={linear:ue,none:ue};for(let e in me)for(let s in ye){const i=ye[s],r=me[e];t[e+s]=s===p||"Back"===s||"Elastic"===s?(t,e)=>r(i(t,e)):r(i)}return t})(),be={linear:ue,none:ue},_e=t=>{if(be[t])return be[t];if(t.indexOf("(")<=-1){const e=me[t]||t.includes("Back")||t.includes("Elastic")?ve[t]():ve[t];return e?be[t]=e:ue}{const e=t.slice(0,-1).split("("),s=ve[e[0]];return s?be[t]=s(...e[1].split(",")):ue}},Te=["steps(","irregular(","linear(","cubicBezier("],xe=t=>{if(V(t))for(let e=0,s=Te.length;e<s;e++)if(L(t,Te[e]))return console.warn(`String syntax for \`ease: "${t}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${t}\``),ue;return O(t)?t:V(t)?_e(t):ue},we={t:0,n:0,u:null,o:null,d:null,s:null},Se={t:0,n:0,u:null,o:null,d:null,s:null},$e={},Ce={func:null},Ee={func:null},ke=[null],Ne=[null,null],De={to:null};let Ae,Ie,Re=0,Le=0;class Be extends ne{constructor(t,e,s,i,n=!1,o=0,a){super(e,s,i),++Le;const l=le(t),h=l.length,c=e.keyframes,p=c?gt(((t,e)=>{const s={};if(P(t)){const e=[].concat(...t.map(t=>Object.keys(t))).filter(q);for(let i=0,r=e.length;i<r;i++){const r=e[i],n=t.map(t=>{const e={};for(let s in t){const i=t[s];q(s)?s===r&&(e.to=i):e[s]=i}return e});s[r]=n}}else{const i=xt(e.duration,A.defaults.duration),r=Object.keys(t).map(e=>({o:parseFloat(e)/100,p:t[e]})).sort((t,e)=>t.o-e.o);r.forEach(t=>{const e=t.o,r=t.p;for(let t in r)if(q(t)){let n=s[t];n||(n=s[t]=[]);const o=e*i;let a=n.length,l=n[a-1];const h={to:r[t]};let d=0;for(let t=0;t<a;t++)d+=n[t].duration;1===a&&(h.from=l.to),r.ease&&(h.ease=r.ease),h.duration=o-(a?d:0),n.push(h)}return t});for(let t in s){const e=s[t];let i;for(let t=0,s=e.length;t<s;t++){const s=e[t],r=s.ease;s.ease=i||void 0,i=r}e[0].duration||e.shift()}}return s})(c,e),e):e,{id:m,delay:f,duration:g,ease:y,playbackEase:v,modifier:b,composition:_,onRender:T}=p,x=s?s.defaults:A.defaults,w=xt(y,x.ease),S=xt(v,x.playbackEase),$=S?xe(S):null,C=!z(w.ease),E=C?w.ease:xt(y,$?"linear":x.ease),k=C?w.settlingDuration:xt(g,x.duration),N=xt(f,x.delay),D=b||x.modifier,I=z(_)&&h>=u?r.none:z(_)?x.composition:_,R=this._offset+(s?s._offset:0);C&&(w.parent=this);let L=NaN,B=NaN,X=0,Y=0;for(let t=0;t<h;t++){const e=l[t],i=o||t,h=a||l;let c=NaN,u=NaN;for(let t in p)if(q(t)){const o=St(e,t),a=Pt(t,e,o);let l=p[t];const m=P(l);if(n&&!m&&(Ne[0]=l,Ne[1]=l,l=Ne),m){const t=l.length,e=!F(l[0]);2===t&&e?(De.to=l,ke[0]=De,Ae=ke):t>2&&e?(Ae=[],l.forEach((t,e)=>{e?1===e?(Ne[1]=t,Ae.push(Ne)):Ae.push(t):Ne[0]=t})):Ae=l}else ke[0]=l,Ae=ke;let f=null,g=null,y=NaN,v=0,b=0;for(let t=Ae.length;b<t;b++){const n=Ae[b];F(n)?Ie=n:(De.to=n,Ie=De),Ce.func=null,Ee.func=null;const l=wt(xt(Ie.composition,I),e,i,h,null,null),c=M(l)?l:r[l];f||c===r.none||(f=jt(e,a));const u=f?f._tail:null,p=s&&u&&u.parent.parent===s?u:g,m=wt(Ie.to,e,i,h,Ce,p);let _;F(m)&&!z(m.to)?(Ie=m,_=m.to):_=m;const T=wt(Ie.from,e,i,h,null,p),x=Ie.ease||E,w=wt(x,e,i,h,null,p),S=O(w)||V(w)?w:x,$=!z(S)&&!z(S.ease),C=$?S.ease:S,A=$?S.settlingDuration:wt(xt(Ie.duration,t>1?wt(k,e,i,h,null,p)/t:k),e,i,h,null,p),L=wt(xt(Ie.delay,b?0:N),e,i,h,null,p),B=Ie.modifier||D,W=!z(T),U=!z(_),q=P(_),j=q||W&&U,G=g?v+L:L,Z=dt(R+G,12);Y||!W&&!q||(Y=1);let Q=g;if(c!==r.none){let t=f._head;for(;t&&!t._isOverridden&&t._absoluteStartTime<=Z;)if(Q=t,t=t._nextRep,t&&t._absoluteStartTime>=Z)for(;t;)Zt(t),t=t._nextRep}if(j){kt(q?wt(_[0],e,i,h,Ee,p):T,we),kt(q?wt(_[1],e,i,h,Ce,p):_,Se);const t=Ct(e,a,o,$e);0===we.t&&(Q?1===Q._valueType&&(we.t=1,we.u=Q._unit):(kt(t,Dt),1===Dt.t&&(we.t=1,we.u=Dt.u)))}else U?kt(_,Se):g?Nt(g,Se):kt(s&&Q&&Q.parent.parent===s?Q._value:Ct(e,a,o,$e),Se),W?kt(T,we):g?Nt(g,we):kt(s&&Q&&Q.parent.parent===s?Q._value:Ct(e,a,o,$e),we);if(we.o&&(we.n=Et(Q?Q._toNumber:kt(Ct(e,a,o,$e),Dt).n,we.n,we.o)),Se.o&&(Se.n=Et(we.n,Se.n,Se.o)),we.t!==Se.t)if(3===we.t||3===Se.t){const t=3===we.t?we:Se,e=3===we.t?Se:we;e.t=3,e.s=ft(t.s),e.d=t.d.map(()=>e.n)}else if(1===we.t||1===Se.t){const t=1===we.t?we:Se,e=1===we.t?Se:we;e.t=1,e.u=t.u}else if(2===we.t||2===Se.t){const t=2===we.t?we:Se,e=2===we.t?Se:we;e.t=2,e.s=t.s,e.d=[0,0,0,1]}if(we.u!==Se.u){let t=Se.u?we:Se;t=ce(e,t,Se.u?Se.u:we.u,!1)}if(Se.d&&we.d&&Se.d.length!==we.d.length){const t=we.d.length>Se.d.length?we:Se,e=t===we?Se:we;e.d=t.d.map((t,s)=>z(e.d[s])?0:e.d[s]),e.s=ft(t.s)}const J=dt(+A||d,12);let K=$e[a];H(K)||($e[a]=null);const tt={parent:this,id:Re++,property:a,target:e,_value:null,_toFunc:Ce.func,_fromFunc:Ee.func,_ease:xe(C),_fromNumbers:ft(we.d),_toNumbers:ft(Se.d),_strings:ft(Se.s),_fromNumber:we.n,_toNumber:Se.n,_numbers:ft(we.d),_number:we.n,_unit:Se.u,_modifier:B,_currentTime:0,_startTime:G,_delay:+L,_updateDuration:J,_changeDuration:J,_absoluteStartTime:Z,_tweenType:o,_valueType:Se.t,_composition:c,_isOverlapped:0,_isOverridden:0,_renderTransforms:0,_inlineValue:K,_prevRep:null,_nextRep:null,_prevAdd:null,_nextAdd:null,_prev:null,_next:null};c!==r.none&&Qt(tt,f);const et=tt._valueType;tt._value=3===et?It(tt,1,-1):2===et?At(tt,1,-1):1===et?`${B(tt._toNumber)}${tt._unit}`:B(tt._toNumber),isNaN(y)&&(y=tt._startTime),v=dt(G+J,12),g=tt,X++,bt(this,tt)}(isNaN(B)||y<B)&&(B=y),(isNaN(L)||v>L)&&(L=v),3===o&&(c=X-b,u=X)}if(!isNaN(c)){let t=0;yt(this,e=>{t>=c&&t<u&&(e._renderTransforms=1,e._composition===r.blend&&yt(Ot.animation,t=>{t.id===e.id&&(t._renderTransforms=1)})),t++})}}h||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation."),B?(yt(this,t=>{t._startTime-t._delay||(t._delay-=B),t._startTime-=B}),L-=B):B=0,L||(L=d,this.iterationCount=0),this.targets=l,this.id=z(m)?Le:m,this.duration=L===d?d:pt((L+this._loopDelay)*this.iterationCount-this._loopDelay)||d,this.onRender=T||x.onRender,this._ease=$,this._delay=B,this.iterationDuration=L,!this._autoplay&&Y&&this.onRender(this)}stretch(t){const e=this.duration;if(e===mt(t))return this;const s=t/e;return yt(this,t=>{t._updateDuration=mt(t._updateDuration*s),t._changeDuration=mt(t._changeDuration*s),t._currentTime*=s,t._startTime*=s,t._absoluteStartTime*=s}),super.stretch(t)}refresh(){return yt(this,t=>{const e=t._toFunc,s=t._fromFunc;(e||s)&&(s?(kt(s(),we),we.u!==t._unit&&t.target[o]&&ce(t.target,we,t._unit,!0),t._fromNumbers=ft(we.d),t._fromNumber=we.n):e&&(kt(Ct(t.target,t.property,t._tweenType),Dt),t._fromNumbers=ft(Dt.d),t._fromNumber=Dt.n),e&&(kt(e(),Se),t._toNumbers=ft(Se.d),t._strings=ft(Se.s),t._toNumber=Se.o?Et(t._fromNumber,Se.n,Se.o):Se.n))}),this.duration===d&&this.restart(),this}revert(){return super.revert(),Ft(this)}then(t){return super.then(t)}}const Pe=(t,e)=>{let s=t.iterationDuration;if(s===d&&(s=0),z(e))return s;if(M(+e))return+e;const i=e,r=t?t.labels:null,n=!H(r),o=((t,e)=>{if(L(e,"<")){const s="<"===e[1],i=t._tail,r=i?i._offset+i._delay:0;return s?r:r+i.duration}})(t,i),a=!z(o),l=E.exec(i);if(l){const t=l[0],e=i.split(t),h=n&&e[0]?r[e[0]]:s,d=a?o:n?h:s,c=+e[1];return Et(d,c,t[0])}return a?o:n?z(r[i])?s:r[i]:s};function Fe(t,e,s,i,r,n){const o=M(t.duration)&&t.duration<=d?s-d:s;e.composition&&Lt(e,o,1,1,1);const a=i?new Be(i,t,e,o,!1,r,n):new ne(t,e,o);return e.composition&&a.init(!0),bt(e,a),yt(e,t=>{const s=t._offset+t._delay+t.duration;s>e.iterationDuration&&(e.iterationDuration=s)}),e.duration=function(t){return pt((t.iterationDuration+t._loopDelay)*t.iterationCount-t._loopDelay)||d}(e),e}let Me=0;class Ve extends ne{constructor(t={}){super(t,null,0),++Me,this.id=z(t.id)?Me:t.id,this.duration=0,this.labels={};const e=t.defaults,s=A.defaults;this.defaults=e?gt(e,s):s,this.composition=xt(t.composition,!0),this.onRender=t.onRender||s.onRender;const i=xt(t.playbackEase,s.playbackEase);this._ease=i?xe(i):null,this.iterationDuration=0}add(t,e,s){const i=F(e),r=F(t);if(i||r){if(this._hasChildren=!0,i){const i=e,r=A.editor&&A.editor.addTimelineChild,n=s&&"Stagger"===s.type&&A.editor,o=O(s)?s:null;if(o||n){const e=ae(t),n=this.duration,a=this.iterationDuration,l=i.id;let h=0;const d=e.length,c=r?r(t,i,this.id,s,d):null,u=o||A.editor.resolveStagger(s.defaultValue);e.forEach(t=>{const s={...c||i};this.duration=n,this.iterationDuration=a,z(l)||(s.id=l+"-"+h),Fe(s,this,Pe(this,u(t,h,e,null,this)),t,h,e),h++})}else{const e=r?r(t,i,this.id,s):i,n=s&&s.type?s.defaultValue:s;Fe(e,this,Pe(this,n),t)}}else Fe(t,this,Pe(this,e));return this.composition&&this.init(!0),this}}sync(t,e){if(z(t)||t&&z(t.pause))return this;t.pause();const s=+(t.effect?t.effect.getTiming().duration:t.duration);return z(t)||z(t.persist)||(t.persist=!0),this.add(t,{currentTime:[0,s],duration:s,delay:0,ease:"linear",playbackEase:"linear"},e)}set(t,e,s){return z(e)?this:(e.duration=d,e.composition=r.replace,this.add(t,e,s))}call(t,e){return z(t)||t&&!O(t)?this:this.add({duration:0,delay:0,onComplete:()=>t(this)},e)}label(t,e){return z(t)||t&&!V(t)||(this.labels[t]=Pe(this,e)),this}remove(t,e){return te(ae(t),this,e),this}stretch(t){const e=this.duration;if(e===mt(t))return this;const s=t/e,i=this.labels;yt(this,t=>t.stretch(t.duration*s));for(let t in i)i[t]*=s;return super.stretch(t)}refresh(){return yt(this,t=>{t.refresh&&t.refresh()}),this}revert(){return super.revert(),yt(this,t=>t.revert,!0),Ft(this)}then(t){return super.then(t)}}const Oe=t=>A.editor?A.editor.addTimeline(t):new Ve(t).init();class ze{constructor(t,e){D.current&&D.current.register(this);const s=()=>{if(this.callbacks.completed)return;let t=!0;for(let e in this.animations)if(!this.animations[e].paused&&t){t=!1;break}t&&this.callbacks.complete()},i={onBegin:()=>{this.callbacks.completed&&this.callbacks.reset(),this.callbacks.play()},onComplete:s,onPause:s},n={v:1,autoplay:!1},o={};if(this.targets=[],this.animations={},this.callbacks=null,!z(t)&&!z(e)){for(let t in e){const s=e[t];q(t)?o[t]=s:L(t,"on")?n[t]=s:i[t]=s}this.callbacks=new Be({v:0},n);for(let e in o){const s=o[e],n=F(s);let a={},l="+=0";if(n){const t=s.unit;V(t)&&(l+=t)}else a.duration=s;a[e]=n?gt({to:l},s):l;const h=gt(i,a);h.composition=r.replace,h.autoplay=!1;const d=this.animations[e]=new Be(t,h,null,0,!1).init();this.targets.length||this.targets.push(...d.targets),this[e]=(t,e,s)=>{const i=d._head;if(z(t)&&i){const t=i._numbers;return t&&t.length?t:i._modifier(i._number)}return yt(d,e=>{if(P(t))for(let s=0,i=t.length;s<i;s++)z(e._numbers[s])||(e._fromNumbers[s]=e._modifier(e._numbers[s]),e._toNumbers[s]=t[s]);else e._fromNumber=e._modifier(e._number),e._toNumber=t;z(s)||(e._ease=xe(s)),e._currentTime=0}),z(e)||d.stretch(e),d.reset(!0).resume(),this}}}}revert(){for(let t in this.animations)this[t]=y,this.animations[t].revert();return this.animations={},this.targets.length=0,this.callbacks&&this.callbacks.revert(),this}}const He=(t,e,s,i,r)=>i+(t-e)/(s-e)*(r-i);var Xe=Object.freeze({__proto__:null,clamp:ht,damp:(t,e,s,i)=>i?1===i?e:ut(t,e,1-Math.exp(-i*s*.1)):t,degToRad:t=>t*Math.PI/180,lerp:ut,mapRange:He,padEnd:(t,e,s)=>`${t}`.padEnd(e,s),padStart:(t,e,s)=>`${t}`.padStart(e,s),radToDeg:t=>180*t/Math.PI,round:dt,roundPad:(t,e)=>(+t).toFixed(e),snap:ct,wrap:(t,e,s)=>((t-e)%(s-e)+(s-e))%(s-e)+e});const Ye=10*u;class We{constructor(t={}){const e=!z(t.bounce)||!z(t.duration);this.timeStep=.02,this.restThreshold=5e-4,this.restDuration=200,this.maxDuration=6e4,this.maxRestSteps=this.restDuration/this.timeStep/u,this.maxIterations=this.maxDuration/this.timeStep/u,this.bn=ht(xt(t.bounce,.5),-1,1),this.pd=ht(xt(t.duration,628),10*A.timeScale,Ye*A.timeScale),this.m=ht(xt(t.mass,1),1,Ye),this.s=ht(xt(t.stiffness,100),d,Ye),this.d=ht(xt(t.damping,10),d,Ye),this.v=ht(xt(t.velocity,0),-1e4,Ye),this.w0=0,this.zeta=0,this.wd=0,this.b=0,this.completed=!1,this.solverDuration=0,this.settlingDuration=0,this.parent=null,this.onComplete=t.onComplete||y,e&&this.calculateSDFromBD(),this.compute(),this.ease=t=>{const e=t*this.settlingDuration,s=this.completed,i=this.pd;return e>=i&&!s&&(this.completed=!0,this.onComplete(this.parent)),e<i&&s&&(this.completed=!1),0===t||1===t?t:this.solve(t*this.solverDuration)}}solve(t){const{zeta:e,w0:s,wd:i,b:r}=this;let n=t;return n=e<1?et(-n*e*s)*(1*K(i*n)+r*J(i*n)):1===e?(1+r*n)*et(-n*s):((1+r)*et((-e*s+i)*n)+(1-r)*et((-e*s-i)*n))/2,1-n}calculateSDFromBD(){const t=1===A.timeScale?this.pd/u:this.pd;this.m=1,this.v=0,this.s=Z(2*at/t,2),this.bn>=0?this.d=4*(1-this.bn)*at/t:this.d=4*at/(t*(1+this.bn)),this.s=dt(ht(this.s,d,Ye),3),this.d=dt(ht(this.d,d,300),3)}calculateBDFromSD(){const t=2*at/Q(this.s);this.pd=t*(1===A.timeScale?u:1);const e=this.d/(2*Q(this.s));this.bn=e<=1?1-this.d*t/(4*at):4*at/(this.d*t)-1,this.bn=dt(ht(this.bn,-1,1),3),this.pd=dt(ht(this.pd,10*A.timeScale,Ye*A.timeScale),3)}compute(){const{maxRestSteps:t,maxIterations:e,restThreshold:s,timeStep:i,m:r,d:n,s:o,v:a}=this,l=this.w0=ht(Q(o/r),d,u),h=this.zeta=n/(2*Q(o*r));h<1?(this.wd=l*Q(1-h*h),this.b=(h*l-a)/this.wd):1===h?(this.wd=0,this.b=-a+l):(this.wd=l*Q(h*h-1),this.b=(h*l-a)/this.wd);let c=0,p=0,m=0;for(;p<=t&&m<=e;)tt(1-this.solve(c))<s?p++:p=0,this.solverDuration=c,c+=i,m++;this.settlingDuration=dt(this.solverDuration*u,0)*A.timeScale}get bounce(){return this.bn}set bounce(t){this.bn=ht(xt(t,1),-1,1),this.calculateSDFromBD(),this.compute()}get duration(){return this.pd}set duration(t){this.pd=ht(xt(t,1),10*A.timeScale,Ye*A.timeScale),this.calculateSDFromBD(),this.compute()}get stiffness(){return this.s}set stiffness(t){this.s=ht(xt(t,100),d,Ye),this.calculateBDFromSD(),this.compute()}get damping(){return this.d}set damping(t){this.d=ht(xt(t,10),d,Ye),this.calculateBDFromSD(),this.compute()}get mass(){return this.m}set mass(t){this.m=ht(xt(t,1),1,Ye),this.compute()}get velocity(){return this.v}set velocity(t){this.v=ht(xt(t,0),-1e4,Ye),this.compute()}}const Ue=t=>new We(t),qe=t=>(console.warn("createSpring() is deprecated use spring() instead"),new We(t)),je={_head:null,_tail:null},Ge=(t,e,s)=>{let i,r=je._head;for(;r;){const n=r._next,o=r.$el===t,a=!e||r.property===e,l=!s||r.parent===s;if(o&&a&&l){i=r.animation;try{i.commitStyles()}catch{}i.cancel(),vt(je,r);const t=r.parent;t&&(t._completed++,t.animations.length===t._completed&&(t.completed=!0,t.paused=!0,t.muteCallbacks||(t.onComplete(t),t._resolve(t))))}r=n}return i},Ze=(t,e,s,i,r)=>{const n=e.animate(i,r),o=r.delay+ +r.duration*r.iterations;n.playbackRate=t._speed,t.paused&&n.pause(),t.duration<o&&(t.duration=o,t.controlAnimation=n),t.animations.push(n),Ge(e,s),bt(je,{parent:t,animation:n,$el:e,property:s,_next:null,_prev:null});const a=()=>Ge(e,s,t);return n.oncancel=a,n.onremove=a,t.persist||(n.onfinish=a),n};function Qe(t,e,s){const i=le(t);if(!i.length)return;const[r]=i,n=St(r,e),o=Pt(e,r,n);let a=Ct(r,o);if(z(s))return a;if(kt(a,Dt),0===Dt.t||1===Dt.t){if(!1===s)return Dt.n;{const t=ce(r,Dt,s,!1);return`${dt(t.n,A.precision)}${t.u}`}}}const Je=(t,e)=>{if(!z(e))return e.duration=d,e.composition=xt(e.composition,r.none),new Be(t,e,null,0,!0).resume()},Ke=(t,e,s)=>{const i=ae(t);for(let t=0,r=i.length;t<r;t++)Ge(i[t],s,e&&e.controlAnimation&&e);return te(i,e,s),i},ts=t=>{t.cancelable&&t.preventDefault()};class es{constructor(t){this.el=t,this.zIndex=0,this.parentElement=null,this.classList={add:y,remove:y}}get x(){return this.el.x||0}set x(t){this.el.x=t}get y(){return this.el.y||0}set y(t){this.el.y=t}get width(){return this.el.width||0}set width(t){this.el.width=t}get height(){return this.el.height||0}set height(t){this.el.height=t}getBoundingClientRect(){return{top:this.y,right:this.x,bottom:this.y+this.height,left:this.x+this.width}}}class ss{constructor(t){this.$el=t,this.inlineTransforms=[],this.point=new DOMPoint,this.inversedMatrix=this.getMatrix().inverse()}normalizePoint(t,e){return this.point.x=t,this.point.y=e,this.point.matrixTransform(this.inversedMatrix)}traverseUp(t){let e=this.$el.parentElement,s=0;for(;e&&e!==i;)t(e,s),e=e.parentElement,s++}getMatrix(){const t=new DOMMatrix;return this.traverseUp(e=>{const s=getComputedStyle(e).transform;if(s){const e=new DOMMatrix(s);t.preMultiplySelf(e)}}),t}remove(){this.traverseUp((t,e)=>{this.inlineTransforms[e]=t.style.transform,t.style.transform="none"})}revert(){this.traverseUp((t,e)=>{const s=this.inlineTransforms[e];""===s?t.style.removeProperty("transform"):t.style.transform=s})}}const is=(t,e)=>t&&O(t)?t(e):t;let rs=0;class ns{constructor(t,e={}){if(!t)return;D.current&&D.current.register(this);const r=e.x,n=e.y,o=e.trigger,a=e.modifier,l=e.releaseEase,h=l&&xe(l),d=!z(l)&&!z(l.ease),u=F(r)&&!z(r.mapTo)?r.mapTo:"translateX",p=F(n)&&!z(n.mapTo)?n.mapTo:"translateY",m=is(e.container,this);this.containerArray=P(m)?m:null,this.$container=m&&!this.containerArray?ae(m)[0]:i.body,this.useWin=this.$container===i.body,this.$scrollContainer=this.useWin?s:this.$container,this.$target=F(t)?new es(t):ae(t)[0],this.$trigger=ae(o||t)[0],this.fixed="fixed"===Qe(this.$target,"position"),this.isFinePointer=!0,this.containerPadding=[0,0,0,0],this.containerFriction=0,this.releaseContainerFriction=0,this.snapX=0,this.snapY=0,this.scrollSpeed=0,this.scrollThreshold=0,this.dragSpeed=0,this.dragThreshold=3,this.maxVelocity=0,this.minVelocity=0,this.velocityMultiplier=0,this.cursor=!1,this.releaseXSpring=d?l:Ue({mass:xt(e.releaseMass,1),stiffness:xt(e.releaseStiffness,80),damping:xt(e.releaseDamping,20)}),this.releaseYSpring=d?l:Ue({mass:xt(e.releaseMass,1),stiffness:xt(e.releaseStiffness,80),damping:xt(e.releaseDamping,20)}),this.releaseEase=h||ve.outQuint,this.hasReleaseSpring=d,this.onGrab=e.onGrab||y,this.onDrag=e.onDrag||y,this.onRelease=e.onRelease||y,this.onUpdate=e.onUpdate||y,this.onSettle=e.onSettle||y,this.onSnap=e.onSnap||y,this.onResize=e.onResize||y,this.onAfterResize=e.onAfterResize||y,this.disabled=[0,0];const f={};if(a&&(f.modifier=a),z(r)||!0===r)f[u]=0;else if(F(r)){const t=r,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[u]=e}else!1===r&&(f[u]=0,this.disabled[0]=1);if(z(n)||!0===n)f[p]=0;else if(F(n)){const t=n,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[p]=e}else!1===n&&(f[p]=0,this.disabled[1]=1);this.animate=new ze(this.$target,f),this.xProp=u,this.yProp=p,this.destX=0,this.destY=0,this.deltaX=0,this.deltaY=0,this.scroll={x:0,y:0},this.coords=[this.x,this.y,0,0],this.snapped=[0,0],this.pointer=[0,0,0,0,0,0,0,0],this.scrollView=[0,0],this.dragArea=[0,0,0,0],this.containerBounds=[-c,c,c,-c],this.scrollBounds=[0,0,0,0],this.targetBounds=[0,0,0,0],this.window=[0,0],this.velocityStack=[0,0,0],this.velocityStackIndex=0,this.velocityTime=B(),this.velocity=0,this.angle=0,this.cursorStyles=null,this.triggerStyles=null,this.bodyStyles=null,this.targetStyles=null,this.touchActionStyles=null,this.transforms=new ss(this.$target),this.overshootCoords={x:0,y:0},this.overshootTicker=new ne({autoplay:!1,onUpdate:()=>{this.updated=!0,this.manual=!0,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,1),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,1)},onComplete:()=>{this.manual=!1,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,0),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,0)}},null,0).init(),this.updateTicker=new ne({autoplay:!1,onUpdate:()=>this.update()},null,0).init(),this.contained=!z(m),this.manual=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.enabled=!1,this.initialized=!1,this.activeProp=this.disabled[1]?u:p,this.animate.callbacks.onRender=()=>{const t=this.updated,e=!(this.grabbed&&t)&&this.released,s=this.x,i=this.y,r=s-this.coords[2],n=i-this.coords[3];this.deltaX=r,this.deltaY=n,this.coords[2]=s,this.coords[3]=i,t&&(r||n)&&this.onUpdate(this),e?(this.computeVelocity(r,n),this.angle=ot(n,r)):this.updated=!1},this.animate.callbacks.onComplete=()=>{!this.grabbed&&this.released&&(this.released=!1),this.manual||(this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.onSettle(this))},this.resizeTicker=new ne({autoplay:!1,duration:150*A.timeScale,onComplete:()=>{this.onResize(this),this.refresh(),this.onAfterResize(this)}}).init(),this.parameters=e,this.resizeObserver=new ResizeObserver(()=>{this.initialized?this.resizeTicker.restart():this.initialized=!0}),this.enable(),this.refresh(),this.resizeObserver.observe(this.$container),F(t)||this.resizeObserver.observe(this.$target)}computeVelocity(t,e){const s=this.velocityTime,i=B(),r=i-s;if(r<17)return this.velocity;this.velocityTime=i;const n=this.velocityStack,o=this.velocityMultiplier,a=this.minVelocity,l=this.maxVelocity,h=this.velocityStackIndex;n[h]=dt(ht(Q(t*t+e*e)/r*o,a,l),5);const d=nt(n[0],n[1],n[2]);return this.velocity=d,this.velocityStackIndex=(h+1)%3,d}setX(t,e=!1){if(this.disabled[0])return;const s=dt(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destX=s,this.snapped[0]=ct(s,this.snapX),this.animate[this.xProp](s,0),this.manual=!1,this}setY(t,e=!1){if(this.disabled[1])return;const s=dt(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destY=s,this.snapped[1]=ct(s,this.snapY),this.animate[this.yProp](s,0),this.manual=!1,this}get x(){return dt(this.animate[this.xProp](),A.precision)}set x(t){this.setX(t,!1)}get y(){return dt(this.animate[this.yProp](),A.precision)}set y(t){this.setY(t,!1)}get progressX(){return He(this.x,this.containerBounds[3],this.containerBounds[1],0,1)}set progressX(t){this.setX(He(t,0,1,this.containerBounds[3],this.containerBounds[1]),!1)}get progressY(){return He(this.y,this.containerBounds[0],this.containerBounds[2],0,1)}set progressY(t){this.setY(He(t,0,1,this.containerBounds[0],this.containerBounds[2]),!1)}updateScrollCoords(){const t=dt(this.useWin?s.scrollX:this.$container.scrollLeft,0),e=dt(this.useWin?s.scrollY:this.$container.scrollTop,0),[i,r,n,o]=this.containerPadding,a=this.scrollThreshold;this.scroll.x=t,this.scroll.y=e,this.scrollBounds[0]=e-this.targetBounds[0]+i-a,this.scrollBounds[1]=t-this.targetBounds[1]-r+a,this.scrollBounds[2]=e-this.targetBounds[2]-n+a,this.scrollBounds[3]=t-this.targetBounds[3]+o-a}updateBoundingValues(){const t=this.$container;if(!t)return;const e=this.x,r=this.y,n=this.coords[2],o=this.coords[3];this.coords[2]=0,this.coords[3]=0,this.setX(0,!0),this.setY(0,!0),this.transforms.remove();const a=this.window[0]=s.innerWidth,l=this.window[1]=s.innerHeight,h=this.useWin,d=t.scrollWidth,c=t.scrollHeight,u=this.fixed,p=t.getBoundingClientRect(),[m,f,g,y]=this.containerPadding;this.dragArea[0]=h?0:p.left,this.dragArea[1]=h?0:p.top,this.scrollView[0]=h?ht(d,a,d):d,this.scrollView[1]=h?ht(c,l,c):c,this.updateScrollCoords();const{width:v,height:b,left:_,top:T,right:x,bottom:w}=t.getBoundingClientRect();this.dragArea[2]=dt(h?ht(v,a,a):v,0),this.dragArea[3]=dt(h?ht(b,l,l):b,0);const S=Qe(t,"overflow"),$="visible"===S,C="hidden"===S;if(this.canScroll=!u&&this.contained&&(t===i.body&&$||!C&&!$)&&(d>this.dragArea[2]+y-f||c>this.dragArea[3]+m-g)&&(!this.containerArray||this.containerArray&&!P(this.containerArray)),this.contained){const e=this.scroll.x,s=this.scroll.y,i=this.canScroll,r=this.$target.getBoundingClientRect(),n=i?h?0:t.scrollLeft:0,o=i?h?0:t.scrollTop:0,d=i?this.scrollView[0]-n-v:0,c=i?this.scrollView[1]-o-b:0;this.targetBounds[0]=dt(r.top+s-(h?0:T),0),this.targetBounds[1]=dt(r.right+e-(h?a:x),0),this.targetBounds[2]=dt(r.bottom+s-(h?l:w),0),this.targetBounds[3]=dt(r.left+e-(h?0:_),0),this.containerArray?(this.containerBounds[0]=this.containerArray[0]+m,this.containerBounds[1]=this.containerArray[1]-f,this.containerBounds[2]=this.containerArray[2]-g,this.containerBounds[3]=this.containerArray[3]+y):(this.containerBounds[0]=-dt(r.top-(u?ht(T,0,l):T)+o-m,0),this.containerBounds[1]=-dt(r.right-(u?ht(x,0,a):x)-d+f,0),this.containerBounds[2]=-dt(r.bottom-(u?ht(w,0,l):w)-c+g,0),this.containerBounds[3]=-dt(r.left-(u?ht(_,0,a):_)+n-y,0))}this.transforms.revert(),this.coords[2]=n,this.coords[3]=o,this.setX(e,!0),this.setY(r,!0)}isOutOfBounds(t,e,s){if(!this.contained)return 0;const[i,r,n,o]=t,[a,l]=this.disabled,h=!a&&e<o||!a&&e>r,d=!l&&s<i||!l&&s>n;return h&&!d?1:!h&&d?2:h&&d?3:0}refresh(){const t=this.parameters,e=t.x,r=t.y,n=is(t.container,this),o=is(t.containerPadding,this)||0,a=P(o)?o:[o,o,o,o],l=this.x,h=this.y,d=is(t.cursor,this),c={onHover:"grab",onGrab:"grabbing"};if(d){const{onHover:t,onGrab:e}=d;t&&(c.onHover=t),e&&(c.onGrab=e)}const u=is(t.dragThreshold,this),p={mouse:3,touch:7};if(M(u))p.mouse=u,p.touch=u;else if(u){const{mouse:t,touch:e}=u;z(t)||(p.mouse=t),z(e)||(p.touch=e)}this.containerArray=P(n)?n:null,this.$container=n&&!this.containerArray?ae(n)[0]:i.body,this.useWin=this.$container===i.body,this.$scrollContainer=this.useWin?s:this.$container,this.isFinePointer=matchMedia("(pointer:fine)").matches,this.containerPadding=xt(a,[0,0,0,0]),this.containerFriction=ht(xt(is(t.containerFriction,this),.8),0,1),this.releaseContainerFriction=ht(xt(is(t.releaseContainerFriction,this),this.containerFriction),0,1),this.snapX=is(F(e)&&!z(e.snap)?e.snap:t.snap,this),this.snapY=is(F(r)&&!z(r.snap)?r.snap:t.snap,this),this.scrollSpeed=xt(is(t.scrollSpeed,this),1.5),this.scrollThreshold=xt(is(t.scrollThreshold,this),20),this.dragSpeed=xt(is(t.dragSpeed,this),1),this.dragThreshold=this.isFinePointer?p.mouse:p.touch,this.minVelocity=xt(is(t.minVelocity,this),0),this.maxVelocity=xt(is(t.maxVelocity,this),50),this.velocityMultiplier=xt(is(t.velocityMultiplier,this),1),this.cursor=!1!==d&&c,this.updateBoundingValues();const[m,f,g,y]=this.containerBounds;this.setX(ht(l,y,f),!0),this.setY(ht(h,m,g),!0)}update(){if(this.updateScrollCoords(),this.canScroll){const[t,e,s,i]=this.containerPadding,[r,n]=this.scrollView,o=this.dragArea[2],a=this.dragArea[3],l=this.scroll.x,h=this.scroll.y,d=this.$container.scrollWidth,c=this.$container.scrollHeight,u=this.useWin?ht(d,this.window[0],d):d,p=this.useWin?ht(c,this.window[1],c):c,m=r-u,f=n-p;this.dragged&&m>0&&(this.coords[0]-=m,this.scrollView[0]=u),this.dragged&&f>0&&(this.coords[1]-=f,this.scrollView[1]=p);const g=10*this.scrollSpeed,y=this.scrollThreshold,[v,b]=this.coords,[_,T,x,w]=this.scrollBounds,S=dt(ht((b-_+t)/y,-1,0)*g,0),$=dt(ht((v-T-e)/y,0,1)*g,0),C=dt(ht((b-x-s)/y,0,1)*g,0),E=dt(ht((v-w+i)/y,-1,0)*g,0);if(S||C||E||$){const[t,e]=this.disabled;let s=l,i=h;t||(s=dt(ht(l+(E||$),0,r-o),0),this.coords[0]-=l-s),e||(i=dt(ht(h+(S||C),0,n-a),0),this.coords[1]-=h-i),this.useWin?this.$scrollContainer.scrollBy(-(l-s),-(h-i)):this.$scrollContainer.scrollTo(s,i)}}const[t,e,s,i]=this.containerBounds,[r,n,o,a,l,h]=this.pointer;this.coords[0]+=(r-l)*this.dragSpeed,this.coords[1]+=(n-h)*this.dragSpeed,this.pointer[4]=r,this.pointer[5]=n;const[d,c]=this.coords,[u,p]=this.snapped,m=(1-this.containerFriction)*this.dragSpeed;this.setX(d>e?e+(d-e)*m:d<i?i+(d-i)*m:d,!1),this.setY(c>s?s+(c-s)*m:c<t?t+(c-t)*m:c,!1),this.computeVelocity(r-l,n-h),this.angle=ot(n-a,r-o);const[f,g]=this.snapped;(f!==u&&this.snapX||g!==p&&this.snapY)&&this.onSnap(this)}stop(){this.updateTicker.pause(),this.overshootTicker.pause();for(let t in this.animate.animations)this.animate.animations[t].pause();return te([this],null,"x"),te([this],null,"y"),te([this],null,"progressX"),te([this],null,"progressY"),te([this.scroll]),te([this.overshootCoords]),this}scrollInView(t,e=0,s=ve.inOutQuad){this.updateScrollCoords();const i=this.destX,r=this.destY,n=this.scroll,o=this.scrollBounds,a=this.canScroll;if(!this.containerArray&&this.isOutOfBounds(o,i,r)){const[l,h,d,u]=o,p=dt(ht(r-l,-c,0),0),m=dt(ht(i-h,0,c),0),f=dt(ht(r-d,0,c),0),g=dt(ht(i-u,-c,0),0);new Be(n,{x:dt(n.x+(g?g-e:m?m+e:0),0),y:dt(n.y+(p?p-e:f?f+e:0),0),duration:z(t)?350*A.timeScale:t,ease:s,onUpdate:()=>{this.canScroll=!1,this.$scrollContainer.scrollTo(n.x,n.y)}}).init().then(()=>{this.canScroll=a})}return this}handleHover(){this.isFinePointer&&this.cursor&&!this.cursorStyles&&(this.cursorStyles=Je(this.$trigger,{cursor:this.cursor.onHover}))}animateInView(t,e=0,s=ve.inOutQuad){this.stop(),this.updateBoundingValues();const i=this.x,r=this.y,[n,o,a,l]=this.containerPadding,h=this.scroll.y-this.targetBounds[0]+n+e,d=this.scroll.x-this.targetBounds[1]-o-e,c=this.scroll.y-this.targetBounds[2]-a-e,u=this.scroll.x-this.targetBounds[3]+l+e,p=this.isOutOfBounds([h,d,c,u],i,r);if(p){const[e,n]=this.disabled,o=ht(ct(i,this.snapX),u,d),a=ht(ct(r,this.snapY),h,c),l=z(t)?350*A.timeScale:t;e||1!==p&&3!==p||this.animate[this.xProp](o,l,s),n||2!==p&&3!==p||this.animate[this.yProp](a,l,s)}return this}handleDown(t){const e=t.target;if(this.grabbed||"range"===e.type)return;t.stopPropagation(),this.grabbed=!0,this.released=!1,this.stop(),this.updateBoundingValues();const s=t.changedTouches,r=s?s[0].clientX:t.clientX,n=s?s[0].clientY:t.clientY,{x:o,y:a}=this.transforms.normalizePoint(r,n),[l,h,d,c]=this.containerBounds,u=(1-this.containerFriction)*this.dragSpeed,p=this.x,m=this.y;this.coords[0]=this.coords[2]=u?p>h?h+(p-h)/u:p<c?c+(p-c)/u:p:p,this.coords[1]=this.coords[3]=u?m>d?d+(m-d)/u:m<l?l+(m-l)/u:m:m,this.pointer[0]=o,this.pointer[1]=a,this.pointer[2]=o,this.pointer[3]=a,this.pointer[4]=o,this.pointer[5]=a,this.pointer[6]=o,this.pointer[7]=a,this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null);const f=Qe(this.$target,"zIndex",!1);rs=(f>rs?f:rs)+1,this.targetStyles=Je(this.$target,{zIndex:rs}),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.isFinePointer&&this.cursor&&(this.bodyStyles=Je(i.body,{cursor:this.cursor.onGrab})),this.scrollInView(100,0,ve.out(3)),this.onGrab(this),i.addEventListener("touchmove",this),i.addEventListener("touchend",this),i.addEventListener("touchcancel",this),i.addEventListener("mousemove",this),i.addEventListener("mouseup",this),i.addEventListener("selectstart",this)}handleMove(t){if(!this.grabbed)return;const e=t.changedTouches,s=e?e[0].clientX:t.clientX,i=e?e[0].clientY:t.clientY,{x:r,y:n}=this.transforms.normalizePoint(s,i),o=r-this.pointer[6],a=n-this.pointer[7];let l=t.target,h=!1,d=!1,c=!1;for(;e&&l&&l!==this.$trigger;){const t=Qe(l,"overflow-y");if("hidden"!==t&&"visible"!==t){const{scrollTop:t,scrollHeight:e,clientHeight:s}=l;if(e>s){c=!0,h=t<=3,d=t>=e-s-3;break}}l=l.parentElement}c&&(!h&&!d||h&&a<0||d&&a>0)?(this.pointer[0]=r,this.pointer[1]=n,this.pointer[2]=r,this.pointer[3]=n,this.pointer[4]=r,this.pointer[5]=n,this.pointer[6]=r,this.pointer[7]=n):(ts(t),this.triggerStyles||(this.triggerStyles=Je(this.$trigger,{pointerEvents:"none"})),this.$trigger.addEventListener("touchstart",ts,{passive:!1}),this.$trigger.addEventListener("touchmove",ts,{passive:!1}),this.$trigger.addEventListener("touchend",ts),(this.dragged||!this.disabled[0]&&tt(o)>this.dragThreshold||!this.disabled[1]&&tt(a)>this.dragThreshold)&&(this.updateTicker.resume(),this.pointer[2]=this.pointer[0],this.pointer[3]=this.pointer[1],this.pointer[0]=r,this.pointer[1]=n,this.dragged=!0,this.released=!1,this.onDrag(this)))}handleUp(){if(!this.grabbed)return;this.updateTicker.pause(),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null);const[t,e]=this.disabled,[s,n,o,a,l,h]=this.pointer,[d,c,u,p]=this.containerBounds,[m,f]=this.snapped,g=this.releaseXSpring,y=this.releaseYSpring,v=this.releaseEase,b=this.hasReleaseSpring,_=this.overshootCoords,T=this.x,x=this.y,w=this.computeVelocity(s-l,n-h),S=this.angle=ot(n-a,s-o),$=150*w,C=(1-this.releaseContainerFriction)*this.dragSpeed,E=T+K(S)*$,k=x+J(S)*$,N=E>c?c+(E-c)*C:E<p?p+(E-p)*C:E,D=k>u?u+(k-u)*C:k<d?d+(k-d)*C:k,I=this.destX=ht(dt(ct(N,this.snapX),5),p,c),R=this.destY=ht(dt(ct(D,this.snapY),5),d,u),L=this.isOutOfBounds(this.containerBounds,E,k);let B=0,P=0,F=v,M=v,V=0;if(_.x=T,_.y=x,!t){const t=I===c?T>c?-1:1:T<p?-1:1,s=dt(T-I,0);g.velocity=e&&b?s?$*t/tt(s):0:w;const{ease:i,settlingDuration:r,restDuration:n}=g;B=T===I?0:b?r:r-n*A.timeScale,b&&(F=i),B>V&&(V=B)}if(!e){const e=R===u?x>u?-1:1:x<d?-1:1,s=dt(x-R,0);y.velocity=t&&b?s?$*e/tt(s):0:w;const{ease:i,settlingDuration:r,restDuration:n}=y;P=x===R?0:b?r:r-n*A.timeScale,b&&(M=i),P>V&&(V=P)}if(!b&&L&&C&&(B||P)){const t=r.blend;new Be(_,{x:{to:N,duration:.65*B},y:{to:D,duration:.65*P},ease:v,composition:t}).init(),new Be(_,{x:{to:I,duration:B},y:{to:R,duration:P},ease:v,composition:t}).init(),this.overshootTicker.stretch(nt(B,P)).restart()}else t||this.animate[this.xProp](I,B,F),e||this.animate[this.yProp](R,P,M);this.scrollInView(V,this.scrollThreshold,v);let O=!1;I!==m&&(this.snapped[0]=I,this.snapX&&(O=!0)),R!==f&&this.snapY&&(this.snapped[1]=R,this.snapY&&(O=!0)),O&&this.onSnap(this),this.grabbed=!1,this.dragged=!1,this.updated=!0,this.released=!0,this.onRelease(this),this.$trigger.removeEventListener("touchstart",ts),this.$trigger.removeEventListener("touchmove",ts),this.$trigger.removeEventListener("touchend",ts),i.removeEventListener("touchmove",this),i.removeEventListener("touchend",this),i.removeEventListener("touchcancel",this),i.removeEventListener("mousemove",this),i.removeEventListener("mouseup",this),i.removeEventListener("selectstart",this)}reset(){return this.stop(),this.resizeTicker.pause(),this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.setX(0,!0),this.setY(0,!0),this.coords[0]=0,this.coords[1]=0,this.pointer[0]=0,this.pointer[1]=0,this.pointer[2]=0,this.pointer[3]=0,this.pointer[4]=0,this.pointer[5]=0,this.pointer[6]=0,this.pointer[7]=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this}enable(){return this.enabled||(this.enabled=!0,this.$target.classList.remove("is-disabled"),this.touchActionStyles=Je(this.$trigger,{touchAction:this.disabled[0]?"pan-x":this.disabled[1]?"pan-y":"none"}),this.$trigger.addEventListener("touchstart",this,{passive:!0}),this.$trigger.addEventListener("mousedown",this,{passive:!0}),this.$trigger.addEventListener("mouseenter",this)),this}disable(){return this.enabled=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.touchActionStyles.revert(),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null),this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null),this.$target.classList.add("is-disabled"),this.$trigger.removeEventListener("touchstart",this),this.$trigger.removeEventListener("mousedown",this),this.$trigger.removeEventListener("mouseenter",this),i.removeEventListener("touchmove",this),i.removeEventListener("touchend",this),i.removeEventListener("touchcancel",this),i.removeEventListener("mousemove",this),i.removeEventListener("mouseup",this),i.removeEventListener("selectstart",this),this}revert(){return this.reset(),this.disable(),this.$target.classList.remove("is-disabled"),this.updateTicker.revert(),this.overshootTicker.revert(),this.resizeTicker.revert(),this.animate.revert(),this.resizeObserver.disconnect(),this}handleEvent(t){switch(t.type){case"mousedown":case"touchstart":this.handleDown(t);break;case"mousemove":case"touchmove":this.handleMove(t);break;case"mouseup":case"touchend":case"touchcancel":this.handleUp();break;case"mouseenter":this.handleHover();break;case"selectstart":ts(t)}}}const os=(t=y)=>new ne({duration:1*A.timeScale,onComplete:t},null,0).resume(),as=t=>{let e;return(...s)=>{let i,r,n,o,a;e&&(i=e.currentIteration,r=e.iterationProgress,n=e.reversed,o=e._alternate,a=e._startTime,e.revert());const l=t(...s);return l&&!O(l)&&l.revert&&(e=l),z(r)||(e.currentIteration=i,e.iterationProgress=(o&&i%2?!n:n)?1-r:r,e._startTime=a),l||y}};class ls{constructor(t={}){D.current&&D.current.register(this);const e=t.root;let r=i;e&&(r=e.current||e.nativeElement||ae(e)[0]||i);const n=t.defaults,o=A.defaults,a=t.mediaQueries;if(this.defaults=n?gt(n,o):o,this.root=r,this.constructors=[],this.revertConstructors=[],this.revertibles=[],this.constructorsOnce=[],this.revertConstructorsOnce=[],this.revertiblesOnce=[],this.once=!1,this.onceIndex=0,this.methods={},this.matches={},this.mediaQueryLists={},this.data={},a)for(let t in a){const e=s.matchMedia(a[t]);this.mediaQueryLists[t]=e,e.addEventListener("change",this)}}register(t){(this.once?this.revertiblesOnce:this.revertibles).push(t)}execute(t){let e=D.current,s=D.root,i=A.defaults;D.current=this,D.root=this.root,A.defaults=this.defaults;const r=this.mediaQueryLists;for(let t in r)this.matches[t]=r[t].matches;const n=t(this);return D.current=e,D.root=s,A.defaults=i,n}refresh(){return this.onceIndex=0,this.execute(()=>{let t=this.revertibles.length,e=this.revertConstructors.length;for(;t--;)this.revertibles[t].revert();for(;e--;)this.revertConstructors[e](this);this.revertibles.length=0,this.revertConstructors.length=0,this.constructors.forEach(t=>{const e=t(this);O(e)&&this.revertConstructors.push(e)})}),this}add(t,e){if(this.once=!1,O(t)){const e=t;this.constructors.push(e),this.execute(()=>{const t=e(this);O(t)&&this.revertConstructors.push(t)})}else this.methods[t]=(...t)=>this.execute(()=>e(...t));return this}addOnce(t){if(this.once=!0,O(t)){const e=this.onceIndex++;if(this.constructorsOnce[e])return this;const s=t;this.constructorsOnce[e]=s,this.execute(()=>{const t=s(this);O(t)&&this.revertConstructorsOnce.push(t)})}return this}keepTime(t){this.once=!0;const e=this.onceIndex++,s=this.constructorsOnce[e];if(O(s))return s(this);const i=as(t);let r;return this.constructorsOnce[e]=i,this.execute(()=>{r=i(this)}),r}handleEvent(t){"change"===t.type&&this.refresh()}revert(){const t=this.revertibles,e=this.revertConstructors,s=this.revertiblesOnce,i=this.revertConstructorsOnce,r=this.mediaQueryLists;let n=t.length,o=e.length,a=s.length,l=i.length;for(;n--;)t[n].revert();for(;o--;)e[o](this);for(;a--;)s[a].revert();for(;l--;)i[l](this);for(let t in r)r[t].removeEventListener("change",this);t.length=0,e.length=0,this.constructors.length=0,s.length=0,i.length=0,this.constructorsOnce.length=0,this.onceIndex=0,this.matches={},this.methods={},this.mediaQueryLists={},this.data={}}}const hs=(t,e)=>t&&O(t)?t(e):t,ds=new Map;class cs{constructor(t){this.element=t,this.useWin=this.element===i.body,this.winWidth=0,this.winHeight=0,this.width=0,this.height=0,this.left=0,this.top=0,this.scale=1,this.zIndex=0,this.scrollX=0,this.scrollY=0,this.prevScrollX=0,this.prevScrollY=0,this.scrollWidth=0,this.scrollHeight=0,this.velocity=0,this.backwardX=!1,this.backwardY=!1,this.scrollTicker=new ne({autoplay:!1,onBegin:()=>this.dataTimer.resume(),onUpdate:()=>{const t=this.backwardX||this.backwardY;yt(this,t=>t.handleScroll(),t)},onComplete:()=>this.dataTimer.pause()}).init(),this.dataTimer=new ne({autoplay:!1,frameRate:30,onUpdate:t=>{const e=t.deltaTime,s=this.prevScrollX,i=this.prevScrollY,r=this.scrollX,n=this.scrollY,o=s-r,a=i-n;this.prevScrollX=r,this.prevScrollY=n,o&&(this.backwardX=s>r),a&&(this.backwardY=i>n),this.velocity=dt(e>0?Math.sqrt(o*o+a*a)/e:0,5)}}).init(),this.resizeTicker=new ne({autoplay:!1,duration:250*A.timeScale,onComplete:()=>{this.updateWindowBounds(),this.refreshScrollObservers(),this.handleScroll()}}).init(),this.wakeTicker=new ne({autoplay:!1,duration:500*A.timeScale,onBegin:()=>{this.scrollTicker.resume()},onComplete:()=>{this.scrollTicker.pause()}}).init(),this._head=null,this._tail=null,this.updateScrollCoords(),this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll(),this.resizeObserver=new ResizeObserver(()=>this.resizeTicker.restart()),this.resizeObserver.observe(this.element),(this.useWin?s:this.element).addEventListener("scroll",this,!1)}updateScrollCoords(){const t=this.useWin,e=this.element;this.scrollX=dt(t?s.scrollX:e.scrollLeft,0),this.scrollY=dt(t?s.scrollY:e.scrollTop,0)}updateWindowBounds(){this.winWidth=s.innerWidth,this.winHeight=(()=>{const t=i.createElement("div");i.body.appendChild(t),t.style.height="100lvh";const e=t.offsetHeight;return i.body.removeChild(t),e})()}updateBounds(){const t=getComputedStyle(this.element),e=this.element;let s,i;if(this.scrollWidth=e.scrollWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),this.scrollHeight=e.scrollHeight+parseFloat(t.marginTop)+parseFloat(t.marginBottom),this.updateWindowBounds(),this.useWin)s=this.winWidth,i=this.winHeight;else{const t=e.getBoundingClientRect();s=e.clientWidth,i=e.clientHeight,this.top=t.top,this.left=t.left,this.scale=t.width?s/t.width:t.height?i/t.height:1}this.width=s,this.height=i}refreshScrollObservers(){yt(this,t=>{t._debug&&t.removeDebug()}),this.updateBounds(),yt(this,t=>{t.refresh(),t.onResize(t),t._debug&&t.debug()})}refresh(){this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll()}handleScroll(){this.updateScrollCoords(),this.wakeTicker.restart()}handleEvent(t){"scroll"===t.type&&this.handleScroll()}revert(){this.scrollTicker.cancel(),this.dataTimer.cancel(),this.resizeTicker.cancel(),this.wakeTicker.cancel(),this.resizeObserver.disconnect(),(this.useWin?s:this.element).removeEventListener("scroll",this),ds.delete(this.element)}}const us=(t,e,s,i,r)=>{const n="min"===e,o="max"===e,a="top"===e||"left"===e||"start"===e||n?0:"bottom"===e||"right"===e||"end"===e||o?"100%":"center"===e?"50%":e,{n:l,u:h}=kt(a,Dt);let d=l;return"%"===h?d=l/100*s:h&&(d=ce(t,Dt,"px",!0).n),o&&i<0&&(d+=i),n&&r>0&&(d+=r),d},ps=(t,e,s,i,r)=>{let n;if(V(e)){const o=E.exec(e);if(o){const a=o[0],l=a[0],h=e.split(a),d="min"===h[0],c="max"===h[0],u=us(t,h[0],s,i,r),p=us(t,h[1],s,i,r);if(d){const e=Et(us(t,"min",s),p,l);n=e<u?u:e}else if(c){const e=Et(us(t,"max",s),p,l);n=e>u?u:e}else n=Et(u,p,l)}else n=us(t,e,s,i,r)}else n=e;return dt(n,0)},ms=t=>{let e;const s=t.targets;for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i[o]){e=i;break}}return e};let fs=0;const gs=["#FF4B4B","#FF971B","#FFC730","#F9F640","#7AFF5A","#18FF74","#17E09B","#3CFFEC","#05DBE9","#33B3F1","#638CF9","#C563FE","#FF4FCF","#F93F8A"];class ys{constructor(t={}){D.current&&D.current.register(this);const e=xt(t.sync,"play pause"),s=e?xe(e):null,r=e&&("linear"===e||e===ue),n=e&&!(s===ue&&!r),o=e&&(M(e)||!0===e||r),a=e&&V(e)&&!n&&!o,l=a?e.split(" ").map(t=>()=>{const e=this.linked;return e&&e[t]?e[t]():null}):null,h=a&&l.length>2;this.index=fs++,this.id=z(t.id)?this.index:t.id,this.container=(t=>{const e=t&&ae(t)[0]||i.body;let s=ds.get(e);return s||(s=new cs(e),ds.set(e,s)),s})(t.container),this.target=null,this.linked=null,this.repeat=null,this.horizontal=null,this.enter=null,this.leave=null,this.sync=n||o||!!l,this.syncEase=n?s:null,this.syncSmooth=o?!0===e||r?1:e:null,this.onSyncEnter=l&&!h&&l[0]?l[0]:y,this.onSyncLeave=l&&!h&&l[1]?l[1]:y,this.onSyncEnterForward=l&&h&&l[0]?l[0]:y,this.onSyncLeaveForward=l&&h&&l[1]?l[1]:y,this.onSyncEnterBackward=l&&h&&l[2]?l[2]:y,this.onSyncLeaveBackward=l&&h&&l[3]?l[3]:y,this.onEnter=t.onEnter||y,this.onLeave=t.onLeave||y,this.onEnterForward=t.onEnterForward||y,this.onLeaveForward=t.onLeaveForward||y,this.onEnterBackward=t.onEnterBackward||y,this.onLeaveBackward=t.onLeaveBackward||y,this.onUpdate=t.onUpdate||y,this.onResize=t.onResize||y,this.onSyncComplete=t.onSyncComplete||y,this.reverted=!1,this.ready=!1,this.completed=!1,this.began=!1,this.isInView=!1,this.forceEnter=!1,this.hasEntered=!1,this.offset=0,this.offsetStart=0,this.offsetEnd=0,this.distance=0,this.prevProgress=0,this.thresholds=["start","end","end","start"],this.coords=[0,0,0,0],this.debugStyles=null,this.$debug=null,this._params=t,this._debug=xt(t.debug,!1),this._next=null,this._prev=null,bt(this.container,this),os(()=>{if(!this.reverted){if(!this.target){const e=ae(t.target)[0];this.target=e||i.body,this.refresh()}this._debug&&this.debug()}})}link(t){if(t&&(t.pause(),this.linked=t,z(t)||z(t.persist)||(t.persist=!0),!this._params.target)){let e;z(t.targets)?yt(t,t=>{t.targets&&!e&&(e=ms(t))}):e=ms(t),this.target=e||i.body,this.refresh()}return this}get velocity(){return this.container.velocity}get backward(){return this.horizontal?this.container.backwardX:this.container.backwardY}get scroll(){return this.horizontal?this.container.scrollX:this.container.scrollY}get progress(){const t=(this.scroll-this.offsetStart)/this.distance;return t===1/0||isNaN(t)?0:dt(ht(t,0,1),6)}refresh(){this.ready=!0,this.reverted=!1;const t=this._params;return this.repeat=xt(hs(t.repeat,this),!0),this.horizontal="x"===xt(hs(t.axis,this),"y"),this.enter=xt(hs(t.enter,this),"end start"),this.leave=xt(hs(t.leave,this),"start end"),this.updateBounds(),this.handleScroll(),this}removeDebug(){return this.$debug&&(this.$debug.parentNode.removeChild(this.$debug),this.$debug=null),this.debugStyles&&(this.debugStyles.revert(),this.$debug=null),this}debug(){this.removeDebug();const t=this.container,e=this.horizontal,s=t.element.querySelector(":scope > .animejs-onscroll-debug"),r=i.createElement("div"),n=i.createElement("div"),o=i.createElement("div"),a=gs[this.index%gs.length],l=t.useWin,h=l?t.winWidth:t.width,d=l?t.winHeight:t.height,c=t.scrollWidth,u=t.scrollHeight,p=this.container.width>360?320:260,m=e?0:10,f=e?10:0,g=e?24:p/2,y=e?g:15,v=e?60:g,b=e?v:y,_=e?"repeat-x":"repeat-y",T=t=>e?"0px "+t+"px":t+"px 2px",x=t=>`linear-gradient(${e?90:0}deg, ${t} 2px, transparent 1px)`,w=(t,e,s,i,r)=>`position:${t};left:${e}px;top:${s}px;width:${i}px;height:${r}px;`;r.style.cssText=`${w("absolute",m,f,e?c:p,e?p:u)}\n pointer-events: none;\n z-index: ${this.container.zIndex++};\n display: flex;\n flex-direction: ${e?"column":"row"};\n filter: drop-shadow(0px 1px 0px rgba(0,0,0,.75));\n `,n.style.cssText=`${w("sticky",0,0,e?h:g,e?g:d)}`,s||(n.style.cssText+=`background:\n ${x("#FFFF")}${T(g-10)} / 100px 100px ${_},\n ${x("#FFF8")}${T(g-10)} / 10px 10px ${_};\n `),o.style.cssText=`${w("relative",0,0,e?c:g,e?g:u)}`,s||(o.style.cssText+=`background:\n ${x("#FFFF")}${T(0)} / ${e?"100px 10px":"10px 100px"} ${_},\n ${x("#FFF8")}${T(0)} / ${e?"10px 0px":"0px 10px"} ${_};\n `);const S=[" enter: "," leave: "];this.coords.forEach((t,s)=>{const r=s>1,l=(r?0:this.offset)+t,m=s%2,f=l<b,g=l>(r?e?h:d:e?c:u)-b,_=(r?m&&!f:!m&&!f)||g,T=i.createElement("div"),x=i.createElement("div"),$=e?_?"right":"left":_?"bottom":"top",C=_?(e?v:y)+(r?e?-1:g?0:-2:e?-1:-2):e?1:0;x.innerHTML=`${this.id}${S[m]}${this.thresholds[s]}`,T.style.cssText=`${w("absolute",0,0,v,y)}\n display: flex;\n flex-direction: ${e?"column":"row"};\n justify-content: flex-${r?"start":"end"};\n align-items: flex-${_?"end":"start"};\n border-${$}: 2px solid ${a};\n `,x.style.cssText=`\n overflow: hidden;\n max-width: ${p/2-10}px;\n height: ${y};\n margin-${e?_?"right":"left":_?"bottom":"top"}: -2px;\n padding: 1px;\n font-family: ui-monospace, monospace;\n font-size: 10px;\n letter-spacing: -.025em;\n line-height: 9px;\n font-weight: 600;\n text-align: ${e&&_||!e&&!r?"right":"left"};\n white-space: pre;\n text-overflow: ellipsis;\n color: ${m?a:"rgba(0,0,0,.75)"};\n background-color: ${m?"rgba(0,0,0,.65)":a};\n border: 2px solid ${m?a:"transparent"};\n border-${e?_?"top-left":"top-right":_?"top-left":"bottom-left"}-radius: 5px;\n border-${e?_?"bottom-left":"bottom-right":_?"top-right":"bottom-right"}-radius: 5px;\n `,T.appendChild(x);let E=l-C+(e?1:0);T.style[e?"left":"top"]=`${E}px`,(r?n:o).appendChild(T)}),r.appendChild(n),r.appendChild(o),t.element.appendChild(r),s||r.classList.add("animejs-onscroll-debug"),this.$debug=r,"static"===Qe(t.element,"position")&&(this.debugStyles=Je(t.element,{position:"relative "}))}updateBounds(){let t;this._debug&&this.removeDebug();const e=this.target,s=this.container,r=this.horizontal,n=this.linked;let o,a=e;for(n&&(o=n.currentTime,n.seek(0,!0));a&&a!==s.element&&a!==i.body;){const e="sticky"===Qe(a,"position")&&Je(a,{position:"static"});a=a.parentElement,e&&(t||(t=[]),t.push(e))}const l=e.getBoundingClientRect(),h=s.scale,d=(r?l.left+s.scrollX-s.left:l.top+s.scrollY-s.top)*h,c=(r?l.width:l.height)*h,u=r?s.width:s.height,p=(r?s.scrollWidth:s.scrollHeight)-u,m=this.enter,f=this.leave;let g="start",y="end",v="end",b="start";if(V(m)){const t=m.split(" ");v=t[0],g=t.length>1?t[1]:g}else if(F(m)){const t=m;z(t.container)||(v=t.container),z(t.target)||(g=t.target)}else M(m)&&(v=m);if(V(f)){const t=f.split(" ");b=t[0],y=t.length>1?t[1]:y}else if(F(f)){const t=f;z(t.container)||(b=t.container),z(t.target)||(y=t.target)}else M(f)&&(b=f);const _=ps(e,g,c),T=ps(e,y,c),x=_+d-u,w=T+d-p,S=ps(e,v,u,x,w),$=ps(e,b,u,x,w),C=_+d-S,E=T+d-$,k=E-C;this.offset=d,this.offsetStart=C,this.offsetEnd=E,this.distance=k<=0?0:k,this.thresholds=[g,y,v,b],this.coords=[_,T,S,$],t&&t.forEach(t=>t.revert()),n&&n.seek(o,!0),this._debug&&this.debug()}handleScroll(){if(!this.ready)return;const t=this.linked,e=this.sync,s=this.syncEase,i=this.syncSmooth,r=t&&(s||i),n=this.horizontal,o=this.container,a=this.scroll,l=a<=this.offsetStart,h=a>=this.offsetEnd,d=!l&&!h,c=a===this.offsetStart||a===this.offsetEnd,u=!this.hasEntered&&c,p=this._debug&&this.$debug;let m=!1,f=!1,g=this.progress;if(l&&this.began&&(this.began=!1),g>0&&!this.began&&(this.began=!0),r){const e=t.progress;if(i&&M(i)){if(i<1){const t=1e-4,s=e<g&&1===g?t:e>g&&!g?-t:0;g=dt(ut(e,g,ut(.01,.2,i))+s,6)}}else s&&(g=s(g));m=g!==this.prevProgress,f=1===e,m&&!f&&i&&e&&o.wakeTicker.restart()}if(p){const t=n?o.scrollY:o.scrollX;p.style[n?"top":"left"]=t+10+"px"}(d&&!this.isInView||u&&!this.forceEnter&&!this.hasEntered)&&(d&&(this.isInView=!0),this.forceEnter&&this.hasEntered?d&&(this.forceEnter=!1):(p&&d&&(p.style.zIndex=""+this.container.zIndex++),this.onSyncEnter(this),this.onEnter(this),this.backward?(this.onSyncEnterBackward(this),this.onEnterBackward(this)):(this.onSyncEnterForward(this),this.onEnterForward(this)),this.hasEntered=!0,u&&(this.forceEnter=!0))),(d||!d&&this.isInView)&&(m=!0),m&&(r&&t.seek(t.duration*g),this.onUpdate(this)),!d&&this.isInView&&(this.isInView=!1,this.onSyncLeave(this),this.onLeave(this),this.backward?(this.onSyncLeaveBackward(this),this.onLeaveBackward(this)):(this.onSyncLeaveForward(this),this.onLeaveForward(this)),e&&!i&&(f=!0)),g>=1&&this.began&&!this.completed&&(e&&f||!e)&&(e&&this.onSyncComplete(this),this.completed=!0,(!this.repeat&&!t||!this.repeat&&t&&t.completed)&&this.revert()),g<1&&this.completed&&(this.completed=!1),this.prevProgress=g}revert(){if(this.reverted)return;const t=this.container;return vt(t,this),t._head||t.revert(),this._debug&&this.removeDebug(),this.reverted=!0,this.ready=!1,this}}const vs=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,bs=(t=.5,e=0,s=.5,i=1)=>t===e&&s===i?ue:r=>0===r||1===r?r:vs(((t,e,s)=>{let i,r,n=0,o=1,a=0;do{r=n+(o-n)/2,i=vs(r,e,s)-t,i>0?o=r:n=r}while(tt(i)>1e-7&&++a<100);return r})(r,t,s),e,i),_s=(t=10,e)=>{const s=e?st:it;return e=>s(ht(e,0,1)*t)*(1/t)},Ts=(...t)=>{const e=t.length;if(!e)return ue;const s=e-1,i=t[0],r=t[s],n=[0],o=[G(i)];for(let e=1;e<s;e++){const i=t[e],r=V(i)?i.trim().split(" "):[i],a=r[0],l=r[1];n.push(z(l)?e/s:G(l)/100),o.push(G(a))}return o.push(G(r)),n.push(1),function(t){for(let e=1,s=n.length;e<s;e++){const s=n[e];if(t<=s){const i=n[e-1],r=o[e-1];return r+(o[e]-r)*(t-i)/(s-i)}}return o[o.length-1]}},xs=(t=10,e=1)=>{const s=[0],i=t-1;for(let t=1;t<i;t++){const r=s[t-1],n=t/i,o=n*(1-e)+(n+((t+1)/i-n)*Math.random())*e;s.push(ht(o,r,1))}return s.push(1),Ts(...s)};var ws=Object.freeze({__proto__:null,Spring:We,createSpring:qe,cubicBezier:bs,eases:ve,irregular:xs,linear:Ts,spring:Ue,steps:_s});const Ss=(t,e=100)=>{const s=[];for(let i=0;i<=e;i++)s.push(dt(t(i/e),4));return`linear(${s.join(", ")})`},$s={},Cs=t=>{let e=$s[t];if(e)return e;if(e="linear",V(t)){if(L(t,"linear")||L(t,"cubic-")||L(t,"steps")||L(t,"ease"))e=t;else if(L(t,"cubicB"))e=R(t);else{const s=_e(t);O(s)&&(e=s===ue?"linear":Ss(s))}$s[t]=e}else if(O(t)){const s=Ss(t);s&&(e=s)}else t.ease&&(e=Ss(t.ease));return e},Es=["x","y","z"],ks=["perspective","width","height","margin","padding","top","right","bottom","left","borderWidth","fontSize","borderRadius",...Es],Ns=(()=>[...Es,...f.filter(t=>["X","Y","Z"].some(e=>t.endsWith(e)))])();let Ds=null;const As=(t,e,s,i,r)=>{let n=V(e)?e:wt(e,s,i,r,null,null);return M(n)?ks.includes(t)||L(t,"translate")?`${n}px`:L(t,"rotate")||L(t,"skew")?`${n}deg`:`${n}`:n},Is=(t,e,s,i,r,n)=>{let o="0";const a=z(i)?getComputedStyle(t)[e]:As(e,i,t,r,n);return o=z(s)?P(i)?i.map(s=>As(e,s,t,r,n)):a:[As(e,s,t,r,n),a],o};class Rs{constructor(t,s){D.current&&D.current.register(this),H(Ds)&&(!e||!z(CSS)&&Object.hasOwnProperty.call(CSS,"registerProperty")?(f.forEach(t=>{const e=L(t,"skew"),s=L(t,"scale"),i=L(t,"rotate"),r=L(t,"translate"),n=i||e,o=n?"<angle>":s?"<number>":r?"<length-percentage>":"*";try{CSS.registerProperty({name:"--"+t,syntax:o,inherits:!1,initialValue:r?"0px":n?"0deg":s?"1":"0"})}catch{}}),Ds=!0):Ds=!1);const i=le(t);i.length||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation.");const r=xt(s.autoplay,A.defaults.autoplay),n=!(!r||!r.link)&&r,o=s.alternate&&!0===s.alternate,a=s.reversed&&!0===s.reversed,h=xt(s.loop,A.defaults.loop),d=!0===h||h===1/0?1/0:M(h)?h+1:1,c=o?a?"alternate-reverse":"alternate":a?"reverse":"normal",v=1===A.timeScale?1:u;this.targets=i,this.animations=[],this.controlAnimation=null,this.onComplete=s.onComplete||A.defaults.onComplete,this.duration=0,this.muteCallbacks=!1,this.completed=!1,this.paused=!r||!1!==n,this.reversed=a,this.persist=xt(s.persist,A.defaults.persist),this.autoplay=r,this._speed=xt(s.playbackRate,A.defaults.playbackRate),this._resolve=y,this._completed=0,this._inlineStyles=[],i.forEach((t,e)=>{const r=t[l],n=Ns.some(t=>s.hasOwnProperty(t)),o=t.style,a=this._inlineStyles[e]={},h=xt(s.ease,A.defaults.ease),u=wt(h,t,e,i,null,null),y=O(u)||V(u)?u:h,b=h.ease&&h,_=Cs(y),T=(b?b.settlingDuration:wt(xt(s.duration,A.defaults.duration),t,e,i,null,null))*v,x=wt(xt(s.delay,A.defaults.delay),t,e,i,null,null)*v,w=xt(s.composition,"replace");for(let l in s){if(!q(l))continue;const h={},u={iterations:d,direction:c,fill:"both",easing:_,duration:T,delay:x,composite:w},p=s[l],g=!!n&&(f.includes(l)?l:m.get(l)),y=g?"transform":l;let b;if(a[y]||(a[y]=o[y]),F(p)){const s=p,n=xt(s.ease,_),a=n.ease&&n,d=s.to,c=s.from;if(u.duration=(a?a.settlingDuration:wt(xt(s.duration,T),t,e,i,null,null))*v,u.delay=wt(xt(s.delay,x),t,e,i,null,null)*v,u.composite=xt(s.composition,w),u.easing=Cs(n),b=Is(t,l,c,d,e,i),g?(h[`--${g}`]=b,r[g]=b):h[l]=Is(t,l,c,d,e,i),Ze(this,t,l,h,u),!z(c))if(g){const t=`--${g}`;o.setProperty(t,h[t][0])}else o[l]=h[l][0]}else b=P(p)?p.map(s=>As(l,s,t,e,i)):As(l,p,t,e,i),g?(h[`--${g}`]=b,r[g]=b):h[l]=b,Ze(this,t,l,h,u)}if(n){let t=p;for(let e in r)t+=`${g[e]}var(--${e})) `;o.transform=t}}),n&&this.autoplay.link(this)}forEach(t){try{const e=V(t)?e=>e[t]():t;this.animations.forEach(e)}catch{}return this}get speed(){return this._speed}set speed(t){this._speed=+t,this.forEach(e=>e.playbackRate=t)}get currentTime(){const t=this.controlAnimation,e=A.timeScale;return this.completed?this.duration:t?+t.currentTime*(1===e?1:e):0}set currentTime(t){const e=t*(1===A.timeScale?1:u);this.forEach(t=>{!this.persist&&e>=this.duration&&t.play(),t.currentTime=e})}get progress(){return this.currentTime/this.duration}set progress(t){this.forEach(e=>e.currentTime=t*this.duration||0)}resume(){return this.paused?(this.paused=!1,this.forEach("play")):this}pause(){return this.paused?this:(this.paused=!0,this.forEach("pause"))}alternate(){return this.reversed=!this.reversed,this.forEach("reverse"),this.paused&&this.forEach("pause"),this}play(){return this.reversed&&this.alternate(),this.resume()}reverse(){return this.reversed||this.alternate(),this.resume()}seek(t,e=!1){return e&&(this.muteCallbacks=!0),t<this.duration&&(this.completed=!1),this.currentTime=t,this.muteCallbacks=!1,this.paused&&this.pause(),this}restart(){return this.completed=!1,this.seek(0,!0).resume()}commitStyles(){return this.forEach("commitStyles")}complete(){return this.seek(this.duration)}cancel(){return this.muteCallbacks=!0,this.commitStyles().forEach("cancel"),this.animations.length=0,requestAnimationFrame(()=>{this.targets.forEach(t=>{"none"===t.style.transform&&t.style.removeProperty("transform")})}),this}revert(){return this.cancel().targets.forEach((t,e)=>{const s=t.style,i=this._inlineStyles[e];for(let e in i){const r=i[e];z(r)||r===p?s.removeProperty(R(e)):t.style[e]=r}t.getAttribute("style")===p&&t.removeAttribute("style")}),this}then(t=y){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=y};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const Ls={animate:(t,e)=>new Rs(t,e),convertEase:Ss};let Bs=0,Ps=0;const Fs=(t,e)=>!(!t||!e)&&(t===e||t.contains(e)),Ms=t=>{if(!t)return null;const e=t.style,s=e.transition||"";return e.setProperty("transition","none","important"),s},Vs=(t,e)=>{if(!t)return;const s=t.style;e?s.transition=e:s.removeProperty("transition")},Os=t=>{const e=t.layout.transitionMuteStore,s=t.$el,i=t.$measure;s&&!e.has(s)&&e.set(s,Ms(s)),i&&!e.has(i)&&e.set(i,Ms(i))},zs=t=>{t.forEach((t,e)=>Vs(e,t)),t.clear()},Hs={display:"none",visibility:"hidden",opacity:"0",transform:"none",position:"static"},Xs=t=>{if(!t)return;const e=t.parentNode;e&&(e._head===t&&(e._head=t._next),e._tail===t&&(e._tail=t._prev),t._prev&&(t._prev._next=t._next),t._next&&(t._next._prev=t._prev),t._prev=null,t._next=null,t.parentNode=null)},Ys=(t,e,s,i)=>{let r=t.dataset.layoutId;r||(r=t.dataset.layoutId="node-"+Ps++);const n=i||{};return n.$el=t,n.$measure=t,n.id=r,n.index=0,n.targets=null,n.delay=0,n.duration=0,n.ease=null,n.state=s,n.layout=s.layout,n.parentNode=e||null,n.isTarget=!1,n.isEntering=!1,n.isLeaving=!1,n.isInlined=!1,n.hasTransform=!1,n.inlineStyles=[],n.inlineTransforms=null,n.inlineTransition=null,n.branchAdded=!1,n.branchRemoved=!1,n.branchNotRendered=!1,n.sizeChanged=!1,n.hasVisibilitySwap=!1,n.hasDisplayNone=!1,n.hasVisibilityHidden=!1,n.measuredInlineTransform=null,n.measuredInlineTransition=null,n.measuredDisplay=null,n.measuredVisibility=null,n.measuredPosition=null,n.measuredHasDisplayNone=!1,n.measuredHasVisibilityHidden=!1,n.measuredIsVisible=!1,n.measuredIsRemoved=!1,n.measuredIsInsideRoot=!1,n.properties={transform:"none",x:0,y:0,left:0,top:0,clientLeft:0,clientTop:0,width:0,height:0},n.layout.properties.forEach(t=>n.properties[t]=0),n._head=null,n._tail=null,n._prev=null,n._next=null,n},Ws=(t,e,s,i)=>{const r=t.$el,n=t.layout.root,o=n===r,a=t.properties,l=t.state.rootNode,h=t.parentNode,d=s.transform,c=r.style.transform,u=!!h&&h.measuredIsRemoved,p=s.position;o&&(t.layout.absoluteCoords="fixed"===p||"absolute"===p),t.$measure=e,t.inlineTransforms=c,t.hasTransform=d&&"none"!==d,t.measuredIsInsideRoot=Fs(n,e),t.measuredInlineTransform=null,t.measuredDisplay=s.display,t.measuredVisibility=s.visibility,t.measuredPosition=p,t.measuredHasDisplayNone="none"===s.display,t.measuredHasVisibilityHidden="hidden"===s.visibility,t.measuredIsVisible=!(t.measuredHasDisplayNone||t.measuredHasVisibilityHidden),t.measuredIsRemoved=t.measuredHasDisplayNone||t.measuredHasVisibilityHidden||u;let m=!1,f=r.previousSibling;for(;f&&(f.nodeType===Node.COMMENT_NODE||f.nodeType===Node.TEXT_NODE&&!f.textContent.trim());)f=f.previousSibling;if(f&&f.nodeType===Node.TEXT_NODE)m=!0;else{for(f=r.nextSibling;f&&(f.nodeType===Node.COMMENT_NODE||f.nodeType===Node.TEXT_NODE&&!f.textContent.trim());)f=f.nextSibling;m=null!==f&&f.nodeType===Node.TEXT_NODE}if(t.isInlined=m,t.hasTransform&&!i){const s=t.layout.transitionMuteStore;s.get(r)||(t.inlineTransition=Ms(r)),e===r?r.style.transform="none":(s.get(e)||(t.measuredInlineTransition=Ms(e)),t.measuredInlineTransform=e.style.transform,e.style.transform="none")}let g,y,v=0,b=0,_=0,T=0;if(!i){const t=e.getBoundingClientRect();v=t.left,b=t.top,_=t.width,T=t.height}for(let t in a){const e="transform"===t?d:s[t]||s.getPropertyValue&&s.getPropertyValue(t);z(e)||(a[t]=e)}if(a.left=v,a.top=b,a.clientLeft=i?0:e.clientLeft,a.clientTop=i?0:e.clientTop,o)t.layout.absoluteCoords?(g=v,y=b):(g=0,y=0);else{const e=h||l,s=e.properties.left,i=e.properties.top,r=e.properties.clientLeft,n=e.properties.clientTop;if(t.layout.absoluteCoords)g=v-s-r,y=b-i-n;else if(e===l){const t=l.properties.left,e=l.properties.top;g=v-t-l.properties.clientLeft,y=b-e-l.properties.clientTop}else g=v-s-r,y=b-i-n}return a.x=g,a.y=y,a.width=_,a.height=T,t},Us=(t,e)=>{if(e)for(let s in e)t.properties[s]=e[s]},qs=(t,e)=>{const s=wt(e.ease,t.$el,t.index,t.targets,null,null),i=O(s)?s:e.ease,r=!z(i)&&!z(i.ease);t.ease=r?i.ease:i,t.duration=r?i.settlingDuration:wt(e.duration,t.$el,t.index,t.targets,null,null),t.delay=wt(e.delay,t.$el,t.index,t.targets,null,null)},js=t=>{const e=t.$el.style,s=t.inlineStyles;s.length=0,t.layout.recordedProperties.forEach(t=>{s.push(t,e[t]||"")})},Gs=t=>{const e=t.$el.style,s=t.inlineStyles;for(let t=0,i=s.length;t<i;t+=2){const i=s[t],r=s[t+1];r&&""!==r?e[i]=r:(e[i]="",e.removeProperty(i))}},Zs=t=>{const e=t.inlineTransforms,s=t.$el.style;!t.hasTransform||!e||t.hasTransform&&"none"===s.transform||e&&"none"===e?s.removeProperty("transform"):e&&(s.transform=e);const i=t.$measure;if(t.hasTransform&&i!==t.$el){const e=i.style,s=t.measuredInlineTransform;s&&""!==s?e.transform=s:e.removeProperty("transform")}t.measuredInlineTransform=null,null!==t.inlineTransition&&(Vs(t.$el,t.inlineTransition),t.inlineTransition=null),i!==t.$el&&null!==t.measuredInlineTransition&&(Vs(i,t.measuredInlineTransition),t.measuredInlineTransition=null)},Qs=t=>{(t.measuredIsRemoved||t.hasVisibilitySwap)&&(t.$el.style.removeProperty("display"),t.$el.style.removeProperty("visibility"),t.hasVisibilitySwap&&(t.$measure.style.removeProperty("display"),t.$measure.style.removeProperty("visibility"))),t.layout.pendingRemoval.delete(t.$el)},Js=(t,e,s)=>(e.properties={...t.properties},e.state=s,e.isTarget=t.isTarget,e.hasTransform=t.hasTransform,e.inlineTransforms=t.inlineTransforms,e.measuredIsVisible=t.measuredIsVisible,e.measuredDisplay=t.measuredDisplay,e.measuredIsRemoved=t.measuredIsRemoved,e.measuredHasDisplayNone=t.measuredHasDisplayNone,e.measuredHasVisibilityHidden=t.measuredHasVisibilityHidden,e.hasDisplayNone=t.hasDisplayNone,e.isInlined=t.isInlined,e.hasVisibilityHidden=t.hasVisibilityHidden,e);class Ks{constructor(t){this.layout=t,this.rootNode=null,this.rootNodes=new Set,this.nodes=new Map,this.scrollX=0,this.scrollY=0}revert(){return this.forEachNode(t=>{this.layout.pendingRemoval.delete(t.$el),t.$el.removeAttribute("data-layout-id"),t.$measure.removeAttribute("data-layout-id")}),this.rootNode=null,this.rootNodes.clear(),this.nodes.clear(),this}getNode(t){if(t&&t.dataset)return this.nodes.get(t.dataset.layoutId)}getComputedValue(t,e){const s=this.getNode(t);if(s)return s.properties[e]}forEach(t,e){let s=t,i=0;for(;s;)if(e(s,i++),s._head)s=s._head;else if(s._next)s=s._next;else{for(;s&&!s._next;)s=s.parentNode;s&&(s=s._next)}}forEachRootNode(t){this.forEach(this.rootNode,t)}forEachNode(t){for(const e of this.rootNodes)this.forEach(e,t)}registerElement(t,e){if(!t||1!==t.nodeType)return null;this.layout.transitionMuteStore.has(t)||this.layout.transitionMuteStore.set(t,Ms(t));const s=[t,e],i=this.layout.root;let r=null;for(;s.length;){const t=s.pop(),e=s.pop();if(!e||1!==e.nodeType||X(e))continue;const n=!!t&&t.measuredIsRemoved,o=n?Hs:getComputedStyle(e),a=!!n||"none"===o.display,l=!!n||"hidden"===o.visibility,h=!a&&!l,d=e.dataset.layoutId,c=Fs(i,e);let u=d?this.nodes.get(d):null;if(u&&u.$el!==e){const a=Fs(i,u.$el),l=u.measuredIsVisible;if(a||!c&&(c||l||!h)){if(a&&!l&&h){Ws(u,e,o,n);let t=e.lastElementChild;for(;t;)s.push(t,u),t=t.previousElementSibling;r||(r=u);continue}{let i=e.lastElementChild;for(;i;)s.push(i,t),i=i.previousElementSibling;r||(r=u);continue}}Xs(u),u=Ys(e,t,this,u)}else u=Ys(e,t,this,u);u.branchAdded=!1,u.branchRemoved=!1,u.branchNotRendered=!1,u.isTarget=!1,u.sizeChanged=!1,u.hasVisibilityHidden=l,u.hasDisplayNone=a,u.hasVisibilitySwap=l&&!u.measuredHasVisibilityHidden||a&&!u.measuredHasDisplayNone,this.nodes.set(u.id,u),u.parentNode=t||null,u._prev=null,u._next=null,t?(this.rootNodes.delete(u),t._head?(t._tail._next=u,u._prev=t._tail,t._tail=u):(t._head=u,t._tail=u)):this.rootNodes.add(u),Ws(u,u.$el,o,n);let p=e.lastElementChild;for(;p;)s.push(p,u),p=p.previousElementSibling;r||(r=u)}return r}ensureDetachedNode(t,e){if(!t||t===this.layout.root)return null;const s=t.dataset.layoutId,i=s?this.nodes.get(s):null;if(i&&i.$el===t)return i;let r=null,n=t.parentElement;for(;n&&n!==this.layout.root;){if(e.has(n)){r=this.ensureDetachedNode(n,e);break}n=n.parentElement}return this.registerElement(t,r)}record(){const t=this.layout,e=t.children,s=t.root,i=P(e)?e:[e],r=[],n="*"===e?s:D.root,o=[];let a=s.parentElement;for(;a&&1===a.nodeType;){const t=getComputedStyle(a);if(t.transform&&"none"!==t.transform){const t=a.style.transform||"",e=Ms(a);o.push(a,t,e),a.style.transform="none"}a=a.parentElement}for(let t=0,e=i.length;t<e;t++){const e=i[t];r[t]=V(e)?n.querySelectorAll(e):e}const l=le(r);this.nodes.clear(),this.rootNodes.clear();const h=this.registerElement(s,null);h.isTarget=!0,this.rootNode=h;const d=new Set;let c=0;const u=[];this.nodes.forEach(t=>{u.push(t.$el)}),this.nodes.forEach((t,e)=>{t.index=c++,t.targets=u,t&&t.measuredIsInsideRoot&&d.add(e)});const p=new Set,m=[];for(let t=0,e=l.length;t<e;t++){const e=l[t];if(e&&1===e.nodeType&&e!==s){if(!Fs(s,e)){const t=e.dataset.layoutId;if(!t||!d.has(t))continue}p.has(e)||(p.add(e),m.push(e))}}for(let t=0,e=m.length;t<e;t++)this.ensureDetachedNode(m[t],p);for(let t=0,e=l.length;t<e;t++){const e=l[t],s=this.getNode(e);if(s){let t=s;for(;t&&!t.isTarget;)t.isTarget=!0,t=t.parentNode}}this.scrollX=window.scrollX,this.scrollY=window.scrollY,this.forEachNode(Zs);for(let t=0,e=o.length;t<e;t+=3){const e=o[t],s=o[t+1],i=o[t+2];s&&""!==s?e.style.transform=s:e.style.removeProperty("transform"),Vs(e,i)}return this}}function ti(t){const e={},s={};for(let i in t){const r=t[i];"duration"===i||"delay"===i||"ease"===i?s[i]=r:e[i]=r}return[e,s]}class ei{constructor(t,e={}){D.current&&D.current.register(this);const s=ti(e.swapAt),i=ti(e.enterFrom),r=ti(e.leaveTo),n=e.properties;if(e.duration=xt(e.duration,350),e.delay=xt(e.delay,0),e.ease=xt(e.ease,"inOut(3.5)"),this.params=e,this.root=le(t)[0],this.id=e.id||Bs++,this.children=e.children||"*",this.absoluteCoords=!1,this.swapAtParams=gt(e.swapAt||{opacity:0},{ease:"inOut(1.75)"}),this.enterFromParams=e.enterFrom||{opacity:0},this.leaveToParams=e.leaveTo||{opacity:0},this.properties=new Set(["opacity","fontSize","color","backgroundColor","borderRadius","border","filter","clipPath"]),s[0])for(let t in s[0])this.properties.add(t);if(i[0])for(let t in i[0])this.properties.add(t);if(r[0])for(let t in r[0])this.properties.add(t);if(n)for(let t=0,e=n.length;t<e;t++)this.properties.add(n[t]);this.recordedProperties=new Set(["display","visibility","translate","position","left","top","marginLeft","marginTop","width","height","maxWidth","maxHeight","minWidth","minHeight"]),this.properties.forEach(t=>this.recordedProperties.add(t)),this.pendingRemoval=new WeakSet,this.transitionMuteStore=new Map,this.oldState=new Ks(this),this.newState=new Ks(this),this.timeline=null,this.transformAnimation=null,this.animating=[],this.swapping=[],this.leaving=[],this.entering=[],this.oldState.record(),zs(this.transitionMuteStore)}revert(){return this.root.classList.remove("is-animated"),this.timeline&&(this.timeline.complete(),this.timeline=null),this.transformAnimation&&(this.transformAnimation.complete(),this.transformAnimation=null),this.animating.length=this.swapping.length=this.leaving.length=this.entering.length=0,this.oldState.revert(),this.newState.revert(),requestAnimationFrame(()=>zs(this.transitionMuteStore)),this}record(){return this.transformAnimation&&(this.transformAnimation.cancel(),this.transformAnimation=null),this.oldState.record(),this.timeline&&(this.timeline.cancel(),this.timeline=null),this.newState.forEachRootNode(Gs),this}animate(t={}){const e={ease:xt(t.ease,this.params.ease),delay:xt(t.delay,this.params.delay),duration:xt(t.duration,this.params.duration)},s={id:this.id},i=xt(t.onComplete,this.params.onComplete),r=xt(t.onPause,this.params.onPause);for(let e in N)"ease"!==e&&"duration"!==e&&"delay"!==e&&(z(t[e])?z(this.params[e])||(s[e]=this.params[e]):s[e]=t[e]);s.onComplete=()=>{const e=t.autoplay,s=A.editor;if(e&&e.linked||s&&s.showPanel)i&&i(this.timeline);else{this.transformAnimation&&this.transformAnimation.cancel(),f.forEachRootNode(t=>{Qs(t),Gs(t)});for(let t=0,e=w.length;t<e;t++){const e=w[t];e.style.transform=f.getComputedValue(e,"transform")}this.root.classList.contains("is-animated")&&(this.root.classList.remove("is-animated"),i&&i(this.timeline)),requestAnimationFrame(()=>{this.root.classList.contains("is-animated")||zs(this.transitionMuteStore)})}},s.onPause=()=>{const e=t.autoplay;if(e&&e.linked)return i&&i(this.timeline),void(r&&r(this.timeline));this.root.classList.contains("is-animated")&&(this.transformAnimation&&this.transformAnimation.cancel(),f.forEachRootNode(Qs),this.root.classList.remove("is-animated"),i&&i(this.timeline),r&&r(this.timeline))},s.composition=!1;const n=gt(gt(t.swapAt||{},this.swapAtParams),e),o=gt(gt(t.enterFrom||{},this.enterFromParams),e),a=gt(gt(t.leaveTo||{},this.leaveToParams),e),[l,h]=ti(n),[d,c]=ti(o),[u,p]=ti(a),m=this.oldState,f=this.newState,g=this.animating,y=this.swapping,v=this.entering,b=this.leaving,_=this.pendingRemoval;g.length=y.length=v.length=b.length=0,m.forEachRootNode(Os),f.record(),f.forEachRootNode(js);const T=[],x=[],w=[],S=[],$=f.rootNode,C=$.$el;f.forEachRootNode(t=>{const e=t.$el,s=t.id,i=t.parentNode,r=!!i&&i.branchAdded,n=!!i&&i.branchRemoved,o=!!i&&i.branchNotRendered;let a=m.nodes.get(s);const l=!a;l?(a=Js(t,{},m),m.nodes.set(s,a),a.measuredIsRemoved=!0):a.measuredIsRemoved&&!t.measuredIsRemoved&&(Js(t,a,m),a.measuredIsRemoved=!0);const h=a.parentNode,c=(h?h.id:null)!==(i?i.id:null),p=a.$el!==t.$el,y=a.measuredIsRemoved,x=t.measuredIsRemoved;if(!a.measuredIsRemoved&&!x&&!l&&(c||p)){const t=a.properties.left,e=a.properties.top,s=i||f.rootNode,r=s.id?m.nodes.get(s.id):null,n=r?r.properties.left:s.properties.left,o=r?r.properties.top:s.properties.top,l=r?r.properties.clientLeft:s.properties.clientLeft,h=r?r.properties.clientTop:s.properties.clientTop;a.properties.x=t-n-l,a.properties.y=e-o-h}t.hasVisibilitySwap&&(t.hasVisibilityHidden&&(t.$el.style.visibility="visible",t.$measure.style.visibility="hidden"),t.hasDisplayNone&&(t.$el.style.display=a.measuredDisplay||t.measuredDisplay||"",t.$measure.style.visibility="hidden"));const w=_.has(e),S=a.measuredIsVisible,C=t.measuredIsVisible,E=!S&&C&&!o,k=!x&&(y||w)&&!r,N=x&&!y&&!n,D=N||x&&w&&!n;t.branchAdded=r||k,t.branchRemoved=n||D,t.branchNotRendered=o||x,x&&S&&(t.$el.style.display=a.measuredDisplay,t.$el.style.visibility="visible",Js(a,t,f)),N?(t.isTarget&&(b.push(e),t.isLeaving=!0),_.add(e)):!x&&w&&_.delete(e),k&&!o||E?(Us(a,d),t.isTarget&&(v.push(e),t.isEntering=!0)):D&&!o&&Us(t,u),t===$||!t.isTarget||t.isEntering||t.isLeaving||g.push(e),T.push(e)});let E=0,k=0,D=0;f.forEachRootNode(t=>{const s=t.$el,i=t.parentNode,r=m.nodes.get(t.id),n=t.properties,o=r.properties;let a=i!==$&&i;for(;a&&!a.isTarget&&a!==$;)a=a.parentNode;t===$?(t.index=0,t.targets=g,qs(t,e)):t.isEntering?(t.index=a?a.index:E,t.targets=a?g:v,qs(t,c),E++):t.isLeaving?(t.index=a?a.index:k,t.targets=a?g:b,k++,qs(t,p)):t.isTarget?(t.index=D++,t.targets=g,qs(t,e)):(t.index=a?a.index:0,t.targets=g,qs(t,h)),r.index=t.index,r.targets=t.targets;for(let e in n)n[e]=wt(n[e],s,t.index,t.targets,null,null),o[e]=wt(o[e],s,r.index,r.targets,null,null);const d=Math.abs(n.width-o.width)>1,u=Math.abs(n.height-o.height)>1;if(t.sizeChanged=d||u,t.isTarget&&(!t.measuredIsRemoved&&r.measuredIsVisible||t.measuredIsRemoved&&t.measuredIsVisible)){"none"===n.transform&&"none"===o.transform||(t.hasTransform=!0,w.push(s));for(let t in n)if("transform"!==t&&n[t]!==o[t]){x.push(s);break}}t.isTarget||(y.push(s),t.sizeChanged&&i&&i.isTarget&&i.sizeChanged&&(l.transform&&(t.hasTransform=!0,w.push(s)),S.push(s)))});const I={delay:t=>f.getNode(t).delay,duration:t=>f.getNode(t).duration,ease:t=>f.getNode(t).ease};if(s.defaults=I,this.timeline=Oe(s),!x.length&&!w.length&&!y.length)return zs(this.transitionMuteStore),this.timeline.complete();if(T.length){this.root.classList.add("is-animated");for(let t=0,e=T.length;t<e;t++){const e=T[t],s=e.dataset.layoutId,i=m.nodes.get(s),r=f.nodes.get(s),n=i.properties;r.isInlined||("grid"!==i.measuredDisplay&&"grid"!==r.measuredDisplay||e.style.setProperty("display","block","important"),(e!==C||this.absoluteCoords)&&(e.style.position=this.absoluteCoords?"fixed":"absolute",e.style.left="0px",e.style.top="0px",e.style.marginLeft="0px",e.style.marginTop="0px",e.style.translate=`${n.x}px ${n.y}px`),e===C&&"static"===r.measuredPosition&&(e.style.position="relative",e.style.left="0px",e.style.top="0px")),e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none"}m.scrollX===window.scrollX&&m.scrollY===window.scrollY||requestAnimationFrame(()=>window.scrollTo(m.scrollX,m.scrollY));for(let t=0,e=x.length;t<e;t++){const e=x[t],s=e.dataset.layoutId,i=m.nodes.get(s),r=f.nodes.get(s),n=i.properties,o=r.properties;let a=!1;const l={composition:"none"};n.width!==o.width&&(l.width=[n.width,o.width],a=!0),n.height!==o.height&&(l.height=[n.height,o.height],a=!0),r.hasTransform||r.isInlined||(l.translate=[`${n.x}px ${n.y}px`,`${o.x}px ${o.y}px`],a=!0),this.properties.forEach(t=>{const e=n[t],s=o[t];"transform"!==t&&e!==s&&(l[t]=[e,s],a=!0)}),a&&this.timeline.add(e,l,0)}}if(y.length){for(let t=0,e=y.length;t<e;t++){const e=y[t],s=m.getNode(e),i=s.properties;e.style.width=`${i.width}px`,e.style.height=`${i.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none",s.isInlined||(e.style.translate=`${i.x}px ${i.y}px`),this.properties.forEach(t=>{"transform"!==t&&(e.style[t]=`${m.getComputedValue(e,t)}`)})}for(let t=0,e=y.length;t<e;t++){const e=y[t],s=f.getNode(e),i=s.properties;this.timeline.call(()=>{e.style.width=`${i.width}px`,e.style.height=`${i.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none",s.isInlined||(e.style.translate=`${i.x}px ${i.y}px`),this.properties.forEach(t=>{"transform"!==t&&(e.style[t]=`${f.getComputedValue(e,t)}`)})},s.delay+s.duration/2)}if(S.length){const t=xe(f.nodes.get(S[0].dataset.layoutId).ease),e=e=>1-t(1-e),s={};if(l)for(let t in l)"transform"!==t&&(s[t]=[{from:e=>m.getComputedValue(e,t),to:l[t]},{from:l[t],to:e=>f.getComputedValue(e,t),ease:e}]);this.timeline.add(S,s,0)}}const R=w.length;if(R){for(let t=0;t<R;t++){const e=w[t],s=f.getNode(e);s.isInlined||(e.style.translate=`${m.getComputedValue(e,"x")}px ${m.getComputedValue(e,"y")}px`),e.style.transform=m.getComputedValue(e,"transform"),S.includes(e)&&(s.ease=wt(n.ease,e,s.index,s.targets,null,null),s.duration=wt(n.duration,e,s.index,s.targets,null,null))}this.transformAnimation=Ls.animate(w,{translate:t=>f.getNode(t).isInlined?"0px 0px":`${f.getComputedValue(t,"x")}px ${f.getComputedValue(t,"y")}px`,transform:t=>{const e=f.getComputedValue(t,"transform");if(!S.includes(t))return e;const s=m.getComputedValue(t,"transform"),i=f.getNode(t);return[s,wt(l.transform,t,i.index,i.targets,null,null),e]},autoplay:!1,...I}),this.timeline.sync(this.transformAnimation,0)}return this.timeline.init()}update(t,e={}){return this.record(),t(this),this.animate(e)}}const si=Xe,ii={},ri=t=>(...e)=>{const s=t(...e);return new Proxy(y,{apply:(t,e,[i])=>s(i),get:(t,e)=>{if(ii[e])return ri((...t)=>{const i=ii[e](...t);return t=>i(s(t))})}})},ni=(t,e,s=0)=>{const i=(...t)=>(t.length<e.length?ri(((t,e=0)=>(...s)=>e?e=>t(...s,e):e=>t(e,...s))(e,s)):e)(...t);return ii[t]||(ii[t]=i),i},oi=ni("roundPad",si.roundPad),ai=ni("padStart",si.padStart),li=ni("padEnd",si.padEnd),hi=ni("wrap",si.wrap),di=ni("mapRange",si.mapRange),ci=ni("degToRad",si.degToRad),ui=ni("radToDeg",si.radToDeg),pi=ni("snap",si.snap),mi=ni("clamp",si.clamp),fi=ni("round",si.round),gi=ni("lerp",si.lerp,1),yi=ni("damp",si.damp,1),vi=(t=0,e=1,s=0)=>{const i=10**s;return Math.floor((Math.random()*(e-t+1/i)+t)*i)/i};let bi=0;const _i=(t,e=0,s=1,i=0)=>{let r=void 0===t?bi++:t;return(t=e,n=s,o=i)=>{r+=1831565813,r=Math.imul(r^r>>>15,1|r),r^=r+Math.imul(r^r>>>7,61|r);const a=10**o;return Math.floor((((r^r>>>14)>>>0)/4294967296*(n-t+1/a)+t)*a)/a}},Ti=t=>t[vi(0,t.length-1)],xi=t=>{let e,s,i=t.length;for(;i;)s=vi(0,--i),e=t[i],t[i]=t[s],t[s]=e;return t},wi=(t,e={})=>{let s,i=[],r=0;const n=e.from,o=e.reversed,a=e.ease,l=!z(a),h=l&&!z(a.ease)?a.ease:l?xe(a):null,d=e.grid,c=!0===d,u=e.axis,m=e.total,f=z(n)||0===n||"first"===n,g="center"===n,y="last"===n,v="random"===n,b=P(n),_=P(t),T=e.use,x=G(_?t[0]:t),w=_?G(t[1]):0,S=$.exec((_?t[1]:t)+p),C=e.start||0+(_?x:0);let E=f?0:M(n)?n:0;return(t,a,l,p,f)=>{const[$]=le(t),k=z(m)?l.length:m,N=!z(T)&&(O(T)?T($,a,k):Ct($,T)),D=M(N)||V(N)&&M(+N)?+N:a;if(g&&(E=(k-1)/2),y&&(E=k-1),!i.length){if(c){let t=!0,e=1/0,s=1/0,r=-1/0,o=-1/0;const a=[],h=[];for(let i=0;i<k;i++){const n=l[i];let d=0,c=0,u=!1;if(n&&O(n.getBoundingClientRect)){const t=n.getBoundingClientRect();d=t.left+t.width/2,c=t.top+t.height/2,u=!0}else{const t=n;t&&M(t.x)&&M(t.y)&&(d=t.x,c=t.y,u=!0)}if(!u){t=!1;break}a.push(d),h.push(c),d<e&&(e=d),c<s&&(s=c),d>r&&(r=d),c>o&&(o=c)}if(t){let t=a[0],l=h[0];b?(t=e+n[0]*(r-e),l=s+n[1]*(o-s)):g?(t=(e+r)/2,l=(s+o)/2):y?(t=a[k-1],l=h[k-1]):M(n)&&(t=a[n],l=h[n]);for(let e=0;e<k;e++){const s=t-a[e],r=l-h[e];let n=Q(s*s+r*r);"x"===u&&(n=-s),"y"===u&&(n=-r),i.push(n)}let d=1/0;for(let t=0,e=i.length;t<e;t++){const e=tt(i[t]);e>0&&e<d&&(d=e)}if(d>0&&d<1/0)for(let t=0,e=i.length;t<e;t++)i[t]=i[t]/d}else for(let t=0;t<k;t++)i.push(tt(E-t))}else for(let t=0;t<k;t++)if(d){let e,s;b?(e=n[0]*(d[0]-1),s=n[1]*(d[1]-1)):g?(e=(d[0]-1)/2,s=(d[1]-1)/2):(e=E%d[0],s=it(E/d[0]));const r=e-t%d[0],o=s-it(t/d[0]);let a=Q(r*r+o*o);"x"===u&&(a=-r),"y"===u&&(a=-o),i.push(a)}else i.push(tt(E-t));r=nt(...i),h&&(i=i.map(t=>h(t/r)*r)),o&&(i=i.map(t=>u?t<0?-1*t:-t:tt(r-t))),v&&(i=xi(i))}const A=_?(w-x)/r:x;z(s)&&(s=f?Pe(f,z(e.start)?f.iterationDuration:C):C);let I=s+(A*dt(i[D],2)||0);return e.modifier&&(I=e.modifier(I)),S&&(I=`${I}${S[2]}`),I}};var Si=Object.freeze({__proto__:null,$:le,addChild:bt,clamp:mi,cleanInlineStyles:Mt,createSeededRandom:_i,damp:yi,degToRad:ci,forEachChildren:yt,get:Qe,keepTime:as,lerp:gi,mapRange:di,padEnd:li,padStart:ai,radToDeg:ui,random:vi,randomPick:Ti,remove:Ke,removeChild:vt,round:fi,roundPad:oi,set:Je,shuffle:xi,snap:pi,stagger:wi,sync:os,wrap:hi});const $i=t=>{const e=ae(t)[0];return e&&X(e)?e:console.warn(`${t} is not a valid SVGGeometryElement`)},Ci=(t,e,s,i,r)=>{const n=s+i,o=r?Math.max(0,Math.min(n,e)):(n%e+e)%e;return t.getPointAtLength(o)},Ei=(t,e,s=0)=>i=>{const r=+t.getTotalLength(),n=i[a],o=t.getCTM(),l=0===s;return{from:0,to:r,modifier:i=>{const a=i+s*r;if("a"===e){const e=Ci(t,r,a,-1,l),s=Ci(t,r,a,1,l);return 180*ot(s.y-e.y,s.x-e.x)/at}{const s=Ci(t,r,a,0,l);return"x"===e?n||!o?s.x:s.x*o.a+s.y*o.c+o.e:n||!o?s.y:s.x*o.b+s.y*o.d+o.f}}}},ki=(t,e=0)=>{const s=$i(t);if(s)return{translateX:Ei(s,"x",e),translateY:Ei(s,"y",e),rotate:Ei(s,"a",e)}},Ni=(t,e=0,s=0)=>ae(t).map(t=>((t,e,s)=>{const i=u,r=getComputedStyle(t),n=r.strokeLinecap,o="non-scaling-stroke"===r.vectorEffect?t:null;let a=n;const l=new Proxy(t,{get(t,e){const s=t[e];return e===h?t:"setAttribute"===e?(...e)=>{if("draw"===e[0]){const s=e[1].split(" "),r=+s[0],l=+s[1],h=(t=>{let e=1;if(t&&t.getCTM){const s=t.getCTM();s&&(e=(Q(s.a*s.a+s.b*s.b)+Q(s.c*s.c+s.d*s.d))/2)}return e})(o),d=-1e3*r*h,c=l*i*h+d,u=i*h+(0===r&&1===l||1===r&&0===l?0:10*h)-c;if("butt"!==n){const e=r===l?"butt":n;a!==e&&(t.style.strokeLinecap=`${e}`,a=e)}t.setAttribute("stroke-dashoffset",`${d}`),t.setAttribute("stroke-dasharray",`${c} ${u}`)}return Reflect.apply(s,t,e)}:O(s)?(...e)=>Reflect.apply(s,t,e):s}});return"1000"!==t.getAttribute("pathLength")&&(t.setAttribute("pathLength","1000"),l.setAttribute("draw",`${e} ${s}`)),l})(t,e,s)),Di=(t,e=.33)=>(s,i,r,n)=>{if(!(s.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${s.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const o=$i(t);if(!o)throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");if(!(o.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${o.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const a="path"===s.tagName,l=a?" ":",",h=n?n._value:null;h&&s.setAttribute(a?"d":"points",h);let d="",c="";if(e){const t=s.getTotalLength(),i=o.getTotalLength(),r=Math.max(Math.ceil(t*e),Math.ceil(i*e));for(let e=0;e<r;e++){const n=e/(r-1),h=s.getPointAtLength(t*n),u=o.getPointAtLength(i*n),p=a?0===e?"M":"L":"";d+=p+dt(h.x,3)+l+h.y+" ",c+=p+dt(u.x,3)+l+u.y+" "}}else d=s.getAttribute(a?"d":"points"),c=o.getAttribute(a?"d":"points");return[d,c]};var Ai=Object.freeze({__proto__:null,createDrawable:Ni,createMotionPath:ki,morphTo:Di});const Ii="undefined"!=typeof Intl&&Intl.Segmenter,Ri=/\{value\}/g,Li=/\{i\}/g,Bi=/(\s+)/,Pi=/^\s+$/,Fi="line",Mi="word",Vi="char",Oi="data-line";let zi=null,Hi=null,Xi=null;const Yi=t=>t.isWordLike||" "===t.segment||M(+t.segment),Wi=t=>t.setAttribute("aria-hidden","true"),Ui=(t,e)=>[...t.querySelectorAll(`[data-${e}]:not([data-${e}] [data-${e}])`)],qi={line:"#00D672",word:"#FF4B4B",char:"#5A87FF"},ji=t=>{if(!t.childElementCount&&!t.textContent.trim()){const e=t.parentElement;t.remove(),e&&ji(e)}},Gi=(t,e,s)=>{const i=t.getAttribute(Oi);if(null!==i&&+i!==e||"BR"===t.tagName){s.add(t);const e=t.previousSibling,i=t.nextSibling;e&&3===e.nodeType&&Pi.test(e.textContent)&&s.add(e),i&&3===i.nodeType&&Pi.test(i.textContent)&&s.add(i)}let r=t.childElementCount;for(;r--;)Gi(t.children[r],e,s);return s},Zi=(t,e={})=>{let s="";const i=V(e.class)?` class="${e.class}"`:"",r=xt(e.clone,!1),n=xt(e.wrap,!1),o=n?!0===n?"clip":n:!!r&&"clip";return n&&(s+=`<span${o?` style="overflow:${o};"`:""}>`),s+=`<span${i}${r?' style="position:relative;"':""} data-${t}="{i}">`,r?(s+="<span>{value}</span>",s+=`<span inert style="position:absolute;top:${"top"===r?"-100%":"bottom"===r?"100%":"0"};left:${"left"===r?"-100%":"right"===r?"100%":"0"};white-space:nowrap;">{value}</span>`):s+="{value}",s+="</span>",n&&(s+="</span>"),s},Qi=(t,e,s,i,r,n,o,a,l)=>{const h=r===Fi,d=r===Vi,c=`_${r}_`,u=O(t)?t(s):t,p=h?"block":"inline-block";Xi.innerHTML=u.replace(Ri,`<i class="${c}"></i>`).replace(Li,`${d?l:h?o:a}`);const m=Xi.content,f=m.firstElementChild,g=m.querySelector(`[data-${r}]`)||f,y=m.querySelectorAll(`i.${c}`),v=y.length;if(v){f.style.display=p,g.style.display=p,g.setAttribute(Oi,`${o}`),h||(g.setAttribute("data-word",`${a}`),d&&g.setAttribute("data-char",`${l}`));let t=v;for(;t--;){const e=y[t],i=e.parentElement;i.style.display=p,h?i.innerHTML=s.innerHTML:i.replaceChild(s.cloneNode(!0),e)}e.push(g),i.appendChild(m)}else console.warn('The expression "{value}" is missing from the provided template.');return n&&(f.style.outline=`1px dotted ${qi[r]}`),f};class Ji{constructor(t,s={}){zi||(zi=Ii?new Ii([],{granularity:Mi}):{segment:t=>{const e=[],s=t.split(Bi);for(let t=0,i=s.length;t<i;t++){const i=s[t];e.push({segment:i,isWordLike:!Pi.test(i)})}return e}}),Hi||(Hi=Ii?new Ii([],{granularity:"grapheme"}):{segment:t=>[...t].map(t=>({segment:t}))}),!Xi&&e&&(Xi=i.createElement("template")),D.current&&D.current.register(this);const{words:r,chars:n,lines:o,accessible:a,includeSpaces:l,debug:h}=s,d=(t=P(t)?t[0]:t)&&t.nodeType?t:(oe(t)||[])[0],c=!0===o?{}:o,u=!0===r||z(r)?{}:r,p=!0===n?{}:n;this.debug=xt(h,!1),this.includeSpaces=xt(l,!1),this.accessible=xt(a,!0),this.linesOnly=c&&!u&&!p,this.lineTemplate=F(c)?Zi(Fi,c):c,this.wordTemplate=F(u)||this.linesOnly?Zi(Mi,u):u,this.charTemplate=F(p)?Zi(Vi,p):p,this.$target=d,this.html=d&&d.innerHTML,this.lines=[],this.words=[],this.chars=[],this.effects=[],this.effectsCleanups=[],this.cache=null,this.ready=!1,this.width=0,this.resizeTimeout=null;const m=()=>this.html&&(c||u||p)&&this.split();this.resizeObserver=new ResizeObserver(()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{const t=d.offsetWidth;t!==this.width&&(this.width=t,m())},150)}),this.lineTemplate&&!this.ready?i.fonts.ready.then(m):m(),d?this.resizeObserver.observe(d):console.warn("No Text Splitter target found.")}addEffect(t){if(!O(t))return console.warn("Effect must return a function."),this;const e=as(t);return this.effects.push(e),this.ready&&(this.effectsCleanups[this.effects.length-1]=e(this)),this}revert(){return clearTimeout(this.resizeTimeout),this.lines.length=this.words.length=this.chars.length=0,this.resizeObserver.disconnect(),this.effectsCleanups.forEach(t=>O(t)?t(this):t.revert&&t.revert()),this.$target.innerHTML=this.html,this}splitNode(t){const e=this.wordTemplate,s=this.charTemplate,r=this.includeSpaces,n=this.debug,o=t.nodeType;if(3===o){const o=t.nodeValue;if(o.trim()){const a=[],l=this.words,h=this.chars,d=zi.segment(o),c=i.createDocumentFragment();let u=null;for(const t of d){const e=t.segment,s=Yi(t);if(!u||s&&u&&Yi(u))a.push(e);else{const t=a.length-1,s=a[t];Bi.test(s)||Bi.test(e)?a.push(e):a[t]+=e}u=t}for(let t=0,o=a.length;t<o;t++){const o=a[t];if(o.trim()){const d=a[t+1],u=r&&d&&!d.trim(),p=o,m=s?Hi.segment(p):null,f=s?i.createDocumentFragment():i.createTextNode(u?o+" ":o);if(s){const t=[...m];for(let e=0,r=t.length;e<r;e++){const o=t[e],a=e===r-1&&u?o.segment+" ":o.segment,d=i.createTextNode(a);Qi(s,h,d,f,Vi,n,-1,l.length,h.length)}}e?Qi(e,l,f,c,Mi,n,-1,l.length,h.length):s?c.appendChild(f):c.appendChild(i.createTextNode(o)),u&&t++}else{if(t&&r)continue;c.appendChild(i.createTextNode(o))}}t.parentNode.replaceChild(c,t)}}else if(1===o){const e=[...t.childNodes];for(let t=0,s=e.length;t<s;t++)this.splitNode(e[t])}}split(t=!1){const e=this.$target,s=!!this.cache&&!t,r=this.lineTemplate,n=this.wordTemplate,o=this.charTemplate,a="loading"!==i.fonts.status,l=r&&a;this.ready=!r||a,(l||t)&&this.effectsCleanups.forEach(t=>O(t)&&t(this)),s||(t&&(e.innerHTML=this.html,this.words.length=this.chars.length=0),this.splitNode(e),this.cache=e.innerHTML),l&&(s&&(e.innerHTML=this.cache),this.lines.length=0,n&&(this.words=Ui(e,Mi))),o&&(l||n)&&(this.chars=Ui(e,Vi));const h=this.words.length?this.words:this.chars;let d,c=0;for(let t=0,e=h.length;t<e;t++){const e=h[t],{top:s,height:i}=e.getBoundingClientRect();!z(d)&&s-d>.5*i&&c++,e.setAttribute(Oi,`${c}`);const r=e.querySelectorAll(`[${Oi}]`);let n=r.length;for(;n--;)r[n].setAttribute(Oi,`${c}`);d=s}if(l){const t=i.createDocumentFragment(),s=new Set,a=[];for(let t=0;t<c+1;t++){const i=e.cloneNode(!0);Gi(i,t,new Set).forEach(t=>{const e=t.parentNode;e&&(1===t.nodeType&&s.add(e),e.removeChild(t))}),a.push(i)}s.forEach(ji);for(let e=0,s=a.length;e<s;e++)Qi(r,this.lines,a[e],t,Fi,this.debug,e);e.innerHTML="",e.appendChild(t),n&&(this.words=Ui(e,Mi)),o&&(this.chars=Ui(e,Vi))}if(this.linesOnly){const t=this.words;let e=t.length;for(;e--;){const s=t[e];s.replaceWith(s.textContent)}t.length=0}if(this.accessible&&(l||!s)){const t=i.createElement("span");t.style.cssText="position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;",t.innerHTML=this.html,e.insertBefore(t,e.firstChild),this.lines.forEach(Wi),this.words.forEach(Wi),this.chars.forEach(Wi)}return this.width=e.offsetWidth,(l||t)&&this.effects.forEach((t,e)=>this.effectsCleanups[e]=t(this)),this}refresh(){this.split(!0)}}const Ki=(t,e)=>new Ji(t,e),tr=(t,e)=>(console.warn("text.split() is deprecated, import splitText() directly, or text.splitText()"),new Ji(t,e)),er=t=>{let e="";for(let s=0,i=t.length;s<i;s++)if(s+2<i&&"-"===t[s+1]&&t.charCodeAt(s)<t.charCodeAt(s+2)){const i=t.charCodeAt(s),r=t.charCodeAt(s+2);for(let t=i;t<=r;t++)e+=String.fromCharCode(t);s+=2}else e+=t[s];return e},sr={lowercase:"a-z",uppercase:"A-Z",numbers:"0-9",symbols:"!%#_|*+=",braille:"⠀-⣿",blocks:"▀-▟",shades:"░-▓"},ir=new WeakMap,rr=(t={})=>{t||(t={});const e=t.chars,s=xe(t.ease||"linear"),i=t.text,r=t.from,n=t.reversed||!1,o=t.perturbation||0,a=t.cursor,l=!0===a?"_":"number"==typeof a?String.fromCharCode(a):"string"==typeof a?a:"",h=l.length,d=t.seed||0,c=void 0===t.override||t.override,u=t.revealRate||60,p=1e3*A.timeScale/u,m=t.settleDuration||300*A.timeScale,f=t.settleRate||30,g=t.duration,v=t.revealDelay,b=t.delay,_=t.onChange||y;return(t,a,u,y)=>{const T="function"==typeof e?e(t,a,u):e||"a-zA-Z0-9!%#_",x=er(sr[T]||T),w=x.length-1,S="function"==typeof g?g(t,a,u):g,$="function"==typeof v?v(t,a,u):v||0,C="function"==typeof b?b(t,a,u):b||0,E=d?_i(d):_i();ir.has(t)||ir.set(t,t.textContent);const k=y?y._value:t.textContent,N=void 0!==i?"function"==typeof i?i(t,a,u):i:y?y._value:ir.get(t),D=" "===N||"&nbsp;"===N?" ":N,I=" "===k?0:k.length,R=D.length,L=!0===c?x:"string"==typeof c&&c.length>0?er(sr[c]||c):null,B=L?L.length-1:0,P=" "===c?" ":null,F=""===c?R:Math.max(I,R),M=S>0?S:(F-1)*p+m,V=dt((M+$)/A.timeScale,0)*A.timeScale,O=$>0?dt($/V,12):0,z=void 0===r||"auto"===r?R<I?"right":"left":r,H=new Int32Array(F);if("random"===z){for(let t=0;t<F;t++)H[t]=t;for(let t=F-1;t>0;t--){const e=E(0,t),s=H[t];H[t]=H[e],H[e]=s}}else{const t="right"===z?(""!==c&&I?I:F)-1:"center"===z?((""!==c&&I?I:F)-1)/2:"number"==typeof z?z:0,e=Math.abs,s=new Array(F);for(let t=0;t<F;t++)s[t]=t;s.sort((s,i)=>e(s-t)-e(i-t));for(let t=0;t<F;t++)H[s[t]]=t}if(n){const t=F-1;for(let e=0;e<F;e++)H[e]=t-H[e]}const X=dt(m/M,12),Y=dt((1-X)/F,12),W=h*Y,U=dt(1e3*A.timeScale/(f*V),12),q=new Float32Array(F),j=new Float32Array(F),G=o>0?o*X:0;for(let t=0;t<F;t++){const e=G>0?(E(0,2e3)-1e3)/1e3*G:0,s=G>0?(E(0,2e3)-1e3)/1e3*G:0;q[t]=H[t]*Y+e,j[t]=Math.ceil((q[t]+X+s)/U)*U}if(R<F&&"left"!==z&&"right"!==z&&"random"!==z){let t=0;for(let e=R;e<F;e++)j[e]>t&&(t=j[e]);const e=new Array(R);for(let t=0;t<R;t++)e[t]=t;e.sort((t,e)=>H[t]-H[e]);const s=(1-t)/R;for(let i=0;i<R;i++){const r=t+i*s;r>j[e[i]]&&(j[e[i]]=r)}}const Z=new Array(F);for(let t=0;t<F;t++)Z[t]=x[E(0,w)];const Q=L?L===x?Z:new Array(F):null;if(Q&&Q!==Z)for(let t=0;t<F;t++)Q[t]=P||L[E(0,L.length-1)];let J=k;if(!y)if(""===c)J="";else if(L){J="";for(let t=0;t<I;t++)J+=" "===k[t]?" ":Q[t]}let K=-1,tt=-1,et="";const st=""!==c,it=!!L,rt=h>0;return{from:0,to:1,duration:V,delay:C,ease:"linear",modifier:t=>{if(t===K)return et;if(K=t,C>0&&t<=0)return et=k,k;if(t<=0)return et=J,J;if(t>=1)return et=D,D;et="";const e=t/U|0,i=e!==tt;i&&(tt=e);const r=O>0?(t-O)/(1-O):t,n=r>0?s(r):0;for(let t=0;t<F;t++){const e=q[t];n>=j[t]?t<R&&(et+=D[t]):n<=0||n<e?st&&t<I&&(it?" "===k[t]?et+=" ":(i&&(Q[t]=P||L[E(0,B)]),et+=Q[t]):et+=k[t]):t<R&&" "===D[t]||t<I&&" "===k[t]?et+=" ":rt&&n-e<W?et+=l[h-1-((n-e)/Y|0)]:(i&&(Z[t]=x[E(0,w)]),et+=Z[t])}return i&&_(et,n),et}}}};var nr=Object.freeze({__proto__:null,TextSplitter:Ji,scrambleText:rr,split:tr,splitText:Ki});t.$=le,t.Animatable=ze,t.AutoLayout=ei,t.Draggable=ns,t.JSAnimation=Be,t.Scope=ls,t.ScrollObserver=ys,t.Spring=We,t.TextSplitter=Ji,t.Timeline=Ve,t.Timer=ne,t.WAAPIAnimation=Rs,t.addChild=bt,t.animate=(t,e)=>A.editor?A.editor.addAnimation(t,e):new Be(t,e,null,0,!1).init(),t.clamp=mi,t.cleanInlineStyles=Mt,t.createAnimatable=(t,e)=>new ze(t,e),t.createDraggable=(t,e)=>new ns(t,e),t.createDrawable=Ni,t.createLayout=(t,e)=>new ei(t,e),t.createMotionPath=ki,t.createScope=t=>new ls(t),t.createSeededRandom=_i,t.createSpring=qe,t.createTimeline=Oe,t.createTimer=t=>new ne(t,null,0).init(),t.cubicBezier=bs,t.damp=yi,t.degToRad=ci,t.eases=ve,t.easings=ws,t.engine=Yt,t.forEachChildren=yt,t.get=Qe,t.globals=A,t.irregular=xs,t.keepTime=as,t.lerp=gi,t.linear=Ts,t.mapRange=di,t.morphTo=Di,t.onScroll=(t={})=>new ys(t),t.padEnd=li,t.padStart=ai,t.radToDeg=ui,t.random=vi,t.randomPick=Ti,t.remove=Ke,t.removeChild=vt,t.round=fi,t.roundPad=oi,t.scrambleText=rr,t.scrollContainers=ds,t.set=Je,t.shuffle=xi,t.snap=pi,t.split=tr,t.splitText=Ki,t.spring=Ue,t.stagger=wi,t.steps=_s,t.svg=Ai,t.sync=os,t.text=nr,t.utils=Si,t.waapi=Ls,t.wrap=hi});
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).anime={})}(this,function(t){"use strict";const e="undefined"!=typeof window,s=e?window:null,i=e?document:null,r={replace:0,none:1,blend:2},n=Symbol(),o=Symbol(),a=Symbol(),l=Symbol(),h=Symbol(),d=1e-11,c=1e12,u=1e3,p="",m=[],f=(()=>{const t=new Map;return t.set("x","translateX"),t.set("y","translateY"),t.set("z","translateZ"),t})(),g=["perspective","translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY"],y=g.reduce((t,e)=>({...t,[e]:e+"("}),{}),_=()=>{},b=/\)\s*[-.\d]/,v=/(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i,T=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i,x=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,S=/hsl\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*\)/i,w=/hsla\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,$=/[-+]?\d*\.?\d+(?:e[-+]?\d)?/gi,C=/^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i,E=/([a-z])([A-Z])/g,k=/(\*=|\+=|-=)/,N=/var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/,D={id:null,keyframes:null,playbackEase:null,playbackRate:1,frameRate:240,loop:0,reversed:!1,alternate:!1,autoplay:!0,persist:!1,duration:u,delay:0,loopDelay:0,ease:"out(2)",composition:r.replace,modifier:t=>t,onBegin:_,onBeforeUpdate:_,onUpdate:_,onLoop:_,onPause:_,onComplete:_,onRender:_},A={current:null,root:i},I={defaults:D,precision:4,timeScale:1,tickThreshold:200,editor:null},R={version:"4.5.0",engine:null};e&&(s.AnimeJS||(s.AnimeJS=[]),s.AnimeJS.push(R));const L=t=>t.replace(E,"$1-$2").toLowerCase(),B=(t,e)=>0===t.indexOf(e),P=Date.now,F=Array.isArray,M=t=>t&&t.constructor===Object,V=t=>"number"==typeof t&&!isNaN(t),O=t=>"string"==typeof t,z=t=>"function"==typeof t,H=t=>void 0===t,X=t=>H(t)||null===t,Y=t=>e&&t instanceof SVGElement,W=t=>v.test(t),U=t=>B(t,"rgb"),q=t=>B(t,"hsl"),j=t=>!I.defaults.hasOwnProperty(t),G=["opacity","rotate","overflow","color"],Z=t=>O(t)?parseFloat(t):t,Q=Math.pow,J=Math.sqrt,K=Math.sin,tt=Math.cos,et=Math.abs,st=Math.exp,it=Math.ceil,rt=Math.floor,nt=Math.asin,ot=Math.max,at=Math.atan2,lt=Math.PI,ht=Math.round,dt=(t,e,s)=>t<e?e:t>s?s:t,ct=(t,e)=>{if(e<0)return t;if(!e)return ht(t);const s=10**e;return ht(t*s)/s},ut=(t,e)=>F(e)?e.reduce((e,s)=>et(s-t)<et(e-t)?s:e):e?ht(t/e)*e:t,pt=(t,e,s)=>1===s?e:0===s?t:t+(e-t)*s,mt=t=>t===1/0?c:t===-1/0?-c:t,ft=t=>t<=d?d:mt(ct(t,11)),gt=t=>F(t)?[...t]:t,yt=(t,e)=>{const s={...t};for(let i in e){const r=t[i];s[i]=H(r)?e[i]:r}return s},_t=(t,e,s,i="_prev",r="_next")=>{let n=t._head,o=r;for(s&&(n=t._tail,o=i);n;){const t=n[o];e(n),n=t}},bt=(t,e,s="_prev",i="_next")=>{const r=e[s],n=e[i];r?r[i]=n:t._head=n,n?n[s]=r:t._tail=r,e[s]=null,e[i]=null},vt=(t,e,s,i="_prev",r="_next")=>{let n=t._tail;for(;n&&s&&s(n,e);)n=n[i];const o=n?n[r]:t._head;n?n[r]=e:t._head=e,o?o[i]=e:t._tail=e,e[i]=n,e[r]=o},Tt=t=>{let e=p;for(let s=0,i=g.length;s<i;s++){const i=g[s],r=t[i];if(void 0!==r){if("translateX"===i){const i=t.translateY;if(void 0!==i){const n=t.translateZ;void 0!==n?(e+=`translate3d(${r},${i},${n}) `,s+=2):(e+=`translate(${r},${i}) `,s+=1);continue}}if("scaleX"===i&&void 0===t.scale){const i=t.scaleY;if(void 0!==i){const n=t.scaleZ;void 0!==n?(e+=`scale3d(${r},${i},${n}) `,s+=2):(e+=`scale(${r},${i}) `,s+=1);continue}}e+=`${y[i]}${r}) `}"rotateZ"===i&&void 0!==t.rotate3d&&(e+=`rotate3d(${t.rotate3d}) `)}return void 0!==t.matrix&&(e+=`matrix(${t.matrix}) `),void 0!==t.matrix3d&&(e+=`matrix3d(${t.matrix3d}) `),e},xt=[];function St(t,e){if(!t)return null;const s=xt.length;t:for(let i=0;i<s;i++){const s=xt[i];if(s.detect&&!s.detect(t))continue;const r=s.targetAdapters;for(let s=0,i=r.length;s<i;s++){const i=r[s];if(i.detect(t)){const s=i.props[e];if(s&&(!s.gate||s.gate(t)))return s;break t}}}for(let i=0;i<s;i++){const s=xt[i];if(s.detect&&!s.detect(t))continue;const r=s.propertyResolvers;for(let s=0,i=r.length;s<i;s++){const i=r[s](t,e);if(i)return i}}return null}const wt=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t),$t=(t,e)=>H(t)?e:t,Ct=(t,e)=>{const s=t.match(N),i=e[o]?e:document.documentElement;let r=getComputedStyle(i)?.getPropertyValue(s[1]);return r&&r.trim()!==p||!s[2]||(r=s[2].trim()),r||0},Et=(t,e,s,i,r,n)=>{if(z(t)){if(!r){const r=t(e,s,i,n);return isNaN(+r)?r||0:+r}const o=()=>{const r=t(e,s,i,n);return isNaN(+r)?r||0:+r};return r.func=o,o()}if(O(t)&&B(t,"var(")){if(!r)return Ct(t,e);const s=()=>Ct(t,e);return r.func=s,s()}return t},kt=(t,e)=>t[o]?t[a]&&((t,e)=>{if(G.includes(e))return!1;if(t.getAttribute(e)||e in t){if("scale"===e){const e=t.parentNode;return e&&"filter"===e.tagName}return!0}})(t,e)?1:g.includes(e)||f.get(e)?3:B(e,"--")?4:e in t.style?2:e in t?0:1:0,Nt=(t,e,s)=>{const i=t.style[e];i&&s&&(s[e]=i);const r=i||getComputedStyle(t[h]||t).getPropertyValue(e);return"auto"===r?"0":r},Dt=(t,e,s,i)=>{const r=H(s)?kt(t,e):s,n=St(t,e);if(n){const s=n.get(t);return s&&i&&(i[e]=s),null==s?0:s}if(0===r){const s=t[e];return s&&i&&(i[e]=s),s||0}if(1===r){const s=t.getAttribute(e);return s&&i&&(i[e]=s),s}return 3===r?((t,e,s)=>{const i=t.style.transform;if(i){const r=t[l];let n=0;const o=i.length;let a;for(;n<o;){for(;n<o&&32===i.charCodeAt(n);)n++;if(n>=o)break;const t=n;for(;n<o&&40!==i.charCodeAt(n);)n++;if(n>=o)break;const e=i.substring(t,n);let s=1;const l=n+1;let h=-1,d=-1;for(n++;n<o&&s>0;){const t=i.charCodeAt(n);40===t?s++:41===t?s--:44===t&&1===s&&(-1===h?h=n:-1===d&&(d=n)),n++}const c=n-1;"translate"===e||"translate3d"===e?(-1===h?r.translateX=i.substring(l,c).trim():(r.translateX=i.substring(l,h).trim(),-1===d?r.translateY=i.substring(h+1,c).trim():(r.translateY=i.substring(h+1,d).trim(),r.translateZ=i.substring(d+1,c).trim())),a=i.substring(l,c)):"scale"===e||"scale3d"===e?-1===h?r.scale=i.substring(l,c).trim():(r.scaleX=i.substring(l,h).trim(),-1===d?r.scaleY=i.substring(h+1,c).trim():(r.scaleY=i.substring(h+1,d).trim(),r.scaleZ=i.substring(d+1,c).trim())):r[e]=i.substring(l,c)}if("translate3d"===e&&a)return s&&(s[e]=a),a;const h=r[e];if(!H(h))return s&&(s[e]=h),h}return"translate3d"===e?"0px, 0px, 0px":"rotate3d"===e?"0, 0, 0, 0deg":B(e,"scale")?"1":B(e,"rotate")||B(e,"skew")?"0deg":"0px"})(t,e,i):4===r?Nt(t,e,i).trimStart():Nt(t,e,i)},At=(t,e,s)=>"-"===s?t-e:"+"===s?t+e:t*e,It=(t,e)=>{if(e.t=0,e.n=0,e.u=null,e.o=null,e.d=null,e.s=null,!t)return e;const s=+t;if(!isNaN(s))return e.n=s,e;let i=t;"="===i[1]&&(e.o=i[0],i=i.slice(2));const r=!i.includes(" ")&&C.exec(i);if(r)return e.t=1,e.n=+r[1],e.u=r[2],e;if(e.o)return e.n=+i,e;if(W(o=i)||(U(o)||q(o))&&(")"===o[o.length-1]||!b.test(o)))return e.t=2,e.d=U(n=i)?(t=>{const e=T.exec(t)||x.exec(t),s=H(e[4])?1:+e[4];return[+e[1],+e[2],+e[3],s]})(n):W(n)?(t=>{const e=t.length,s=4===e||5===e;return[+("0x"+t[1]+t[s?1:2]),+("0x"+t[s?2:3]+t[s?2:4]),+("0x"+t[s?3:5]+t[s?3:6]),5===e||9===e?+(+("0x"+t[s?4:7]+t[s?4:8])/255).toFixed(3):1]})(n):q(n)?(t=>{const e=S.exec(t)||w.exec(t),s=+e[1]/360,i=+e[2]/100,r=+e[3]/100,n=H(e[4])?1:+e[4];let o,a,l;if(0===i)o=a=l=r;else{const t=r<.5?r*(1+i):r+i-r*i,e=2*r-t;o=ct(255*wt(e,t,s+1/3),0),a=ct(255*wt(e,t,s),0),l=ct(255*wt(e,t,s-1/3),0)}return[o,a,l,n]})(n):[0,0,0,1],e;var n,o;{const t=i.match($);return e.t=3,e.d=t?t.map(Number):[],e.s=i.split($)||[],e}},Rt=(t,e)=>(e.t=t._valueType,e.n=t._toNumber,e.u=t._unit,e.o=null,e.d=gt(t._toNumbers),e.s=gt(t._strings),e),Lt={t:0,n:0,u:null,o:null,d:null,s:null},Bt=(t,e,s)=>{const i=t._modifier,r=t._fromNumbers,n=t._toNumbers,o=t._strings;let a=o[0];for(let l=0,h=n.length;l<h;l++){const h=i(ct(pt(r[l],n[l],e),s)),d=o[l+1];a+=`${d?h+d:h}`,t._numbers[l]=h}return a},Pt=(t,e,s,i,n)=>{const o=t.parent,a=t.duration,h=t.completed,c=t.iterationDuration,u=t.iterationCount,p=t._currentIteration,m=t._loopDelay,f=t._reversed,g=t._alternate,y=t._hasChildren,_=t._delay,b=t._currentTime,v=_+c,T=e-_,x=dt(b,-_,a),S=dt(T,-_,a),w=T-b,$=S>0,C=S>=a,E=a<=d,k=2===n;let N=0,D=T,A=0;if(u>1){const e=c+(C?0:m),s=~~(S/e);t._currentIteration=dt(s,0,u),C&&t._currentIteration--,N=t._currentIteration%2,D=S-s*e||0}const R=f^(g&&N),L=t._ease;let B=C?R?0:a:R?c-D:D;L&&(B=c*L(B/c)||0);const P=(o?o.backwards:T<b)?!R:!!R;if(t._currentTime=T,t._iterationTime=B,t.backwards=P,$&&!t.began?(t.began=!0,s||o&&(P||!o.began)||t.onBegin(t)):T<=0&&(t.began=!1),s||y||!$||t._currentIteration===p||t.onLoop(t),k||1===n&&(e>=(o&&_>0?0:_)&&e<=v||e<=_&&x>_||e>=v&&x!==a)||B>=v&&x!==a||B<=_&&x>0&&!C||e<=x&&x===a&&h||C&&!h&&E){if($&&(t.computeDeltaTime(x),s||t.onBeforeUpdate(t)),!y){const e=k||(P?-1*w:w)>=I.tickThreshold,n=ct(t._offset+(o?o._offset:0)+_+B,12);let a,h,d,c,u=t._head,p=0;for(;u;){const t=u._composition,s=u._currentTime,o=u._changeDuration,m=u._absoluteStartTime+u._changeDuration,f=u._nextRep,g=u._prevRep,y=t!==r.none,_=g?g._absoluteStartTime+g._changeDuration:0,b=g&&g.parent!==u.parent,v=!f||f._isOverridden?m:f.parent===u.parent?m+f._delay:f._absoluteStartTime<f._absoluteUpdateStartTime?f._absoluteStartTime:f._absoluteUpdateStartTime;if((e||(s!==o||n<=v||g&&!b&&(!f||f.parent!==u.parent))&&(0!==s||n>=u._absoluteStartTime||b&&!u._hasFromValue&&!g._isOverridden&&n>=_||f&&!f._isOverridden&&f.parent===u.parent&&0!==f._currentTime&&B<f._startTime))&&(!g||b||B>=u._startTime)&&(!y||!u._isOverridden&&(!u._isOverlapped||n<=m)&&(!f||f._isOverridden||n<=v)&&(!g||g._isOverridden||(b?n>=u._absoluteStartTime||!u._hasFromValue&&n>=_:n>=_+u._delay)))){const e=u._currentTime=dt(B-u._startTime,0,o),s=u._ease(e/u._updateDuration),n=u._modifier,m=u._valueType,f=u._tweenType,g=0===f,_=0===m,b=_&&g||0===s||1===s?-1:I.precision;let v,T;if(_)v=T=n(ct(pt(u._fromNumber,u._toNumber,s),b));else if(1===m)T=n(ct(pt(u._fromNumber,u._toNumber,s),b)),v=`${T}${u._unit}`;else if(2===m){const t=u._numbers,e=u._fromNumbers,r=u._toNumbers,o=1-s,a=e[0],l=e[1],h=e[2],d=r[0],c=r[1],p=r[2];t[0]=n(Math.sqrt(a*a*o+d*d*s)),t[1]=n(Math.sqrt(l*l*o+c*c*s)),t[2]=n(Math.sqrt(h*h*o+p*p*s)),t[3]=n(pt(e[3],r[3],s)),u._setter&&!i||(v=`rgba(${ct(t[0],0)},${ct(t[1],0)},${ct(t[2],0)},${t[3]})`)}else 3===m&&(v=Bt(u,s,b));if(y&&(u._number=T),i||t===r.blend)u._value=v;else{const t=u.property;a=u.target,u._setter?u._setter(a,T,u):g?a[t]=v:1===f?a.setAttribute(t,v):(h=a.style,3===f?(a!==d&&(d=a,c=a[l]),c[t]=v,p=1):2===f?h[t]=v:4===f&&h.setProperty(t,v)),$&&(A=1)}}else s&&g&&!b&&B<u._startTime&&(u._currentTime=0);p&&u._renderTransforms&&(h.transform=Tt(c),p=0),u=u._next}!s&&A&&t.onRender(t)}!s&&$&&t.onUpdate(t)}return o&&E?!s&&(o.began&&!P&&T>0&&!h||P&&T<=d&&h)&&(t.onComplete(t),t.completed=!P):$&&C?u===1/0?t._startTime+=t.duration:t._currentIteration>=u-1&&(t.paused=!0,h||y||(t.completed=!0,s||o&&(P||!o.began)||(t.onComplete(t),t._resolve(t)))):t.completed=!1,A},Ft=(t,e,s,i,r)=>{const n=t._currentIteration;if(Pt(t,e,s,i,r),t._hasChildren){const o=t,a=o.backwards,l=i?e:o._iterationTime,h=P();let c=0,u=!0;if(!i&&o._currentIteration!==n){const t=o.iterationDuration;_t(o,e=>{if(a){const i=e.duration,r=e._offset+e._delay;s||!(i<=d)||r&&r+i!==t||e.onComplete(e)}else!e.completed&&!e.backwards&&e._currentTime<e.iterationDuration&&Pt(e,t,s,1,2),e.began=!1,e.completed=!1}),s||o.onLoop(o)}_t(o,t=>{const e=ct((l-t._offset)*t._speed,12);if(a&&e>t._delay+t.duration)return;const n=t._fps<o._fps?t.requestTick(h):r;c+=Pt(t,e,s,i,n),!t.completed&&u&&(u=!1)},a),!s&&c&&o.onRender(o),(u||a)&&o._currentTime>=o.duration&&(o.paused=!0,o.completed||(o.completed=!0,s||(o.onComplete(o),o._resolve(o))))}},Mt={},Vt=(t,e,s)=>{if(3===s)return f.get(t)||t;if(2===s||1===s&&Y(e)&&t in e.style){const e=Mt[t];if(e)return e;{const e=t?L(t):t;return Mt[t]=e,e}}return t},Ot=(t,e=!1)=>{if(t._hasChildren)_t(t,t=>Ot(t,e),!0);else{const s=t;s.pause(),_t(s,t=>{const i=t.property,r=t.target,n=t._tweenType,a=t._inlineValue,h=X(a)||a===p;if(t._setter){if(!e&&!h){if(It(a,Lt),Lt.d){const e=Lt.d,s=t._numbers;for(let t=0,i=e.length;t<i;t++)s[t]=e[t]}else t._number=Lt.n;t._setter(t.target,t._number,t)}}else if(0===n)e||h||(r[i]=a);else if(r[o])if(1===n)e||(h?r.removeAttribute(i):r.setAttribute(i,a));else{const e=r.style;if(3===n){const s=r[l];h?delete s[i]:s[i]=a,t._renderTransforms&&(Object.keys(s).length?e.transform=Tt(s):e.removeProperty("transform"))}else h?e.removeProperty(L(i)):e[i]=a}r[o]&&s._tail===t&&s.targets.forEach(t=>{t.getAttribute&&t.getAttribute("style")===p&&t.removeAttribute("style")})})}return t},zt=t=>Ot(t,!0);class Ht{constructor(t=0){this.deltaTime=0,this._currentTime=t,this._lastTickTime=t,this._startTime=t,this._lastTime=t,this._frameDuration=u/240,this._fps=240,this._speed=1,this._hasChildren=!1,this._head=null,this._tail=null}get fps(){return this._fps}set fps(t){const e=+t,s=e<d?d:e,i=u/s;s>D.frameRate&&(D.frameRate=s),this._fps=s,this._frameDuration=i}get speed(){return this._speed}set speed(t){const e=+t;this._speed=e<d?d:e}requestTick(t){const e=this._frameDuration,s=t-this._lastTickTime,i=.25*e;return s+(i<4?i:4)<e?0:(this._lastTickTime=s>=e?t-s%e:t,1)}computeDeltaTime(t){const e=t-this._lastTime;return this.deltaTime=e,this._lastTime=t,e}}const Xt={animation:null,update:_},Yt=(()=>e?requestAnimationFrame:setImmediate)(),Wt=(()=>e?cancelAnimationFrame:clearImmediate)();class Ut extends Ht{constructor(t){super(t),this.useDefaultMainLoop=!0,this.pauseOnDocumentHidden=!0,this.defaults=D,this.paused=!0,this.reqId=0}update(){const t=this._currentTime=P();if(this.requestTick(t)){this.computeDeltaTime(t);const e=this._speed,s=this._fps;let i=this._head;for(;i;){const r=i._next;i.paused?(bt(this,i),this._hasChildren=!!this._tail,i._running=!1,i.completed&&!i._cancelled&&i.cancel()):Ft(i,(t-i._startTime)*i._speed*e,0,0,i._fps<s?i.requestTick(t):1),i=r}Xt.update()}}wake(){return this.useDefaultMainLoop&&!this.reqId&&(this.requestTick(P()),this.reqId=Yt(jt)),this}pause(){if(this.reqId)return this.paused=!0,Gt()}resume(){if(this.paused)return this.paused=!1,_t(this,t=>t.resetTime()),this.wake()}get speed(){return this._speed*(1===I.timeScale?1:u)}set speed(t){const e=t*I.timeScale;this._speed!==e&&(this._speed=e,_t(this,t=>t.speed=t._speed))}get timeUnit(){return 1===I.timeScale?"ms":"s"}set timeUnit(t){const e="s"===t,s=e?.001:1;if(I.timeScale!==s){I.timeScale=s,I.tickThreshold=200*s;const t=e?.001:u;this.defaults.duration*=t,this._speed*=t}}get precision(){return I.precision}set precision(t){I.precision=t}}const qt=(()=>{const t=new Ut(P());return e&&(R.engine=t,i.addEventListener("visibilitychange",()=>{t.pauseOnDocumentHidden&&(i.hidden?t.pause():t.resume())})),t})(),jt=()=>{qt._head?(qt.reqId=Yt(jt),qt.update()):qt.reqId=0},Gt=()=>(Wt(qt.reqId),qt.reqId=0,qt),Zt={_rep:new WeakMap,_add:new Map},Qt=(t,e,s="_rep")=>{const i=Zt[s];let r=i.get(t);return r||(r={},i.set(t,r)),r[e]?r[e]:r[e]={_head:null,_tail:null}},Jt=(t,e)=>t._isOverridden||t._absoluteStartTime>e._absoluteStartTime,Kt=t=>{t._isOverlapped=1,t._isOverridden=1,t._changeDuration=d,t._currentTime=d},te=(t,e)=>{const s=t._composition;if(s===r.replace){const s=t._absoluteStartTime;vt(e,t,Jt,"_prevRep","_nextRep");const i=t._prevRep;if(i){const e=i.parent,r=i._absoluteEndTime;if(t.parent.id!==e.id&&e.iterationCount>1&&r+(e.duration-e.iterationDuration)>s){Kt(i);let t=i._prevRep;for(;t&&t.parent.id===e.id;)Kt(t),t=t._prevRep}const n=t._absoluteUpdateStartTime;if(r>n){const t=i._startTime,e=r-(t+i._updateDuration),s=ct(n-e-t,12);i._changeDuration=s,i._currentTime=s,i._isOverlapped=1,s<d&&Kt(i)}const o=t.parent.parent;if(!o||o!==e.parent){let t=!0;if(_t(e,e=>{e._isOverlapped||(t=!1)}),t){const t=e.parent;if(t){let s=!0;_t(t,t=>{t!==e&&_t(t,t=>{t._isOverlapped||(s=!1)})}),s&&t.cancel()}else e.cancel()}}}}else if(s===r.blend){const e=Qt(t.target,t.property,"_add"),s=(t=>{let e=Xt.animation;return e||(e={duration:d,computeDeltaTime:_,_offset:0,_delay:0,_head:null,_tail:null},Xt.animation=e,Xt.update=()=>{t.forEach(t=>{for(let e in t){const s=t[e],i=s._head;if(i){const t=i._valueType,e=3===t||2===t?gt(i._fromNumbers):null;let r=i._fromNumber,n=s._tail;for(;n&&n!==i;){if(e)for(let t=0,s=n._numbers.length;t<s;t++)e[t]+=n._numbers[t];else r+=n._number;n=n._prevAdd}i._toNumber=r,i._toNumbers=e}}}),Pt(e,1,1,0,2)}),e})(Zt._add);let i=e._head;i||(i={...t},i._composition=r.replace,i._updateDuration=d,i._startTime=0,i._numbers=gt(t._fromNumbers),i._number=0,i._next=null,i._prev=null,vt(e,i),vt(s,i));const n=t._toNumber;if(t._fromNumber=i._fromNumber-n,t._toNumber=0,t._numbers=gt(t._fromNumbers),t._number=0,i._fromNumber=n,t._toNumbers.length){const e=gt(t._toNumbers);e.forEach((e,s)=>{t._fromNumbers[s]=i._fromNumbers[s]-e,t._toNumbers[s]=0}),i._fromNumbers=e}vt(e,t,null,"_prevAdd","_nextAdd")}return t},ee=t=>{const e=t._composition;if(e!==r.none){const s=t.target,i=t.property,n=Zt._rep.get(s)[i];if(bt(n,t,"_prevRep","_nextRep"),e===r.blend){const e=Zt._add,r=e.get(s);if(!r)return;const n=r[i],o=Xt.animation;bt(n,t,"_prevAdd","_nextAdd");const a=n._head;if(a&&a===n._tail){bt(n,a,"_prevAdd","_nextAdd"),bt(o,a);let t=!0;for(let e in r)if(r[e]._head){t=!1;break}t&&e.delete(s)}}}return t},se=(t,e,s)=>{let i=!1;return _t(e,r=>{const n=r.target;if(t.includes(n)){const t=r.property,o=r._tweenType,a=Vt(s,n,o);(!a||a&&a===t)&&(r.parent._tail===r&&3===r._tweenType&&r._prev&&3===r._prev._tweenType&&(r._prev._renderTransforms=1),bt(e,r),ee(r),i=!0)}},!0),i},ie=(t,e,s)=>{const i=e||qt;let r;if(i._hasChildren){let e=0;_t(i,n=>{if(!n._hasChildren)if(r=se(t,n,s),r&&!n._head)n.cancel(),bt(i,n);else{const t=n._offset+n._delay+n.duration;t>e&&(e=t)}n._head?ie(t,n,s):n._hasChildren=!1},!0),H(i.iterationDuration)||(i.iterationDuration=e)}else r=se(t,i,s);r&&!i._head&&(i._hasChildren=!1,i.cancel&&i.cancel())},re=t=>(t.paused=!0,t.began=!1,t.completed=!1,t),ne=t=>t._cancelled?(t._hasChildren?_t(t,ne):_t(t,t=>{t._composition!==r.none&&te(t,Qt(t.target,t.property))}),t._cancelled=0,t):t;let oe=0;const ae=(t,e)=>t._priority>e._priority;class le extends Ht{constructor(t={},e=null,s=0){super(0),++oe;const{id:i,delay:r,duration:n,reversed:o,alternate:a,loop:l,loopDelay:h,autoplay:c,frameRate:u,playbackRate:p,priority:m,onComplete:f,onLoop:g,onPause:y,onBegin:b,onBeforeUpdate:v,onUpdate:T}=t;A.current&&A.current.register(this);const x=e?0:qt._lastTickTime,S=e?e.defaults:I.defaults,w=z(r)||H(r)?S.delay:+r,$=z(n)||H(n)?1/0:+n,C=$t(l,S.loop),E=$t(h,S.loopDelay);let k=!0===C||C===1/0||C<0?1/0:C+1,N=0;e?N=s:(qt.reqId||qt.requestTick(P()),N=(qt._lastTickTime-qt._startTime)*I.timeScale),this.id=H(i)?oe:i,this.parent=e,this.duration=mt(($+E)*k-E)||d,this.backwards=!1,this.paused=!0,this.began=!1,this.completed=!1,this.onBegin=b||S.onBegin,this.onBeforeUpdate=v||S.onBeforeUpdate,this.onUpdate=T||S.onUpdate,this.onLoop=g||S.onLoop,this.onPause=y||S.onPause,this.onComplete=f||S.onComplete,this.iterationDuration=$,this.iterationCount=k,this._autoplay=!e&&$t(c,S.autoplay),this._offset=N,this._delay=w,this._loopDelay=E,this._iterationTime=0,this._currentIteration=0,this._resolve=_,this._running=!1,this._reversed=+$t(o,S.reversed),this._reverse=this._reversed,this._cancelled=0,this._alternate=$t(a,S.alternate),this._prev=null,this._next=null,this._lastTickTime=x,this._startTime=x,this._lastTime=x,this._fps=$t(u,S.frameRate),this._speed=$t(p,S.playbackRate),this._priority=+$t(m,1)}get cancelled(){return!!this._cancelled}set cancelled(t){t?this.cancel():this.reset(!0).play()}get currentTime(){return dt(ct(this._currentTime,I.precision),-this._delay,this.duration)}set currentTime(t){const e=this.paused;this.pause().seek(+t),e||this.resume()}get iterationCurrentTime(){return dt(ct(this._iterationTime,I.precision),0,this.iterationDuration)}set iterationCurrentTime(t){this.currentTime=this.iterationDuration*this._currentIteration+t}get progress(){return dt(ct(this._currentTime/this.duration,10),0,1)}set progress(t){this.currentTime=this.duration*t}get iterationProgress(){return dt(ct(this._iterationTime/this.iterationDuration,10),0,1)}set iterationProgress(t){const e=this.iterationDuration;this.currentTime=e*this._currentIteration+e*t}get currentIteration(){return this._currentIteration}set currentIteration(t){this.currentTime=this.iterationDuration*dt(+t,0,this.iterationCount-1)}get reversed(){return!!this._reversed}set reversed(t){t?this.reverse():this.play()}get speed(){return super.speed}set speed(t){super.speed=t,this.resetTime()}reset(t=!1){return ne(this),this._reversed&&!this._reverse&&(this.reversed=!1),this._iterationTime=this.iterationDuration,Ft(this,0,1,~~t,2),re(this),this._hasChildren&&_t(this,re),this}init(t=!1){this.fps=this._fps,this.speed=this._speed,!t&&this._hasChildren&&Ft(this,this.duration,1,~~t,2),this.reset(t);const e=this._autoplay;return!0===e?this.resume():e&&!H(e.linked)&&e.link(this),this}resetTime(){const t=1/(this._speed*qt._speed);return this._startTime=P()-(this._currentTime+this._delay)*t,this}pause(){return this.paused||(this.paused=!0,this.onPause(this)),this}resume(){return this.paused?(this.paused=!1,this.duration<=d&&!this._hasChildren?Ft(this,d,0,0,2):(this._running||(vt(qt,this,ae),qt._hasChildren=!0,this._running=!0),this.resetTime(),this._startTime-=12,qt.wake()),this):this}restart(){return this.reset().resume()}seek(t,e=0,s=0){ne(this),this.completed=!1;const i=this.paused;return this.paused=!0,Ft(this,t+this._delay,~~e,~~s,1),i?this:this.resume()}alternate(){const t=this._reversed,e=this.iterationCount,s=this.iterationDuration,i=e===1/0?rt(c/s):e;return this._reversed=+(!this._alternate||i%2?!t:t),e===1/0?this.iterationProgress=this._reversed?1-this.iterationProgress:this.iterationProgress:this.seek(s*i-this._currentTime),this.resetTime(),this}play(){return this._reversed&&this.alternate(),this.resume()}reverse(){return this._reversed||this.alternate(),this.resume()}cancel(){return this._hasChildren?_t(this,t=>t.cancel(),!0):_t(this,ee),this._cancelled=1,this.pause()}stretch(t){const e=this.duration,s=ft(t);if(e===s)return this;const i=t/e,r=t<=d;return this.duration=r?d:s,this.iterationDuration=r?d:ft(this.iterationDuration*i),this._offset*=i,this._delay*=i,this._loopDelay*=i,this}revert(){Ft(this,0,1,0,1);const t=this._autoplay;return t&&t.linked&&t.linked===this&&t.revert(),this.cancel()}complete(t=0){return this.seek(this.duration,t).cancel()}then(t=_){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=_};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}function he(t){const e=O(t)?A.root.querySelectorAll(t):t;if(e instanceof NodeList||e instanceof HTMLCollection)return e}function de(t){if(X(t))return[];if(!e)return F(t)&&t.flat(1/0)||[t];if(F(t)){const e=t.flat(1/0),s=[];for(let t=0,i=e.length;t<i;t++){const i=e[t];if(!X(i)){const t=he(i);if(t)for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!X(i)){let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}else{let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}}return s}const s=he(t);return s?Array.from(s):[t]}function ce(t){const e=de(t),s=e.length;for(let t=0;t<s;t++){const s=e[t];if(!s[n]){s[n]=!0;const t=Y(s);(s.nodeType||t)&&(s[o]=!0,s[a]=t,s[l]={})}}return e}const ue={deg:1,rad:180/lt,turn:360},pe={},me=(t,e,s,r=!1)=>{const n=e.u,o=e.n;if(1===e.t&&n===s)return e;const a=o+n+s,l=pe[a];if(H(l)||r){let r;if(n in ue)r=o*ue[n]/ue[s];else{const e=100,a=t.cloneNode(),l=t.parentNode,h=l&&l!==i?l:i.body;h.appendChild(a);const d=a.style;d.width=e+n;const c=a.offsetWidth||e;d.width=e+s;const u=c/(a.offsetWidth||e);h.removeChild(a),r=u*o}e.n=r,pe[a]=r}else e.n=l;return e.t,e.u=s,e},fe=t=>t,ge=(t=1.68)=>e=>Q(e,+t),ye={in:t=>e=>t(e),out:t=>e=>1-t(1-e),inOut:t=>e=>e<.5?t(2*e)/2:1-t(-2*e+2)/2,outIn:t=>e=>e<.5?(1-t(1-2*e))/2:(t(2*e-1)+1)/2},_e=lt/2,be=2*lt,ve={[p]:ge,Quad:ge(2),Cubic:ge(3),Quart:ge(4),Quint:ge(5),Sine:t=>1-tt(t*_e),Circ:t=>1-J(1-t*t),Expo:t=>t?Q(2,10*t-10):0,Bounce:t=>{let e,s=4;for(;t<((e=Q(2,--s))-1)/11;);return 1/Q(4,3-s)-7.5625*Q((3*e-2)/22-t,2)},Back:(t=1.7)=>e=>(+t+1)*e*e*e-+t*e*e,Elastic:(t=1,e=.3)=>{const s=dt(+t,1,10),i=dt(+e,d,2),r=i/be*nt(1/s),n=be/i;return t=>0===t||1===t?t:-s*Q(2,-10*(1-t))*K((1-t-r)*n)}},Te=(()=>{const t={linear:fe,none:fe};for(let e in ye)for(let s in ve){const i=ve[s],r=ye[e];t[e+s]=s===p||"Back"===s||"Elastic"===s?(t,e)=>r(i(t,e)):r(i)}return t})(),xe={linear:fe,none:fe},Se=t=>{if(xe[t])return xe[t];if(t.indexOf("(")<=-1){const e=ye[t]||t.includes("Back")||t.includes("Elastic")?Te[t]():Te[t];return e?xe[t]=e:fe}{const e=t.slice(0,-1).split("("),s=Te[e[0]];return s?xe[t]=s(...e[1].split(",")):fe}},we=["steps(","irregular(","linear(","cubicBezier("],$e=t=>{if(O(t))for(let e=0,s=we.length;e<s;e++)if(B(t,we[e]))return console.warn(`String syntax for \`ease: "${t}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${t}\``),fe;return z(t)?t:O(t)?Se(t):fe},Ce={t:0,n:0,u:null,o:null,d:null,s:null},Ee={t:0,n:0,u:null,o:null,d:null,s:null},ke={},Ne={func:null},De={func:null},Ae=[null],Ie=[null,null],Re={to:null};let Le,Be,Pe=0,Fe=0;class Me extends le{constructor(t,e,s,i,n=!1,o=0,a){super(e,s,i),this._head,this._tail,++Fe;const l=ce(t),h=l.length,c=e.keyframes,p=c?yt(((t,e)=>{const s={};if(F(t)){const e=[].concat(...t.map(t=>Object.keys(t))).filter(j);for(let i=0,r=e.length;i<r;i++){const r=e[i],n=t.map(t=>{const e={};for(let s in t){const i=t[s];j(s)?s===r&&(e.to=i):e[s]=i}return e});s[r]=n}}else{const i=$t(e.duration,I.defaults.duration),r=Object.keys(t).map(e=>({o:parseFloat(e)/100,p:t[e]})).sort((t,e)=>t.o-e.o);r.forEach(t=>{const e=t.o,r=t.p;for(let t in r)if(j(t)){let n=s[t];n||(n=s[t]=[]);const o=e*i;let a=n.length,l=n[a-1];const h={to:r[t]};let d=0;for(let t=0;t<a;t++)d+=n[t].duration;1===a&&(h.from=l.to),r.ease&&(h.ease=r.ease),h.duration=o-(a?d:0),n.push(h)}return t});for(let t in s){const e=s[t];let i;for(let t=0,s=e.length;t<s;t++){const s=e[t],r=s.ease;s.ease=i||void 0,i=r}e[0].duration||e.shift()}}return s})(c,e),e):e,{id:f,delay:g,duration:y,ease:_,playbackEase:b,modifier:v,composition:T,onRender:x}=p,S=s?s.defaults:I.defaults,w=$t(_,S.ease),$=$t(b,S.playbackEase),C=$?$e($):null,E=!H(w.ease),k=E?w.ease:$t(_,C?"linear":S.ease),N=E?w.settlingDuration:$t(y,S.duration),D=$t(g,S.delay),A=v||S.modifier,R=H(T)&&h>=u?r.none:H(T)?S.composition:T,L=this._offset+(s?s._offset:0);E&&(w.parent=this);let B=NaN,P=NaN,Y=0,W=0;for(let t=0;t<h;t++){const e=l[t],i=o||t,h=a||l;let c=NaN,u=NaN;for(let t in p)if(j(t)){const o=kt(e,t),a=St(e,t),l=Vt(t,e,o);let f=p[t];const g=F(f);if(n&&!g&&(Ie[0]=f,Ie[1]=f,f=Ie),g){const t=f.length,e=!M(f[0]);2===t&&e?(Re.to=f,Ae[0]=Re,Le=Ae):t>2&&e?(Le=[],f.forEach((t,e)=>{e?1===e?(Ie[1]=t,Le.push(Ie)):Le.push(t):Ie[0]=t})):Le=f}else Ae[0]=f,Le=Ae;let y=null,_=null,b=NaN,v=0,T=0;for(let t=Le.length;T<t;T++){const n=Le[T];M(n)?Be=n:(Re.to=n,Be=Re),Ne.func=null,De.func=null;const c=Et($t(Be.composition,R),e,i,h,null,null),u=V(c)?c:r[c];y||u===r.none||(y=Qt(e,l));const p=y?y._tail:null,f=s&&p&&p.parent.parent===s?p:_,g=Et(Be.to,e,i,h,Ne,f);let x;M(g)&&!H(g.to)?(Be=g,x=g.to):x=g;const S=Et(Be.from,e,i,h,De,f),w=Be.ease||k,$=Et(w,e,i,h,null,f),C=z($)||O($)?$:w,E=!H(C)&&!H(C.ease),I=E?C.ease:C,B=E?C.settlingDuration:Et($t(Be.duration,t>1?Et(N,e,i,h,null,f)/t:N),e,i,h,null,f),P=Et($t(Be.delay,T?0:D),e,i,h,null,f),U=Be.modifier||A,q=!H(S),j=!H(x),G=F(x),Z=G||q&&j,Q=_?v:0,J=_?v+P:P,K=ct(L+J,12),tt=ct(L+Q,12);W||!q&&!G||(W=1);let et=_;if(u!==r.none){let t=y._head;for(;t&&t._absoluteStartTime<=K;)if(t._isOverridden||(et=t),t=t._nextRep,t&&t._absoluteStartTime>=K)for(;t;)Kt(t),t=t._nextRep}if(Z){It(G?Et(x[0],e,i,h,De,f):S,Ce),It(G?Et(x[1],e,i,h,Ne,f):x,Ee);const t=Dt(e,l,o,ke);0===Ce.t&&(et?1===et._valueType&&(Ce.t=1,Ce.u=et._unit):(It(t,Lt),1===Lt.t&&(Ce.t=1,Ce.u=Lt.u)))}else j?It(x,Ee):_?Rt(_,Ee):It(s&&et&&et.parent.parent===s?et._value:Dt(e,l,o,ke),Ee),q?It(S,Ce):_?Rt(_,Ce):It(s&&et&&et.parent.parent===s?et._value:Dt(e,l,o,ke),Ce);if(Ce.o&&(Ce.n=At(et?et._toNumber:It(Dt(e,l,o,ke),Lt).n,Ce.n,Ce.o)),Ee.o&&(Ee.n=At(Ce.n,Ee.n,Ee.o)),Ce.t!==Ee.t)if(3===Ce.t||3===Ee.t){const t=3===Ce.t?Ce:Ee,e=3===Ce.t?Ee:Ce;e.t=3,e.s=gt(t.s),e.d=t.d.map(()=>e.n)}else if(1===Ce.t||1===Ee.t){const t=1===Ce.t?Ce:Ee,e=1===Ce.t?Ee:Ce;e.t=1,e.u=t.u}else if(2===Ce.t||2===Ee.t){const t=2===Ce.t?Ce:Ee,e=2===Ce.t?Ee:Ce;e.t=2,e.d=t.d.map(()=>0)}if(Ce.u!==Ee.u){let t=Ee.u?Ce:Ee;t=me(e,t,Ee.u?Ee.u:Ce.u,!1)}if(Ee.d&&Ce.d&&Ee.d.length!==Ce.d.length){const t=Ce.d.length>Ee.d.length?Ce:Ee,e=t===Ce?Ee:Ce;e.d=t.d.map((t,s)=>H(e.d[s])?0:e.d[s]),e.s=gt(t.s)}const st=ct(+B||d,12);let it=ke[l];X(it)||(ke[l]=null);const rt=a?a.set:null;v=ct(J+st,12);const nt=Ce.d,ot=Ee.d,at=Ee.s,lt={parent:this,id:Pe++,property:l,target:e,_value:null,_toFunc:Ne.func,_fromFunc:De.func,_ease:$e(I),_fromNumbers:nt?gt(nt):m,_toNumbers:ot?gt(ot):m,_strings:at?gt(at):m,_fromNumber:Ce.n,_toNumber:Ee.n,_numbers:nt?gt(nt):m,_number:Ce.n,_unit:Ee.u,_modifier:U,_currentTime:0,_startTime:J,_delay:+P,_updateDuration:st,_changeDuration:st,_absoluteStartTime:K,_absoluteUpdateStartTime:tt,_absoluteEndTime:ct(L+v,12),_hasFromValue:q||G?1:0,_tweenType:o,_setter:rt,_valueType:Ee.t,_composition:u,_isOverlapped:0,_isOverridden:0,_renderTransforms:0,_inlineValue:it,_prevRep:null,_nextRep:null,_prevAdd:null,_nextAdd:null,_prev:null,_next:null};u!==r.none&&te(lt,y);const ht=lt._valueType;if(3===ht)lt._value=Bt(lt,1,-1);else if(1===ht)lt._value=`${U(lt._toNumber)}${lt._unit}`;else if(2===ht){const t=Ee.d;lt._value=`rgba(${ct(t[0],0)},${ct(t[1],0)},${ct(t[2],0)},${t[3]})`}else lt._value=U(lt._toNumber);isNaN(b)&&(b=lt._startTime),_=lt,Y++,vt(this,lt)}(isNaN(P)||b<P)&&(P=b),(isNaN(B)||v>B)&&(B=v),3===o&&(c=Y-T,u=Y)}if(!isNaN(c)){let t=0;_t(this,e=>{t>=c&&t<u&&(e._renderTransforms=1,e._composition===r.blend&&_t(Xt.animation,t=>{t.id===e.id&&(t._renderTransforms=1)})),t++})}}h||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation."),P?(_t(this,t=>{t._startTime-t._delay||(t._delay-=P),t._startTime-=P}),B-=P):P=0,B||(B=d,this.iterationCount=0),this.targets=l,this.id=H(f)?Fe:f,this.duration=B===d?d:mt((B+this._loopDelay)*this.iterationCount-this._loopDelay)||d,this.onRender=x||S.onRender,this._ease=C,this._delay=P,this.iterationDuration=B,!this._autoplay&&W&&this.onRender(this)}stretch(t){const e=this.duration;if(e===ft(t))return this;const s=t/e;return _t(this,t=>{t._updateDuration=ft(t._updateDuration*s),t._changeDuration=ft(t._changeDuration*s),t._currentTime*=s,t._delay*=s,t._startTime*=s,t._absoluteStartTime*=s,t._absoluteUpdateStartTime*=s,t._absoluteEndTime*=s}),super.stretch(t)}refresh(){return _t(this,t=>{const e=t._toFunc,s=t._fromFunc;(e||s)&&(s?(It(s(),Ce),Ce.u!==t._unit&&t.target[o]&&me(t.target,Ce,t._unit,!0),t._fromNumbers=gt(Ce.d),t._fromNumber=Ce.n):e&&(It(Dt(t.target,t.property,t._tweenType),Lt),t._fromNumbers=gt(Lt.d),t._fromNumber=Lt.n),e&&(It(e(),Ee),t._toNumbers=gt(Ee.d),t._strings=gt(Ee.s),t._toNumber=Ee.o?At(t._fromNumber,Ee.n,Ee.o):Ee.n))}),this.duration===d&&this.restart(),this}revert(){return super.revert(),Ot(this)}then(t){return super.then(t)}}const Ve=(t,e)=>{let s=t.iterationDuration;if(s===d&&(s=0),H(e))return s;if(V(+e))return+e;const i=e,r=t?t.labels:null,n=!X(r),o=((t,e)=>{if(B(e,"<")){const s="<"===e[1],i=t._tail,r=i?i._offset+i._delay:0;return s?r:r+i.duration}})(t,i),a=!H(o),l=k.exec(i);if(l){const t=l[0],e=i.split(t),h=n&&e[0]?r[e[0]]:s,d=a?o:n?h:s,c=+e[1];return At(d,c,t[0])}return a?o:n?H(r[i])?s:r[i]:s};function Oe(t,e,s,i,r,n){const o=V(t.duration)&&t.duration<=d?s-d:s;e.composition&&Ft(e,o,1,1,1);const a=i?new Me(i,t,e,o,!1,r,n):new le(t,e,o);return e.composition&&a.init(!0),vt(e,a),_t(e,t=>{const s=t._offset+t._delay+t.duration;s>e.iterationDuration&&(e.iterationDuration=s)}),e.duration=function(t){return mt((t.iterationDuration+t._loopDelay)*t.iterationCount-t._loopDelay)||d}(e),e}let ze=0;class He extends le{constructor(t={}){super(t,null,0),++ze,this.id=H(t.id)?ze:t.id,this.duration=0,this.labels={};const e=t.defaults,s=I.defaults;this.defaults=e?yt(e,s):s,this.composition=$t(t.composition,!0),this.onRender=t.onRender||s.onRender;const i=$t(t.playbackEase,s.playbackEase);this._ease=i?$e(i):null,this.iterationDuration=0}add(t,e,s){const i=M(e),r=M(t);if(i||r){if(this._hasChildren=!0,i){const i=e,r=I.editor&&I.editor.addTimelineChild,n=s&&"Stagger"===s.type&&I.editor,o=z(s)?s:null;if(o||n){const e=de(t),n=this.duration,a=this.iterationDuration,l=i.id;let h=0;const d=e.length,c=r?r(t,i,this.id,s,d):null,u=o||I.editor.resolveStagger(s.defaultValue);e.forEach(t=>{const s={...c||i};this.duration=n,this.iterationDuration=a,H(l)||(s.id=l+"-"+h),Oe(s,this,Ve(this,u(t,h,e,null,this)),t,h,e),h++})}else{const e=r?r(t,i,this.id,s):i,n=s&&s.type?s.defaultValue:s;Oe(e,this,Ve(this,n),t)}}else Oe(t,this,Ve(this,e));return this.composition&&this.init(!0),this}}sync(t,e){if(H(t)||t&&H(t.pause))return this;t.pause();const s=+(t.effect?t.effect.getTiming().duration:t.duration);H(t)||H(t.persist)||(t.persist=!0);const i=I.editor,r=i&&i.addTimelineChild;i&&i.addTimelineSync&&(e=i.addTimelineSync(t,e,this.id),i.addTimelineChild=null);const n=this.add(t,{currentTime:[0,s],duration:s,delay:0,ease:"linear",playbackEase:"linear"},e);return i&&(i.addTimelineChild=r),n}set(t,e,s){return H(e)?this:(e.duration=d,e.composition=r.replace,this.add(t,e,s))}call(t,e){return H(t)||t&&!z(t)?this:(I.editor&&I.editor.addTimelineCall&&(e=I.editor.addTimelineCall(t,e,this.id)),this.add({duration:0,delay:0,onComplete:()=>t(this)},e))}label(t,e){return H(t)||t&&!O(t)||(I.editor&&I.editor.addTimelineLabel&&(e=I.editor.addTimelineLabel(t,e,this.id)),this.labels[t]=Ve(this,e)),this}remove(t,e){return ie(de(t),this,e),this}stretch(t){const e=this.duration;if(e===ft(t))return this;const s=t/e,i=this.labels;_t(this,t=>t.stretch(t.duration*s));for(let t in i)i[t]*=s;return super.stretch(t)}refresh(){return _t(this,t=>{t.refresh&&t.refresh()}),this}revert(){return super.revert(),_t(this,t=>t.revert,!0),Ot(this)}then(t){return super.then(t)}}const Xe=t=>I.editor?I.editor.addTimeline(t):new He(t).init();class Ye{constructor(t,e){A.current&&A.current.register(this);const s=()=>{if(this.callbacks.completed)return;let t=!0;for(let e in this.animations)if(!this.animations[e].paused&&t){t=!1;break}t&&this.callbacks.complete()},i={onBegin:()=>{this.callbacks.completed&&this.callbacks.reset(),this.callbacks.play()},onComplete:s,onPause:s},n={v:1,autoplay:!1},o={};if(this.targets=[],this.animations={},this.callbacks=null,!H(t)&&!H(e)){for(let t in e){const s=e[t];j(t)?o[t]=s:B(t,"on")?n[t]=s:i[t]=s}this.callbacks=new Me({v:0},n);for(let e in o){const s=o[e],n=M(s);let a={},l="+=0";if(n){const t=s.unit;O(t)&&(l+=t)}else a.duration=s;a[e]=n?yt({to:l},s):l;const h=yt(i,a);h.composition=r.replace,h.autoplay=!1;const d=this.animations[e]=new Me(t,h,null,0,!1).init();this.targets.length||this.targets.push(...d.targets),this[e]=(t,e,s)=>{const i=d._head;if(H(t)&&i){const t=i._numbers;return t&&t.length?t:i._modifier(i._number)}return _t(d,e=>{if(F(t))for(let s=0,i=t.length;s<i;s++)H(e._numbers[s])||(e._fromNumbers[s]=e._modifier(e._numbers[s]),e._toNumbers[s]=t[s]);else e._fromNumber=e._modifier(e._number),e._toNumber=t;H(s)||(e._ease=$e(s)),e._currentTime=0}),H(e)||d.stretch(e),d.reset(!0).resume(),this}}}}revert(){for(let t in this.animations)this[t]=_,this.animations[t].revert();return this.animations={},this.targets.length=0,this.callbacks&&this.callbacks.revert(),this}}const We=(t,e,s,i,r)=>i+(t-e)/(s-e)*(r-i);var Ue=Object.freeze({__proto__:null,clamp:dt,damp:(t,e,s,i)=>i?1===i?e:pt(t,e,1-Math.exp(-i*s*.1)):t,degToRad:t=>t*Math.PI/180,lerp:pt,mapRange:We,padEnd:(t,e,s)=>`${t}`.padEnd(e,s),padStart:(t,e,s)=>`${t}`.padStart(e,s),radToDeg:t=>180*t/Math.PI,round:ct,roundPad:(t,e)=>(+t).toFixed(e),snap:ut,wrap:(t,e,s)=>((t-e)%(s-e)+(s-e))%(s-e)+e});const qe=10*u;class je{constructor(t={}){const e=!H(t.bounce)||!H(t.duration);this.timeStep=.02,this.restThreshold=5e-4,this.restDuration=200,this.maxDuration=6e4,this.maxRestSteps=this.restDuration/this.timeStep/u,this.maxIterations=this.maxDuration/this.timeStep/u,this.bn=dt($t(t.bounce,.5),-1,1),this.pd=dt($t(t.duration,628),10*I.timeScale,qe*I.timeScale),this.m=dt($t(t.mass,1),1,qe),this.s=dt($t(t.stiffness,100),d,qe),this.d=dt($t(t.damping,10),d,qe),this.v=dt($t(t.velocity,0),-1e4,qe),this.w0=0,this.zeta=0,this.wd=0,this.b=0,this.completed=!1,this.solverDuration=0,this.settlingDuration=0,this.parent=null,this.onComplete=t.onComplete||_,e&&this.calculateSDFromBD(),this.compute(),this.ease=t=>{const e=t*this.settlingDuration,s=this.completed,i=this.pd;return e>=i&&!s&&(this.completed=!0,this.onComplete(this.parent)),e<i&&s&&(this.completed=!1),0===t||1===t?t:this.solve(t*this.solverDuration)}}solve(t){const{zeta:e,w0:s,wd:i,b:r}=this;let n=t;return n=e<1?st(-n*e*s)*(1*tt(i*n)+r*K(i*n)):1===e?(1+r*n)*st(-n*s):((1+r)*st((-e*s+i)*n)+(1-r)*st((-e*s-i)*n))/2,1-n}calculateSDFromBD(){const t=1===I.timeScale?this.pd/u:this.pd;this.m=1,this.v=0,this.s=Q(2*lt/t,2),this.bn>=0?this.d=4*(1-this.bn)*lt/t:this.d=4*lt/(t*(1+this.bn)),this.s=ct(dt(this.s,d,qe),3),this.d=ct(dt(this.d,d,300),3)}calculateBDFromSD(){const t=2*lt/J(this.s);this.pd=t*(1===I.timeScale?u:1);const e=this.d/(2*J(this.s));this.bn=e<=1?1-this.d*t/(4*lt):4*lt/(this.d*t)-1,this.bn=ct(dt(this.bn,-1,1),3),this.pd=ct(dt(this.pd,10*I.timeScale,qe*I.timeScale),3)}compute(){const{maxRestSteps:t,maxIterations:e,restThreshold:s,timeStep:i,m:r,d:n,s:o,v:a}=this,l=this.w0=dt(J(o/r),d,u),h=this.zeta=n/(2*J(o*r));h<1?(this.wd=l*J(1-h*h),this.b=(h*l-a)/this.wd):1===h?(this.wd=0,this.b=-a+l):(this.wd=l*J(h*h-1),this.b=(h*l-a)/this.wd);let c=0,p=0,m=0;for(;p<=t&&m<=e;)et(1-this.solve(c))<s?p++:p=0,this.solverDuration=c,c+=i,m++;this.settlingDuration=ct(this.solverDuration*u,0)*I.timeScale}get bounce(){return this.bn}set bounce(t){this.bn=dt($t(t,1),-1,1),this.calculateSDFromBD(),this.compute()}get duration(){return this.pd}set duration(t){this.pd=dt($t(t,1),10*I.timeScale,qe*I.timeScale),this.calculateSDFromBD(),this.compute()}get stiffness(){return this.s}set stiffness(t){this.s=dt($t(t,100),d,qe),this.calculateBDFromSD(),this.compute()}get damping(){return this.d}set damping(t){this.d=dt($t(t,10),d,qe),this.calculateBDFromSD(),this.compute()}get mass(){return this.m}set mass(t){this.m=dt($t(t,1),1,qe),this.compute()}get velocity(){return this.v}set velocity(t){this.v=dt($t(t,0),-1e4,qe),this.compute()}}const Ge=t=>new je(t),Ze=t=>(console.warn("createSpring() is deprecated use spring() instead"),new je(t)),Qe={_head:null,_tail:null},Je=(t,e,s)=>{let i,r=Qe._head;for(;r;){const n=r._next,o=r.$el===t,a=!e||r.property===e,l=!s||r.parent===s;if(o&&a&&l){i=r.animation;try{i.commitStyles()}catch{}i.cancel(),bt(Qe,r);const t=r.parent;t&&(t._completed++,t.animations.length===t._completed&&(t.completed=!0,t.paused=!0,t.muteCallbacks||(t.onComplete(t),t._resolve(t))))}r=n}return i},Ke=(t,e,s,i,r)=>{const n=e.animate(i,r),o=r.delay+ +r.duration*r.iterations;n.playbackRate=t._speed,t.paused&&n.pause(),t.duration<o&&(t.duration=o,t.controlAnimation=n),t.animations.push(n),Je(e,s),vt(Qe,{parent:t,animation:n,$el:e,property:s,_next:null,_prev:null});const a=()=>Je(e,s,t);return n.oncancel=a,n.onremove=a,t.persist||(n.onfinish=a),n};function ts(t,e,s){const i=ce(t);if(!i.length)return;const[r]=i,n=kt(r,e),o=Vt(e,r,n);let a=Dt(r,o);if(H(s))return a;if(It(a,Lt),0===Lt.t||1===Lt.t){if(!1===s)return Lt.n;{const t=me(r,Lt,s,!1);return`${ct(t.n,I.precision)}${t.u}`}}}const es=(t,e)=>{if(!H(e))return I.editor&&I.editor.addSet?I.editor.addSet(t,e):(e.duration=d,e.composition=$t(e.composition,r.none),new Me(t,e,null,0,!0).resume())},ss=(t,e,s)=>{const i=de(t);for(let t=0,r=i.length;t<r;t++)Je(i[t],s,e&&e.controlAnimation&&e);return ie(i,e,s),i},is=t=>{t.cancelable&&t.preventDefault()};class rs{constructor(t){this.el=t,this.zIndex=0,this.parentElement=null,this.classList={add:_,remove:_}}get x(){return this.el.x||0}set x(t){this.el.x=t}get y(){return this.el.y||0}set y(t){this.el.y=t}get width(){return this.el.width||0}set width(t){this.el.width=t}get height(){return this.el.height||0}set height(t){this.el.height=t}getBoundingClientRect(){return{top:this.y,right:this.x,bottom:this.y+this.height,left:this.x+this.width}}}class ns{constructor(t){this.$el=t,this.inlineTransforms=[],this.point=new DOMPoint,this.inversedMatrix=this.getMatrix().inverse()}normalizePoint(t,e){return this.point.x=t,this.point.y=e,this.point.matrixTransform(this.inversedMatrix)}traverseUp(t){let e=this.$el.parentElement,s=0;for(;e&&e!==i;)t(e,s),e=e.parentElement,s++}getMatrix(){const t=new DOMMatrix;return this.traverseUp(e=>{const s=getComputedStyle(e).transform;if(s){const e=new DOMMatrix(s);t.preMultiplySelf(e)}}),t}remove(){this.traverseUp((t,e)=>{this.inlineTransforms[e]=t.style.transform,t.style.transform="none"})}revert(){this.traverseUp((t,e)=>{const s=this.inlineTransforms[e];""===s?t.style.removeProperty("transform"):t.style.transform=s})}}const os=(t,e)=>t&&z(t)?t(e):t;let as=0;class ls{constructor(t,e={}){if(!t)return;A.current&&A.current.register(this);const r=e.x,n=e.y,o=e.trigger,a=e.modifier,l=e.releaseEase,h=l&&$e(l),d=!H(l)&&!H(l.ease),u=M(r)&&!H(r.mapTo)?r.mapTo:"translateX",p=M(n)&&!H(n.mapTo)?n.mapTo:"translateY",m=os(e.container,this);this.containerArray=F(m)?m:null,this.$container=m&&!this.containerArray?de(m)[0]:i.body,this.useWin=this.$container===i.body,this.$scrollContainer=this.useWin?s:this.$container,this.$target=M(t)?new rs(t):de(t)[0],this.$trigger=de(o||t)[0],this.fixed="fixed"===ts(this.$target,"position"),this.isFinePointer=!0,this.containerPadding=[0,0,0,0],this.containerFriction=0,this.releaseContainerFriction=0,this.snapX=0,this.snapY=0,this.scrollSpeed=0,this.scrollThreshold=0,this.dragSpeed=0,this.dragThreshold=3,this.maxVelocity=0,this.minVelocity=0,this.velocityMultiplier=0,this.cursor=!1,this.releaseXSpring=d?l:Ge({mass:$t(e.releaseMass,1),stiffness:$t(e.releaseStiffness,80),damping:$t(e.releaseDamping,20)}),this.releaseYSpring=d?l:Ge({mass:$t(e.releaseMass,1),stiffness:$t(e.releaseStiffness,80),damping:$t(e.releaseDamping,20)}),this.releaseEase=h||Te.outQuint,this.hasReleaseSpring=d,this.onGrab=e.onGrab||_,this.onDrag=e.onDrag||_,this.onRelease=e.onRelease||_,this.onUpdate=e.onUpdate||_,this.onSettle=e.onSettle||_,this.onSnap=e.onSnap||_,this.onResize=e.onResize||_,this.onAfterResize=e.onAfterResize||_,this.disabled=[0,0];const f={};if(a&&(f.modifier=a),H(r)||!0===r)f[u]=0;else if(M(r)){const t=r,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[u]=e}else!1===r&&(f[u]=0,this.disabled[0]=1);if(H(n)||!0===n)f[p]=0;else if(M(n)){const t=n,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[p]=e}else!1===n&&(f[p]=0,this.disabled[1]=1);this.animate=new Ye(this.$target,f),this.xProp=u,this.yProp=p,this.destX=0,this.destY=0,this.deltaX=0,this.deltaY=0,this.scroll={x:0,y:0},this.coords=[this.x,this.y,0,0],this.snapped=[0,0],this.pointer=[0,0,0,0,0,0,0,0],this.scrollView=[0,0],this.dragArea=[0,0,0,0],this.containerBounds=[-c,c,c,-c],this.scrollBounds=[0,0,0,0],this.targetBounds=[0,0,0,0],this.window=[0,0],this.velocityStack=[0,0,0],this.velocityStackIndex=0,this.velocityTime=P(),this.velocity=0,this.angle=0,this.cursorStyles=null,this.triggerStyles=null,this.bodyStyles=null,this.targetStyles=null,this.touchActionStyles=null,this.transforms=new ns(this.$target),this.overshootCoords={x:0,y:0},this.overshootTicker=new le({autoplay:!1,onUpdate:()=>{this.updated=!0,this.manual=!0,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,1),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,1)},onComplete:()=>{this.manual=!1,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,0),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,0)}},null,0).init(),this.updateTicker=new le({autoplay:!1,onUpdate:()=>this.update()},null,0).init(),this.contained=!H(m),this.manual=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.enabled=!1,this.initialized=!1,this.activeProp=this.disabled[1]?u:p,this.animate.callbacks.onRender=()=>{const t=this.updated,e=!(this.grabbed&&t)&&this.released,s=this.x,i=this.y,r=s-this.coords[2],n=i-this.coords[3];this.deltaX=r,this.deltaY=n,this.coords[2]=s,this.coords[3]=i,t&&(r||n)&&this.onUpdate(this),e?(this.computeVelocity(r,n),this.angle=at(n,r)):this.updated=!1},this.animate.callbacks.onComplete=()=>{!this.grabbed&&this.released&&(this.released=!1),this.manual||(this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.onSettle(this))},this.resizeTicker=new le({autoplay:!1,duration:150*I.timeScale,onComplete:()=>{this.onResize(this),this.refresh(),this.onAfterResize(this)}}).init(),this.parameters=e,this.resizeObserver=new ResizeObserver(()=>{this.initialized?this.resizeTicker.restart():this.initialized=!0}),this.enable(),this.refresh(),this.resizeObserver.observe(this.$container),M(t)||this.resizeObserver.observe(this.$target)}computeVelocity(t,e){const s=this.velocityTime,i=P(),r=i-s;if(r<17)return this.velocity;this.velocityTime=i;const n=this.velocityStack,o=this.velocityMultiplier,a=this.minVelocity,l=this.maxVelocity,h=this.velocityStackIndex;n[h]=ct(dt(J(t*t+e*e)/r*o,a,l),5);const d=ot(n[0],n[1],n[2]);return this.velocity=d,this.velocityStackIndex=(h+1)%3,d}setX(t,e=!1){if(this.disabled[0])return;const s=ct(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destX=s,this.snapped[0]=ut(s,this.snapX),this.animate[this.xProp](s,0),this.manual=!1,this}setY(t,e=!1){if(this.disabled[1])return;const s=ct(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destY=s,this.snapped[1]=ut(s,this.snapY),this.animate[this.yProp](s,0),this.manual=!1,this}get x(){return ct(this.animate[this.xProp](),I.precision)}set x(t){this.setX(t,!1)}get y(){return ct(this.animate[this.yProp](),I.precision)}set y(t){this.setY(t,!1)}get progressX(){return We(this.x,this.containerBounds[3],this.containerBounds[1],0,1)}set progressX(t){this.setX(We(t,0,1,this.containerBounds[3],this.containerBounds[1]),!1)}get progressY(){return We(this.y,this.containerBounds[0],this.containerBounds[2],0,1)}set progressY(t){this.setY(We(t,0,1,this.containerBounds[0],this.containerBounds[2]),!1)}updateScrollCoords(){const t=ct(this.useWin?s.scrollX:this.$container.scrollLeft,0),e=ct(this.useWin?s.scrollY:this.$container.scrollTop,0),[i,r,n,o]=this.containerPadding,a=this.scrollThreshold;this.scroll.x=t,this.scroll.y=e,this.scrollBounds[0]=e-this.targetBounds[0]+i-a,this.scrollBounds[1]=t-this.targetBounds[1]-r+a,this.scrollBounds[2]=e-this.targetBounds[2]-n+a,this.scrollBounds[3]=t-this.targetBounds[3]+o-a}updateBoundingValues(){const t=this.$container;if(!t)return;const e=this.x,r=this.y,n=this.coords[2],o=this.coords[3];this.coords[2]=0,this.coords[3]=0,this.setX(0,!0),this.setY(0,!0),this.transforms.remove();const a=this.window[0]=s.innerWidth,l=this.window[1]=s.innerHeight,h=this.useWin,d=t.scrollWidth,c=t.scrollHeight,u=this.fixed,p=t.getBoundingClientRect(),[m,f,g,y]=this.containerPadding;this.dragArea[0]=h?0:p.left,this.dragArea[1]=h?0:p.top,this.scrollView[0]=h?dt(d,a,d):d,this.scrollView[1]=h?dt(c,l,c):c,this.updateScrollCoords();const{width:_,height:b,left:v,top:T,right:x,bottom:S}=t.getBoundingClientRect();this.dragArea[2]=ct(h?dt(_,a,a):_,0),this.dragArea[3]=ct(h?dt(b,l,l):b,0);const w=ts(t,"overflow"),$="visible"===w,C="hidden"===w;if(this.canScroll=!u&&this.contained&&(t===i.body&&$||!C&&!$)&&(d>this.dragArea[2]+y-f||c>this.dragArea[3]+m-g)&&(!this.containerArray||this.containerArray&&!F(this.containerArray)),this.contained){const e=this.scroll.x,s=this.scroll.y,i=this.canScroll,r=this.$target.getBoundingClientRect(),n=i?h?0:t.scrollLeft:0,o=i?h?0:t.scrollTop:0,d=i?this.scrollView[0]-n-_:0,c=i?this.scrollView[1]-o-b:0;this.targetBounds[0]=ct(r.top+s-(h?0:T),0),this.targetBounds[1]=ct(r.right+e-(h?a:x),0),this.targetBounds[2]=ct(r.bottom+s-(h?l:S),0),this.targetBounds[3]=ct(r.left+e-(h?0:v),0),this.containerArray?(this.containerBounds[0]=this.containerArray[0]+m,this.containerBounds[1]=this.containerArray[1]-f,this.containerBounds[2]=this.containerArray[2]-g,this.containerBounds[3]=this.containerArray[3]+y):(this.containerBounds[0]=-ct(r.top-(u?dt(T,0,l):T)+o-m,0),this.containerBounds[1]=-ct(r.right-(u?dt(x,0,a):x)-d+f,0),this.containerBounds[2]=-ct(r.bottom-(u?dt(S,0,l):S)-c+g,0),this.containerBounds[3]=-ct(r.left-(u?dt(v,0,a):v)+n-y,0))}this.transforms.revert(),this.coords[2]=n,this.coords[3]=o,this.setX(e,!0),this.setY(r,!0)}isOutOfBounds(t,e,s){if(!this.contained)return 0;const[i,r,n,o]=t,[a,l]=this.disabled,h=!a&&e<o||!a&&e>r,d=!l&&s<i||!l&&s>n;return h&&!d?1:!h&&d?2:h&&d?3:0}refresh(){const t=this.parameters,e=t.x,r=t.y,n=os(t.container,this),o=os(t.containerPadding,this)||0,a=F(o)?o:[o,o,o,o],l=this.x,h=this.y,d=os(t.cursor,this),c={onHover:"grab",onGrab:"grabbing"};if(d){const{onHover:t,onGrab:e}=d;t&&(c.onHover=t),e&&(c.onGrab=e)}const u=os(t.dragThreshold,this),p={mouse:3,touch:7};if(V(u))p.mouse=u,p.touch=u;else if(u){const{mouse:t,touch:e}=u;H(t)||(p.mouse=t),H(e)||(p.touch=e)}this.containerArray=F(n)?n:null,this.$container=n&&!this.containerArray?de(n)[0]:i.body,this.useWin=this.$container===i.body,this.$scrollContainer=this.useWin?s:this.$container,this.isFinePointer=matchMedia("(pointer:fine)").matches,this.containerPadding=$t(a,[0,0,0,0]),this.containerFriction=dt($t(os(t.containerFriction,this),.8),0,1),this.releaseContainerFriction=dt($t(os(t.releaseContainerFriction,this),this.containerFriction),0,1),this.snapX=os(M(e)&&!H(e.snap)?e.snap:t.snap,this),this.snapY=os(M(r)&&!H(r.snap)?r.snap:t.snap,this),this.scrollSpeed=$t(os(t.scrollSpeed,this),1.5),this.scrollThreshold=$t(os(t.scrollThreshold,this),20),this.dragSpeed=$t(os(t.dragSpeed,this),1),this.dragThreshold=this.isFinePointer?p.mouse:p.touch,this.minVelocity=$t(os(t.minVelocity,this),0),this.maxVelocity=$t(os(t.maxVelocity,this),50),this.velocityMultiplier=$t(os(t.velocityMultiplier,this),1),this.cursor=!1!==d&&c,this.updateBoundingValues();const[m,f,g,y]=this.containerBounds;this.setX(dt(l,y,f),!0),this.setY(dt(h,m,g),!0)}update(){if(this.updateScrollCoords(),this.canScroll){const[t,e,s,i]=this.containerPadding,[r,n]=this.scrollView,o=this.dragArea[2],a=this.dragArea[3],l=this.scroll.x,h=this.scroll.y,d=this.$container.scrollWidth,c=this.$container.scrollHeight,u=this.useWin?dt(d,this.window[0],d):d,p=this.useWin?dt(c,this.window[1],c):c,m=r-u,f=n-p;this.dragged&&m>0&&(this.coords[0]-=m,this.scrollView[0]=u),this.dragged&&f>0&&(this.coords[1]-=f,this.scrollView[1]=p);const g=10*this.scrollSpeed,y=this.scrollThreshold,[_,b]=this.coords,[v,T,x,S]=this.scrollBounds,w=ct(dt((b-v+t)/y,-1,0)*g,0),$=ct(dt((_-T-e)/y,0,1)*g,0),C=ct(dt((b-x-s)/y,0,1)*g,0),E=ct(dt((_-S+i)/y,-1,0)*g,0);if(w||C||E||$){const[t,e]=this.disabled;let s=l,i=h;t||(s=ct(dt(l+(E||$),0,r-o),0),this.coords[0]-=l-s),e||(i=ct(dt(h+(w||C),0,n-a),0),this.coords[1]-=h-i),this.useWin?this.$scrollContainer.scrollBy(-(l-s),-(h-i)):this.$scrollContainer.scrollTo(s,i)}}const[t,e,s,i]=this.containerBounds,[r,n,o,a,l,h]=this.pointer;this.coords[0]+=(r-l)*this.dragSpeed,this.coords[1]+=(n-h)*this.dragSpeed,this.pointer[4]=r,this.pointer[5]=n;const[d,c]=this.coords,[u,p]=this.snapped,m=(1-this.containerFriction)*this.dragSpeed;this.setX(d>e?e+(d-e)*m:d<i?i+(d-i)*m:d,!1),this.setY(c>s?s+(c-s)*m:c<t?t+(c-t)*m:c,!1),this.computeVelocity(r-l,n-h),this.angle=at(n-a,r-o);const[f,g]=this.snapped;(f!==u&&this.snapX||g!==p&&this.snapY)&&this.onSnap(this)}stop(){this.updateTicker.pause(),this.overshootTicker.pause();for(let t in this.animate.animations)this.animate.animations[t].pause();return ie([this],null,"x"),ie([this],null,"y"),ie([this],null,"progressX"),ie([this],null,"progressY"),ie([this.scroll]),ie([this.overshootCoords]),this}scrollInView(t,e=0,s=Te.inOutQuad){this.updateScrollCoords();const i=this.destX,r=this.destY,n=this.scroll,o=this.scrollBounds,a=this.canScroll;if(!this.containerArray&&this.isOutOfBounds(o,i,r)){const[l,h,d,u]=o,p=ct(dt(r-l,-c,0),0),m=ct(dt(i-h,0,c),0),f=ct(dt(r-d,0,c),0),g=ct(dt(i-u,-c,0),0);new Me(n,{x:ct(n.x+(g?g-e:m?m+e:0),0),y:ct(n.y+(p?p-e:f?f+e:0),0),duration:H(t)?350*I.timeScale:t,ease:s,onUpdate:()=>{this.canScroll=!1,this.$scrollContainer.scrollTo(n.x,n.y)}}).init().then(()=>{this.canScroll=a})}return this}handleHover(){this.isFinePointer&&this.cursor&&!this.cursorStyles&&(this.cursorStyles=es(this.$trigger,{cursor:this.cursor.onHover}))}animateInView(t,e=0,s=Te.inOutQuad){this.stop(),this.updateBoundingValues();const i=this.x,r=this.y,[n,o,a,l]=this.containerPadding,h=this.scroll.y-this.targetBounds[0]+n+e,d=this.scroll.x-this.targetBounds[1]-o-e,c=this.scroll.y-this.targetBounds[2]-a-e,u=this.scroll.x-this.targetBounds[3]+l+e,p=this.isOutOfBounds([h,d,c,u],i,r);if(p){const[e,n]=this.disabled,o=dt(ut(i,this.snapX),u,d),a=dt(ut(r,this.snapY),h,c),l=H(t)?350*I.timeScale:t;e||1!==p&&3!==p||this.animate[this.xProp](o,l,s),n||2!==p&&3!==p||this.animate[this.yProp](a,l,s)}return this}handleDown(t){const e=t.target;if(this.grabbed||"range"===e.type)return;t.stopPropagation(),this.grabbed=!0,this.released=!1,this.stop(),this.updateBoundingValues();const s=t.changedTouches,r=s?s[0].clientX:t.clientX,n=s?s[0].clientY:t.clientY,{x:o,y:a}=this.transforms.normalizePoint(r,n),[l,h,d,c]=this.containerBounds,u=(1-this.containerFriction)*this.dragSpeed,p=this.x,m=this.y;this.coords[0]=this.coords[2]=u?p>h?h+(p-h)/u:p<c?c+(p-c)/u:p:p,this.coords[1]=this.coords[3]=u?m>d?d+(m-d)/u:m<l?l+(m-l)/u:m:m,this.pointer[0]=o,this.pointer[1]=a,this.pointer[2]=o,this.pointer[3]=a,this.pointer[4]=o,this.pointer[5]=a,this.pointer[6]=o,this.pointer[7]=a,this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null);const f=ts(this.$target,"zIndex",!1);as=(f>as?f:as)+1,this.targetStyles=es(this.$target,{zIndex:as}),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.isFinePointer&&this.cursor&&(this.bodyStyles=es(i.body,{cursor:this.cursor.onGrab})),this.scrollInView(100,0,Te.out(3)),this.onGrab(this),i.addEventListener("touchmove",this),i.addEventListener("touchend",this),i.addEventListener("touchcancel",this),i.addEventListener("mousemove",this),i.addEventListener("mouseup",this),i.addEventListener("selectstart",this)}handleMove(t){if(!this.grabbed)return;const e=t.changedTouches,s=e?e[0].clientX:t.clientX,i=e?e[0].clientY:t.clientY,{x:r,y:n}=this.transforms.normalizePoint(s,i),o=r-this.pointer[6],a=n-this.pointer[7];let l=t.target,h=!1,d=!1,c=!1;for(;e&&l&&l!==this.$trigger;){const t=ts(l,"overflow-y");if("hidden"!==t&&"visible"!==t){const{scrollTop:t,scrollHeight:e,clientHeight:s}=l;if(e>s){c=!0,h=t<=3,d=t>=e-s-3;break}}l=l.parentElement}c&&(!h&&!d||h&&a<0||d&&a>0)?(this.pointer[0]=r,this.pointer[1]=n,this.pointer[2]=r,this.pointer[3]=n,this.pointer[4]=r,this.pointer[5]=n,this.pointer[6]=r,this.pointer[7]=n):(is(t),this.triggerStyles||(this.triggerStyles=es(this.$trigger,{pointerEvents:"none"})),this.$trigger.addEventListener("touchstart",is,{passive:!1}),this.$trigger.addEventListener("touchmove",is,{passive:!1}),this.$trigger.addEventListener("touchend",is),(this.dragged||!this.disabled[0]&&et(o)>this.dragThreshold||!this.disabled[1]&&et(a)>this.dragThreshold)&&(this.updateTicker.resume(),this.pointer[2]=this.pointer[0],this.pointer[3]=this.pointer[1],this.pointer[0]=r,this.pointer[1]=n,this.dragged=!0,this.released=!1,this.onDrag(this)))}handleUp(){if(!this.grabbed)return;this.updateTicker.pause(),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null);const[t,e]=this.disabled,[s,n,o,a,l,h]=this.pointer,[d,c,u,p]=this.containerBounds,[m,f]=this.snapped,g=this.releaseXSpring,y=this.releaseYSpring,_=this.releaseEase,b=this.hasReleaseSpring,v=this.overshootCoords,T=this.x,x=this.y,S=this.computeVelocity(s-l,n-h),w=this.angle=at(n-a,s-o),$=150*S,C=(1-this.releaseContainerFriction)*this.dragSpeed,E=T+tt(w)*$,k=x+K(w)*$,N=E>c?c+(E-c)*C:E<p?p+(E-p)*C:E,D=k>u?u+(k-u)*C:k<d?d+(k-d)*C:k,A=this.destX=dt(ct(ut(N,this.snapX),5),p,c),R=this.destY=dt(ct(ut(D,this.snapY),5),d,u),L=this.isOutOfBounds(this.containerBounds,E,k);let B=0,P=0,F=_,M=_,V=0;if(v.x=T,v.y=x,!t){const t=A===c?T>c?-1:1:T<p?-1:1,s=ct(T-A,0);g.velocity=e&&b?s?$*t/et(s):0:S;const{ease:i,settlingDuration:r,restDuration:n}=g;B=T===A?0:b?r:r-n*I.timeScale,b&&(F=i),B>V&&(V=B)}if(!e){const e=R===u?x>u?-1:1:x<d?-1:1,s=ct(x-R,0);y.velocity=t&&b?s?$*e/et(s):0:S;const{ease:i,settlingDuration:r,restDuration:n}=y;P=x===R?0:b?r:r-n*I.timeScale,b&&(M=i),P>V&&(V=P)}if(!b&&L&&C&&(B||P)){const t=r.blend;new Me(v,{x:{to:N,duration:.65*B},y:{to:D,duration:.65*P},ease:_,composition:t}).init(),new Me(v,{x:{to:A,duration:B},y:{to:R,duration:P},ease:_,composition:t}).init(),this.overshootTicker.stretch(ot(B,P)).restart()}else t||this.animate[this.xProp](A,B,F),e||this.animate[this.yProp](R,P,M);this.scrollInView(V,this.scrollThreshold,_);let O=!1;A!==m&&(this.snapped[0]=A,this.snapX&&(O=!0)),R!==f&&this.snapY&&(this.snapped[1]=R,this.snapY&&(O=!0)),O&&this.onSnap(this),this.grabbed=!1,this.dragged=!1,this.updated=!0,this.released=!0,this.onRelease(this),this.$trigger.removeEventListener("touchstart",is),this.$trigger.removeEventListener("touchmove",is),this.$trigger.removeEventListener("touchend",is),i.removeEventListener("touchmove",this),i.removeEventListener("touchend",this),i.removeEventListener("touchcancel",this),i.removeEventListener("mousemove",this),i.removeEventListener("mouseup",this),i.removeEventListener("selectstart",this)}reset(){return this.stop(),this.resizeTicker.pause(),this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.setX(0,!0),this.setY(0,!0),this.coords[0]=0,this.coords[1]=0,this.pointer[0]=0,this.pointer[1]=0,this.pointer[2]=0,this.pointer[3]=0,this.pointer[4]=0,this.pointer[5]=0,this.pointer[6]=0,this.pointer[7]=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this}enable(){return this.enabled||(this.enabled=!0,this.$target.classList.remove("is-disabled"),this.touchActionStyles=es(this.$trigger,{touchAction:this.disabled[0]?"pan-x":this.disabled[1]?"pan-y":"none"}),this.$trigger.addEventListener("touchstart",this,{passive:!0}),this.$trigger.addEventListener("mousedown",this,{passive:!0}),this.$trigger.addEventListener("mouseenter",this)),this}disable(){return this.enabled=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.touchActionStyles.revert(),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null),this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null),this.$target.classList.add("is-disabled"),this.$trigger.removeEventListener("touchstart",this),this.$trigger.removeEventListener("mousedown",this),this.$trigger.removeEventListener("mouseenter",this),i.removeEventListener("touchmove",this),i.removeEventListener("touchend",this),i.removeEventListener("touchcancel",this),i.removeEventListener("mousemove",this),i.removeEventListener("mouseup",this),i.removeEventListener("selectstart",this),this}revert(){return this.reset(),this.disable(),this.$target.classList.remove("is-disabled"),this.updateTicker.revert(),this.overshootTicker.revert(),this.resizeTicker.revert(),this.animate.revert(),this.resizeObserver.disconnect(),this}handleEvent(t){switch(t.type){case"mousedown":case"touchstart":this.handleDown(t);break;case"mousemove":case"touchmove":this.handleMove(t);break;case"mouseup":case"touchend":case"touchcancel":this.handleUp();break;case"mouseenter":this.handleHover();break;case"selectstart":is(t)}}}const hs=(t=_)=>new le({duration:1*I.timeScale,onComplete:t},null,0).resume(),ds=t=>{let e;return(...s)=>{let i,r,n,o,a;e&&(i=e.currentIteration,r=e.iterationProgress,n=e.reversed,o=e._alternate,a=e._startTime,e.revert());const l=t(...s);return l&&!z(l)&&l.revert&&(e=l),H(r)||(e.currentIteration=i,e.iterationProgress=(o&&i%2?!n:n)?1-r:r,e._startTime=a),l||_}};class cs{constructor(t={}){A.current&&A.current.register(this);const e=t.root;let r=i;e&&(r=e.current||e.nativeElement||de(e)[0]||i);const n=t.defaults,o=I.defaults,a=t.mediaQueries;if(this.defaults=n?yt(n,o):o,this.root=r,this.constructors=[],this.revertConstructors=[],this.revertibles=[],this.constructorsOnce=[],this.revertConstructorsOnce=[],this.revertiblesOnce=[],this.once=!1,this.onceIndex=0,this.methods={},this.matches={},this.mediaQueryLists={},this.data={},a)for(let t in a){const e=s.matchMedia(a[t]);this.mediaQueryLists[t]=e,e.addEventListener("change",this)}}register(t){(this.once?this.revertiblesOnce:this.revertibles).push(t)}execute(t){let e=A.current,s=A.root,i=I.defaults;A.current=this,A.root=this.root,I.defaults=this.defaults;const r=this.mediaQueryLists;for(let t in r)this.matches[t]=r[t].matches;const n=t(this);return A.current=e,A.root=s,I.defaults=i,n}refresh(){return this.onceIndex=0,this.execute(()=>{let t=this.revertibles.length,e=this.revertConstructors.length;for(;t--;)this.revertibles[t].revert();for(;e--;)this.revertConstructors[e](this);this.revertibles.length=0,this.revertConstructors.length=0,this.constructors.forEach(t=>{const e=t(this);z(e)&&this.revertConstructors.push(e)})}),this}add(t,e){if(this.once=!1,z(t)){const e=t;this.constructors.push(e),this.execute(()=>{const t=e(this);z(t)&&this.revertConstructors.push(t)})}else this.methods[t]=(...t)=>this.execute(()=>e(...t));return this}addOnce(t){if(this.once=!0,z(t)){const e=this.onceIndex++;if(this.constructorsOnce[e])return this;const s=t;this.constructorsOnce[e]=s,this.execute(()=>{const t=s(this);z(t)&&this.revertConstructorsOnce.push(t)})}return this}keepTime(t){this.once=!0;const e=this.onceIndex++,s=this.constructorsOnce[e];if(z(s))return s(this);const i=ds(t);let r;return this.constructorsOnce[e]=i,this.execute(()=>{r=i(this)}),r}handleEvent(t){"change"===t.type&&this.refresh()}revert(){const t=this.revertibles,e=this.revertConstructors,s=this.revertiblesOnce,i=this.revertConstructorsOnce,r=this.mediaQueryLists;let n=t.length,o=e.length,a=s.length,l=i.length;for(;n--;)t[n].revert();for(;o--;)e[o](this);for(;a--;)s[a].revert();for(;l--;)i[l](this);for(let t in r)r[t].removeEventListener("change",this);t.length=0,e.length=0,this.constructors.length=0,s.length=0,i.length=0,this.constructorsOnce.length=0,this.onceIndex=0,this.matches={},this.methods={},this.mediaQueryLists={},this.data={}}}const us=(t,e)=>t&&z(t)?t(e):t,ps=new Map;class ms{constructor(t){this.element=t,this.useWin=this.element===i.body,this.winWidth=0,this.winHeight=0,this.width=0,this.height=0,this.left=0,this.top=0,this.scale=1,this.zIndex=0,this.scrollX=0,this.scrollY=0,this.prevScrollX=0,this.prevScrollY=0,this.scrollWidth=0,this.scrollHeight=0,this.velocity=0,this.backwardX=!1,this.backwardY=!1,this.scrollTicker=new le({autoplay:!1,onBegin:()=>this.dataTimer.resume(),onUpdate:()=>{const t=this.backwardX||this.backwardY;_t(this,t=>t.handleScroll(),t)},onComplete:()=>this.dataTimer.pause()}).init(),this.dataTimer=new le({autoplay:!1,frameRate:30,onUpdate:t=>{const e=t.deltaTime,s=this.prevScrollX,i=this.prevScrollY,r=this.scrollX,n=this.scrollY,o=s-r,a=i-n;this.prevScrollX=r,this.prevScrollY=n,o&&(this.backwardX=s>r),a&&(this.backwardY=i>n),this.velocity=ct(e>0?Math.sqrt(o*o+a*a)/e:0,5)}}).init(),this.resizeTicker=new le({autoplay:!1,duration:250*I.timeScale,onComplete:()=>{this.updateWindowBounds(),this.refreshScrollObservers(),this.handleScroll()}}).init(),this.wakeTicker=new le({autoplay:!1,duration:500*I.timeScale,onBegin:()=>{this.scrollTicker.resume()},onComplete:()=>{this.scrollTicker.pause()}}).init(),this._head=null,this._tail=null,this.updateScrollCoords(),this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll(),this.resizeObserver=new ResizeObserver(()=>this.resizeTicker.restart()),this.resizeObserver.observe(this.element),(this.useWin?s:this.element).addEventListener("scroll",this,!1)}updateScrollCoords(){const t=this.useWin,e=this.element;this.scrollX=ct(t?s.scrollX:e.scrollLeft,0),this.scrollY=ct(t?s.scrollY:e.scrollTop,0)}updateWindowBounds(){this.winWidth=s.innerWidth,this.winHeight=(()=>{const t=i.createElement("div");i.body.appendChild(t),t.style.height="100lvh";const e=t.offsetHeight;return i.body.removeChild(t),e})()}updateBounds(){const t=getComputedStyle(this.element),e=this.element;let s,i;if(this.scrollWidth=e.scrollWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),this.scrollHeight=e.scrollHeight+parseFloat(t.marginTop)+parseFloat(t.marginBottom),this.updateWindowBounds(),this.useWin)s=this.winWidth,i=this.winHeight;else{const t=e.getBoundingClientRect();s=e.clientWidth,i=e.clientHeight,this.top=t.top,this.left=t.left,this.scale=t.width?s/t.width:t.height?i/t.height:1}this.width=s,this.height=i}refreshScrollObservers(){_t(this,t=>{t.ready&&t._debug&&t.removeDebug()}),this.updateBounds(),_t(this,t=>{t.ready&&(t.refresh(),t.onResize(t),t._debug&&t.debug())})}refresh(){this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll()}handleScroll(){this.updateScrollCoords(),this.wakeTicker.restart()}handleEvent(t){"scroll"===t.type&&this.handleScroll()}revert(){this.scrollTicker.cancel(),this.dataTimer.cancel(),this.resizeTicker.cancel(),this.wakeTicker.cancel(),this.resizeObserver.disconnect(),(this.useWin?s:this.element).removeEventListener("scroll",this),ps.delete(this.element)}}const fs=(t,e,s,i,r)=>{const n="min"===e,o="max"===e,a="top"===e||"left"===e||"start"===e||n?0:"bottom"===e||"right"===e||"end"===e||o?"100%":"center"===e?"50%":e,{n:l,u:h}=It(a,Lt);let d=l;return"%"===h?d=l/100*s:h&&(d=me(t,Lt,"px",!0).n),o&&i<0&&(d+=i),n&&r>0&&(d+=r),d},gs=(t,e,s,i,r)=>{let n;if(O(e)){const o=k.exec(e);if(o){const a=o[0],l=a[0],h=e.split(a),d="min"===h[0],c="max"===h[0],u=fs(t,h[0],s,i,r),p=fs(t,h[1],s,i,r);if(d){const e=At(fs(t,"min",s),p,l);n=e<u?u:e}else if(c){const e=At(fs(t,"max",s),p,l);n=e>u?u:e}else n=At(u,p,l)}else n=fs(t,e,s,i,r)}else n=e;return ct(n,0)},ys=t=>{let e;const s=t.targets;for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i[o]){e=i;break}}return e};let _s=0;const bs=["#FF4B4B","#FF971B","#FFC730","#F9F640","#7AFF5A","#18FF74","#17E09B","#3CFFEC","#05DBE9","#33B3F1","#638CF9","#C563FE","#FF4FCF","#F93F8A"];class vs{constructor(t={}){A.current&&A.current.register(this);const e=$t(t.sync,"play pause"),s=e?$e(e):null,r=e&&("linear"===e||e===fe),n=e&&!(s===fe&&!r),o=e&&(V(e)||!0===e||r),a=e&&O(e)&&!n&&!o,l=a?e.split(" ").map(t=>()=>{const e=this.linked;return e&&e[t]?e[t]():null}):null,h=a&&l.length>2;this.index=_s++,this.id=H(t.id)?this.index:t.id,this.container=(t=>{const e=t&&de(t)[0]||i.body;let s=ps.get(e);return s||(s=new ms(e),ps.set(e,s)),s})(t.container),this.target=null,this.linked=null,this.repeat=null,this.horizontal=null,this.enter=null,this.leave=null,this.sync=n||o||!!l,this.syncEase=n?s:null,this.syncSmooth=o?!0===e||r?1:e:null,this.onSyncEnter=l&&!h&&l[0]?l[0]:_,this.onSyncLeave=l&&!h&&l[1]?l[1]:_,this.onSyncEnterForward=l&&h&&l[0]?l[0]:_,this.onSyncLeaveForward=l&&h&&l[1]?l[1]:_,this.onSyncEnterBackward=l&&h&&l[2]?l[2]:_,this.onSyncLeaveBackward=l&&h&&l[3]?l[3]:_,this.onEnter=t.onEnter||_,this.onLeave=t.onLeave||_,this.onEnterForward=t.onEnterForward||_,this.onLeaveForward=t.onLeaveForward||_,this.onEnterBackward=t.onEnterBackward||_,this.onLeaveBackward=t.onLeaveBackward||_,this.onUpdate=t.onUpdate||_,this.onResize=t.onResize||_,this.onSyncComplete=t.onSyncComplete||_,this.reverted=!1,this.ready=!1,this.completed=!1,this.began=!1,this.isInView=!1,this.forceEnter=!1,this.hasEntered=!1,this.offset=0,this.offsetStart=0,this.offsetEnd=0,this.distance=0,this.prevProgress=0,this.thresholds=["start","end","end","start"],this.coords=[0,0,0,0],this.debugStyles=null,this.$debug=null,this._params=t,this._debug=$t(t.debug,!1),this._next=null,this._prev=null,vt(this.container,this),hs(()=>{if(!this.reverted){if(!this.target){const e=de(t.target)[0];this.target=e||i.body,this.refresh()}this._debug&&this.debug()}})}link(t){if(t&&(t.pause(),this.linked=t,H(t)||H(t.persist)||(t.persist=!0),!this._params.target)){let e;H(t.targets)?_t(t,t=>{t.targets&&!e&&(e=ys(t))}):e=ys(t),this.target=e||i.body,this.refresh()}return this}get velocity(){return this.container.velocity}get backward(){return this.horizontal?this.container.backwardX:this.container.backwardY}get scroll(){return this.horizontal?this.container.scrollX:this.container.scrollY}get progress(){const t=(this.scroll-this.offsetStart)/this.distance;return t===1/0||isNaN(t)?0:ct(dt(t,0,1),6)}refresh(){this.ready=!0,this.reverted=!1;const t=this._params;return this.repeat=$t(us(t.repeat,this),!0),this.horizontal="x"===$t(us(t.axis,this),"y"),this.enter=$t(us(t.enter,this),"end start"),this.leave=$t(us(t.leave,this),"start end"),this.updateBounds(),this.handleScroll(),this}removeDebug(){return this.$debug&&(this.$debug.parentNode.removeChild(this.$debug),this.$debug=null),this.debugStyles&&(this.debugStyles.revert(),this.$debug=null),this}debug(){this.removeDebug();const t=this.container,e=this.horizontal,s=t.element.querySelector(":scope > .animejs-onscroll-debug"),r=i.createElement("div"),n=i.createElement("div"),o=i.createElement("div"),a=bs[this.index%bs.length],l=t.useWin,h=l?t.winWidth:t.width,d=l?t.winHeight:t.height,c=t.scrollWidth,u=t.scrollHeight,p=this.container.width>360?320:260,m=e?0:10,f=e?10:0,g=e?24:p/2,y=e?g:15,_=e?60:g,b=e?_:y,v=e?"repeat-x":"repeat-y",T=t=>e?"0px "+t+"px":t+"px 2px",x=t=>`linear-gradient(${e?90:0}deg, ${t} 2px, transparent 1px)`,S=(t,e,s,i,r)=>`position:${t};left:${e}px;top:${s}px;width:${i}px;height:${r}px;`;r.style.cssText=`${S("absolute",m,f,e?c:p,e?p:u)}\n pointer-events: none;\n z-index: ${this.container.zIndex++};\n display: flex;\n flex-direction: ${e?"column":"row"};\n filter: drop-shadow(0px 1px 0px rgba(0,0,0,.75));\n `,n.style.cssText=`${S("sticky",0,0,e?h:g,e?g:d)}`,s||(n.style.cssText+=`background:\n ${x("#FFFF")}${T(g-10)} / 100px 100px ${v},\n ${x("#FFF8")}${T(g-10)} / 10px 10px ${v};\n `),o.style.cssText=`${S("relative",0,0,e?c:g,e?g:u)}`,s||(o.style.cssText+=`background:\n ${x("#FFFF")}${T(0)} / ${e?"100px 10px":"10px 100px"} ${v},\n ${x("#FFF8")}${T(0)} / ${e?"10px 0px":"0px 10px"} ${v};\n `);const w=[" enter: "," leave: "];this.coords.forEach((t,s)=>{const r=s>1,l=(r?0:this.offset)+t,m=s%2,f=l<b,g=l>(r?e?h:d:e?c:u)-b,v=(r?m&&!f:!m&&!f)||g,T=i.createElement("div"),x=i.createElement("div"),$=e?v?"right":"left":v?"bottom":"top",C=v?(e?_:y)+(r?e?-1:g?0:-2:e?-1:-2):e?1:0;x.innerHTML=`${this.id}${w[m]}${this.thresholds[s]}`,T.style.cssText=`${S("absolute",0,0,_,y)}\n display: flex;\n flex-direction: ${e?"column":"row"};\n justify-content: flex-${r?"start":"end"};\n align-items: flex-${v?"end":"start"};\n border-${$}: 2px solid ${a};\n `,x.style.cssText=`\n overflow: hidden;\n max-width: ${p/2-10}px;\n height: ${y};\n margin-${e?v?"right":"left":v?"bottom":"top"}: -2px;\n padding: 1px;\n font-family: ui-monospace, monospace;\n font-size: 10px;\n letter-spacing: -.025em;\n line-height: 9px;\n font-weight: 600;\n text-align: ${e&&v||!e&&!r?"right":"left"};\n white-space: pre;\n text-overflow: ellipsis;\n color: ${m?a:"rgba(0,0,0,.75)"};\n background-color: ${m?"rgba(0,0,0,.65)":a};\n border: 2px solid ${m?a:"transparent"};\n border-${e?v?"top-left":"top-right":v?"top-left":"bottom-left"}-radius: 5px;\n border-${e?v?"bottom-left":"bottom-right":v?"top-right":"bottom-right"}-radius: 5px;\n `,T.appendChild(x);let E=l-C+(e?1:0);T.style[e?"left":"top"]=`${E}px`,(r?n:o).appendChild(T)}),r.appendChild(n),r.appendChild(o),t.element.appendChild(r),s||r.classList.add("animejs-onscroll-debug"),this.$debug=r,"static"===ts(t.element,"position")&&(this.debugStyles=es(t.element,{position:"relative "}))}updateBounds(){let t;this._debug&&this.removeDebug();const e=this.target,s=this.container,r=this.horizontal,n=this.linked;let o,a=e;for(n&&(o=n.currentTime,n.seek(0,!0));a&&a!==s.element&&a!==i.body;){const e="sticky"===ts(a,"position")&&es(a,{position:"static"});a=a.parentElement,e&&(t||(t=[]),t.push(e))}const l=e.getBoundingClientRect(),h=s.scale,d=(r?l.left+s.scrollX-s.left:l.top+s.scrollY-s.top)*h,c=(r?l.width:l.height)*h,u=r?s.width:s.height,p=(r?s.scrollWidth:s.scrollHeight)-u,m=this.enter,f=this.leave;let g="start",y="end",_="end",b="start";if(O(m)){const t=m.split(" ");_=t[0],g=t.length>1?t[1]:g}else if(M(m)){const t=m;H(t.container)||(_=t.container),H(t.target)||(g=t.target)}else V(m)&&(_=m);if(O(f)){const t=f.split(" ");b=t[0],y=t.length>1?t[1]:y}else if(M(f)){const t=f;H(t.container)||(b=t.container),H(t.target)||(y=t.target)}else V(f)&&(b=f);const v=gs(e,g,c),T=gs(e,y,c),x=v+d-u,S=T+d-p,w=gs(e,_,u,x,S),$=gs(e,b,u,x,S),C=v+d-w,E=T+d-$,k=E-C;this.offset=d,this.offsetStart=C,this.offsetEnd=E,this.distance=k<=0?0:k,this.thresholds=[g,y,_,b],this.coords=[v,T,w,$],t&&t.forEach(t=>t.revert()),n&&n.seek(o,!0),this._debug&&this.debug()}handleScroll(){if(!this.ready)return;const t=this.linked,e=this.sync,s=this.syncEase,i=this.syncSmooth,r=t&&(s||i),n=this.horizontal,o=this.container,a=this.scroll,l=a<=this.offsetStart,h=a>=this.offsetEnd,d=!l&&!h,c=a===this.offsetStart||a===this.offsetEnd,u=!this.hasEntered&&c,p=this._debug&&this.$debug;let m=!1,f=!1,g=this.progress;if(l&&this.began&&(this.began=!1),g>0&&!this.began&&(this.began=!0),r){const e=t.progress;if(i&&V(i)){if(i<1){const t=1e-4,s=e<g&&1===g?t:e>g&&!g?-t:0;g=ct(pt(e,g,pt(.01,.2,i))+s,6)}}else s&&(g=s(g));m=g!==this.prevProgress,f=1===e,m&&!f&&i&&e&&o.wakeTicker.restart()}if(p){const t=n?o.scrollY:o.scrollX;p.style[n?"top":"left"]=t+10+"px"}(d&&!this.isInView||u&&!this.forceEnter&&!this.hasEntered)&&(d&&(this.isInView=!0),this.forceEnter&&this.hasEntered?d&&(this.forceEnter=!1):(p&&d&&(p.style.zIndex=""+this.container.zIndex++),this.onSyncEnter(this),this.onEnter(this),this.backward?(this.onSyncEnterBackward(this),this.onEnterBackward(this)):(this.onSyncEnterForward(this),this.onEnterForward(this)),this.hasEntered=!0,u&&(this.forceEnter=!0))),(d||!d&&this.isInView)&&(m=!0),m&&(r&&t.seek(t.duration*g),this.onUpdate(this)),!d&&this.isInView&&(this.isInView=!1,this.onSyncLeave(this),this.onLeave(this),this.backward?(this.onSyncLeaveBackward(this),this.onLeaveBackward(this)):(this.onSyncLeaveForward(this),this.onLeaveForward(this)),e&&!i&&(f=!0)),g>=1&&this.began&&!this.completed&&(e&&f||!e)&&(e&&this.onSyncComplete(this),this.completed=!0,(!this.repeat&&!t||!this.repeat&&t&&t.completed)&&this.revert()),g<1&&this.completed&&(this.completed=!1),this.prevProgress=g}revert(){if(this.reverted)return;const t=this.container;return bt(t,this),t._head||t.revert(),this._debug&&this.removeDebug(),this.reverted=!0,this.ready=!1,this}}const Ts=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,xs=(t=.5,e=0,s=.5,i=1)=>t===e&&s===i?fe:r=>0===r||1===r?r:Ts(((t,e,s)=>{let i,r,n=0,o=1,a=0;do{r=n+(o-n)/2,i=Ts(r,e,s)-t,i>0?o=r:n=r}while(et(i)>1e-7&&++a<100);return r})(r,t,s),e,i),Ss=(t=10,e)=>{const s=e?it:rt;return e=>s(dt(e,0,1)*t)*(1/t)},ws=(...t)=>{const e=t.length;if(!e)return fe;const s=e-1,i=t[0],r=t[s],n=[0],o=[Z(i)];for(let e=1;e<s;e++){const i=t[e],r=O(i)?i.trim().split(" "):[i],a=r[0],l=r[1];n.push(H(l)?e/s:Z(l)/100),o.push(Z(a))}return o.push(Z(r)),n.push(1),function(t){for(let e=1,s=n.length;e<s;e++){const s=n[e];if(t<=s){const i=n[e-1],r=o[e-1];return r+(o[e]-r)*(t-i)/(s-i)}}return o[o.length-1]}},$s=(t=10,e=1)=>{const s=[0],i=t-1;for(let t=1;t<i;t++){const r=s[t-1],n=t/i,o=n*(1-e)+(n+((t+1)/i-n)*Math.random())*e;s.push(dt(o,r,1))}return s.push(1),ws(...s)};var Cs=Object.freeze({__proto__:null,Spring:je,createSpring:Ze,cubicBezier:xs,eases:Te,irregular:$s,linear:ws,spring:Ge,steps:Ss});const Es=(t,e=100)=>{const s=[];for(let i=0;i<=e;i++)s.push(ct(t(i/e),4));return`linear(${s.join(", ")})`},ks={},Ns=t=>{let e=ks[t];if(e)return e;if(e="linear",O(t)){if(B(t,"linear")||B(t,"cubic-")||B(t,"steps")||B(t,"ease"))e=t;else if(B(t,"cubicB"))e=L(t);else{const s=Se(t);z(s)&&(e=s===fe?"linear":Es(s))}ks[t]=e}else if(z(t)){const s=Es(t);s&&(e=s)}else t.ease&&(e=Es(t.ease));return e},Ds=["x","y","z"],As=["perspective","width","height","margin","padding","top","right","bottom","left","borderWidth","fontSize","borderRadius",...Ds],Is=(()=>[...Ds,...g.filter(t=>["X","Y","Z"].some(e=>t.endsWith(e)))])();let Rs=null;const Ls=(t,e,s,i,r)=>{let n=O(e)?e:Et(e,s,i,r,null,null);return V(n)?As.includes(t)||B(t,"translate")?`${n}px`:B(t,"rotate")||B(t,"skew")?`${n}deg`:`${n}`:n},Bs=(t,e,s,i,r,n)=>{let o="0";const a=H(i)?getComputedStyle(t)[e]:Ls(e,i,t,r,n);return o=H(s)?F(i)?i.map(s=>Ls(e,s,t,r,n)):a:[Ls(e,s,t,r,n),a],o};class Ps{constructor(t,s){A.current&&A.current.register(this),X(Rs)&&(!e||!H(CSS)&&Object.hasOwnProperty.call(CSS,"registerProperty")?(g.forEach(t=>{const e=B(t,"skew"),s=B(t,"scale"),i=B(t,"rotate"),r=B(t,"translate"),n=i||e,o=n?"<angle>":s?"<number>":r?"<length-percentage>":"*";try{CSS.registerProperty({name:"--"+t,syntax:o,inherits:!1,initialValue:r?"0px":n?"0deg":s?"1":"0"})}catch{}}),Rs=!0):Rs=!1);const i=ce(t);i.length||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation.");const r=$t(s.autoplay,I.defaults.autoplay),n=!(!r||!r.link)&&r,o=s.alternate&&!0===s.alternate,a=s.reversed&&!0===s.reversed,h=$t(s.loop,I.defaults.loop),d=!0===h||h===1/0?1/0:V(h)?h+1:1,c=o?a?"alternate-reverse":"alternate":a?"reverse":"normal",m=1===I.timeScale?1:u;this.targets=i,this.animations=[],this.controlAnimation=null,this.onComplete=s.onComplete||I.defaults.onComplete,this.duration=0,this.muteCallbacks=!1,this.completed=!1,this.paused=!r||!1!==n,this.reversed=a,this.persist=$t(s.persist,I.defaults.persist),this.autoplay=r,this._speed=$t(s.playbackRate,I.defaults.playbackRate),this._resolve=_,this._completed=0,this._inlineStyles=[],i.forEach((t,e)=>{const r=t[l],n=Is.some(t=>s.hasOwnProperty(t)),o=t.style,a=this._inlineStyles[e]={},h=$t(s.ease,I.defaults.ease),u=Et(h,t,e,i,null,null),_=z(u)||O(u)?u:h,b=h.ease&&h,v=Ns(_),T=(b?b.settlingDuration:Et($t(s.duration,I.defaults.duration),t,e,i,null,null))*m,x=Et($t(s.delay,I.defaults.delay),t,e,i,null,null)*m,S=$t(s.composition,"replace");for(let l in s){if(!j(l))continue;const h={},u={iterations:d,direction:c,fill:"both",easing:v,duration:T,delay:x,composite:S},p=s[l],y=!!n&&(g.includes(l)?l:f.get(l)),_=y?"transform":l;let b;if(a[_]||(a[_]=o[_]),M(p)){const s=p,n=$t(s.ease,v),a=n.ease&&n,d=s.to,c=s.from;if(u.duration=(a?a.settlingDuration:Et($t(s.duration,T),t,e,i,null,null))*m,u.delay=Et($t(s.delay,x),t,e,i,null,null)*m,u.composite=$t(s.composition,S),u.easing=Ns(n),b=Bs(t,l,c,d,e,i),y?(h[`--${y}`]=b,r[y]=b):h[l]=Bs(t,l,c,d,e,i),Ke(this,t,l,h,u),!H(c))if(y){const t=`--${y}`;o.setProperty(t,h[t][0])}else o[l]=h[l][0]}else b=F(p)?p.map(s=>Ls(l,s,t,e,i)):Ls(l,p,t,e,i),y?(h[`--${y}`]=b,r[y]=b):h[l]=b,Ke(this,t,l,h,u)}if(n){let t=p;for(let e in r)t+=`${y[e]}var(--${e})) `;o.transform=t}}),n&&this.autoplay.link(this)}forEach(t){try{const e=O(t)?e=>e[t]():t;this.animations.forEach(e)}catch{}return this}get speed(){return this._speed}set speed(t){this._speed=+t,this.forEach(e=>e.playbackRate=t)}get currentTime(){const t=this.controlAnimation,e=I.timeScale;return this.completed?this.duration:t?+t.currentTime*(1===e?1:e):0}set currentTime(t){const e=t*(1===I.timeScale?1:u);this.forEach(t=>{!this.persist&&e>=this.duration&&t.play(),t.currentTime=e})}get progress(){return this.currentTime/this.duration}set progress(t){this.forEach(e=>e.currentTime=t*this.duration||0)}resume(){return this.paused?(this.paused=!1,this.forEach("play")):this}pause(){return this.paused?this:(this.paused=!0,this.forEach("pause"))}alternate(){return this.reversed=!this.reversed,this.forEach("reverse"),this.paused&&this.forEach("pause"),this}play(){return this.reversed&&this.alternate(),this.resume()}reverse(){return this.reversed||this.alternate(),this.resume()}seek(t,e=!1){return e&&(this.muteCallbacks=!0),t<this.duration&&(this.completed=!1),this.currentTime=t,this.muteCallbacks=!1,this.paused&&this.pause(),this}restart(){return this.completed=!1,this.seek(0,!0).resume()}commitStyles(){return this.forEach("commitStyles")}complete(){return this.seek(this.duration)}cancel(){return this.muteCallbacks=!0,this.commitStyles().forEach("cancel"),this.animations.length=0,requestAnimationFrame(()=>{this.targets.forEach(t=>{"none"===t.style.transform&&t.style.removeProperty("transform")})}),this}revert(){return this.cancel().targets.forEach((t,e)=>{const s=t.style,i=this._inlineStyles[e];for(let e in i){const r=i[e];H(r)||r===p?s.removeProperty(L(e)):t.style[e]=r}t.getAttribute("style")===p&&t.removeAttribute("style")}),this}then(t=_){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=_};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const Fs={animate:(t,e)=>new Ps(t,e),convertEase:Es};let Ms=0,Vs=0;const Os=(t,e)=>!(!t||!e)&&(t===e||t.contains(e)),zs=t=>{if(!t)return null;const e=t.style,s=e.transition||"";return e.setProperty("transition","none","important"),s},Hs=(t,e)=>{if(!t)return;const s=t.style;e?s.transition=e:s.removeProperty("transition")},Xs=t=>{const e=t.layout.transitionMuteStore,s=t.$el,i=t.$measure;s&&!e.has(s)&&e.set(s,zs(s)),i&&!e.has(i)&&e.set(i,zs(i))},Ys=t=>{t.forEach((t,e)=>Hs(e,t)),t.clear()},Ws={display:"none",visibility:"hidden",opacity:"0",transform:"none",position:"static"},Us=t=>{if(!t)return;const e=t.parentNode;e&&(e._head===t&&(e._head=t._next),e._tail===t&&(e._tail=t._prev),t._prev&&(t._prev._next=t._next),t._next&&(t._next._prev=t._prev),t._prev=null,t._next=null,t.parentNode=null)},qs=(t,e,s,i)=>{let r=t.dataset.layoutId;r||(r=t.dataset.layoutId="node-"+Vs++);const n=i||{};return n.$el=t,n.$measure=t,n.id=r,n.index=0,n.targets=null,n.delay=0,n.duration=0,n.ease=null,n.state=s,n.layout=s.layout,n.parentNode=e||null,n.isTarget=!1,n.isEntering=!1,n.isLeaving=!1,n.isInlined=!1,n.hasTransform=!1,n.inlineStyles=[],n.inlineTransforms=null,n.inlineTransition=null,n.branchAdded=!1,n.branchRemoved=!1,n.branchNotRendered=!1,n.sizeChanged=!1,n.hasVisibilitySwap=!1,n.hasDisplayNone=!1,n.hasVisibilityHidden=!1,n.measuredInlineTransform=null,n.measuredInlineTransition=null,n.measuredDisplay=null,n.measuredVisibility=null,n.measuredPosition=null,n.measuredHasDisplayNone=!1,n.measuredHasVisibilityHidden=!1,n.measuredIsVisible=!1,n.measuredIsRemoved=!1,n.measuredIsInsideRoot=!1,n.properties={transform:"none",x:0,y:0,left:0,top:0,clientLeft:0,clientTop:0,width:0,height:0},n.layout.properties.forEach(t=>n.properties[t]=0),n._head=null,n._tail=null,n._prev=null,n._next=null,n},js=(t,e,s,i)=>{const r=t.$el,n=t.layout.root,o=n===r,a=t.properties,l=t.state.rootNode,h=t.parentNode,d=s.transform,c=r.style.transform,u=!!h&&h.measuredIsRemoved,p=s.position;o&&(t.layout.absoluteCoords="fixed"===p||"absolute"===p),t.$measure=e,t.inlineTransforms=c,t.hasTransform=d&&"none"!==d,t.measuredIsInsideRoot=Os(n,e),t.measuredInlineTransform=null,t.measuredDisplay=s.display,t.measuredVisibility=s.visibility,t.measuredPosition=p,t.measuredHasDisplayNone="none"===s.display,t.measuredHasVisibilityHidden="hidden"===s.visibility,t.measuredIsVisible=!(t.measuredHasDisplayNone||t.measuredHasVisibilityHidden),t.measuredIsRemoved=t.measuredHasDisplayNone||t.measuredHasVisibilityHidden||u;let m=!1,f=r.previousSibling;for(;f&&(f.nodeType===Node.COMMENT_NODE||f.nodeType===Node.TEXT_NODE&&!f.textContent.trim());)f=f.previousSibling;if(f&&f.nodeType===Node.TEXT_NODE)m=!0;else{for(f=r.nextSibling;f&&(f.nodeType===Node.COMMENT_NODE||f.nodeType===Node.TEXT_NODE&&!f.textContent.trim());)f=f.nextSibling;m=null!==f&&f.nodeType===Node.TEXT_NODE}if(t.isInlined=m,t.hasTransform&&!i){const s=t.layout.transitionMuteStore;s.get(r)||(t.inlineTransition=zs(r)),e===r?r.style.transform="none":(s.get(e)||(t.measuredInlineTransition=zs(e)),t.measuredInlineTransform=e.style.transform,e.style.transform="none")}let g,y,_=0,b=0,v=0,T=0;if(!i){const t=e.getBoundingClientRect();_=t.left,b=t.top,v=t.width,T=t.height}for(let t in a){const e="transform"===t?d:s[t]||s.getPropertyValue&&s.getPropertyValue(t);H(e)||(a[t]=e)}if(a.left=_,a.top=b,a.clientLeft=i?0:e.clientLeft,a.clientTop=i?0:e.clientTop,o)t.layout.absoluteCoords?(g=_,y=b):(g=0,y=0);else{const e=h||l,s=e.properties.left,i=e.properties.top,r=e.properties.clientLeft,n=e.properties.clientTop;if(t.layout.absoluteCoords)g=_-s-r,y=b-i-n;else if(e===l){const t=l.properties.left,e=l.properties.top;g=_-t-l.properties.clientLeft,y=b-e-l.properties.clientTop}else g=_-s-r,y=b-i-n}return a.x=g,a.y=y,a.width=v,a.height=T,t},Gs=(t,e)=>{if(e)for(let s in e)t.properties[s]=e[s]},Zs=(t,e)=>{const s=Et(e.ease,t.$el,t.index,t.targets,null,null),i=z(s)?s:e.ease,r=!H(i)&&!H(i.ease);t.ease=r?i.ease:i,t.duration=r?i.settlingDuration:Et(e.duration,t.$el,t.index,t.targets,null,null),t.delay=Et(e.delay,t.$el,t.index,t.targets,null,null)},Qs=t=>{const e=t.$el.style,s=t.inlineStyles;s.length=0,t.layout.recordedProperties.forEach(t=>{s.push(t,e[t]||"")})},Js=t=>{const e=t.$el.style,s=t.inlineStyles;for(let t=0,i=s.length;t<i;t+=2){const i=s[t],r=s[t+1];r&&""!==r?e[i]=r:(e[i]="",e.removeProperty(i))}},Ks=t=>{const e=t.inlineTransforms,s=t.$el.style;!t.hasTransform||!e||t.hasTransform&&"none"===s.transform||e&&"none"===e?s.removeProperty("transform"):e&&(s.transform=e);const i=t.$measure;if(t.hasTransform&&i!==t.$el){const e=i.style,s=t.measuredInlineTransform;s&&""!==s?e.transform=s:e.removeProperty("transform")}t.measuredInlineTransform=null,null!==t.inlineTransition&&(Hs(t.$el,t.inlineTransition),t.inlineTransition=null),i!==t.$el&&null!==t.measuredInlineTransition&&(Hs(i,t.measuredInlineTransition),t.measuredInlineTransition=null)},ti=t=>{(t.measuredIsRemoved||t.hasVisibilitySwap)&&(t.$el.style.removeProperty("display"),t.$el.style.removeProperty("visibility"),t.hasVisibilitySwap&&(t.$measure.style.removeProperty("display"),t.$measure.style.removeProperty("visibility"))),t.layout.pendingRemoval.delete(t.$el)},ei=(t,e,s)=>(e.properties={...t.properties},e.state=s,e.isTarget=t.isTarget,e.hasTransform=t.hasTransform,e.inlineTransforms=t.inlineTransforms,e.measuredIsVisible=t.measuredIsVisible,e.measuredDisplay=t.measuredDisplay,e.measuredIsRemoved=t.measuredIsRemoved,e.measuredHasDisplayNone=t.measuredHasDisplayNone,e.measuredHasVisibilityHidden=t.measuredHasVisibilityHidden,e.hasDisplayNone=t.hasDisplayNone,e.isInlined=t.isInlined,e.hasVisibilityHidden=t.hasVisibilityHidden,e);class si{constructor(t){this.layout=t,this.rootNode=null,this.rootNodes=new Set,this.nodes=new Map,this.scrollX=0,this.scrollY=0}revert(){return this.forEachNode(t=>{this.layout.pendingRemoval.delete(t.$el),t.$el.removeAttribute("data-layout-id"),t.$measure.removeAttribute("data-layout-id")}),this.rootNode=null,this.rootNodes.clear(),this.nodes.clear(),this}getNode(t){if(t&&t.dataset)return this.nodes.get(t.dataset.layoutId)}getComputedValue(t,e){const s=this.getNode(t);if(s)return s.properties[e]}forEach(t,e){let s=t,i=0;for(;s;)if(e(s,i++),s._head)s=s._head;else if(s._next)s=s._next;else{for(;s&&!s._next;)s=s.parentNode;s&&(s=s._next)}}forEachRootNode(t){this.forEach(this.rootNode,t)}forEachNode(t){for(const e of this.rootNodes)this.forEach(e,t)}registerElement(t,e){if(!t||1!==t.nodeType)return null;this.layout.transitionMuteStore.has(t)||this.layout.transitionMuteStore.set(t,zs(t));const s=[t,e],i=this.layout.root;let r=null;for(;s.length;){const t=s.pop(),e=s.pop();if(!e||1!==e.nodeType||Y(e))continue;const n=!!t&&t.measuredIsRemoved,o=n?Ws:getComputedStyle(e),a=!!n||"none"===o.display,l=!!n||"hidden"===o.visibility,h=!a&&!l,d=e.dataset.layoutId,c=Os(i,e);let u=d?this.nodes.get(d):null;if(u&&u.$el!==e){const a=Os(i,u.$el),l=u.measuredIsVisible;if(a||!c&&(c||l||!h)){if(a&&!l&&h){js(u,e,o,n);let t=e.lastElementChild;for(;t;)s.push(t,u),t=t.previousElementSibling;r||(r=u);continue}{let i=e.lastElementChild;for(;i;)s.push(i,t),i=i.previousElementSibling;r||(r=u);continue}}Us(u),u=qs(e,t,this,u)}else u=qs(e,t,this,u);u.branchAdded=!1,u.branchRemoved=!1,u.branchNotRendered=!1,u.isTarget=!1,u.sizeChanged=!1,u.hasVisibilityHidden=l,u.hasDisplayNone=a,u.hasVisibilitySwap=l&&!u.measuredHasVisibilityHidden||a&&!u.measuredHasDisplayNone,this.nodes.set(u.id,u),u.parentNode=t||null,u._prev=null,u._next=null,t?(this.rootNodes.delete(u),t._head?(t._tail._next=u,u._prev=t._tail,t._tail=u):(t._head=u,t._tail=u)):this.rootNodes.add(u),js(u,u.$el,o,n);let p=e.lastElementChild;for(;p;)s.push(p,u),p=p.previousElementSibling;r||(r=u)}return r}ensureDetachedNode(t,e){if(!t||t===this.layout.root)return null;const s=t.dataset.layoutId,i=s?this.nodes.get(s):null;if(i&&i.$el===t)return i;let r=null,n=t.parentElement;for(;n&&n!==this.layout.root;){if(e.has(n)){r=this.ensureDetachedNode(n,e);break}n=n.parentElement}return this.registerElement(t,r)}record(){const t=this.layout,e=t.children,s=t.root,i=F(e)?e:[e],r=[],n="*"===e?s:A.root,o=[];let a=s.parentElement;for(;a&&1===a.nodeType;){const t=getComputedStyle(a);if(t.transform&&"none"!==t.transform){const t=a.style.transform||"",e=zs(a);o.push(a,t,e),a.style.transform="none"}a=a.parentElement}for(let t=0,e=i.length;t<e;t++){const e=i[t];r[t]=O(e)?n.querySelectorAll(e):e}const l=ce(r);this.nodes.clear(),this.rootNodes.clear();const h=this.registerElement(s,null);h.isTarget=!0,this.rootNode=h;const d=new Set;let c=0;const u=[];this.nodes.forEach(t=>{u.push(t.$el)}),this.nodes.forEach((t,e)=>{t.index=c++,t.targets=u,t&&t.measuredIsInsideRoot&&d.add(e)});const p=new Set,m=[];for(let t=0,e=l.length;t<e;t++){const e=l[t];if(e&&1===e.nodeType&&e!==s){if(!Os(s,e)){const t=e.dataset.layoutId;if(!t||!d.has(t))continue}p.has(e)||(p.add(e),m.push(e))}}for(let t=0,e=m.length;t<e;t++)this.ensureDetachedNode(m[t],p);for(let t=0,e=l.length;t<e;t++){const e=l[t],s=this.getNode(e);if(s){let t=s;for(;t&&!t.isTarget;)t.isTarget=!0,t=t.parentNode}}this.scrollX=window.scrollX,this.scrollY=window.scrollY,this.forEachNode(Ks);for(let t=0,e=o.length;t<e;t+=3){const e=o[t],s=o[t+1],i=o[t+2];s&&""!==s?e.style.transform=s:e.style.removeProperty("transform"),Hs(e,i)}return this}}function ii(t){const e={},s={};for(let i in t){const r=t[i];"duration"===i||"delay"===i||"ease"===i?s[i]=r:e[i]=r}return[e,s]}class ri{constructor(t,e={}){A.current&&A.current.register(this);const s=ii(e.swapAt),i=ii(e.enterFrom),r=ii(e.leaveTo),n=e.properties;if(e.duration=$t(e.duration,350),e.delay=$t(e.delay,0),e.ease=$t(e.ease,"inOut(3.5)"),this.params=e,this.root=ce(t)[0],this.id=e.id||Ms++,this.children=e.children||"*",this.absoluteCoords=!1,this.swapAtParams=yt(e.swapAt||{opacity:0},{ease:"inOut(1.75)"}),this.enterFromParams=e.enterFrom||{opacity:0},this.leaveToParams=e.leaveTo||{opacity:0},this.properties=new Set(["opacity","fontSize","color","backgroundColor","borderRadius","border","filter","clipPath"]),s[0])for(let t in s[0])this.properties.add(t);if(i[0])for(let t in i[0])this.properties.add(t);if(r[0])for(let t in r[0])this.properties.add(t);if(n)for(let t=0,e=n.length;t<e;t++)this.properties.add(n[t]);this.recordedProperties=new Set(["display","visibility","translate","position","left","top","marginLeft","marginTop","width","height","maxWidth","maxHeight","minWidth","minHeight"]),this.properties.forEach(t=>this.recordedProperties.add(t)),this.pendingRemoval=new WeakSet,this.transitionMuteStore=new Map,this.oldState=new si(this),this.newState=new si(this),this.timeline=null,this.transformAnimation=null,this.animating=[],this.swapping=[],this.leaving=[],this.entering=[],this.oldState.record(),Ys(this.transitionMuteStore)}revert(){return this.root.classList.remove("is-animated"),this.timeline&&(this.timeline.complete(),this.timeline=null),this.transformAnimation&&(this.transformAnimation.complete(),this.transformAnimation=null),this.animating.length=this.swapping.length=this.leaving.length=this.entering.length=0,this.oldState.revert(),this.newState.revert(),requestAnimationFrame(()=>Ys(this.transitionMuteStore)),this}record(){return this.transformAnimation&&(this.transformAnimation.cancel(),this.transformAnimation=null),this.oldState.record(),this.timeline&&(this.timeline.cancel(),this.timeline=null),this.newState.forEachRootNode(Js),this}animate(t={}){const e={ease:$t(t.ease,this.params.ease),delay:$t(t.delay,this.params.delay),duration:$t(t.duration,this.params.duration)},s={id:this.id},i=$t(t.onComplete,this.params.onComplete),r=$t(t.onPause,this.params.onPause);for(let e in D)"ease"!==e&&"duration"!==e&&"delay"!==e&&(H(t[e])?H(this.params[e])||(s[e]=this.params[e]):s[e]=t[e]);s.onComplete=()=>{const e=t.autoplay,s=I.editor;if(e&&e.linked||s&&s.showPanel)i&&i(this.timeline);else{this.transformAnimation&&this.transformAnimation.cancel(),f.forEachRootNode(t=>{ti(t),Js(t)});for(let t=0,e=S.length;t<e;t++){const e=S[t];e.style.transform=f.getComputedValue(e,"transform")}this.root.classList.contains("is-animated")&&(this.root.classList.remove("is-animated"),i&&i(this.timeline)),requestAnimationFrame(()=>{this.root.classList.contains("is-animated")||Ys(this.transitionMuteStore)})}},s.onPause=()=>{const e=t.autoplay;if(e&&e.linked)return i&&i(this.timeline),void(r&&r(this.timeline));this.root.classList.contains("is-animated")&&(this.transformAnimation&&this.transformAnimation.cancel(),f.forEachRootNode(ti),this.root.classList.remove("is-animated"),i&&i(this.timeline),r&&r(this.timeline))},s.composition=!1;const n=yt(yt(t.swapAt||{},this.swapAtParams),e),o=yt(yt(t.enterFrom||{},this.enterFromParams),e),a=yt(yt(t.leaveTo||{},this.leaveToParams),e),[l,h]=ii(n),[d,c]=ii(o),[u,p]=ii(a),m=this.oldState,f=this.newState,g=this.animating,y=this.swapping,_=this.entering,b=this.leaving,v=this.pendingRemoval;g.length=y.length=_.length=b.length=0,m.forEachRootNode(Xs),f.record(),f.forEachRootNode(Qs);const T=[],x=[],S=[],w=[],$=f.rootNode,C=$.$el;f.forEachRootNode(t=>{const e=t.$el,s=t.id,i=t.parentNode,r=!!i&&i.branchAdded,n=!!i&&i.branchRemoved,o=!!i&&i.branchNotRendered;let a=m.nodes.get(s);const l=!a;l?(a=ei(t,{},m),m.nodes.set(s,a),a.measuredIsRemoved=!0):a.measuredIsRemoved&&!t.measuredIsRemoved&&(ei(t,a,m),a.measuredIsRemoved=!0);const h=a.parentNode,c=(h?h.id:null)!==(i?i.id:null),p=a.$el!==t.$el,y=a.measuredIsRemoved,x=t.measuredIsRemoved;if(!a.measuredIsRemoved&&!x&&!l&&(c||p)){const t=a.properties.left,e=a.properties.top,s=i||f.rootNode,r=s.id?m.nodes.get(s.id):null,n=r?r.properties.left:s.properties.left,o=r?r.properties.top:s.properties.top,l=r?r.properties.clientLeft:s.properties.clientLeft,h=r?r.properties.clientTop:s.properties.clientTop;a.properties.x=t-n-l,a.properties.y=e-o-h}t.hasVisibilitySwap&&(t.hasVisibilityHidden&&(t.$el.style.visibility="visible",t.$measure.style.visibility="hidden"),t.hasDisplayNone&&(t.$el.style.display=a.measuredDisplay||t.measuredDisplay||"",t.$measure.style.visibility="hidden"));const S=v.has(e),w=a.measuredIsVisible,C=t.measuredIsVisible,E=!w&&C&&!o,k=!x&&(y||S)&&!r,N=x&&!y&&!n,D=N||x&&S&&!n;t.branchAdded=r||k,t.branchRemoved=n||D,t.branchNotRendered=o||x,x&&w&&(t.$el.style.display=a.measuredDisplay,t.$el.style.visibility="visible",ei(a,t,f)),N?(t.isTarget&&(b.push(e),t.isLeaving=!0),v.add(e)):!x&&S&&v.delete(e),k&&!o||E?(Gs(a,d),t.isTarget&&(_.push(e),t.isEntering=!0)):D&&!o&&Gs(t,u),t===$||!t.isTarget||t.isEntering||t.isLeaving||g.push(e),T.push(e)});let E=0,k=0,N=0;f.forEachRootNode(t=>{const s=t.$el,i=t.parentNode,r=m.nodes.get(t.id),n=t.properties,o=r.properties;let a=i!==$&&i;for(;a&&!a.isTarget&&a!==$;)a=a.parentNode;t===$?(t.index=0,t.targets=g,Zs(t,e)):t.isEntering?(t.index=a?a.index:E,t.targets=a?g:_,Zs(t,c),E++):t.isLeaving?(t.index=a?a.index:k,t.targets=a?g:b,k++,Zs(t,p)):t.isTarget?(t.index=N++,t.targets=g,Zs(t,e)):(t.index=a?a.index:0,t.targets=g,Zs(t,h)),r.index=t.index,r.targets=t.targets;for(let e in n)n[e]=Et(n[e],s,t.index,t.targets,null,null),o[e]=Et(o[e],s,r.index,r.targets,null,null);const d=Math.abs(n.width-o.width)>1,u=Math.abs(n.height-o.height)>1;if(t.sizeChanged=d||u,t.isTarget&&(!t.measuredIsRemoved&&r.measuredIsVisible||t.measuredIsRemoved&&t.measuredIsVisible)){"none"===n.transform&&"none"===o.transform||(t.hasTransform=!0,S.push(s));for(let t in n)if("transform"!==t&&n[t]!==o[t]){x.push(s);break}}t.isTarget||(y.push(s),t.sizeChanged&&i&&i.isTarget&&i.sizeChanged&&(l.transform&&(t.hasTransform=!0,S.push(s)),w.push(s)))});const A={delay:t=>f.getNode(t).delay,duration:t=>f.getNode(t).duration,ease:t=>f.getNode(t).ease};if(s.defaults=A,this.timeline=Xe(s),!x.length&&!S.length&&!y.length)return Ys(this.transitionMuteStore),this.timeline.complete();if(T.length){this.root.classList.add("is-animated");for(let t=0,e=T.length;t<e;t++){const e=T[t],s=e.dataset.layoutId,i=m.nodes.get(s),r=f.nodes.get(s),n=i.properties;r.isInlined||("grid"!==i.measuredDisplay&&"grid"!==r.measuredDisplay||e.style.setProperty("display","block","important"),(e!==C||this.absoluteCoords)&&(e.style.position=this.absoluteCoords?"fixed":"absolute",e.style.left="0px",e.style.top="0px",e.style.marginLeft="0px",e.style.marginTop="0px",e.style.translate=`${n.x}px ${n.y}px`),e===C&&"static"===r.measuredPosition&&(e.style.position="relative",e.style.left="0px",e.style.top="0px")),e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none"}m.scrollX===window.scrollX&&m.scrollY===window.scrollY||requestAnimationFrame(()=>window.scrollTo(m.scrollX,m.scrollY));for(let t=0,e=x.length;t<e;t++){const e=x[t],s=e.dataset.layoutId,i=m.nodes.get(s),r=f.nodes.get(s),n=i.properties,o=r.properties;let a=!1;const l={composition:"none"};n.width!==o.width&&(l.width=[n.width,o.width],a=!0),n.height!==o.height&&(l.height=[n.height,o.height],a=!0),r.hasTransform||r.isInlined||(l.translate=[`${n.x}px ${n.y}px`,`${o.x}px ${o.y}px`],a=!0),this.properties.forEach(t=>{const e=n[t],s=o[t];"transform"!==t&&e!==s&&(l[t]=[e,s],a=!0)}),a&&this.timeline.add(e,l,0)}}if(y.length){for(let t=0,e=y.length;t<e;t++){const e=y[t],s=m.getNode(e),i=s.properties;e.style.width=`${i.width}px`,e.style.height=`${i.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none",s.isInlined||(e.style.translate=`${i.x}px ${i.y}px`),this.properties.forEach(t=>{"transform"!==t&&(e.style[t]=`${m.getComputedValue(e,t)}`)})}for(let t=0,e=y.length;t<e;t++){const e=y[t],s=f.getNode(e),i=s.properties;this.timeline.call(()=>{e.style.width=`${i.width}px`,e.style.height=`${i.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none",s.isInlined||(e.style.translate=`${i.x}px ${i.y}px`),this.properties.forEach(t=>{"transform"!==t&&(e.style[t]=`${f.getComputedValue(e,t)}`)})},s.delay+s.duration/2)}if(w.length){const t=$e(f.nodes.get(w[0].dataset.layoutId).ease),e=e=>1-t(1-e),s={};if(l)for(let t in l)"transform"!==t&&(s[t]=[{from:e=>m.getComputedValue(e,t),to:l[t]},{from:l[t],to:e=>f.getComputedValue(e,t),ease:e}]);this.timeline.add(w,s,0)}}const R=S.length;if(R){for(let t=0;t<R;t++){const e=S[t],s=f.getNode(e);s.isInlined||(e.style.translate=`${m.getComputedValue(e,"x")}px ${m.getComputedValue(e,"y")}px`),e.style.transform=m.getComputedValue(e,"transform"),w.includes(e)&&(s.ease=Et(n.ease,e,s.index,s.targets,null,null),s.duration=Et(n.duration,e,s.index,s.targets,null,null))}this.transformAnimation=Fs.animate(S,{translate:t=>f.getNode(t).isInlined?"0px 0px":`${f.getComputedValue(t,"x")}px ${f.getComputedValue(t,"y")}px`,transform:t=>{const e=f.getComputedValue(t,"transform");if(!w.includes(t))return e;const s=m.getComputedValue(t,"transform"),i=f.getNode(t);return[s,Et(l.transform,t,i.index,i.targets,null,null),e]},autoplay:!1,...A}),this.timeline.sync(this.transformAnimation,0)}return this.timeline.init()}update(t,e={}){return this.record(),t(this),this.animate(e)}}const ni=Ue,oi={},ai=t=>(...e)=>{const s=t(...e);return new Proxy(_,{apply:(t,e,[i])=>s(i),get:(t,e)=>{if(oi[e])return ai((...t)=>{const i=oi[e](...t);return t=>i(s(t))})}})},li=(t,e,s=0)=>{const i=(...t)=>(t.length<e.length?ai(((t,e=0)=>(...s)=>e?e=>t(...s,e):e=>t(e,...s))(e,s)):e)(...t);return oi[t]||(oi[t]=i),i},hi=li("roundPad",ni.roundPad),di=li("padStart",ni.padStart),ci=li("padEnd",ni.padEnd),ui=li("wrap",ni.wrap),pi=li("mapRange",ni.mapRange),mi=li("degToRad",ni.degToRad),fi=li("radToDeg",ni.radToDeg),gi=li("snap",ni.snap),yi=li("clamp",ni.clamp),_i=li("round",ni.round),bi=li("lerp",ni.lerp,1),vi=li("damp",ni.damp,1),Ti=(t=0,e=1,s=0)=>{const i=10**s;return Math.floor((Math.random()*(e-t+1/i)+t)*i)/i};let xi=0;const Si=(t,e=0,s=1,i=0)=>{let r=void 0===t?xi++:t;return(t=e,n=s,o=i)=>{r+=1831565813,r=Math.imul(r^r>>>15,1|r),r^=r+Math.imul(r^r>>>7,61|r);const a=10**o;return Math.floor((((r^r>>>14)>>>0)/4294967296*(n-t+1/a)+t)*a)/a}},wi=t=>t[Ti(0,t.length-1)],$i=(t,e=Ti)=>{let s,i,r=t.length;for(;r;)i=e(0,--r),s=t[r],t[r]=t[i],t[i]=s;return t},Ci=(t,e={})=>{let s,i=[],r=0,n=null;const o=e.from,a=e.reversed,l=e.ease,h=!H(l),d=h&&!H(l.ease)?l.ease:h?$e(l):null,c=e.grid,u=!0===c,m=e.axis,f=e.total,g=H(o)||0===o||"first"===o,y="center"===o,_="last"===o,b="random"===o,v=F(o),T=F(t),x=e.use,S=Z(T?t[0]:t),w=T?Z(t[1]):0,$=C.exec((T?t[1]:t)+p),E=e.start||0+(T?S:0),k=e.seed,N=H(k)||!1===k?Ti:Si(!0===k?0:k),D=e.jitter,A=!H(D),I=F(D),R=I?D[0]:D||0,L=I?D[1]:D||0;let B=g?0:V(o)?o:0;return(t,l,h,p,g)=>{const[C]=ce(t),k=H(f)?h.length:f,D=!H(x)&&(z(x)?x(C,l,k):Dt(C,x)),I=V(D)||O(D)&&V(+D)?+D:l,P=I>=0&&I<k?I:l;if(y&&(B=(k-1)/2),_&&(B=k-1),!i.length){if(u){let t=!0,e=!1,s=1/0,r=1/0,n=1/0,a=-1/0,l=-1/0,d=-1/0;const c=[],u=[],p=[];for(let i=0;i<k;i++){const o=h[i];let m=0,f=0,g=0,y=!1;if(o&&z(o.getBoundingClientRect)){const t=o.getBoundingClientRect();m=t.left+t.width/2,f=t.top+t.height/2,y=!0}else{const t=o;t&&V(t.x)&&V(t.y)&&(m=t.x,f=t.y,V(t.z)&&(g=t.z,e=!0),y=!0)}if(!y){t=!1;break}c.push(m),u.push(f),p.push(g),m<s&&(s=m),f<r&&(r=f),g<n&&(n=g),m>a&&(a=m),f>l&&(l=f),g>d&&(d=g)}if(t){let t=c[0],h=u[0],f=p[0];v?(t=s+o[0]*(a-s),h=r+o[1]*(l-r),f=e?n+(o.length>=3?o[2]:.5)*(d-n):0):y?(t=(s+a)/2,h=(r+l)/2,f=(n+d)/2):_?(t=c[k-1],h=u[k-1],f=p[k-1]):V(o)&&(t=c[o],h=u[o],f=p[o]);for(let s=0;s<k;s++){const r=t-c[s],n=h-u[s],o=f-p[s];let a=J(r*r+n*n+(e?o*o:0));"x"===m&&(a=-r),"y"===m&&(a=-n),"z"===m&&(a=-o),i.push(a)}let g=1/0;for(let t=0;t<k;t++){const e=et(i[t]);e>0&&e<g&&(g=e)}if(g>0&&g<1/0)for(let t=0;t<k;t++)i[t]=i[t]/g}else for(let t=0;t<k;t++)i.push(et(B-t))}else for(let t=0;t<k;t++)if(c){const e=c.length,s=c[0]*c[1];let r,n,a;v?(r=o[0]*(c[0]-1),n=o[1]*(c[1]-1),a=3===e?(o.length>=3?o[2]:.5)*(c[2]-1):0):y?(r=(c[0]-1)/2,n=(c[1]-1)/2,a=3===e?(c[2]-1)/2:0):(r=B%c[0],n=rt(B/c[0])%c[1],a=3===e?rt(B/s):0);const l=r-t%c[0],h=n-rt(t/c[0])%c[1],d=a-(3===e?rt(t/s):0);let u=J(l*l+h*h+(3===e?d*d:0));"x"===m&&(u=-l),"y"===m&&(u=-h),"z"===m&&(u=-d),i.push(u)}else i.push(et(B-t));r=i[0];for(let t=1;t<k;t++)i[t]>r&&(r=i[t]);if(d||a)for(let t=0;t<k;t++){let e=i[t];d&&(e=d(e/r)*r),a&&(e=m?-e:et(r-e)),i[t]=e}if(A){n=new Array(k);for(let t=0;t<k;t++)n[t]=N(-1,1,4)}b&&(i=$i(i,N))}const F=T?(w-S)/r:S;H(s)&&(s=g?Ve(g,H(e.start)?g.iterationDuration:E):E);let M=s+(F*ct(i[P],2)||0);if(A){const t=r?i[P]/r:0,e=R+(L-R)*t;M+=n[P]*e}return e.modifier&&(M=e.modifier(M)),$&&(M=`${M}${$[2]}`),M}};var Ei=Object.freeze({__proto__:null,$:ce,addChild:vt,clamp:yi,cleanInlineStyles:zt,createSeededRandom:Si,damp:vi,degToRad:mi,forEachChildren:_t,get:ts,keepTime:ds,lerp:bi,mapRange:pi,padEnd:ci,padStart:di,radToDeg:fi,random:Ti,randomPick:wi,remove:ss,removeChild:bt,round:_i,roundPad:hi,set:es,shuffle:$i,snap:gi,stagger:Ci,sync:hs,wrap:ui});const ki=t=>{const e=de(t)[0];return e&&Y(e)?e:console.warn(`${t} is not a valid SVGGeometryElement`)},Ni=(t,e,s,i,r)=>{const n=s+i,o=r?Math.max(0,Math.min(n,e)):(n%e+e)%e;return t.getPointAtLength(o)},Di=(t,e,s=0)=>i=>{const r=+t.getTotalLength(),n=i[a],o=t.getCTM(),l=0===s;return{from:0,to:r,modifier:i=>{const a=i+s*r;if("a"===e){const e=Ni(t,r,a,-1,l),s=Ni(t,r,a,1,l);return 180*at(s.y-e.y,s.x-e.x)/lt}{const s=Ni(t,r,a,0,l);return"x"===e?n||!o?s.x:s.x*o.a+s.y*o.c+o.e:n||!o?s.y:s.x*o.b+s.y*o.d+o.f}}}},Ai=(t,e=0)=>{const s=ki(t);if(s)return{translateX:Di(s,"x",e),translateY:Di(s,"y",e),rotate:Di(s,"a",e)}},Ii=(t,e=0,s=0)=>de(t).map(t=>((t,e,s)=>{const i=u,r=getComputedStyle(t),n=r.strokeLinecap,o="non-scaling-stroke"===r.vectorEffect?t:null;let a=n;const l=new Proxy(t,{get(t,e){const s=t[e];return e===h?t:"setAttribute"===e?(...e)=>{if("draw"===e[0]){const s=e[1].split(" "),r=+s[0],l=+s[1],h=(t=>{let e=1;if(t&&t.getCTM){const s=t.getCTM();s&&(e=(J(s.a*s.a+s.b*s.b)+J(s.c*s.c+s.d*s.d))/2)}return e})(o),d=-1e3*r*h,c=l*i*h+d,u=i*h+(0===r&&1===l||1===r&&0===l?0:10*h)-c;if("butt"!==n){const e=r===l?"butt":n;a!==e&&(t.style.strokeLinecap=`${e}`,a=e)}t.setAttribute("stroke-dashoffset",`${d}`),t.setAttribute("stroke-dasharray",`${c} ${u}`)}return Reflect.apply(s,t,e)}:z(s)?(...e)=>Reflect.apply(s,t,e):s}});return"1000"!==t.getAttribute("pathLength")&&(t.setAttribute("pathLength","1000"),l.setAttribute("draw",`${e} ${s}`)),l})(t,e,s)),Ri=(t,e=.33)=>(s,i,r,n)=>{if(!(s.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${s.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const o=ki(t);if(!o)throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");if(!(o.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${o.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const a="path"===s.tagName,l=a?" ":",",h=n?n._value:null;h&&s.setAttribute(a?"d":"points",h);let d="",c="";if(e){const t=s.getTotalLength(),i=o.getTotalLength(),r=Math.max(Math.ceil(t*e),Math.ceil(i*e));for(let e=0;e<r;e++){const n=e/(r-1),h=s.getPointAtLength(t*n),u=o.getPointAtLength(i*n),p=a?0===e?"M":"L":"";d+=p+ct(h.x,3)+l+h.y+" ",c+=p+ct(u.x,3)+l+u.y+" "}}else d=s.getAttribute(a?"d":"points"),c=o.getAttribute(a?"d":"points");return[d,c]};var Li=Object.freeze({__proto__:null,createDrawable:Ii,createMotionPath:Ai,morphTo:Ri});const Bi="undefined"!=typeof Intl&&Intl.Segmenter,Pi=/\{value\}/g,Fi=/\{i\}/g,Mi=/(\s+)/,Vi=/^\s+$/,Oi="line",zi="word",Hi="char",Xi="data-line";let Yi=null,Wi=null,Ui=null;const qi=t=>t.isWordLike||" "===t.segment||V(+t.segment),ji=t=>t.setAttribute("aria-hidden","true"),Gi=(t,e)=>[...t.querySelectorAll(`[data-${e}]:not([data-${e}] [data-${e}])`)],Zi={line:"#00D672",word:"#FF4B4B",char:"#5A87FF"},Qi=t=>{if(!t.childElementCount&&!t.textContent.trim()){const e=t.parentElement;t.remove(),e&&Qi(e)}},Ji=(t,e,s)=>{const i=t.getAttribute(Xi);if(null!==i&&+i!==e||"BR"===t.tagName){s.add(t);const e=t.previousSibling,i=t.nextSibling;e&&3===e.nodeType&&Vi.test(e.textContent)&&s.add(e),i&&3===i.nodeType&&Vi.test(i.textContent)&&s.add(i)}let r=t.childElementCount;for(;r--;)Ji(t.children[r],e,s);return s},Ki=(t,e={})=>{let s="";e||(e={});const i=O(e.class)?` class="${e.class}"`:"",r=$t(e.clone,!1),n=$t(e.wrap,!1),o=n?!0===n?"clip":n:!!r&&"clip";return n&&(s+=`<span${o?` style="overflow:${o};"`:""}>`),s+=`<span${i}${r?' style="position:relative;"':""} data-${t}="{i}">`,r?(s+="<span>{value}</span>",s+=`<span inert style="position:absolute;top:${"top"===r?"-100%":"bottom"===r?"100%":"0"};left:${"left"===r?"-100%":"right"===r?"100%":"0"};white-space:nowrap;">{value}</span>`):s+="{value}",s+="</span>",n&&(s+="</span>"),s},tr=(t,e,s,i,r,n,o,a,l)=>{const h=r===Oi,d=r===Hi,c=`_${r}_`,u=z(t)?t(s):t,p=h?"block":"inline-block";Ui.innerHTML=u.replace(Pi,`<i class="${c}"></i>`).replace(Fi,`${d?l:h?o:a}`);const m=Ui.content,f=m.firstElementChild,g=m.querySelector(`[data-${r}]`)||f,y=m.querySelectorAll(`i.${c}`),_=y.length;if(_){f.style.display=p,g.style.display=p,g.setAttribute(Xi,`${o}`),h||(g.setAttribute("data-word",`${a}`),d&&g.setAttribute("data-char",`${l}`));let t=_;for(;t--;){const e=y[t],i=e.parentElement;i.style.display=p,h?i.innerHTML=s.innerHTML:i.replaceChild(s.cloneNode(!0),e)}e.push(g),i.appendChild(m)}else console.warn('The expression "{value}" is missing from the provided template.');return n&&(f.style.outline=`1px dotted ${Zi[r]}`),f};class er{constructor(t,s={}){Yi||(Yi=Bi?new Bi([],{granularity:zi}):{segment:t=>{const e=[],s=t.split(Mi);for(let t=0,i=s.length;t<i;t++){const i=s[t];e.push({segment:i,isWordLike:!Vi.test(i)})}return e}}),Wi||(Wi=Bi?new Bi([],{granularity:"grapheme"}):{segment:t=>[...t].map(t=>({segment:t}))}),!Ui&&e&&(Ui=i.createElement("template")),A.current&&A.current.register(this);const{words:r,chars:n,lines:o,accessible:a,includeSpaces:l,debug:h}=s,d=(t=F(t)?t[0]:t)&&t.nodeType?t:(he(t)||[])[0],c=!0===o?{}:o,u=!0===r||H(r)?{}:r,p=!0===n?{}:n;this.debug=$t(h,!1),this.includeSpaces=$t(l,!1),this.accessible=$t(a,!0),this.linesOnly=c&&!u&&!p,this.lineTemplate=M(c)?Ki(Oi,c):c,this.wordTemplate=M(u)||this.linesOnly?Ki(zi,u):u,this.charTemplate=M(p)?Ki(Hi,p):p,this.$target=d,this.html=d&&d.innerHTML,this.lines=[],this.words=[],this.chars=[],this.effects=[],this.effectsCleanups=[],this.cache=null,this.ready=!1,this.width=0,this.resizeTimeout=null;const m=()=>this.html&&(c||u||p)&&this.split();this.resizeObserver=new ResizeObserver(()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{const t=d.offsetWidth;t!==this.width&&(this.width=t,m())},150)}),this.lineTemplate&&!this.ready?i.fonts.ready.then(m):m(),d?this.resizeObserver.observe(d):console.warn("No Text Splitter target found.")}addEffect(t){if(!z(t))return console.warn("Effect must return a function."),this;const e=ds(t);return this.effects.push(e),this.ready&&(this.effectsCleanups[this.effects.length-1]=e(this)),this}revert(){return clearTimeout(this.resizeTimeout),this.lines.length=this.words.length=this.chars.length=0,this.resizeObserver.disconnect(),this.effectsCleanups.forEach(t=>z(t)?t(this):t.revert&&t.revert()),this.$target.innerHTML=this.html,this}splitNode(t){const e=this.wordTemplate,s=this.charTemplate,r=this.includeSpaces,n=this.debug,o=t.nodeType;if(3===o){const o=t.nodeValue;if(o.trim()){const a=[],l=this.words,h=this.chars,d=Yi.segment(o),c=i.createDocumentFragment();let u=null;for(const t of d){const e=t.segment,s=qi(t);if(!u||s&&u&&qi(u))a.push(e);else{const t=a.length-1,s=a[t];Mi.test(s)||Mi.test(e)?a.push(e):a[t]+=e}u=t}for(let t=0,o=a.length;t<o;t++){const o=a[t];if(o.trim()){const d=a[t+1],u=r&&d&&!d.trim(),p=o,m=s?Wi.segment(p):null,f=s?i.createDocumentFragment():i.createTextNode(u?o+" ":o);if(s){const t=[...m];for(let e=0,r=t.length;e<r;e++){const o=t[e],a=e===r-1&&u?o.segment+" ":o.segment,d=i.createTextNode(a);tr(s,h,d,f,Hi,n,-1,l.length,h.length)}}e?tr(e,l,f,c,zi,n,-1,l.length,h.length):s?c.appendChild(f):c.appendChild(i.createTextNode(o)),u&&t++}else{if(t&&r)continue;c.appendChild(i.createTextNode(o))}}t.parentNode.replaceChild(c,t)}}else if(1===o){const e=[...t.childNodes];for(let t=0,s=e.length;t<s;t++)this.splitNode(e[t])}}split(t=!1){const e=this.$target,s=!!this.cache&&!t,r=this.lineTemplate,n=this.wordTemplate,o=this.charTemplate,a="loading"!==i.fonts.status,l=r&&a;this.ready=!r||a,(l||t)&&this.effectsCleanups.forEach(t=>z(t)&&t(this)),s||(t&&(e.innerHTML=this.html,this.words.length=this.chars.length=0),this.splitNode(e),this.cache=e.innerHTML),l&&(s&&(e.innerHTML=this.cache),this.lines.length=0,n&&(this.words=Gi(e,zi))),o&&(l||n)&&(this.chars=Gi(e,Hi));const h=this.words.length?this.words:this.chars;let d,c=0;for(let t=0,e=h.length;t<e;t++){const e=h[t],{top:s,height:i}=e.getBoundingClientRect();!H(d)&&s-d>.5*i&&c++,e.setAttribute(Xi,`${c}`);const r=e.querySelectorAll(`[${Xi}]`);let n=r.length;for(;n--;)r[n].setAttribute(Xi,`${c}`);d=s}if(l){const t=i.createDocumentFragment(),s=new Set,a=[];for(let t=0;t<c+1;t++){const i=e.cloneNode(!0);Ji(i,t,new Set).forEach(t=>{const e=t.parentNode;e&&(1===t.nodeType&&s.add(e),e.removeChild(t))}),a.push(i)}s.forEach(Qi);for(let e=0,s=a.length;e<s;e++)tr(r,this.lines,a[e],t,Oi,this.debug,e);e.innerHTML="",e.appendChild(t),n&&(this.words=Gi(e,zi)),o&&(this.chars=Gi(e,Hi))}if(this.linesOnly){const t=this.words;let e=t.length;for(;e--;){const s=t[e];s.replaceWith(s.textContent)}t.length=0}if(this.accessible&&(l||!s)){const t=i.createElement("span");t.style.cssText="position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;",t.innerHTML=this.html,e.insertBefore(t,e.firstChild),this.lines.forEach(ji),this.words.forEach(ji),this.chars.forEach(ji)}return this.width=e.offsetWidth,(l||t)&&this.effects.forEach((t,e)=>this.effectsCleanups[e]=t(this)),this}refresh(){this.split(!0)}}const sr=(t,e)=>new er(t,e),ir=(t,e)=>(console.warn("text.split() is deprecated, import splitText() directly, or text.splitText()"),new er(t,e)),rr=t=>{let e="";for(let s=0,i=t.length;s<i;s++)if(s+2<i&&"-"===t[s+1]&&t.charCodeAt(s)<t.charCodeAt(s+2)){const i=t.charCodeAt(s),r=t.charCodeAt(s+2);for(let t=i;t<=r;t++)e+=String.fromCharCode(t);s+=2}else e+=t[s];return e},nr={lowercase:"a-z",uppercase:"A-Z",numbers:"0-9",symbols:"!%#_|*+=",braille:"⠀-⣿",blocks:"▀-▟",shades:"░-▓"},or=new WeakMap,ar=(t={})=>{t||(t={});const e=t.chars,s=$e(t.ease||"linear"),i=t.text,r=t.from,n=t.reversed||!1,o=t.perturbation||0,a=t.cursor,l=!0===a?"_":"number"==typeof a?String.fromCharCode(a):"string"==typeof a?a:"",h=l.length,d=t.seed||0,c=void 0===t.override||t.override,u=t.revealRate||60,p=1e3*I.timeScale/u,m=t.settleDuration||300*I.timeScale,f=t.settleRate||30,g=t.duration,y=t.revealDelay,b=t.delay,v=t.onChange||_;return(t,a,u,_)=>{const T="function"==typeof e?e(t,a,u):e||"a-zA-Z0-9!%#_",x=rr(nr[T]||T),S=x.length-1,w="function"==typeof g?g(t,a,u):g,$="function"==typeof y?y(t,a,u):y||0,C="function"==typeof b?b(t,a,u):b||0,E=d?Si(d):Si();or.has(t)||or.set(t,t.textContent);const k=_?_._value:t.textContent,N=void 0!==i?"function"==typeof i?i(t,a,u):i:_?_._value:or.get(t),D=" "===N||"&nbsp;"===N?" ":N,A=" "===k?0:k.length,R=D.length,L=!0===c?x:"string"==typeof c&&c.length>0?rr(nr[c]||c):null,B=L?L.length-1:0,P=" "===c?" ":null,F=""===c?R:Math.max(A,R),M=w>0?w:(F-1)*p+m,V=ct((M+$)/I.timeScale,0)*I.timeScale,O=$>0?ct($/V,12):0,z=void 0===r||"auto"===r?R<A?"right":"left":r,H=new Int32Array(F);if("random"===z){for(let t=0;t<F;t++)H[t]=t;for(let t=F-1;t>0;t--){const e=E(0,t),s=H[t];H[t]=H[e],H[e]=s}}else{const t="right"===z?(""!==c&&A?A:F)-1:"center"===z?((""!==c&&A?A:F)-1)/2:"number"==typeof z?z:0,e=Math.abs,s=new Array(F);for(let t=0;t<F;t++)s[t]=t;s.sort((s,i)=>e(s-t)-e(i-t));for(let t=0;t<F;t++)H[s[t]]=t}if(n){const t=F-1;for(let e=0;e<F;e++)H[e]=t-H[e]}const X=ct(m/M,12),Y=ct((1-X)/F,12),W=h*Y,U=ct(1e3*I.timeScale/(f*V),12),q=new Float32Array(F),j=new Float32Array(F),G=o>0?o*X:0;for(let t=0;t<F;t++){const e=G>0?(E(0,2e3)-1e3)/1e3*G:0,s=G>0?(E(0,2e3)-1e3)/1e3*G:0;q[t]=H[t]*Y+e,j[t]=Math.ceil((q[t]+X+s)/U)*U}if(R<F&&"left"!==z&&"right"!==z&&"random"!==z){let t=0;for(let e=R;e<F;e++)j[e]>t&&(t=j[e]);const e=new Array(R);for(let t=0;t<R;t++)e[t]=t;e.sort((t,e)=>H[t]-H[e]);const s=(1-t)/R;for(let i=0;i<R;i++){const r=t+i*s;r>j[e[i]]&&(j[e[i]]=r)}}const Z=new Array(F);for(let t=0;t<F;t++)Z[t]=x[E(0,S)];const Q=L?L===x?Z:new Array(F):null;if(Q&&Q!==Z)for(let t=0;t<F;t++)Q[t]=P||L[E(0,L.length-1)];let J=k;if(!_)if(""===c)J="";else if(L){J="";for(let t=0;t<A;t++)J+=" "===k[t]?" ":Q[t]}let K=-1,tt=-1,et="";const st=""!==c,it=!!L,rt=h>0;return{from:0,to:1,duration:V,delay:C,ease:"linear",modifier:t=>{if(t===K)return et;if(K=t,C>0&&t<=0)return et=k,k;if(t<=0)return et=J,J;if(t>=1)return et=D,D;et="";const e=t/U|0,i=e!==tt;i&&(tt=e);const r=O>0?(t-O)/(1-O):t,n=r>0?s(r):0;for(let t=0;t<F;t++){const e=q[t];n>=j[t]?t<R&&(et+=D[t]):n<=0||n<e?st&&t<A&&(it?" "===k[t]?et+=" ":(i&&(Q[t]=P||L[E(0,B)]),et+=Q[t]):et+=k[t]):t<R&&" "===D[t]||t<A&&" "===k[t]?et+=" ":rt&&n-e<W?et+=l[h-1-((n-e)/Y|0)]:(i&&(Z[t]=x[E(0,S)]),et+=Z[t])}return i&&v(et,n),et}}}};var lr=Object.freeze({__proto__:null,TextSplitter:er,scrambleText:ar,split:ir,splitText:sr});t.$=ce,t.Animatable=Ye,t.AutoLayout=ri,t.Draggable=ls,t.JSAnimation=Me,t.Scope=cs,t.ScrollObserver=vs,t.Spring=je,t.TextSplitter=er,t.Timeline=He,t.Timer=le,t.WAAPIAnimation=Ps,t.addChild=vt,t.animate=(t,e)=>I.editor?I.editor.addAnimation(t,e):new Me(t,e,null,0,!1).init(),t.clamp=yi,t.cleanInlineStyles=zt,t.createAnimatable=(t,e)=>new Ye(t,e),t.createDraggable=(t,e)=>new ls(t,e),t.createDrawable=Ii,t.createLayout=(t,e)=>new ri(t,e),t.createMotionPath=Ai,t.createScope=t=>new cs(t),t.createSeededRandom=Si,t.createSpring=Ze,t.createTimeline=Xe,t.createTimer=t=>new le(t,null,0).init(),t.cubicBezier=xs,t.damp=vi,t.degToRad=mi,t.eases=Te,t.easings=Cs,t.engine=qt,t.forEachChildren=_t,t.get=ts,t.globals=I,t.irregular=$s,t.keepTime=ds,t.lerp=bi,t.linear=ws,t.mapRange=pi,t.morphTo=Ri,t.onScroll=(t={})=>new vs(t),t.padEnd=ci,t.padStart=di,t.radToDeg=fi,t.random=Ti,t.randomPick=wi,t.remove=ss,t.removeChild=bt,t.round=_i,t.roundPad=hi,t.scrambleText=ar,t.scrollContainers=ps,t.set=es,t.shuffle=$i,t.snap=gi,t.split=ir,t.splitText=sr,t.spring=Ge,t.stagger=Ci,t.steps=Ss,t.svg=Li,t.sync=hs,t.text=lr,t.utils=Ei,t.waapi=Fs,t.wrap=ui});
diff --git a/dist/modules/adapters/index.cjs b/dist/modules/adapters/index.cjs
new file mode 100644
index 00000000..bf00bcd3
--- /dev/null
+++ b/dist/modules/adapters/index.cjs
@@ -0,0 +1,14 @@
+/**
+ * Anime.js - adapters - CJS
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+'use strict';
+
+var registry = require('./registry.cjs');
+
+
+
+exports.registerAdapter = registry.registerAdapter;
diff --git a/dist/modules/adapters/index.d.ts b/dist/modules/adapters/index.d.ts
new file mode 100644
index 00000000..a2a8ce25
--- /dev/null
+++ b/dist/modules/adapters/index.d.ts
@@ -0,0 +1 @@
+export { registerAdapter } from "./registry.js";
diff --git a/dist/modules/adapters/index.js b/dist/modules/adapters/index.js
new file mode 100644
index 00000000..f1719c7d
--- /dev/null
+++ b/dist/modules/adapters/index.js
@@ -0,0 +1,8 @@
+/**
+ * Anime.js - adapters - ESM
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+export { registerAdapter } from './registry.js';
diff --git a/dist/modules/adapters/registry.cjs b/dist/modules/adapters/registry.cjs
new file mode 100644
index 00000000..ae23ee2e
--- /dev/null
+++ b/dist/modules/adapters/registry.cjs
@@ -0,0 +1,149 @@
+/**
+ * Anime.js - adapters - CJS
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+'use strict';
+
+/**
+ * Anime.js adapter API. Each library or class group that wants to extend `animate()` and `utils.set()` calls `registerAdapter()` to create its own `Adapter`. The returned `Adapter` exposes `registerTargetAdapter(detect)` for per-class detection and `registerPropertyResolver(fn)` for global Color / Vector / pattern-based fallbacks.
+ *
+ * import { registerAdapter } from 'animejs/adapters';
+ *
+ * const myAdapter = registerAdapter();
+ * const widget = myAdapter.registerTargetAdapter((t) => t instanceof MyWidget);
+ * widget.registerProperty('value',
+ * (t) => t.getValue(),
+ * (target, value) => target.setValue(value),
+ * );
+ *
+ * For scalar tweens, `value` is the interpolated number. For color and complex tweens it is `undefined`; read `tween._numbers` instead. `gate(target)` scopes the prop to a subset of matching targets.
+ *
+ * Resolution order: every Adapter's target adapters in registration order (first match wins) then every Adapter's property resolvers (first non-null wins) then engine direct property path.
+ */
+
+/**
+ * @typedef TargetAdapterEntry
+ * @property {(t: any) => any} get
+ * @property {(target: any, value: number, tween: any) => void} set
+ * @property {(t: any) => boolean} [gate]
+ */
+
+const alwaysTrue = () => true;
+
+class TargetAdapter {
+ /**
+ * @param {(t: any) => boolean} detect
+ */
+ constructor(detect) {
+ this.detect = detect;
+ /** @type {Record<string, TargetAdapterEntry>} */
+ this.props = {};
+ }
+
+ /**
+ * Registers a property the adapter handles. `setter` receives `(target, value, tween)`. For color and complex tweens `value` is `undefined`, read `tween._numbers` instead. `gate(target)` scopes the prop to a subset of matching targets.
+ *
+ * @param {string} name
+ * @param {(t: any) => any} getter
+ * @param {(target: any, value: number, tween: any) => void} setter
+ * @param {(t: any) => boolean} [gate]
+ */
+ registerProperty(name, getter, setter, gate) {
+ this.props[name] = {
+ get: getter,
+ set: setter,
+ gate: gate || alwaysTrue,
+ };
+ }
+}
+
+class Adapter {
+ /**
+ * @param {((t: any) => boolean) | null} [detect]
+ * Optional gate. When provided, every lookup against this Adapter's target adapters and resolvers is skipped if `detect(target)` returns falsy. Lets the Adapter as a whole short-circuit on unrelated targets.
+ */
+ constructor(detect) {
+ /** @type {((t: any) => boolean) | null} */
+ this.detect = detect || null;
+ /** @type {TargetAdapter[]} */
+ this.targetAdapters = [];
+ /** @type {((target: any, name: string) => TargetAdapterEntry | null)[]} */
+ this.propertyResolvers = [];
+ }
+
+ /**
+ * Creates and registers a `TargetAdapter` scoped to this Adapter.
+ *
+ * @param {(t: any) => boolean} detect
+ * @return {TargetAdapter}
+ */
+ registerTargetAdapter(detect) {
+ const ta = new TargetAdapter(detect);
+ this.targetAdapters.push(ta);
+ return ta;
+ }
+
+ /**
+ * Registers a property resolver scoped to this Adapter. Resolvers are functions invoked at tween creation when no target adapter has claimed the name; the function returns an entry for names it handles or `null` to defer. Use for runtime-matched patterns (Color / Vector axis detection, name-prefix conventions, etc.).
+ *
+ * @param {(target: any, name: string) => TargetAdapterEntry | null} resolver
+ */
+ registerPropertyResolver(resolver) {
+ if (this.propertyResolvers.indexOf(resolver) === -1) this.propertyResolvers.push(resolver);
+ }
+}
+
+const adapters = /** @type {Adapter[]} */([]);
+
+/**
+ * Creates and registers an Adapter. Each library extending `animate()` calls this once and uses the returned Adapter to wire up its target adapters and property resolvers. The optional `detect` short-circuits all lookups against the Adapter when the target is unrelated.
+ *
+ * @param {(t: any) => boolean} [detect]
+ * @return {Adapter}
+ */
+function registerAdapter(detect) {
+ const a = new Adapter(detect);
+ adapters.push(a);
+ return a;
+}
+
+/**
+ * Internal resolution. Tries every Adapter's target adapters first (in registration order, first match wins), then every Adapter's property resolvers.
+ *
+ * @param {any} target
+ * @param {string} name
+ * @return {TargetAdapterEntry | null}
+ */
+function resolveAdapterEntry(target, name) {
+ if (!target) return null;
+ const al = adapters.length;
+ outer: for (let i = 0; i < al; i++) {
+ const a = adapters[i];
+ if (a.detect && !a.detect(target)) continue;
+ const tas = a.targetAdapters;
+ for (let j = 0, m = tas.length; j < m; j++) {
+ const ta = tas[j];
+ if (ta.detect(target)) {
+ const entry = ta.props[name];
+ if (entry && (!entry.gate || entry.gate(target))) return entry;
+ break outer;
+ }
+ }
+ }
+ for (let i = 0; i < al; i++) {
+ const a = adapters[i];
+ if (a.detect && !a.detect(target)) continue;
+ const rs = a.propertyResolvers;
+ for (let j = 0, m = rs.length; j < m; j++) {
+ const entry = rs[j](target, name);
+ if (entry) return entry;
+ }
+ }
+ return null;
+}
+
+exports.registerAdapter = registerAdapter;
+exports.resolveAdapterEntry = resolveAdapterEntry;
diff --git a/dist/modules/adapters/registry.d.ts b/dist/modules/adapters/registry.d.ts
new file mode 100644
index 00000000..43672f94
--- /dev/null
+++ b/dist/modules/adapters/registry.d.ts
@@ -0,0 +1,65 @@
+/**
+ * Creates and registers an Adapter. Each library extending `animate()` calls this once and uses the returned Adapter to wire up its target adapters and property resolvers. The optional `detect` short-circuits all lookups against the Adapter when the target is unrelated.
+ *
+ * @param {(t: any) => boolean} [detect]
+ * @return {Adapter}
+ */
+export function registerAdapter(detect?: (t: any) => boolean): Adapter;
+/**
+ * Internal resolution. Tries every Adapter's target adapters first (in registration order, first match wins), then every Adapter's property resolvers.
+ *
+ * @param {any} target
+ * @param {string} name
+ * @return {TargetAdapterEntry | null}
+ */
+export function resolveAdapterEntry(target: any, name: string): TargetAdapterEntry | null;
+export type TargetAdapterEntry = {
+ get: (t: any) => any;
+ set: (target: any, value: number, tween: any) => void;
+ gate?: (t: any) => boolean;
+};
+declare class Adapter {
+ /**
+ * @param {((t: any) => boolean) | null} [detect]
+ * Optional gate. When provided, every lookup against this Adapter's target adapters and resolvers is skipped if `detect(target)` returns falsy. Lets the Adapter as a whole short-circuit on unrelated targets.
+ */
+ constructor(detect?: ((t: any) => boolean) | null);
+ /** @type {((t: any) => boolean) | null} */
+ detect: ((t: any) => boolean) | null;
+ /** @type {TargetAdapter[]} */
+ targetAdapters: TargetAdapter[];
+ /** @type {((target: any, name: string) => TargetAdapterEntry | null)[]} */
+ propertyResolvers: ((target: any, name: string) => TargetAdapterEntry | null)[];
+ /**
+ * Creates and registers a `TargetAdapter` scoped to this Adapter.
+ *
+ * @param {(t: any) => boolean} detect
+ * @return {TargetAdapter}
+ */
+ registerTargetAdapter(detect: (t: any) => boolean): TargetAdapter;
+ /**
+ * Registers a property resolver scoped to this Adapter. Resolvers are functions invoked at tween creation when no target adapter has claimed the name; the function returns an entry for names it handles or `null` to defer. Use for runtime-matched patterns (Color / Vector axis detection, name-prefix conventions, etc.).
+ *
+ * @param {(target: any, name: string) => TargetAdapterEntry | null} resolver
+ */
+ registerPropertyResolver(resolver: (target: any, name: string) => TargetAdapterEntry | null): void;
+}
+declare class TargetAdapter {
+ /**
+ * @param {(t: any) => boolean} detect
+ */
+ constructor(detect: (t: any) => boolean);
+ detect: (t: any) => boolean;
+ /** @type {Record<string, TargetAdapterEntry>} */
+ props: Record<string, TargetAdapterEntry>;
+ /**
+ * Registers a property the adapter handles. `setter` receives `(target, value, tween)`. For color and complex tweens `value` is `undefined`, read `tween._numbers` instead. `gate(target)` scopes the prop to a subset of matching targets.
+ *
+ * @param {string} name
+ * @param {(t: any) => any} getter
+ * @param {(target: any, value: number, tween: any) => void} setter
+ * @param {(t: any) => boolean} [gate]
+ */
+ registerProperty(name: string, getter: (t: any) => any, setter: (target: any, value: number, tween: any) => void, gate?: (t: any) => boolean): void;
+}
+export {};
diff --git a/dist/modules/adapters/registry.js b/dist/modules/adapters/registry.js
new file mode 100644
index 00000000..89dc0e32
--- /dev/null
+++ b/dist/modules/adapters/registry.js
@@ -0,0 +1,146 @@
+/**
+ * Anime.js - adapters - ESM
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+/**
+ * Anime.js adapter API. Each library or class group that wants to extend `animate()` and `utils.set()` calls `registerAdapter()` to create its own `Adapter`. The returned `Adapter` exposes `registerTargetAdapter(detect)` for per-class detection and `registerPropertyResolver(fn)` for global Color / Vector / pattern-based fallbacks.
+ *
+ * import { registerAdapter } from 'animejs/adapters';
+ *
+ * const myAdapter = registerAdapter();
+ * const widget = myAdapter.registerTargetAdapter((t) => t instanceof MyWidget);
+ * widget.registerProperty('value',
+ * (t) => t.getValue(),
+ * (target, value) => target.setValue(value),
+ * );
+ *
+ * For scalar tweens, `value` is the interpolated number. For color and complex tweens it is `undefined`; read `tween._numbers` instead. `gate(target)` scopes the prop to a subset of matching targets.
+ *
+ * Resolution order: every Adapter's target adapters in registration order (first match wins) then every Adapter's property resolvers (first non-null wins) then engine direct property path.
+ */
+
+/**
+ * @typedef TargetAdapterEntry
+ * @property {(t: any) => any} get
+ * @property {(target: any, value: number, tween: any) => void} set
+ * @property {(t: any) => boolean} [gate]
+ */
+
+const alwaysTrue = () => true;
+
+class TargetAdapter {
+ /**
+ * @param {(t: any) => boolean} detect
+ */
+ constructor(detect) {
+ this.detect = detect;
+ /** @type {Record<string, TargetAdapterEntry>} */
+ this.props = {};
+ }
+
+ /**
+ * Registers a property the adapter handles. `setter` receives `(target, value, tween)`. For color and complex tweens `value` is `undefined`, read `tween._numbers` instead. `gate(target)` scopes the prop to a subset of matching targets.
+ *
+ * @param {string} name
+ * @param {(t: any) => any} getter
+ * @param {(target: any, value: number, tween: any) => void} setter
+ * @param {(t: any) => boolean} [gate]
+ */
+ registerProperty(name, getter, setter, gate) {
+ this.props[name] = {
+ get: getter,
+ set: setter,
+ gate: gate || alwaysTrue,
+ };
+ }
+}
+
+class Adapter {
+ /**
+ * @param {((t: any) => boolean) | null} [detect]
+ * Optional gate. When provided, every lookup against this Adapter's target adapters and resolvers is skipped if `detect(target)` returns falsy. Lets the Adapter as a whole short-circuit on unrelated targets.
+ */
+ constructor(detect) {
+ /** @type {((t: any) => boolean) | null} */
+ this.detect = detect || null;
+ /** @type {TargetAdapter[]} */
+ this.targetAdapters = [];
+ /** @type {((target: any, name: string) => TargetAdapterEntry | null)[]} */
+ this.propertyResolvers = [];
+ }
+
+ /**
+ * Creates and registers a `TargetAdapter` scoped to this Adapter.
+ *
+ * @param {(t: any) => boolean} detect
+ * @return {TargetAdapter}
+ */
+ registerTargetAdapter(detect) {
+ const ta = new TargetAdapter(detect);
+ this.targetAdapters.push(ta);
+ return ta;
+ }
+
+ /**
+ * Registers a property resolver scoped to this Adapter. Resolvers are functions invoked at tween creation when no target adapter has claimed the name; the function returns an entry for names it handles or `null` to defer. Use for runtime-matched patterns (Color / Vector axis detection, name-prefix conventions, etc.).
+ *
+ * @param {(target: any, name: string) => TargetAdapterEntry | null} resolver
+ */
+ registerPropertyResolver(resolver) {
+ if (this.propertyResolvers.indexOf(resolver) === -1) this.propertyResolvers.push(resolver);
+ }
+}
+
+const adapters = /** @type {Adapter[]} */([]);
+
+/**
+ * Creates and registers an Adapter. Each library extending `animate()` calls this once and uses the returned Adapter to wire up its target adapters and property resolvers. The optional `detect` short-circuits all lookups against the Adapter when the target is unrelated.
+ *
+ * @param {(t: any) => boolean} [detect]
+ * @return {Adapter}
+ */
+function registerAdapter(detect) {
+ const a = new Adapter(detect);
+ adapters.push(a);
+ return a;
+}
+
+/**
+ * Internal resolution. Tries every Adapter's target adapters first (in registration order, first match wins), then every Adapter's property resolvers.
+ *
+ * @param {any} target
+ * @param {string} name
+ * @return {TargetAdapterEntry | null}
+ */
+function resolveAdapterEntry(target, name) {
+ if (!target) return null;
+ const al = adapters.length;
+ outer: for (let i = 0; i < al; i++) {
+ const a = adapters[i];
+ if (a.detect && !a.detect(target)) continue;
+ const tas = a.targetAdapters;
+ for (let j = 0, m = tas.length; j < m; j++) {
+ const ta = tas[j];
+ if (ta.detect(target)) {
+ const entry = ta.props[name];
+ if (entry && (!entry.gate || entry.gate(target))) return entry;
+ break outer;
+ }
+ }
+ }
+ for (let i = 0; i < al; i++) {
+ const a = adapters[i];
+ if (a.detect && !a.detect(target)) continue;
+ const rs = a.propertyResolvers;
+ for (let j = 0, m = rs.length; j < m; j++) {
+ const entry = rs[j](target, name);
+ if (entry) return entry;
+ }
+ }
+ return null;
+}
+
+export { registerAdapter, resolveAdapterEntry };
diff --git a/dist/modules/adapters/three/adapter.cjs b/dist/modules/adapters/three/adapter.cjs
new file mode 100644
index 00000000..56f65531
--- /dev/null
+++ b/dist/modules/adapters/three/adapter.cjs
@@ -0,0 +1,26 @@
+/**
+ * Anime.js - adapters - CJS
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+'use strict';
+
+var registry = require('../registry.cjs');
+
+// Duck-typed gate for three.js targets, used as threeAdapter's Adapter-level detect.
+// Early-rejects DOM nodes via nodeType so the OR chain only runs on non-DOM objects.
+// Includes the isAnimejsInstanceProxy marker set in instance.js for per-instance wrappers.
+const isThreeTarget = (t) => !!(
+ t && !t.nodeType && (
+ t.isObject3D || t.isMaterial || t.isTexture ||
+ t.isFog || t.isFogExp2 || t.isUniformNode ||
+ t.isColor || t.isVector2 || t.isVector3 || t.isVector4 ||
+ t.isAnimejsInstanceProxy
+ )
+);
+
+const threeAdapter = registry.registerAdapter(isThreeTarget);
+
+exports.threeAdapter = threeAdapter;
diff --git a/dist/modules/adapters/three/adapter.d.ts b/dist/modules/adapters/three/adapter.d.ts
new file mode 100644
index 00000000..cd53f965
--- /dev/null
+++ b/dist/modules/adapters/three/adapter.d.ts
@@ -0,0 +1,15 @@
+export const threeAdapter: {
+ detect: (t: any) => boolean;
+ targetAdapters: {
+ detect: (t: any) => boolean;
+ props: Record<string, import("../registry.js").TargetAdapterEntry>;
+ registerProperty(name: string, getter: (t: any) => any, setter: (target: any, value: number, tween: any) => void, gate?: (t: any) => boolean): void;
+ }[];
+ propertyResolvers: ((target: any, name: string) => import("../registry.js").TargetAdapterEntry | null)[];
+ registerTargetAdapter(detect: (t: any) => boolean): {
+ detect: (t: any) => boolean;
+ props: Record<string, import("../registry.js").TargetAdapterEntry>;
+ registerProperty(name: string, getter: (t: any) => any, setter: (target: any, value: number, tween: any) => void, gate?: (t: any) => boolean): void;
+ };
+ registerPropertyResolver(resolver: (target: any, name: string) => TargetAdapterEntry | null): void;
+};
diff --git a/dist/modules/adapters/three/adapter.js b/dist/modules/adapters/three/adapter.js
new file mode 100644
index 00000000..3b8c181f
--- /dev/null
+++ b/dist/modules/adapters/three/adapter.js
@@ -0,0 +1,24 @@
+/**
+ * Anime.js - adapters - ESM
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+import { registerAdapter } from '../registry.js';
+
+// Duck-typed gate for three.js targets, used as threeAdapter's Adapter-level detect.
+// Early-rejects DOM nodes via nodeType so the OR chain only runs on non-DOM objects.
+// Includes the isAnimejsInstanceProxy marker set in instance.js for per-instance wrappers.
+const isThreeTarget = (t) => !!(
+ t && !t.nodeType && (
+ t.isObject3D || t.isMaterial || t.isTexture ||
+ t.isFog || t.isFogExp2 || t.isUniformNode ||
+ t.isColor || t.isVector2 || t.isVector3 || t.isVector4 ||
+ t.isAnimejsInstanceProxy
+ )
+);
+
+const threeAdapter = registerAdapter(isThreeTarget);
+
+export { threeAdapter };
diff --git a/dist/modules/adapters/three/helpers.cjs b/dist/modules/adapters/three/helpers.cjs
new file mode 100644
index 00000000..690137a2
--- /dev/null
+++ b/dist/modules/adapters/three/helpers.cjs
@@ -0,0 +1,297 @@
+/**
+ * Anime.js - adapters - CJS
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+'use strict';
+
+var three = require('three');
+var number = require('../../utils/number.cjs');
+
+/**
+ * Generic read/write helpers for the three.js bindings. Each operates on a target (or target array) and walks to the leaf via a path tag - direct (`target[name]`), uniform (`target.uniforms[name].value`), or TSL node (`target[name].value`). Adapter and resolver files pass the matching `PATH_*` constant; the JIT specializes each call site so the branch in `leafAt` / `writeLeafScalar` constant-folds.
+ */
+
+
+const COLOR_NORM = 1 / 255;
+
+const AXIS_MAP = /** @type {Record<string, 'x' | 'y' | 'z' | 'w'>} */({ X: 'x', Y: 'y', Z: 'z', W: 'w' });
+
+const PATH_DIRECT = 0;
+const PATH_UNIFORM = 1;
+const PATH_NODE = 2;
+
+const KIND_COLOR = 0;
+const KIND_SCALAR = 1;
+const KIND_VECTOR = 2;
+
+// Reuse one mutable descriptor across calls, callers must consume immediately since the next call mutates it.
+const desc = { kind: 0, path: 0, base: '', axis: /** @type {'x' | 'y' | 'z' | 'w'} */('x') };
+
+/**
+ * Patches a column-major `Matrix4.elements` array in place with CSS-style `skewX(α)` / `skewY(β)`, the 3D extension `skewZ(γ)` (shears z by x), and a `transform-origin` shift.
+ *
+ * @param {number[]} e
+ * @param {number} skewX
+ * @param {number} skewY
+ * @param {number} skewZ
+ * @param {number} ox
+ * @param {number} oy
+ * @param {number} oz
+ */
+function applySkewOrigin(e, skewX, skewY, skewZ, ox, oy, oz) {
+ if (skewX !== 0) {
+ const t = Math.tan(number.degToRad(skewX));
+ e[4] += e[0] * t;
+ e[5] += e[1] * t;
+ e[6] += e[2] * t;
+ }
+ if (skewY !== 0) {
+ const t = Math.tan(number.degToRad(skewY));
+ e[0] += e[4] * t;
+ e[1] += e[5] * t;
+ e[2] += e[6] * t;
+ }
+ if (skewZ !== 0) {
+ const t = Math.tan(number.degToRad(skewZ));
+ e[0] += e[8] * t;
+ e[1] += e[9] * t;
+ e[2] += e[10] * t;
+ }
+ if (ox !== 0 || oy !== 0 || oz !== 0) {
+ e[12] += ox - (e[0] * ox + e[4] * oy + e[8] * oz);
+ e[13] += oy - (e[1] * ox + e[5] * oy + e[9] * oz);
+ e[14] += oz - (e[2] * ox + e[6] * oy + e[10] * oz);
+ }
+}
+
+/**
+ * @param {any} c
+ * @return {String | null}
+ */
+function readColorHex(c) {
+ return c ? `#${c.getHexString(three.SRGBColorSpace)}` : null;
+}
+
+/**
+ * Returns `true` when `v` is a `Vector2/3/4` instance whose dimension covers `axis`. `Quaternion` and plain `{x,y,z,w}`-shaped objects are intentionally rejected.
+ *
+ * @param {any} v
+ * @param {'x' | 'y' | 'z' | 'w'} axis
+ * @return {boolean}
+ */
+function isVectorWith(v, axis) {
+ if (!v) return false;
+ if (axis === 'x' || axis === 'y') return !!(v.isVector2 || v.isVector3 || v.isVector4);
+ if (axis === 'z') return !!(v.isVector3 || v.isVector4);
+ return !!v.isVector4;
+}
+
+/**
+ * Classifies `target[name]` and returns a descriptor `{ kind, path, base, axis }` (or `null`). Used by the resolver entries in `resolvers.js` and by the `Object3D` adapter to build the matching access pattern for any three.js target (Object3D, Material, Texture, Fog, UniformNode).
+ *
+ * @param {any} target
+ * @param {string} name
+ * @return {{ kind: number, path: number, base: string, axis: 'x' | 'y' | 'z' | 'w' } | null}
+ */
+function classifyTargetProp(target, name) {
+ const value = target[name];
+ if (value !== undefined) {
+ if (value && value.isColor) {
+ desc.kind = KIND_COLOR; desc.path = PATH_DIRECT;
+ return desc;
+ }
+ if (value && value.isUniformNode) {
+ // Route TSL slot writes through node value, booleans share the scalar entry.
+ const v = value.value;
+ if (v && v.isColor) {
+ desc.kind = KIND_COLOR; desc.path = PATH_NODE;
+ return desc;
+ }
+ if (typeof v === 'number' || typeof v === 'boolean') {
+ desc.kind = KIND_SCALAR; desc.path = PATH_NODE;
+ return desc;
+ }
+ return null;
+ }
+ if (typeof value === 'number' || typeof value === 'boolean') {
+ desc.kind = KIND_SCALAR; desc.path = PATH_DIRECT;
+ return desc;
+ }
+ return null;
+ }
+ const uniforms = target.uniforms;
+ const u = uniforms && uniforms[name];
+ if (u) {
+ const uv = u.value;
+ if (uv && uv.isColor) {
+ desc.kind = KIND_COLOR; desc.path = PATH_UNIFORM;
+ return desc;
+ }
+ if (typeof uv === 'number') {
+ desc.kind = KIND_SCALAR; desc.path = PATH_UNIFORM;
+ return desc;
+ }
+ }
+ // Decompose vector axis for names like posX, uOffsetY, uVec4W, colorNodeX.
+ const axis = AXIS_MAP[name[name.length - 1]];
+ if (axis) {
+ const base = name.slice(0, -1);
+ if (isVectorWith(target[base], axis)) {
+ desc.kind = KIND_VECTOR; desc.path = PATH_DIRECT; desc.base = base; desc.axis = axis;
+ return desc;
+ }
+ const baseSlot = target[base];
+ if (baseSlot && baseSlot.isUniformNode && isVectorWith(baseSlot.value, axis)) {
+ desc.kind = KIND_VECTOR; desc.path = PATH_NODE; desc.base = base; desc.axis = axis;
+ return desc;
+ }
+ const ub = uniforms && uniforms[base];
+ if (ub && isVectorWith(ub.value, axis)) {
+ desc.kind = KIND_VECTOR; desc.path = PATH_UNIFORM; desc.base = base; desc.axis = axis;
+ return desc;
+ }
+ }
+ return null;
+}
+
+function leafAt(target, name, path) {
+ if (path === PATH_DIRECT) return target[name];
+ if (path === PATH_UNIFORM) {
+ const u = target.uniforms;
+ const e = u && u[name];
+ return e ? e.value : null;
+ }
+ const n = target[name];
+ return n ? n.value : null;
+}
+
+function writeLeafScalar(target, name, v, path) {
+ if (path === PATH_DIRECT) { target[name] = v; return; }
+ if (path === PATH_UNIFORM) {
+ const u = target.uniforms;
+ const e = u && u[name];
+ if (e) e.value = v;
+ return;
+ }
+ const n = target[name];
+ if (n) n.value = v;
+}
+
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {number} path
+ * @param {number} [defaultValue]
+ * @return {number}
+ */
+function readScalar(target, name, path, defaultValue) {
+ if (defaultValue === undefined) defaultValue = 0;
+ if (!target) return defaultValue;
+ const first = Array.isArray(target) ? target[0] : target;
+ if (!first) return defaultValue;
+ const v = leafAt(first, name, path);
+ return v === undefined || v === null ? defaultValue : v;
+}
+
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {number} v
+ * @param {number} path
+ */
+function writeScalar(target, name, v, path) {
+ if (!target) return;
+ if (Array.isArray(target)) {
+ for (let i = 0, l = target.length; i < l; i++) writeLeafScalar(target[i], name, v, path);
+ } else {
+ writeLeafScalar(target, name, v, path);
+ }
+}
+
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {number} path
+ * @return {String | null}
+ */
+function readColorAt(target, name, path) {
+ if (!target) return null;
+ const first = Array.isArray(target) ? target[0] : target;
+ return readColorHex(first ? leafAt(first, name, path) : null);
+}
+
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {Array.<Number>} ns
+ * @param {number} path
+ */
+function writeColorAt(target, name, ns, path) {
+ if (!target) return;
+ const r = ns[0] * COLOR_NORM;
+ const g = ns[1] * COLOR_NORM;
+ const b = ns[2] * COLOR_NORM;
+ if (Array.isArray(target)) {
+ for (let i = 0, l = target.length; i < l; i++) {
+ const c = leafAt(target[i], name, path);
+ if (c) c.setRGB(r, g, b, three.SRGBColorSpace);
+ }
+ } else {
+ const c = leafAt(target, name, path);
+ if (c) c.setRGB(r, g, b, three.SRGBColorSpace);
+ }
+}
+
+/**
+ * @param {any} target
+ * @param {string} base
+ * @param {'x' | 'y' | 'z' | 'w'} axis
+ * @param {number} path
+ * @return {number}
+ */
+function readVectorAt(target, base, axis, path) {
+ if (!target) return 0;
+ const first = Array.isArray(target) ? target[0] : target;
+ const vec = first ? leafAt(first, base, path) : null;
+ return vec ? vec[axis] : 0;
+}
+
+/**
+ * @param {any} target
+ * @param {string} base
+ * @param {'x' | 'y' | 'z' | 'w'} axis
+ * @param {number} v
+ * @param {number} path
+ */
+function writeVectorAt(target, base, axis, v, path) {
+ if (!target) return;
+ if (Array.isArray(target)) {
+ for (let i = 0, l = target.length; i < l; i++) {
+ const vec = leafAt(target[i], base, path);
+ if (vec) vec[axis] = v;
+ }
+ } else {
+ const vec = leafAt(target, base, path);
+ if (vec) vec[axis] = v;
+ }
+}
+
+exports.AXIS_MAP = AXIS_MAP;
+exports.COLOR_NORM = COLOR_NORM;
+exports.KIND_COLOR = KIND_COLOR;
+exports.KIND_SCALAR = KIND_SCALAR;
+exports.KIND_VECTOR = KIND_VECTOR;
+exports.PATH_DIRECT = PATH_DIRECT;
+exports.applySkewOrigin = applySkewOrigin;
+exports.classifyTargetProp = classifyTargetProp;
+exports.isVectorWith = isVectorWith;
+exports.readColorAt = readColorAt;
+exports.readColorHex = readColorHex;
+exports.readScalar = readScalar;
+exports.readVectorAt = readVectorAt;
+exports.writeColorAt = writeColorAt;
+exports.writeScalar = writeScalar;
+exports.writeVectorAt = writeVectorAt;
diff --git a/dist/modules/adapters/three/helpers.d.ts b/dist/modules/adapters/three/helpers.d.ts
new file mode 100644
index 00000000..85449554
--- /dev/null
+++ b/dist/modules/adapters/three/helpers.d.ts
@@ -0,0 +1,89 @@
+/**
+ * Patches a column-major `Matrix4.elements` array in place with CSS-style `skewX(α)` / `skewY(β)`, the 3D extension `skewZ(γ)` (shears z by x), and a `transform-origin` shift.
+ *
+ * @param {number[]} e
+ * @param {number} skewX
+ * @param {number} skewY
+ * @param {number} skewZ
+ * @param {number} ox
+ * @param {number} oy
+ * @param {number} oz
+ */
+export function applySkewOrigin(e: number[], skewX: number, skewY: number, skewZ: number, ox: number, oy: number, oz: number): void;
+/**
+ * @param {any} c
+ * @return {String | null}
+ */
+export function readColorHex(c: any): string | null;
+/**
+ * Returns `true` when `v` is a `Vector2/3/4` instance whose dimension covers `axis`. `Quaternion` and plain `{x,y,z,w}`-shaped objects are intentionally rejected.
+ *
+ * @param {any} v
+ * @param {'x' | 'y' | 'z' | 'w'} axis
+ * @return {boolean}
+ */
+export function isVectorWith(v: any, axis: "x" | "y" | "z" | "w"): boolean;
+/**
+ * Classifies `target[name]` and returns a descriptor `{ kind, path, base, axis }` (or `null`). Used by the resolver entries in `resolvers.js` and by the `Object3D` adapter to build the matching access pattern for any three.js target (Object3D, Material, Texture, Fog, UniformNode).
+ *
+ * @param {any} target
+ * @param {string} name
+ * @return {{ kind: number, path: number, base: string, axis: 'x' | 'y' | 'z' | 'w' } | null}
+ */
+export function classifyTargetProp(target: any, name: string): {
+ kind: number;
+ path: number;
+ base: string;
+ axis: "x" | "y" | "z" | "w";
+} | null;
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {number} path
+ * @param {number} [defaultValue]
+ * @return {number}
+ */
+export function readScalar(target: any, name: string, path: number, defaultValue?: number): number;
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {number} v
+ * @param {number} path
+ */
+export function writeScalar(target: any, name: string, v: number, path: number): void;
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {number} path
+ * @return {String | null}
+ */
+export function readColorAt(target: any, name: string, path: number): string | null;
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {Array.<Number>} ns
+ * @param {number} path
+ */
+export function writeColorAt(target: any, name: string, ns: Array<number>, path: number): void;
+/**
+ * @param {any} target
+ * @param {string} base
+ * @param {'x' | 'y' | 'z' | 'w'} axis
+ * @param {number} path
+ * @return {number}
+ */
+export function readVectorAt(target: any, base: string, axis: "x" | "y" | "z" | "w", path: number): number;
+/**
+ * @param {any} target
+ * @param {string} base
+ * @param {'x' | 'y' | 'z' | 'w'} axis
+ * @param {number} v
+ * @param {number} path
+ */
+export function writeVectorAt(target: any, base: string, axis: "x" | "y" | "z" | "w", v: number, path: number): void;
+export const COLOR_NORM: number;
+export const AXIS_MAP: Record<string, "x" | "y" | "z" | "w">;
+export const PATH_DIRECT: 0;
+export const KIND_COLOR: 0;
+export const KIND_SCALAR: 1;
+export const KIND_VECTOR: 2;
diff --git a/dist/modules/adapters/three/helpers.js b/dist/modules/adapters/three/helpers.js
new file mode 100644
index 00000000..3a56d962
--- /dev/null
+++ b/dist/modules/adapters/three/helpers.js
@@ -0,0 +1,280 @@
+/**
+ * Anime.js - adapters - ESM
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+import { SRGBColorSpace } from 'three';
+import { degToRad } from '../../utils/number.js';
+
+/**
+ * Generic read/write helpers for the three.js bindings. Each operates on a target (or target array) and walks to the leaf via a path tag - direct (`target[name]`), uniform (`target.uniforms[name].value`), or TSL node (`target[name].value`). Adapter and resolver files pass the matching `PATH_*` constant; the JIT specializes each call site so the branch in `leafAt` / `writeLeafScalar` constant-folds.
+ */
+
+
+const COLOR_NORM = 1 / 255;
+
+const AXIS_MAP = /** @type {Record<string, 'x' | 'y' | 'z' | 'w'>} */({ X: 'x', Y: 'y', Z: 'z', W: 'w' });
+
+const PATH_DIRECT = 0;
+const PATH_UNIFORM = 1;
+const PATH_NODE = 2;
+
+const KIND_COLOR = 0;
+const KIND_SCALAR = 1;
+const KIND_VECTOR = 2;
+
+// Reuse one mutable descriptor across calls, callers must consume immediately since the next call mutates it.
+const desc = { kind: 0, path: 0, base: '', axis: /** @type {'x' | 'y' | 'z' | 'w'} */('x') };
+
+/**
+ * Patches a column-major `Matrix4.elements` array in place with CSS-style `skewX(α)` / `skewY(β)`, the 3D extension `skewZ(γ)` (shears z by x), and a `transform-origin` shift.
+ *
+ * @param {number[]} e
+ * @param {number} skewX
+ * @param {number} skewY
+ * @param {number} skewZ
+ * @param {number} ox
+ * @param {number} oy
+ * @param {number} oz
+ */
+function applySkewOrigin(e, skewX, skewY, skewZ, ox, oy, oz) {
+ if (skewX !== 0) {
+ const t = Math.tan(degToRad(skewX));
+ e[4] += e[0] * t;
+ e[5] += e[1] * t;
+ e[6] += e[2] * t;
+ }
+ if (skewY !== 0) {
+ const t = Math.tan(degToRad(skewY));
+ e[0] += e[4] * t;
+ e[1] += e[5] * t;
+ e[2] += e[6] * t;
+ }
+ if (skewZ !== 0) {
+ const t = Math.tan(degToRad(skewZ));
+ e[0] += e[8] * t;
+ e[1] += e[9] * t;
+ e[2] += e[10] * t;
+ }
+ if (ox !== 0 || oy !== 0 || oz !== 0) {
+ e[12] += ox - (e[0] * ox + e[4] * oy + e[8] * oz);
+ e[13] += oy - (e[1] * ox + e[5] * oy + e[9] * oz);
+ e[14] += oz - (e[2] * ox + e[6] * oy + e[10] * oz);
+ }
+}
+
+/**
+ * @param {any} c
+ * @return {String | null}
+ */
+function readColorHex(c) {
+ return c ? `#${c.getHexString(SRGBColorSpace)}` : null;
+}
+
+/**
+ * Returns `true` when `v` is a `Vector2/3/4` instance whose dimension covers `axis`. `Quaternion` and plain `{x,y,z,w}`-shaped objects are intentionally rejected.
+ *
+ * @param {any} v
+ * @param {'x' | 'y' | 'z' | 'w'} axis
+ * @return {boolean}
+ */
+function isVectorWith(v, axis) {
+ if (!v) return false;
+ if (axis === 'x' || axis === 'y') return !!(v.isVector2 || v.isVector3 || v.isVector4);
+ if (axis === 'z') return !!(v.isVector3 || v.isVector4);
+ return !!v.isVector4;
+}
+
+/**
+ * Classifies `target[name]` and returns a descriptor `{ kind, path, base, axis }` (or `null`). Used by the resolver entries in `resolvers.js` and by the `Object3D` adapter to build the matching access pattern for any three.js target (Object3D, Material, Texture, Fog, UniformNode).
+ *
+ * @param {any} target
+ * @param {string} name
+ * @return {{ kind: number, path: number, base: string, axis: 'x' | 'y' | 'z' | 'w' } | null}
+ */
+function classifyTargetProp(target, name) {
+ const value = target[name];
+ if (value !== undefined) {
+ if (value && value.isColor) {
+ desc.kind = KIND_COLOR; desc.path = PATH_DIRECT;
+ return desc;
+ }
+ if (value && value.isUniformNode) {
+ // Route TSL slot writes through node value, booleans share the scalar entry.
+ const v = value.value;
+ if (v && v.isColor) {
+ desc.kind = KIND_COLOR; desc.path = PATH_NODE;
+ return desc;
+ }
+ if (typeof v === 'number' || typeof v === 'boolean') {
+ desc.kind = KIND_SCALAR; desc.path = PATH_NODE;
+ return desc;
+ }
+ return null;
+ }
+ if (typeof value === 'number' || typeof value === 'boolean') {
+ desc.kind = KIND_SCALAR; desc.path = PATH_DIRECT;
+ return desc;
+ }
+ return null;
+ }
+ const uniforms = target.uniforms;
+ const u = uniforms && uniforms[name];
+ if (u) {
+ const uv = u.value;
+ if (uv && uv.isColor) {
+ desc.kind = KIND_COLOR; desc.path = PATH_UNIFORM;
+ return desc;
+ }
+ if (typeof uv === 'number') {
+ desc.kind = KIND_SCALAR; desc.path = PATH_UNIFORM;
+ return desc;
+ }
+ }
+ // Decompose vector axis for names like posX, uOffsetY, uVec4W, colorNodeX.
+ const axis = AXIS_MAP[name[name.length - 1]];
+ if (axis) {
+ const base = name.slice(0, -1);
+ if (isVectorWith(target[base], axis)) {
+ desc.kind = KIND_VECTOR; desc.path = PATH_DIRECT; desc.base = base; desc.axis = axis;
+ return desc;
+ }
+ const baseSlot = target[base];
+ if (baseSlot && baseSlot.isUniformNode && isVectorWith(baseSlot.value, axis)) {
+ desc.kind = KIND_VECTOR; desc.path = PATH_NODE; desc.base = base; desc.axis = axis;
+ return desc;
+ }
+ const ub = uniforms && uniforms[base];
+ if (ub && isVectorWith(ub.value, axis)) {
+ desc.kind = KIND_VECTOR; desc.path = PATH_UNIFORM; desc.base = base; desc.axis = axis;
+ return desc;
+ }
+ }
+ return null;
+}
+
+function leafAt(target, name, path) {
+ if (path === PATH_DIRECT) return target[name];
+ if (path === PATH_UNIFORM) {
+ const u = target.uniforms;
+ const e = u && u[name];
+ return e ? e.value : null;
+ }
+ const n = target[name];
+ return n ? n.value : null;
+}
+
+function writeLeafScalar(target, name, v, path) {
+ if (path === PATH_DIRECT) { target[name] = v; return; }
+ if (path === PATH_UNIFORM) {
+ const u = target.uniforms;
+ const e = u && u[name];
+ if (e) e.value = v;
+ return;
+ }
+ const n = target[name];
+ if (n) n.value = v;
+}
+
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {number} path
+ * @param {number} [defaultValue]
+ * @return {number}
+ */
+function readScalar(target, name, path, defaultValue) {
+ if (defaultValue === undefined) defaultValue = 0;
+ if (!target) return defaultValue;
+ const first = Array.isArray(target) ? target[0] : target;
+ if (!first) return defaultValue;
+ const v = leafAt(first, name, path);
+ return v === undefined || v === null ? defaultValue : v;
+}
+
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {number} v
+ * @param {number} path
+ */
+function writeScalar(target, name, v, path) {
+ if (!target) return;
+ if (Array.isArray(target)) {
+ for (let i = 0, l = target.length; i < l; i++) writeLeafScalar(target[i], name, v, path);
+ } else {
+ writeLeafScalar(target, name, v, path);
+ }
+}
+
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {number} path
+ * @return {String | null}
+ */
+function readColorAt(target, name, path) {
+ if (!target) return null;
+ const first = Array.isArray(target) ? target[0] : target;
+ return readColorHex(first ? leafAt(first, name, path) : null);
+}
+
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {Array.<Number>} ns
+ * @param {number} path
+ */
+function writeColorAt(target, name, ns, path) {
+ if (!target) return;
+ const r = ns[0] * COLOR_NORM;
+ const g = ns[1] * COLOR_NORM;
+ const b = ns[2] * COLOR_NORM;
+ if (Array.isArray(target)) {
+ for (let i = 0, l = target.length; i < l; i++) {
+ const c = leafAt(target[i], name, path);
+ if (c) c.setRGB(r, g, b, SRGBColorSpace);
+ }
+ } else {
+ const c = leafAt(target, name, path);
+ if (c) c.setRGB(r, g, b, SRGBColorSpace);
+ }
+}
+
+/**
+ * @param {any} target
+ * @param {string} base
+ * @param {'x' | 'y' | 'z' | 'w'} axis
+ * @param {number} path
+ * @return {number}
+ */
+function readVectorAt(target, base, axis, path) {
+ if (!target) return 0;
+ const first = Array.isArray(target) ? target[0] : target;
+ const vec = first ? leafAt(first, base, path) : null;
+ return vec ? vec[axis] : 0;
+}
+
+/**
+ * @param {any} target
+ * @param {string} base
+ * @param {'x' | 'y' | 'z' | 'w'} axis
+ * @param {number} v
+ * @param {number} path
+ */
+function writeVectorAt(target, base, axis, v, path) {
+ if (!target) return;
+ if (Array.isArray(target)) {
+ for (let i = 0, l = target.length; i < l; i++) {
+ const vec = leafAt(target[i], base, path);
+ if (vec) vec[axis] = v;
+ }
+ } else {
+ const vec = leafAt(target, base, path);
+ if (vec) vec[axis] = v;
+ }
+}
+
+export { AXIS_MAP, COLOR_NORM, KIND_COLOR, KIND_SCALAR, KIND_VECTOR, PATH_DIRECT, applySkewOrigin, classifyTargetProp, isVectorWith, readColorAt, readColorHex, readScalar, readVectorAt, writeColorAt, writeScalar, writeVectorAt };
diff --git a/dist/modules/adapters/three/index.cjs b/dist/modules/adapters/three/index.cjs
new file mode 100644
index 00000000..05a87a9f
--- /dev/null
+++ b/dist/modules/adapters/three/index.cjs
@@ -0,0 +1,20 @@
+/**
+ * Anime.js - adapters - CJS
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+'use strict';
+
+var adapter = require('./adapter.cjs');
+require('./resolvers.cjs');
+require('./uniform.cjs');
+require('./object3d.cjs');
+var instance = require('./instance.cjs');
+
+
+
+exports.threeAdapter = adapter.threeAdapter;
+exports.commitChanges = instance.commitChanges;
+exports.getInstances = instance.getInstances;
diff --git a/dist/modules/adapters/three/index.d.ts b/dist/modules/adapters/three/index.d.ts
new file mode 100644
index 00000000..58e2cfba
--- /dev/null
+++ b/dist/modules/adapters/three/index.d.ts
@@ -0,0 +1,2 @@
+export { threeAdapter } from "./adapter.js";
+export { getInstances, commitChanges } from "./instance.js";
diff --git a/dist/modules/adapters/three/index.js b/dist/modules/adapters/three/index.js
new file mode 100644
index 00000000..07dc038f
--- /dev/null
+++ b/dist/modules/adapters/three/index.js
@@ -0,0 +1,12 @@
+/**
+ * Anime.js - adapters - ESM
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+export { threeAdapter } from './adapter.js';
+import './resolvers.js';
+import './uniform.js';
+import './object3d.js';
+export { commitChanges, getInstances } from './instance.js';
diff --git a/dist/modules/adapters/three/instance.cjs b/dist/modules/adapters/three/instance.cjs
new file mode 100644
index 00000000..035a04e2
--- /dev/null
+++ b/dist/modules/adapters/three/instance.cjs
@@ -0,0 +1,368 @@
+/**
+ * Anime.js - adapters - CJS
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+'use strict';
+
+var three = require('three');
+var number = require('../../utils/number.cjs');
+var adapter = require('./adapter.cjs');
+var helpers = require('./helpers.cjs');
+
+const hasSkewOrigin = (t) => !!(t._skewX || t._skewY || t._skewZ || t._originX || t._originY || t._originZ);
+
+/**
+ * @import { Object3D, InstancedMesh } from 'three'
+ *
+ * @typedef {InstancedMesh | BatchedMesh} InstanceParent
+ */
+
+const DIRTY_POS = 1;
+const DIRTY_ROT = 2;
+const DIRTY_SCALE = 4;
+const DIRTY_SKEW = 8;
+
+/** @type {WeakMap<InstanceParent, InstanceBinding>} */
+const bindings = new WeakMap();
+
+/**
+ * Per-mesh state for `InstancedMesh` / `BatchedMesh` animations. Holds the instance array, the dirty queue, and the chained `onBeforeRender` closure.
+ */
+class InstanceBinding {
+
+ /** @param {InstanceParent} mesh */
+ constructor(mesh) {
+ this.mesh = mesh;
+ this.hasInstanceMatrix = 'instanceMatrix' in mesh;
+ /** @type {(Instance | null)[]} */
+ this.instances = [];
+ /** @type {Instance[]} */
+ this.dirtyList = [];
+ /** @type {Object3D['onBeforeRender'] | null} */
+ this.userOnBeforeRender = mesh.onBeforeRender || null;
+ this.chainedHandler = makeChainedHandler(this);
+ Object.defineProperty(mesh, 'onBeforeRender', {
+ configurable: true,
+ get: () => this.chainedHandler,
+ set: (fn) => { this.userOnBeforeRender = fn; },
+ });
+ }
+
+ flush() {
+ const list = this.dirtyList;
+ if (list.length === 0) return;
+ for (let i = 0, l = list.length; i < l; i++) list[i]._flush();
+ if (this.hasInstanceMatrix) /** @type {InstancedMesh} */(this.mesh).instanceMatrix.needsUpdate = true;
+ list.length = 0;
+ }
+
+}
+
+/**
+ * @param {InstanceBinding} binding
+ * @return {Object3D['onBeforeRender']}
+ */
+function makeChainedHandler(binding) {
+ return function (renderer, scene, camera, geometry, material, group) {
+ binding.flush();
+ const u = binding.userOnBeforeRender;
+ if (u) u.call(binding.mesh, renderer, scene, camera, geometry, material, group);
+ };
+}
+
+/**
+ * Per-instance adapter for `InstancedMesh` or `BatchedMesh`. Returned by `getInstances(mesh)`. Exposes the same flat properties as the mesh adapter, applied to a single instance id. Writes are coalesced and flushed before each render via `onBeforeRender`; call `commitChanges(mesh)` if you need to read `mesh.instanceMatrix` between a tick and a render.
+ *
+ * Caveats:
+ * - `opacity` writes the parent's shared material, every instance is affected.
+ * - `visible` is backed by `BatchedMesh.setVisibleAt`. On `InstancedMesh` it is a no-op, use `scale = 0` to hide an instance.
+ */
+class Instance {
+
+ /**
+ * @param {InstanceBinding} binding
+ * @param {number} id
+ */
+ constructor(binding, id) {
+ this.isAnimejsInstanceProxy = true;
+ this.parent = binding.mesh;
+ this.id = id;
+ this._position = new three.Vector3();
+ this._rotation = new three.Euler(0, 0, 0, 'XYZ');
+ this._scale = new three.Vector3(1, 1, 1);
+ this._matrix = new three.Matrix4();
+ this._quat = new three.Quaternion();
+ // Pre-allocate _color so the hidden class stays stable, set color mutates it in place rather than re-binding the field.
+ this._color = new three.Color();
+ this._dirty = 0;
+ // Skew in degrees and transform-origin in object-space.
+ // applySkewOrigin computes Math.tan inline per non-zero axis, so we only carry the user-facing angle here.
+ this._skewX = 0;
+ this._skewY = 0;
+ this._skewZ = 0;
+ this._originX = 0;
+ this._originY = 0;
+ this._originZ = 0;
+ // Skip the position-only fast path in _flush whenever any skew or origin is non-zero, since both modify the matrix beyond pure translation.
+ this._hasSkewOrigin = false;
+ // Cache the binding dirty queue once so per-frame setters skip a property hop.
+ /** @type {Instance[]} */
+ this._dirtyList = binding.dirtyList;
+ // Cache parent capability flags once so per-frame setters skip prototype-chain in checks.
+ const parent = binding.mesh;
+ this._hasSetColor = 'setColorAt' in parent;
+ this._hasSetVisible = 'setVisibleAt' in parent;
+ this._hasGetVisible = 'getVisibleAt' in parent;
+
+ parent.getMatrixAt(id, this._matrix);
+ if (this._matrix.elements[15] === 0) this._matrix.identity();
+ this._matrix.decompose(this._position, this._quat, this._scale);
+ this._rotation.setFromQuaternion(this._quat, 'XYZ');
+
+ if ('getColorAt' in parent && 'instanceColor' in parent && parent.instanceColor) {
+ parent.getColorAt(id, this._color);
+ }
+ }
+
+ /**
+ * @param {number} flag
+ */
+ _markDirty(flag) {
+ // Enqueue once per frame, later flags only OR into _dirty without re-pushing to the queue.
+ if (this._dirty === 0) this._dirtyList.push(this);
+ this._dirty |= flag;
+ }
+
+ _flush() {
+ const d = this._dirty;
+ if (!d) return;
+ const m = this._matrix;
+ const p = this._position;
+ if (d === DIRTY_POS && !this._hasSkewOrigin) {
+ const e = m.elements;
+ e[12] = p.x; e[13] = p.y; e[14] = p.z;
+ } else {
+ const q = this._quat;
+ if (d & DIRTY_ROT) q.setFromEuler(this._rotation);
+ m.compose(p, q, this._scale);
+ if (this._hasSkewOrigin) {
+ helpers.applySkewOrigin(m.elements, this._skewX, this._skewY, this._skewZ, this._originX, this._originY, this._originZ);
+ }
+ }
+ this.parent.setMatrixAt(this.id, m);
+ this._dirty = 0;
+ }
+
+ get x() { return this._position.x; }
+ set x(v) { this._position.x = v; this._markDirty(DIRTY_POS); }
+
+ get y() { return this._position.y; }
+ set y(v) { this._position.y = v; this._markDirty(DIRTY_POS); }
+
+ get z() { return this._position.z; }
+ set z(v) { this._position.z = v; this._markDirty(DIRTY_POS); }
+
+ get rotateX() { return number.radToDeg(this._rotation.x); }
+ set rotateX(v) { this._rotation.x = number.degToRad(v); this._markDirty(DIRTY_ROT); }
+
+ get rotateY() { return number.radToDeg(this._rotation.y); }
+ set rotateY(v) { this._rotation.y = number.degToRad(v); this._markDirty(DIRTY_ROT); }
+
+ get rotateZ() { return number.radToDeg(this._rotation.z); }
+ set rotateZ(v) { this._rotation.z = number.degToRad(v); this._markDirty(DIRTY_ROT); }
+
+ get scaleX() { return this._scale.x; }
+ set scaleX(v) { this._scale.x = v; this._markDirty(DIRTY_SCALE); }
+
+ get scaleY() { return this._scale.y; }
+ set scaleY(v) { this._scale.y = v; this._markDirty(DIRTY_SCALE); }
+
+ get scaleZ() { return this._scale.z; }
+ set scaleZ(v) { this._scale.z = v; this._markDirty(DIRTY_SCALE); }
+
+ get scale() { return this._scale.x; }
+ set scale(v) {
+ const s = this._scale;
+ s.x = v; s.y = v; s.z = v;
+ this._markDirty(DIRTY_SCALE);
+ }
+
+ get skewX() { return this._skewX; }
+ set skewX(v) {
+ this._skewX = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get skewY() { return this._skewY; }
+ set skewY(v) {
+ this._skewY = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get skewZ() { return this._skewZ; }
+ set skewZ(v) {
+ this._skewZ = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get transformOriginX() { return this._originX; }
+ set transformOriginX(v) {
+ this._originX = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get transformOriginY() { return this._originY; }
+ set transformOriginY(v) {
+ this._originY = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get transformOriginZ() { return this._originZ; }
+ set transformOriginZ(v) {
+ this._originZ = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get opacity() {
+ return helpers.readScalar(/** @type {any} */(this.parent).material, 'opacity', helpers.PATH_DIRECT, 1);
+ }
+ /** @param {number} v */
+ set opacity(v) {
+ helpers.writeScalar(/** @type {any} */(this.parent).material, 'opacity', v, helpers.PATH_DIRECT);
+ }
+
+ get visible() {
+ return this._hasGetVisible ? /** @type {any} */(this.parent).getVisibleAt(this.id) : true;
+ }
+ /** @param {boolean} v */
+ set visible(v) {
+ if (this._hasSetVisible) /** @type {any} */(this.parent).setVisibleAt(this.id, v);
+ }
+
+}
+
+/**
+ * Flushes pending matrix writes for every dirty instance of `mesh`.
+ * Called automatically before each render. Call it yourself if you read
+ * `mesh.instanceMatrix` between an animation tick and the next render.
+ *
+ * @param {InstanceParent} mesh
+ */
+function commitChanges(mesh) {
+ const binding = bindings.get(mesh);
+ if (binding) binding.flush();
+}
+
+/**
+ * Returns an array of per-instance adapters for `mesh`. Index by id, deleted slots on `BatchedMesh` are `null`. Pass the array (or a slice / a single element) to `animate()`.
+ *
+ * animate(getInstances(mesh), { x: 100, delay: stagger(5) });
+ * animate(getInstances(mesh)[42], { scale: 2 });
+ *
+ * The same array reference is preserved across `mesh.count` / `addInstance` / `deleteInstance` calls. Entries are pushed, nulled, or truncated in place. Animations bound to an outdated reference keep tweening their original adapters.
+ *
+ * `mesh.onBeforeRender` is replaced with an accessor that flushes
+ * pending instance writes before each render and forwards to your
+ * handler. Assigning your own `mesh.onBeforeRender = fn` keeps the
+ * auto-flush, but reading `mesh.onBeforeRender` afterwards returns the
+ * chained dispatcher rather than `fn` itself, so identity checks
+ * (`mesh.onBeforeRender === fn`) will not match.
+ *
+ * @param {InstanceParent} mesh
+ * @return {(Instance | null)[]}
+ */
+function getInstances(mesh) {
+ let binding = bindings.get(mesh);
+ if (!binding) {
+ binding = new InstanceBinding(mesh);
+ bindings.set(mesh, binding);
+ }
+ if (mesh instanceof three.BatchedMesh) {
+ return refreshBatched(binding);
+ }
+ return refreshInstanced(binding);
+}
+
+/**
+ * @param {InstanceBinding} binding
+ * @return {(Instance | null)[]}
+ */
+function refreshInstanced(binding) {
+ const mesh = /** @type {InstancedMesh} */(binding.mesh);
+ const count = mesh.count;
+ const arr = binding.instances;
+ if (arr.length === 0 && count > 0) {
+ arr.length = count;
+ for (let i = 0; i < count; i++) arr[i] = new Instance(binding, i);
+ return arr;
+ }
+ if (arr.length < count) {
+ for (let i = arr.length; i < count; i++) arr.push(new Instance(binding, i));
+ } else if (arr.length > count) {
+ arr.length = count;
+ }
+ return arr;
+}
+
+/**
+ * @param {InstanceBinding} binding
+ * @return {(Instance | null)[]}
+ */
+function refreshBatched(binding) {
+ const mesh = /** @type {BatchedMesh} */(binding.mesh);
+ const arr = binding.instances;
+ // Read three internal _instanceInfo to skip slots marked inactive by deleteInstance.
+ // Iterate the full slot count, not instanceCount, since deleted slots leave gaps but live ids past them must still be visited.
+ const instanceInfo = /** @type {{ _instanceInfo?: { active: boolean }[] }} */(mesh)._instanceInfo ?? [];
+ const len = instanceInfo.length;
+ if (arr.length < len) arr.length = len;
+ for (let i = 0; i < len; i++) {
+ const info = instanceInfo[i];
+ const inactive = info && info.active === false;
+ if (inactive) {
+ arr[i] = null;
+ } else if (!arr[i]) {
+ arr[i] = new Instance(binding, i);
+ }
+ }
+ if (arr.length > len) arr.length = len;
+ return arr;
+}
+
+const instanceAdapter = adapter.threeAdapter.registerTargetAdapter((t) => t instanceof Instance);
+instanceAdapter.registerProperty('color',
+ (t) => helpers.readColorHex(t._color),
+ (t, _, tw) => {
+ if (!t._hasSetColor) return;
+ const ns = tw._numbers;
+ t._color.setRGB(ns[0] * helpers.COLOR_NORM, ns[1] * helpers.COLOR_NORM, ns[2] * helpers.COLOR_NORM, three.SRGBColorSpace);
+ const p = /** @type {any} */(t.parent);
+ p.setColorAt(t.id, t._color);
+ if (p.instanceColor) p.instanceColor.needsUpdate = true;
+ },
+);
+// Shorthand 3-token string x y z routed via the engine COMPLEX path.
+// The setter reads tween _numbers for the per-frame lerped triplet.
+instanceAdapter.registerProperty('transformOrigin',
+ (t) => `${t._originX} ${t._originY} ${t._originZ}`,
+ (t, _, tw) => {
+ const ns = tw._numbers;
+ t._originX = ns[0];
+ t._originY = ns[1];
+ t._originZ = ns[2];
+ t._hasSkewOrigin = hasSkewOrigin(t);
+ t._markDirty(DIRTY_SKEW);
+ },
+);
+
+exports.commitChanges = commitChanges;
+exports.getInstances = getInstances;
diff --git a/dist/modules/adapters/three/instance.d.ts b/dist/modules/adapters/three/instance.d.ts
new file mode 100644
index 00000000..25d54e07
--- /dev/null
+++ b/dist/modules/adapters/three/instance.d.ts
@@ -0,0 +1,133 @@
+/**
+ * Flushes pending matrix writes for every dirty instance of `mesh`.
+ * Called automatically before each render. Call it yourself if you read
+ * `mesh.instanceMatrix` between an animation tick and the next render.
+ *
+ * @param {InstanceParent} mesh
+ */
+export function commitChanges(mesh: InstanceParent): void;
+/**
+ * Returns an array of per-instance adapters for `mesh`. Index by id, deleted slots on `BatchedMesh` are `null`. Pass the array (or a slice / a single element) to `animate()`.
+ *
+ * animate(getInstances(mesh), { x: 100, delay: stagger(5) });
+ * animate(getInstances(mesh)[42], { scale: 2 });
+ *
+ * The same array reference is preserved across `mesh.count` / `addInstance` / `deleteInstance` calls. Entries are pushed, nulled, or truncated in place. Animations bound to an outdated reference keep tweening their original adapters.
+ *
+ * `mesh.onBeforeRender` is replaced with an accessor that flushes
+ * pending instance writes before each render and forwards to your
+ * handler. Assigning your own `mesh.onBeforeRender = fn` keeps the
+ * auto-flush, but reading `mesh.onBeforeRender` afterwards returns the
+ * chained dispatcher rather than `fn` itself, so identity checks
+ * (`mesh.onBeforeRender === fn`) will not match.
+ *
+ * @param {InstanceParent} mesh
+ * @return {(Instance | null)[]}
+ */
+export function getInstances(mesh: InstanceParent): (Instance | null)[];
+export type InstanceParent = InstancedMesh | BatchedMesh;
+/**
+ * Per-instance adapter for `InstancedMesh` or `BatchedMesh`. Returned by `getInstances(mesh)`. Exposes the same flat properties as the mesh adapter, applied to a single instance id. Writes are coalesced and flushed before each render via `onBeforeRender`; call `commitChanges(mesh)` if you need to read `mesh.instanceMatrix` between a tick and a render.
+ *
+ * Caveats:
+ * - `opacity` writes the parent's shared material, every instance is affected.
+ * - `visible` is backed by `BatchedMesh.setVisibleAt`. On `InstancedMesh` it is a no-op, use `scale = 0` to hide an instance.
+ */
+declare class Instance {
+ /**
+ * @param {InstanceBinding} binding
+ * @param {number} id
+ */
+ constructor(binding: InstanceBinding, id: number);
+ isAnimejsInstanceProxy: boolean;
+ parent: InstanceParent;
+ id: number;
+ _position: Vector3;
+ _rotation: Euler;
+ _scale: Vector3;
+ _matrix: Matrix4;
+ _quat: Quaternion;
+ _color: Color;
+ _dirty: number;
+ _skewX: number;
+ _skewY: number;
+ _skewZ: number;
+ _originX: number;
+ _originY: number;
+ _originZ: number;
+ _hasSkewOrigin: boolean;
+ /** @type {Instance[]} */
+ _dirtyList: Instance[];
+ _hasSetColor: boolean;
+ _hasSetVisible: boolean;
+ _hasGetVisible: boolean;
+ /**
+ * @param {number} flag
+ */
+ _markDirty(flag: number): void;
+ _flush(): void;
+ set x(v: number);
+ get x(): number;
+ set y(v: number);
+ get y(): number;
+ set z(v: number);
+ get z(): number;
+ set rotateX(v: number);
+ get rotateX(): number;
+ set rotateY(v: number);
+ get rotateY(): number;
+ set rotateZ(v: number);
+ get rotateZ(): number;
+ set scaleX(v: number);
+ get scaleX(): number;
+ set scaleY(v: number);
+ get scaleY(): number;
+ set scaleZ(v: number);
+ get scaleZ(): number;
+ set scale(v: number);
+ get scale(): number;
+ set skewX(v: number);
+ get skewX(): number;
+ set skewY(v: number);
+ get skewY(): number;
+ set skewZ(v: number);
+ get skewZ(): number;
+ set transformOriginX(v: number);
+ get transformOriginX(): number;
+ set transformOriginY(v: number);
+ get transformOriginY(): number;
+ set transformOriginZ(v: number);
+ get transformOriginZ(): number;
+ /** @param {number} v */
+ set opacity(v: number);
+ get opacity(): number;
+ /** @param {boolean} v */
+ set visible(v: boolean);
+ get visible(): boolean;
+}
+import type { InstancedMesh } from 'three';
+import { BatchedMesh } from 'three';
+import { Vector3 } from 'three';
+import { Euler } from 'three';
+import { Matrix4 } from 'three';
+import { Quaternion } from 'three';
+import { Color } from 'three';
+/**
+ * Per-mesh state for `InstancedMesh` / `BatchedMesh` animations. Holds the instance array, the dirty queue, and the chained `onBeforeRender` closure.
+ */
+declare class InstanceBinding {
+ /** @param {InstanceParent} mesh */
+ constructor(mesh: InstanceParent);
+ mesh: InstanceParent;
+ hasInstanceMatrix: boolean;
+ /** @type {(Instance | null)[]} */
+ instances: (Instance | null)[];
+ /** @type {Instance[]} */
+ dirtyList: Instance[];
+ /** @type {Object3D['onBeforeRender'] | null} */
+ userOnBeforeRender: Object3D["onBeforeRender"] | null;
+ chainedHandler: (renderer: import("three").WebGLRenderer, scene: import("three").Scene, camera: import("three").Camera, geometry: import("three").BufferGeometry, material: import("three").Material, group: import("three").Group) => void;
+ flush(): void;
+}
+import type { Object3D } from 'three';
+export {};
diff --git a/dist/modules/adapters/three/instance.js b/dist/modules/adapters/three/instance.js
new file mode 100644
index 00000000..e78f4dfd
--- /dev/null
+++ b/dist/modules/adapters/three/instance.js
@@ -0,0 +1,365 @@
+/**
+ * Anime.js - adapters - ESM
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+import { SRGBColorSpace, Vector3, Euler, Matrix4, Quaternion, Color, BatchedMesh } from 'three';
+import { radToDeg, degToRad } from '../../utils/number.js';
+import { threeAdapter } from './adapter.js';
+import { readColorHex, COLOR_NORM, applySkewOrigin, readScalar, PATH_DIRECT, writeScalar } from './helpers.js';
+
+const hasSkewOrigin = (t) => !!(t._skewX || t._skewY || t._skewZ || t._originX || t._originY || t._originZ);
+
+/**
+ * @import { Object3D, InstancedMesh } from 'three'
+ *
+ * @typedef {InstancedMesh | BatchedMesh} InstanceParent
+ */
+
+const DIRTY_POS = 1;
+const DIRTY_ROT = 2;
+const DIRTY_SCALE = 4;
+const DIRTY_SKEW = 8;
+
+/** @type {WeakMap<InstanceParent, InstanceBinding>} */
+const bindings = new WeakMap();
+
+/**
+ * Per-mesh state for `InstancedMesh` / `BatchedMesh` animations. Holds the instance array, the dirty queue, and the chained `onBeforeRender` closure.
+ */
+class InstanceBinding {
+
+ /** @param {InstanceParent} mesh */
+ constructor(mesh) {
+ this.mesh = mesh;
+ this.hasInstanceMatrix = 'instanceMatrix' in mesh;
+ /** @type {(Instance | null)[]} */
+ this.instances = [];
+ /** @type {Instance[]} */
+ this.dirtyList = [];
+ /** @type {Object3D['onBeforeRender'] | null} */
+ this.userOnBeforeRender = mesh.onBeforeRender || null;
+ this.chainedHandler = makeChainedHandler(this);
+ Object.defineProperty(mesh, 'onBeforeRender', {
+ configurable: true,
+ get: () => this.chainedHandler,
+ set: (fn) => { this.userOnBeforeRender = fn; },
+ });
+ }
+
+ flush() {
+ const list = this.dirtyList;
+ if (list.length === 0) return;
+ for (let i = 0, l = list.length; i < l; i++) list[i]._flush();
+ if (this.hasInstanceMatrix) /** @type {InstancedMesh} */(this.mesh).instanceMatrix.needsUpdate = true;
+ list.length = 0;
+ }
+
+}
+
+/**
+ * @param {InstanceBinding} binding
+ * @return {Object3D['onBeforeRender']}
+ */
+function makeChainedHandler(binding) {
+ return function (renderer, scene, camera, geometry, material, group) {
+ binding.flush();
+ const u = binding.userOnBeforeRender;
+ if (u) u.call(binding.mesh, renderer, scene, camera, geometry, material, group);
+ };
+}
+
+/**
+ * Per-instance adapter for `InstancedMesh` or `BatchedMesh`. Returned by `getInstances(mesh)`. Exposes the same flat properties as the mesh adapter, applied to a single instance id. Writes are coalesced and flushed before each render via `onBeforeRender`; call `commitChanges(mesh)` if you need to read `mesh.instanceMatrix` between a tick and a render.
+ *
+ * Caveats:
+ * - `opacity` writes the parent's shared material, every instance is affected.
+ * - `visible` is backed by `BatchedMesh.setVisibleAt`. On `InstancedMesh` it is a no-op, use `scale = 0` to hide an instance.
+ */
+class Instance {
+
+ /**
+ * @param {InstanceBinding} binding
+ * @param {number} id
+ */
+ constructor(binding, id) {
+ this.isAnimejsInstanceProxy = true;
+ this.parent = binding.mesh;
+ this.id = id;
+ this._position = new Vector3();
+ this._rotation = new Euler(0, 0, 0, 'XYZ');
+ this._scale = new Vector3(1, 1, 1);
+ this._matrix = new Matrix4();
+ this._quat = new Quaternion();
+ // Pre-allocate _color so the hidden class stays stable, set color mutates it in place rather than re-binding the field.
+ this._color = new Color();
+ this._dirty = 0;
+ // Skew in degrees and transform-origin in object-space.
+ // applySkewOrigin computes Math.tan inline per non-zero axis, so we only carry the user-facing angle here.
+ this._skewX = 0;
+ this._skewY = 0;
+ this._skewZ = 0;
+ this._originX = 0;
+ this._originY = 0;
+ this._originZ = 0;
+ // Skip the position-only fast path in _flush whenever any skew or origin is non-zero, since both modify the matrix beyond pure translation.
+ this._hasSkewOrigin = false;
+ // Cache the binding dirty queue once so per-frame setters skip a property hop.
+ /** @type {Instance[]} */
+ this._dirtyList = binding.dirtyList;
+ // Cache parent capability flags once so per-frame setters skip prototype-chain in checks.
+ const parent = binding.mesh;
+ this._hasSetColor = 'setColorAt' in parent;
+ this._hasSetVisible = 'setVisibleAt' in parent;
+ this._hasGetVisible = 'getVisibleAt' in parent;
+
+ parent.getMatrixAt(id, this._matrix);
+ if (this._matrix.elements[15] === 0) this._matrix.identity();
+ this._matrix.decompose(this._position, this._quat, this._scale);
+ this._rotation.setFromQuaternion(this._quat, 'XYZ');
+
+ if ('getColorAt' in parent && 'instanceColor' in parent && parent.instanceColor) {
+ parent.getColorAt(id, this._color);
+ }
+ }
+
+ /**
+ * @param {number} flag
+ */
+ _markDirty(flag) {
+ // Enqueue once per frame, later flags only OR into _dirty without re-pushing to the queue.
+ if (this._dirty === 0) this._dirtyList.push(this);
+ this._dirty |= flag;
+ }
+
+ _flush() {
+ const d = this._dirty;
+ if (!d) return;
+ const m = this._matrix;
+ const p = this._position;
+ if (d === DIRTY_POS && !this._hasSkewOrigin) {
+ const e = m.elements;
+ e[12] = p.x; e[13] = p.y; e[14] = p.z;
+ } else {
+ const q = this._quat;
+ if (d & DIRTY_ROT) q.setFromEuler(this._rotation);
+ m.compose(p, q, this._scale);
+ if (this._hasSkewOrigin) {
+ applySkewOrigin(m.elements, this._skewX, this._skewY, this._skewZ, this._originX, this._originY, this._originZ);
+ }
+ }
+ this.parent.setMatrixAt(this.id, m);
+ this._dirty = 0;
+ }
+
+ get x() { return this._position.x; }
+ set x(v) { this._position.x = v; this._markDirty(DIRTY_POS); }
+
+ get y() { return this._position.y; }
+ set y(v) { this._position.y = v; this._markDirty(DIRTY_POS); }
+
+ get z() { return this._position.z; }
+ set z(v) { this._position.z = v; this._markDirty(DIRTY_POS); }
+
+ get rotateX() { return radToDeg(this._rotation.x); }
+ set rotateX(v) { this._rotation.x = degToRad(v); this._markDirty(DIRTY_ROT); }
+
+ get rotateY() { return radToDeg(this._rotation.y); }
+ set rotateY(v) { this._rotation.y = degToRad(v); this._markDirty(DIRTY_ROT); }
+
+ get rotateZ() { return radToDeg(this._rotation.z); }
+ set rotateZ(v) { this._rotation.z = degToRad(v); this._markDirty(DIRTY_ROT); }
+
+ get scaleX() { return this._scale.x; }
+ set scaleX(v) { this._scale.x = v; this._markDirty(DIRTY_SCALE); }
+
+ get scaleY() { return this._scale.y; }
+ set scaleY(v) { this._scale.y = v; this._markDirty(DIRTY_SCALE); }
+
+ get scaleZ() { return this._scale.z; }
+ set scaleZ(v) { this._scale.z = v; this._markDirty(DIRTY_SCALE); }
+
+ get scale() { return this._scale.x; }
+ set scale(v) {
+ const s = this._scale;
+ s.x = v; s.y = v; s.z = v;
+ this._markDirty(DIRTY_SCALE);
+ }
+
+ get skewX() { return this._skewX; }
+ set skewX(v) {
+ this._skewX = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get skewY() { return this._skewY; }
+ set skewY(v) {
+ this._skewY = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get skewZ() { return this._skewZ; }
+ set skewZ(v) {
+ this._skewZ = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get transformOriginX() { return this._originX; }
+ set transformOriginX(v) {
+ this._originX = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get transformOriginY() { return this._originY; }
+ set transformOriginY(v) {
+ this._originY = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get transformOriginZ() { return this._originZ; }
+ set transformOriginZ(v) {
+ this._originZ = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get opacity() {
+ return readScalar(/** @type {any} */(this.parent).material, 'opacity', PATH_DIRECT, 1);
+ }
+ /** @param {number} v */
+ set opacity(v) {
+ writeScalar(/** @type {any} */(this.parent).material, 'opacity', v, PATH_DIRECT);
+ }
+
+ get visible() {
+ return this._hasGetVisible ? /** @type {any} */(this.parent).getVisibleAt(this.id) : true;
+ }
+ /** @param {boolean} v */
+ set visible(v) {
+ if (this._hasSetVisible) /** @type {any} */(this.parent).setVisibleAt(this.id, v);
+ }
+
+}
+
+/**
+ * Flushes pending matrix writes for every dirty instance of `mesh`.
+ * Called automatically before each render. Call it yourself if you read
+ * `mesh.instanceMatrix` between an animation tick and the next render.
+ *
+ * @param {InstanceParent} mesh
+ */
+function commitChanges(mesh) {
+ const binding = bindings.get(mesh);
+ if (binding) binding.flush();
+}
+
+/**
+ * Returns an array of per-instance adapters for `mesh`. Index by id, deleted slots on `BatchedMesh` are `null`. Pass the array (or a slice / a single element) to `animate()`.
+ *
+ * animate(getInstances(mesh), { x: 100, delay: stagger(5) });
+ * animate(getInstances(mesh)[42], { scale: 2 });
+ *
+ * The same array reference is preserved across `mesh.count` / `addInstance` / `deleteInstance` calls. Entries are pushed, nulled, or truncated in place. Animations bound to an outdated reference keep tweening their original adapters.
+ *
+ * `mesh.onBeforeRender` is replaced with an accessor that flushes
+ * pending instance writes before each render and forwards to your
+ * handler. Assigning your own `mesh.onBeforeRender = fn` keeps the
+ * auto-flush, but reading `mesh.onBeforeRender` afterwards returns the
+ * chained dispatcher rather than `fn` itself, so identity checks
+ * (`mesh.onBeforeRender === fn`) will not match.
+ *
+ * @param {InstanceParent} mesh
+ * @return {(Instance | null)[]}
+ */
+function getInstances(mesh) {
+ let binding = bindings.get(mesh);
+ if (!binding) {
+ binding = new InstanceBinding(mesh);
+ bindings.set(mesh, binding);
+ }
+ if (mesh instanceof BatchedMesh) {
+ return refreshBatched(binding);
+ }
+ return refreshInstanced(binding);
+}
+
+/**
+ * @param {InstanceBinding} binding
+ * @return {(Instance | null)[]}
+ */
+function refreshInstanced(binding) {
+ const mesh = /** @type {InstancedMesh} */(binding.mesh);
+ const count = mesh.count;
+ const arr = binding.instances;
+ if (arr.length === 0 && count > 0) {
+ arr.length = count;
+ for (let i = 0; i < count; i++) arr[i] = new Instance(binding, i);
+ return arr;
+ }
+ if (arr.length < count) {
+ for (let i = arr.length; i < count; i++) arr.push(new Instance(binding, i));
+ } else if (arr.length > count) {
+ arr.length = count;
+ }
+ return arr;
+}
+
+/**
+ * @param {InstanceBinding} binding
+ * @return {(Instance | null)[]}
+ */
+function refreshBatched(binding) {
+ const mesh = /** @type {BatchedMesh} */(binding.mesh);
+ const arr = binding.instances;
+ // Read three internal _instanceInfo to skip slots marked inactive by deleteInstance.
+ // Iterate the full slot count, not instanceCount, since deleted slots leave gaps but live ids past them must still be visited.
+ const instanceInfo = /** @type {{ _instanceInfo?: { active: boolean }[] }} */(mesh)._instanceInfo ?? [];
+ const len = instanceInfo.length;
+ if (arr.length < len) arr.length = len;
+ for (let i = 0; i < len; i++) {
+ const info = instanceInfo[i];
+ const inactive = info && info.active === false;
+ if (inactive) {
+ arr[i] = null;
+ } else if (!arr[i]) {
+ arr[i] = new Instance(binding, i);
+ }
+ }
+ if (arr.length > len) arr.length = len;
+ return arr;
+}
+
+const instanceAdapter = threeAdapter.registerTargetAdapter((t) => t instanceof Instance);
+instanceAdapter.registerProperty('color',
+ (t) => readColorHex(t._color),
+ (t, _, tw) => {
+ if (!t._hasSetColor) return;
+ const ns = tw._numbers;
+ t._color.setRGB(ns[0] * COLOR_NORM, ns[1] * COLOR_NORM, ns[2] * COLOR_NORM, SRGBColorSpace);
+ const p = /** @type {any} */(t.parent);
+ p.setColorAt(t.id, t._color);
+ if (p.instanceColor) p.instanceColor.needsUpdate = true;
+ },
+);
+// Shorthand 3-token string x y z routed via the engine COMPLEX path.
+// The setter reads tween _numbers for the per-frame lerped triplet.
+instanceAdapter.registerProperty('transformOrigin',
+ (t) => `${t._originX} ${t._originY} ${t._originZ}`,
+ (t, _, tw) => {
+ const ns = tw._numbers;
+ t._originX = ns[0];
+ t._originY = ns[1];
+ t._originZ = ns[2];
+ t._hasSkewOrigin = hasSkewOrigin(t);
+ t._markDirty(DIRTY_SKEW);
+ },
+);
+
+export { commitChanges, getInstances };
diff --git a/dist/modules/adapters/three/object3d.cjs b/dist/modules/adapters/three/object3d.cjs
new file mode 100644
index 00000000..77fb1763
--- /dev/null
+++ b/dist/modules/adapters/three/object3d.cjs
@@ -0,0 +1,214 @@
+/**
+ * Anime.js - adapters - CJS
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+'use strict';
+
+var three = require('three');
+var number = require('../../utils/number.cjs');
+var adapter = require('./adapter.cjs');
+var helpers = require('./helpers.cjs');
+
+/**
+ * `Object3D` adapter. Maps flat properties (position, rotation, scale, opacity, color, visible, light / audio / camera specifics) onto the matching three.js fields, and auto-detects material props (direct / uniform / TSL `UniformNode`) on the target's `material` at tween creation.
+ */
+
+
+const colorTarget = (t) => t.isLight ? t : t.material;
+
+// Per-mesh skew and transformOrigin state, stored under a private symbol so we add one hidden property instead of polluting the Object3D surface with seven underscored fields.
+const skewSymbol = Symbol('animejs.skewOrigin');
+
+// Fallback opacity storage for Object3D targets without a material such as Groups or CSS2DObjects.
+// Without it reads always return the default 1, so reverse-direction tweens between two non-default values collapse to a no-op delta and the visibility flip never fires on the way back.
+const opacitySymbol = Symbol('animejs.opacity');
+
+/**
+ * Sets `o.visible` based on opacity and current scale. If `opacity` is omitted, reads it from `o.material` (defaults to `1` when no material is present).
+ *
+ * @param {Object3D & { material?: import('three').Material | import('three').Material[] }} o
+ * @param {number} [opacity]
+ */
+function setVisibility(o, opacity) {
+ if (opacity === undefined) {
+ if (o.material) {
+ opacity = helpers.readScalar(o.material, 'opacity', helpers.PATH_DIRECT, 1);
+ } else {
+ const v = o[opacitySymbol];
+ opacity = v === undefined ? 1 : v;
+ }
+ }
+ const s = o.scale;
+ o.visible = !!(opacity && s.x && s.y && s.z);
+}
+
+/**
+ * Installs a per-mesh `updateMatrix` override on first skew / transformOrigin write. The override calls the original three.js compose, then patches the result with `applySkewOrigin` whenever any axis is non-zero. Idempotent.
+ *
+ * @param {any} mesh
+ * @return {{ skewX: number, skewY: number, skewZ: number, originX: number, originY: number, originZ: number }}
+ */
+function installSkewMatrix(mesh) {
+ let s = mesh[skewSymbol];
+ if (s) return s;
+ s = mesh[skewSymbol] = { skewX: 0, skewY: 0, skewZ: 0, originX: 0, originY: 0, originZ: 0 };
+ const original = mesh.updateMatrix;
+ mesh.updateMatrix = function () {
+ original.call(this);
+ const st = this[skewSymbol];
+ if (st.skewX !== 0 || st.skewY !== 0 || st.skewZ !== 0 || st.originX !== 0 || st.originY !== 0 || st.originZ !== 0) {
+ helpers.applySkewOrigin(this.matrix.elements, st.skewX, st.skewY, st.skewZ, st.originX, st.originY, st.originZ);
+ }
+ };
+ return s;
+}
+
+const threeObject3D = adapter.threeAdapter.registerTargetAdapter((t) => t instanceof three.Object3D);
+
+// Position
+threeObject3D.registerProperty('x', (t) => t.position.x, (t, v) => { t.position.x = v; });
+threeObject3D.registerProperty('y', (t) => t.position.y, (t, v) => { t.position.y = v; });
+threeObject3D.registerProperty('z', (t) => t.position.z, (t, v) => { t.position.z = v; });
+
+// Rotation in degrees
+threeObject3D.registerProperty('rotateX', (t) => number.radToDeg(t.rotation.x), (t, v) => { t.rotation.x = number.degToRad(v); });
+threeObject3D.registerProperty('rotateY', (t) => number.radToDeg(t.rotation.y), (t, v) => { t.rotation.y = number.degToRad(v); });
+threeObject3D.registerProperty('rotateZ', (t) => number.radToDeg(t.rotation.z), (t, v) => { t.rotation.z = number.degToRad(v); });
+
+// Scale per-axis and uniform
+threeObject3D.registerProperty('scaleX', (t) => t.scale.x, (t, v) => { t.scale.x = v; setVisibility(t); });
+threeObject3D.registerProperty('scaleY', (t) => t.scale.y, (t, v) => { t.scale.y = v; setVisibility(t); });
+threeObject3D.registerProperty('scaleZ', (t) => t.scale.z, (t, v) => { t.scale.z = v; setVisibility(t); });
+threeObject3D.registerProperty('scale',
+ (t) => t.scale.x,
+ (t, v) => {
+ t.scale.x = v; t.scale.y = v; t.scale.z = v;
+ setVisibility(t);
+ },
+);
+
+// Material
+threeObject3D.registerProperty('visible', (t) => t.visible, (t, v) => { t.visible = !!v; });
+threeObject3D.registerProperty('opacity',
+ (t) => {
+ if (t.material) return helpers.readScalar(t.material, 'opacity', helpers.PATH_DIRECT, 1);
+ const v = t[opacitySymbol];
+ return v === undefined ? 1 : v;
+ },
+ (t, v) => {
+ if (t.material) helpers.writeScalar(t.material, 'opacity', v, helpers.PATH_DIRECT);
+ else t[opacitySymbol] = v;
+ setVisibility(t, v);
+ },
+ (t) => !t.isLight,
+);
+threeObject3D.registerProperty('color',
+ (t) => helpers.readColorAt(colorTarget(t), 'color', helpers.PATH_DIRECT),
+ (t, _, tw) => helpers.writeColorAt(colorTarget(t), 'color', tw._numbers, helpers.PATH_DIRECT),
+);
+
+// HemisphereLight
+threeObject3D.registerProperty('groundColor',
+ (t) => helpers.readColorAt(t, 'groundColor', helpers.PATH_DIRECT),
+ (t, _, tw) => helpers.writeColorAt(t, 'groundColor', tw._numbers, helpers.PATH_DIRECT),
+ (t) => !!t.groundColor,
+);
+
+// Scene background, lazily initializes scene background to a Color on first write so the user does not have to set one upfront.
+threeObject3D.registerProperty('background',
+ (t) => {
+ const bg = /** @type {any} */(t).background;
+ return bg && bg.isColor ? helpers.readColorHex(bg) : '#000000';
+ },
+ (t, _, tw) => {
+ const scene = /** @type {any} */(t);
+ let bg = scene.background;
+ if (!bg || !bg.isColor) {
+ bg = new three.Color();
+ scene.background = bg;
+ }
+ const ns = tw._numbers;
+ bg.setRGB(ns[0] * helpers.COLOR_NORM, ns[1] * helpers.COLOR_NORM, ns[2] * helpers.COLOR_NORM, three.SRGBColorSpace);
+ },
+ (t) => !!t.isScene,
+);
+
+// Method-bridged props for Audio and PerspectiveCamera focalLength, read via getXxx and write via setXxx.
+const registerMethodProp = (apiName, getter, setter, gate) => {
+ threeObject3D.registerProperty(apiName,
+ (t) => t[getter](),
+ (t, v) => { t[setter](v); },
+ (t) => !!t[gate],
+ );
+};
+registerMethodProp('volume', 'getVolume', 'setVolume', 'setVolume');
+// PositionalAudio
+registerMethodProp('refDistance', 'getRefDistance', 'setRefDistance', 'setRefDistance');
+registerMethodProp('rolloffFactor', 'getRolloffFactor', 'setRolloffFactor', 'setRefDistance');
+registerMethodProp('maxDistance', 'getMaxDistance', 'setMaxDistance', 'setRefDistance');
+// PerspectiveCamera
+registerMethodProp('focalLength', 'getFocalLength', 'setFocalLength', 'setFocalLength');
+
+// Camera projection-update props, setter writes the value then calls updateProjectionMatrix.
+const registerCameraProp = (apiName, gate) => {
+ threeObject3D.registerProperty(apiName,
+ (t) => t[apiName],
+ (t, v) => { t[apiName] = v; t.updateProjectionMatrix(); },
+ gate,
+ );
+};
+const isPersp = (t) => !!t.isPerspectiveCamera;
+const isOrtho = (t) => !!t.isOrthographicCamera;
+registerCameraProp('fov', isPersp);
+registerCameraProp('aspect', isPersp);
+registerCameraProp('left', isOrtho);
+registerCameraProp('right', isOrtho);
+registerCameraProp('top', isOrtho);
+registerCameraProp('bottom', isOrtho);
+
+// Skew in degrees and transform-origin in object-space.
+// Patches mesh updateMatrix on first write so the standard PRS compose is followed by an in-place skew and origin shift.
+// Reads default to 0 for meshes that have never been written.
+/**
+ * @param {String} apiName
+ * @param {String} key
+ */
+const registerSkewProp = (apiName, key) => {
+ threeObject3D.registerProperty(apiName,
+ (t) => { const s = /** @type {any} */(t)[skewSymbol]; return s ? s[key] : 0; },
+ (t, v) => { installSkewMatrix(t)[key] = v; },
+ );
+};
+registerSkewProp('skewX', 'skewX');
+registerSkewProp('skewY', 'skewY');
+registerSkewProp('skewZ', 'skewZ');
+registerSkewProp('transformOriginX', 'originX');
+registerSkewProp('transformOriginY', 'originY');
+registerSkewProp('transformOriginZ', 'originZ');
+
+// Shorthand 3-token string x y z or 2-string from-to array routed via the engine COMPLEX path.
+// The setter reads tween _numbers for the per-frame lerped triplet.
+threeObject3D.registerProperty('transformOrigin',
+ (t) => {
+ const s = /** @type {any} */(t)[skewSymbol];
+ return s ? `${s.originX} ${s.originY} ${s.originZ}` : '0 0 0';
+ },
+ (t, _, tw) => {
+ const s = installSkewMatrix(t);
+ const ns = tw._numbers;
+ s.originX = ns[0];
+ s.originY = ns[1];
+ s.originZ = ns[2];
+ },
+);
+
+// Shared by both camera types.
+const isCamera = (t) => !!t.isPerspectiveCamera || !!t.isOrthographicCamera;
+registerCameraProp('near', isCamera);
+registerCameraProp('far', isCamera);
+registerCameraProp('zoom', isCamera);
+
+// Auto-detection for material props on meshes and direct Vector / Color fields on the target is provided by the shared resolvers in resolvers.js.
diff --git a/dist/modules/adapters/three/object3d.d.ts b/dist/modules/adapters/three/object3d.d.ts
new file mode 100644
index 00000000..cb0ff5c3
--- /dev/null
+++ b/dist/modules/adapters/three/object3d.d.ts
@@ -0,0 +1 @@
+export {};
diff --git a/dist/modules/adapters/three/object3d.js b/dist/modules/adapters/three/object3d.js
new file mode 100644
index 00000000..6fefc7c0
--- /dev/null
+++ b/dist/modules/adapters/three/object3d.js
@@ -0,0 +1,212 @@
+/**
+ * Anime.js - adapters - ESM
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+import { Object3D, Color, SRGBColorSpace } from 'three';
+import { radToDeg, degToRad } from '../../utils/number.js';
+import { threeAdapter } from './adapter.js';
+import { readScalar, PATH_DIRECT, writeScalar, readColorAt, writeColorAt, readColorHex, COLOR_NORM, applySkewOrigin } from './helpers.js';
+
+/**
+ * `Object3D` adapter. Maps flat properties (position, rotation, scale, opacity, color, visible, light / audio / camera specifics) onto the matching three.js fields, and auto-detects material props (direct / uniform / TSL `UniformNode`) on the target's `material` at tween creation.
+ */
+
+
+const colorTarget = (t) => t.isLight ? t : t.material;
+
+// Per-mesh skew and transformOrigin state, stored under a private symbol so we add one hidden property instead of polluting the Object3D surface with seven underscored fields.
+const skewSymbol = Symbol('animejs.skewOrigin');
+
+// Fallback opacity storage for Object3D targets without a material such as Groups or CSS2DObjects.
+// Without it reads always return the default 1, so reverse-direction tweens between two non-default values collapse to a no-op delta and the visibility flip never fires on the way back.
+const opacitySymbol = Symbol('animejs.opacity');
+
+/**
+ * Sets `o.visible` based on opacity and current scale. If `opacity` is omitted, reads it from `o.material` (defaults to `1` when no material is present).
+ *
+ * @param {Object3D & { material?: import('three').Material | import('three').Material[] }} o
+ * @param {number} [opacity]
+ */
+function setVisibility(o, opacity) {
+ if (opacity === undefined) {
+ if (o.material) {
+ opacity = readScalar(o.material, 'opacity', PATH_DIRECT, 1);
+ } else {
+ const v = o[opacitySymbol];
+ opacity = v === undefined ? 1 : v;
+ }
+ }
+ const s = o.scale;
+ o.visible = !!(opacity && s.x && s.y && s.z);
+}
+
+/**
+ * Installs a per-mesh `updateMatrix` override on first skew / transformOrigin write. The override calls the original three.js compose, then patches the result with `applySkewOrigin` whenever any axis is non-zero. Idempotent.
+ *
+ * @param {any} mesh
+ * @return {{ skewX: number, skewY: number, skewZ: number, originX: number, originY: number, originZ: number }}
+ */
+function installSkewMatrix(mesh) {
+ let s = mesh[skewSymbol];
+ if (s) return s;
+ s = mesh[skewSymbol] = { skewX: 0, skewY: 0, skewZ: 0, originX: 0, originY: 0, originZ: 0 };
+ const original = mesh.updateMatrix;
+ mesh.updateMatrix = function () {
+ original.call(this);
+ const st = this[skewSymbol];
+ if (st.skewX !== 0 || st.skewY !== 0 || st.skewZ !== 0 || st.originX !== 0 || st.originY !== 0 || st.originZ !== 0) {
+ applySkewOrigin(this.matrix.elements, st.skewX, st.skewY, st.skewZ, st.originX, st.originY, st.originZ);
+ }
+ };
+ return s;
+}
+
+const threeObject3D = threeAdapter.registerTargetAdapter((t) => t instanceof Object3D);
+
+// Position
+threeObject3D.registerProperty('x', (t) => t.position.x, (t, v) => { t.position.x = v; });
+threeObject3D.registerProperty('y', (t) => t.position.y, (t, v) => { t.position.y = v; });
+threeObject3D.registerProperty('z', (t) => t.position.z, (t, v) => { t.position.z = v; });
+
+// Rotation in degrees
+threeObject3D.registerProperty('rotateX', (t) => radToDeg(t.rotation.x), (t, v) => { t.rotation.x = degToRad(v); });
+threeObject3D.registerProperty('rotateY', (t) => radToDeg(t.rotation.y), (t, v) => { t.rotation.y = degToRad(v); });
+threeObject3D.registerProperty('rotateZ', (t) => radToDeg(t.rotation.z), (t, v) => { t.rotation.z = degToRad(v); });
+
+// Scale per-axis and uniform
+threeObject3D.registerProperty('scaleX', (t) => t.scale.x, (t, v) => { t.scale.x = v; setVisibility(t); });
+threeObject3D.registerProperty('scaleY', (t) => t.scale.y, (t, v) => { t.scale.y = v; setVisibility(t); });
+threeObject3D.registerProperty('scaleZ', (t) => t.scale.z, (t, v) => { t.scale.z = v; setVisibility(t); });
+threeObject3D.registerProperty('scale',
+ (t) => t.scale.x,
+ (t, v) => {
+ t.scale.x = v; t.scale.y = v; t.scale.z = v;
+ setVisibility(t);
+ },
+);
+
+// Material
+threeObject3D.registerProperty('visible', (t) => t.visible, (t, v) => { t.visible = !!v; });
+threeObject3D.registerProperty('opacity',
+ (t) => {
+ if (t.material) return readScalar(t.material, 'opacity', PATH_DIRECT, 1);
+ const v = t[opacitySymbol];
+ return v === undefined ? 1 : v;
+ },
+ (t, v) => {
+ if (t.material) writeScalar(t.material, 'opacity', v, PATH_DIRECT);
+ else t[opacitySymbol] = v;
+ setVisibility(t, v);
+ },
+ (t) => !t.isLight,
+);
+threeObject3D.registerProperty('color',
+ (t) => readColorAt(colorTarget(t), 'color', PATH_DIRECT),
+ (t, _, tw) => writeColorAt(colorTarget(t), 'color', tw._numbers, PATH_DIRECT),
+);
+
+// HemisphereLight
+threeObject3D.registerProperty('groundColor',
+ (t) => readColorAt(t, 'groundColor', PATH_DIRECT),
+ (t, _, tw) => writeColorAt(t, 'groundColor', tw._numbers, PATH_DIRECT),
+ (t) => !!t.groundColor,
+);
+
+// Scene background, lazily initializes scene background to a Color on first write so the user does not have to set one upfront.
+threeObject3D.registerProperty('background',
+ (t) => {
+ const bg = /** @type {any} */(t).background;
+ return bg && bg.isColor ? readColorHex(bg) : '#000000';
+ },
+ (t, _, tw) => {
+ const scene = /** @type {any} */(t);
+ let bg = scene.background;
+ if (!bg || !bg.isColor) {
+ bg = new Color();
+ scene.background = bg;
+ }
+ const ns = tw._numbers;
+ bg.setRGB(ns[0] * COLOR_NORM, ns[1] * COLOR_NORM, ns[2] * COLOR_NORM, SRGBColorSpace);
+ },
+ (t) => !!t.isScene,
+);
+
+// Method-bridged props for Audio and PerspectiveCamera focalLength, read via getXxx and write via setXxx.
+const registerMethodProp = (apiName, getter, setter, gate) => {
+ threeObject3D.registerProperty(apiName,
+ (t) => t[getter](),
+ (t, v) => { t[setter](v); },
+ (t) => !!t[gate],
+ );
+};
+registerMethodProp('volume', 'getVolume', 'setVolume', 'setVolume');
+// PositionalAudio
+registerMethodProp('refDistance', 'getRefDistance', 'setRefDistance', 'setRefDistance');
+registerMethodProp('rolloffFactor', 'getRolloffFactor', 'setRolloffFactor', 'setRefDistance');
+registerMethodProp('maxDistance', 'getMaxDistance', 'setMaxDistance', 'setRefDistance');
+// PerspectiveCamera
+registerMethodProp('focalLength', 'getFocalLength', 'setFocalLength', 'setFocalLength');
+
+// Camera projection-update props, setter writes the value then calls updateProjectionMatrix.
+const registerCameraProp = (apiName, gate) => {
+ threeObject3D.registerProperty(apiName,
+ (t) => t[apiName],
+ (t, v) => { t[apiName] = v; t.updateProjectionMatrix(); },
+ gate,
+ );
+};
+const isPersp = (t) => !!t.isPerspectiveCamera;
+const isOrtho = (t) => !!t.isOrthographicCamera;
+registerCameraProp('fov', isPersp);
+registerCameraProp('aspect', isPersp);
+registerCameraProp('left', isOrtho);
+registerCameraProp('right', isOrtho);
+registerCameraProp('top', isOrtho);
+registerCameraProp('bottom', isOrtho);
+
+// Skew in degrees and transform-origin in object-space.
+// Patches mesh updateMatrix on first write so the standard PRS compose is followed by an in-place skew and origin shift.
+// Reads default to 0 for meshes that have never been written.
+/**
+ * @param {String} apiName
+ * @param {String} key
+ */
+const registerSkewProp = (apiName, key) => {
+ threeObject3D.registerProperty(apiName,
+ (t) => { const s = /** @type {any} */(t)[skewSymbol]; return s ? s[key] : 0; },
+ (t, v) => { installSkewMatrix(t)[key] = v; },
+ );
+};
+registerSkewProp('skewX', 'skewX');
+registerSkewProp('skewY', 'skewY');
+registerSkewProp('skewZ', 'skewZ');
+registerSkewProp('transformOriginX', 'originX');
+registerSkewProp('transformOriginY', 'originY');
+registerSkewProp('transformOriginZ', 'originZ');
+
+// Shorthand 3-token string x y z or 2-string from-to array routed via the engine COMPLEX path.
+// The setter reads tween _numbers for the per-frame lerped triplet.
+threeObject3D.registerProperty('transformOrigin',
+ (t) => {
+ const s = /** @type {any} */(t)[skewSymbol];
+ return s ? `${s.originX} ${s.originY} ${s.originZ}` : '0 0 0';
+ },
+ (t, _, tw) => {
+ const s = installSkewMatrix(t);
+ const ns = tw._numbers;
+ s.originX = ns[0];
+ s.originY = ns[1];
+ s.originZ = ns[2];
+ },
+);
+
+// Shared by both camera types.
+const isCamera = (t) => !!t.isPerspectiveCamera || !!t.isOrthographicCamera;
+registerCameraProp('near', isCamera);
+registerCameraProp('far', isCamera);
+registerCameraProp('zoom', isCamera);
+
+// Auto-detection for material props on meshes and direct Vector / Color fields on the target is provided by the shared resolvers in resolvers.js.
diff --git a/dist/modules/adapters/three/resolvers.cjs b/dist/modules/adapters/three/resolvers.cjs
new file mode 100644
index 00000000..2a6e8fe5
--- /dev/null
+++ b/dist/modules/adapters/three/resolvers.cjs
@@ -0,0 +1,105 @@
+/**
+ * Anime.js - adapters - CJS
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+'use strict';
+
+var adapter = require('./adapter.cjs');
+var number = require('../../utils/number.cjs');
+var helpers = require('./helpers.cjs');
+
+/**
+ * Global property resolvers for three.js targets. Auto-detect `Color`-typed properties, `Vector2/3/4` axis components, shader uniforms, and TSL `UniformNode` slots on any three.js object. For mesh-like targets, a second resolver walks to `target.material` and runs the same detection there.
+ */
+
+
+const identity = (t) => t;
+const getMaterial = (t) => t.material;
+
+const directColorCache = [{}, {}, {}];
+const directScalarCache = [{}, {}, {}];
+const directVectorCache = [{}, {}, {}];
+
+const materialColorCache = [{}, {}, {}];
+const materialScalarCache = [{}, {}, {}];
+const materialVectorCache = [{}, {}, {}];
+
+const buildEntry = (name, d, getHost, colorCaches, scalarCaches, vectorCaches) => {
+ const path = d.path;
+ if (d.kind === helpers.KIND_COLOR) {
+ const cache = colorCaches[path];
+ return cache[name] || (cache[name] = {
+ get: (t) => helpers.readColorAt(getHost(t), name, path),
+ set: (t, _, tw) => helpers.writeColorAt(getHost(t), name, tw._numbers, path),
+ });
+ }
+ if (d.kind === helpers.KIND_SCALAR) {
+ const cache = scalarCaches[path];
+ return cache[name] || (cache[name] = {
+ get: (t) => helpers.readScalar(getHost(t), name, path),
+ set: (t, v) => helpers.writeScalar(getHost(t), name, v, path),
+ });
+ }
+ // KIND_VECTOR
+ const base = d.base;
+ const axis = d.axis;
+ const cache = vectorCaches[path];
+ return cache[name] || (cache[name] = {
+ get: (t) => helpers.readVectorAt(getHost(t), base, axis, path),
+ set: (t, v) => helpers.writeVectorAt(getHost(t), base, axis, v, path),
+ });
+};
+
+// Detect direct Color, Vector axis, uniforms, and UniformNode slots on the target.
+// Numeric or boolean direct fields fall through to the engine OBJECT path.
+adapter.threeAdapter.registerPropertyResolver((target, name) => {
+ const d = helpers.classifyTargetProp(target, name);
+ if (!d) return null;
+ if (d.kind === helpers.KIND_SCALAR && d.path === helpers.PATH_DIRECT) return null;
+ return buildEntry(name, d, identity, directColorCache, directScalarCache, directVectorCache);
+});
+
+// Walk to target.material for meshes and other Object3D subclasses with a material field.
+// Skip when the target already exposes the name directly so a mesh-level mapping wins.
+adapter.threeAdapter.registerPropertyResolver((target, name) => {
+ if (target[name] !== undefined) return null;
+ const m = target.material;
+ if (!m) return null;
+ const first = Array.isArray(m) ? m[0] : m;
+ if (!first) return null;
+ const d = helpers.classifyTargetProp(first, name);
+ if (!d) return null;
+ return buildEntry(name, d, getMaterial, materialColorCache, materialScalarCache, materialVectorCache);
+});
+
+// Convert angle-named scalar fields between degrees and radians so users animate in degrees on any three.js target.
+// Object3D Euler rotation is excluded because Euler is not a number, the rotateX/Y/Z mappings handle it.
+const ANGLE_NAMES = { rotation: 1, angle: 1 };
+const angleEntries = {};
+adapter.threeAdapter.registerPropertyResolver((target, name) => {
+ if (!ANGLE_NAMES[name]) return null;
+ if (typeof target[name] !== 'number') return null;
+ return angleEntries[name] || (angleEntries[name] = {
+ get: (t) => number.radToDeg(t[name]),
+ set: (t, v) => { t[name] = number.degToRad(v); },
+ });
+});
+
+// Decompose Euler-typed angle fields to axis components in degrees, like rotationX, rotationY, rotationZ when rotation is an Euler.
+// Object3D mappings win because static adapter props beat resolvers, so this only catches non-Object3D targets with an Euler rotation field.
+const eulerAxisEntries = {};
+adapter.threeAdapter.registerPropertyResolver((target, name) => {
+ const axis = helpers.AXIS_MAP[name[name.length - 1]];
+ if (!axis) return null;
+ const base = name.slice(0, -1);
+ if (!ANGLE_NAMES[base]) return null;
+ const v = target[base];
+ if (!v || !v.isEuler) return null;
+ return eulerAxisEntries[name] || (eulerAxisEntries[name] = {
+ get: (t) => number.radToDeg(t[base][axis]),
+ set: (t, v) => { t[base][axis] = number.degToRad(v); },
+ });
+});
diff --git a/dist/modules/adapters/three/resolvers.d.ts b/dist/modules/adapters/three/resolvers.d.ts
new file mode 100644
index 00000000..cb0ff5c3
--- /dev/null
+++ b/dist/modules/adapters/three/resolvers.d.ts
@@ -0,0 +1 @@
+export {};
diff --git a/dist/modules/adapters/three/resolvers.js b/dist/modules/adapters/three/resolvers.js
new file mode 100644
index 00000000..17fb6442
--- /dev/null
+++ b/dist/modules/adapters/three/resolvers.js
@@ -0,0 +1,103 @@
+/**
+ * Anime.js - adapters - ESM
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+import { threeAdapter } from './adapter.js';
+import { radToDeg, degToRad } from '../../utils/number.js';
+import { classifyTargetProp, KIND_SCALAR, PATH_DIRECT, AXIS_MAP, KIND_COLOR, writeColorAt, readColorAt, writeScalar, readScalar, writeVectorAt, readVectorAt } from './helpers.js';
+
+/**
+ * Global property resolvers for three.js targets. Auto-detect `Color`-typed properties, `Vector2/3/4` axis components, shader uniforms, and TSL `UniformNode` slots on any three.js object. For mesh-like targets, a second resolver walks to `target.material` and runs the same detection there.
+ */
+
+
+const identity = (t) => t;
+const getMaterial = (t) => t.material;
+
+const directColorCache = [{}, {}, {}];
+const directScalarCache = [{}, {}, {}];
+const directVectorCache = [{}, {}, {}];
+
+const materialColorCache = [{}, {}, {}];
+const materialScalarCache = [{}, {}, {}];
+const materialVectorCache = [{}, {}, {}];
+
+const buildEntry = (name, d, getHost, colorCaches, scalarCaches, vectorCaches) => {
+ const path = d.path;
+ if (d.kind === KIND_COLOR) {
+ const cache = colorCaches[path];
+ return cache[name] || (cache[name] = {
+ get: (t) => readColorAt(getHost(t), name, path),
+ set: (t, _, tw) => writeColorAt(getHost(t), name, tw._numbers, path),
+ });
+ }
+ if (d.kind === KIND_SCALAR) {
+ const cache = scalarCaches[path];
+ return cache[name] || (cache[name] = {
+ get: (t) => readScalar(getHost(t), name, path),
+ set: (t, v) => writeScalar(getHost(t), name, v, path),
+ });
+ }
+ // KIND_VECTOR
+ const base = d.base;
+ const axis = d.axis;
+ const cache = vectorCaches[path];
+ return cache[name] || (cache[name] = {
+ get: (t) => readVectorAt(getHost(t), base, axis, path),
+ set: (t, v) => writeVectorAt(getHost(t), base, axis, v, path),
+ });
+};
+
+// Detect direct Color, Vector axis, uniforms, and UniformNode slots on the target.
+// Numeric or boolean direct fields fall through to the engine OBJECT path.
+threeAdapter.registerPropertyResolver((target, name) => {
+ const d = classifyTargetProp(target, name);
+ if (!d) return null;
+ if (d.kind === KIND_SCALAR && d.path === PATH_DIRECT) return null;
+ return buildEntry(name, d, identity, directColorCache, directScalarCache, directVectorCache);
+});
+
+// Walk to target.material for meshes and other Object3D subclasses with a material field.
+// Skip when the target already exposes the name directly so a mesh-level mapping wins.
+threeAdapter.registerPropertyResolver((target, name) => {
+ if (target[name] !== undefined) return null;
+ const m = target.material;
+ if (!m) return null;
+ const first = Array.isArray(m) ? m[0] : m;
+ if (!first) return null;
+ const d = classifyTargetProp(first, name);
+ if (!d) return null;
+ return buildEntry(name, d, getMaterial, materialColorCache, materialScalarCache, materialVectorCache);
+});
+
+// Convert angle-named scalar fields between degrees and radians so users animate in degrees on any three.js target.
+// Object3D Euler rotation is excluded because Euler is not a number, the rotateX/Y/Z mappings handle it.
+const ANGLE_NAMES = { rotation: 1, angle: 1 };
+const angleEntries = {};
+threeAdapter.registerPropertyResolver((target, name) => {
+ if (!ANGLE_NAMES[name]) return null;
+ if (typeof target[name] !== 'number') return null;
+ return angleEntries[name] || (angleEntries[name] = {
+ get: (t) => radToDeg(t[name]),
+ set: (t, v) => { t[name] = degToRad(v); },
+ });
+});
+
+// Decompose Euler-typed angle fields to axis components in degrees, like rotationX, rotationY, rotationZ when rotation is an Euler.
+// Object3D mappings win because static adapter props beat resolvers, so this only catches non-Object3D targets with an Euler rotation field.
+const eulerAxisEntries = {};
+threeAdapter.registerPropertyResolver((target, name) => {
+ const axis = AXIS_MAP[name[name.length - 1]];
+ if (!axis) return null;
+ const base = name.slice(0, -1);
+ if (!ANGLE_NAMES[base]) return null;
+ const v = target[base];
+ if (!v || !v.isEuler) return null;
+ return eulerAxisEntries[name] || (eulerAxisEntries[name] = {
+ get: (t) => radToDeg(t[base][axis]),
+ set: (t, v) => { t[base][axis] = degToRad(v); },
+ });
+});
diff --git a/dist/modules/adapters/three/uniform.cjs b/dist/modules/adapters/three/uniform.cjs
new file mode 100644
index 00000000..d8956ca3
--- /dev/null
+++ b/dist/modules/adapters/three/uniform.cjs
@@ -0,0 +1,41 @@
+/**
+ * Anime.js - adapters - CJS
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+'use strict';
+
+var three = require('three');
+var adapter = require('./adapter.cjs');
+var helpers = require('./helpers.cjs');
+
+/**
+ * Bare `UniformNode` adapter. Auto-detects `UniformNode` instances and exposes their `.value` for animation. Scalars and booleans animate via `value`, `Color` uniforms via `color`, and `Vector2/3/4` uniforms via `x` / `y` / `z` / `w` axes.
+ *
+ * import 'animejs/bindings/three';
+ * import { uniform } from 'three/tsl';
+ * animate(uniform(0), { value: 1 });
+ * animate(uniform(new Color()), { color: '#0f0' });
+ * animate(uniform(new Vector3()), { x: 1, y: 0.5 });
+ *
+ * `UniformNode` slots assigned to `NodeMaterial` (`material.colorNode`, `material.offsetNode`, ...) are auto-detected by the shared resolvers in `resolvers.js`. Non-uniform nodes (`mix`, `add`, computed expressions), `Matrix3/4` and `Texture` valued uniforms, and `UniformArrayNode` / `BufferNode` are out of scope and fall through to the engine's direct property path.
+ */
+
+
+const uniformNode = adapter.threeAdapter.registerTargetAdapter((t) => !!(t && t.isUniformNode));
+
+// Scalar and bool uniforms animate via the engine OBJECT fallthrough on value, no adapter prop needed since the engine writes uniform value natively.
+uniformNode.registerProperty('color',
+ (t) => helpers.readColorHex(t.value),
+ (t, _, tw) => {
+ const ns = tw._numbers;
+ t.value.setRGB(ns[0] * helpers.COLOR_NORM, ns[1] * helpers.COLOR_NORM, ns[2] * helpers.COLOR_NORM, three.SRGBColorSpace);
+ },
+ (t) => !!(t.value && t.value.isColor),
+);
+uniformNode.registerProperty('x', (t) => t.value.x, (t, v) => { t.value.x = v; }, (t) => helpers.isVectorWith(t.value, 'x'));
+uniformNode.registerProperty('y', (t) => t.value.y, (t, v) => { t.value.y = v; }, (t) => helpers.isVectorWith(t.value, 'y'));
+uniformNode.registerProperty('z', (t) => t.value.z, (t, v) => { t.value.z = v; }, (t) => helpers.isVectorWith(t.value, 'z'));
+uniformNode.registerProperty('w', (t) => t.value.w, (t, v) => { t.value.w = v; }, (t) => helpers.isVectorWith(t.value, 'w'));
diff --git a/dist/modules/adapters/three/uniform.d.ts b/dist/modules/adapters/three/uniform.d.ts
new file mode 100644
index 00000000..cb0ff5c3
--- /dev/null
+++ b/dist/modules/adapters/three/uniform.d.ts
@@ -0,0 +1 @@
+export {};
diff --git a/dist/modules/adapters/three/uniform.js b/dist/modules/adapters/three/uniform.js
new file mode 100644
index 00000000..dd737690
--- /dev/null
+++ b/dist/modules/adapters/three/uniform.js
@@ -0,0 +1,39 @@
+/**
+ * Anime.js - adapters - ESM
+ * @version v4.5.0
+ * @license MIT
+ * @copyright 2026 - Julian Garnier
+ */
+
+import { SRGBColorSpace } from 'three';
+import { threeAdapter } from './adapter.js';
+import { readColorHex, COLOR_NORM, isVectorWith } from './helpers.js';
+
+/**
+ * Bare `UniformNode` adapter. Auto-detects `UniformNode` instances and exposes their `.value` for animation. Scalars and booleans animate via `value`, `Color` uniforms via `color`, and `Vector2/3/4` uniforms via `x` / `y` / `z` / `w` axes.
+ *
+ * import 'animejs/bindings/three';
+ * import { uniform } from 'three/tsl';
+ * animate(uniform(0), { value: 1 });
+ * animate(uniform(new Color()), { color: '#0f0' });
+ * animate(uniform(new Vector3()), { x: 1, y: 0.5 });
+ *
+ * `UniformNode` slots assigned to `NodeMaterial` (`material.colorNode`, `material.offsetNode`, ...) are auto-detected by the shared resolvers in `resolvers.js`. Non-uniform nodes (`mix`, `add`, computed expressions), `Matrix3/4` and `Texture` valued uniforms, and `UniformArrayNode` / `BufferNode` are out of scope and fall through to the engine's direct property path.
+ */
+
+
+const uniformNode = threeAdapter.registerTargetAdapter((t) => !!(t && t.isUniformNode));
+
+// Scalar and bool uniforms animate via the engine OBJECT fallthrough on value, no adapter prop needed since the engine writes uniform value natively.
+uniformNode.registerProperty('color',
+ (t) => readColorHex(t.value),
+ (t, _, tw) => {
+ const ns = tw._numbers;
+ t.value.setRGB(ns[0] * COLOR_NORM, ns[1] * COLOR_NORM, ns[2] * COLOR_NORM, SRGBColorSpace);
+ },
+ (t) => !!(t.value && t.value.isColor),
+);
+uniformNode.registerProperty('x', (t) => t.value.x, (t, v) => { t.value.x = v; }, (t) => isVectorWith(t.value, 'x'));
+uniformNode.registerProperty('y', (t) => t.value.y, (t, v) => { t.value.y = v; }, (t) => isVectorWith(t.value, 'y'));
+uniformNode.registerProperty('z', (t) => t.value.z, (t, v) => { t.value.z = v; }, (t) => isVectorWith(t.value, 'z'));
+uniformNode.registerProperty('w', (t) => t.value.w, (t, v) => { t.value.w = v; }, (t) => isVectorWith(t.value, 'w'));
diff --git a/dist/modules/animatable/animatable.cjs b/dist/modules/animatable/animatable.cjs
index 969ec4f6..b708342c 100644
--- a/dist/modules/animatable/animatable.cjs
+++ b/dist/modules/animatable/animatable.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - animatable - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -60,6 +60,7 @@ class Animatable {
const callbacksAnimationParams = { v: 1, autoplay: false };
const properties = {};
this.targets = [];
+ /** @type {Record<String, JSAnimation>} */
this.animations = {};
/** @type {JSAnimation|null} */
this.callbacks = null;
diff --git a/dist/modules/animatable/animatable.d.ts b/dist/modules/animatable/animatable.d.ts
index 7a18f83c..f6a87928 100644
--- a/dist/modules/animatable/animatable.d.ts
+++ b/dist/modules/animatable/animatable.d.ts
@@ -16,7 +16,8 @@ export class Animatable {
*/
constructor(targets: TargetsParam, parameters: AnimatableParams);
targets: (HTMLElement | SVGElement | import("../types/index.js").JSTarget)[];
- animations: {};
+ /** @type {Record<String, JSAnimation>} */
+ animations: Record<string, JSAnimation>;
/** @type {JSAnimation|null} */
callbacks: JSAnimation | null;
revert(): this;
diff --git a/dist/modules/animatable/animatable.js b/dist/modules/animatable/animatable.js
index 2966f089..b02ac2fb 100644
--- a/dist/modules/animatable/animatable.js
+++ b/dist/modules/animatable/animatable.js
@@ -1,6 +1,6 @@
/**
* Anime.js - animatable - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -58,6 +58,7 @@ class Animatable {
const callbacksAnimationParams = { v: 1, autoplay: false };
const properties = {};
this.targets = [];
+ /** @type {Record<String, JSAnimation>} */
this.animations = {};
/** @type {JSAnimation|null} */
this.callbacks = null;
diff --git a/dist/modules/animatable/index.cjs b/dist/modules/animatable/index.cjs
index 45cff6a3..750c30c4 100644
--- a/dist/modules/animatable/index.cjs
+++ b/dist/modules/animatable/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - animatable - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/animatable/index.js b/dist/modules/animatable/index.js
index 581dc999..9e50ec8e 100644
--- a/dist/modules/animatable/index.js
+++ b/dist/modules/animatable/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - animatable - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/animation/additive.cjs b/dist/modules/animation/additive.cjs
index 1c798554..0cc9cbaf 100644
--- a/dist/modules/animation/additive.cjs
+++ b/dist/modules/animation/additive.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - animation - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/animation/additive.js b/dist/modules/animation/additive.js
index 1161c3a0..b9a3ae92 100644
--- a/dist/modules/animation/additive.js
+++ b/dist/modules/animation/additive.js
@@ -1,6 +1,6 @@
/**
* Anime.js - animation - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/animation/animation.cjs b/dist/modules/animation/animation.cjs
index a8ba1526..593881c0 100644
--- a/dist/modules/animation/animation.cjs
+++ b/dist/modules/animation/animation.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - animation - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -11,6 +11,7 @@ var consts = require('../core/consts.cjs');
var helpers = require('../core/helpers.cjs');
var globals = require('../core/globals.cjs');
var targets = require('../core/targets.cjs');
+var registry = require('../adapters/registry.cjs');
var values = require('../core/values.cjs');
var styles = require('../core/styles.cjs');
var units = require('../core/units.cjs');
@@ -176,6 +177,11 @@ class JSAnimation extends timer.Timer {
super(/** @type {TimerParams & AnimationParams} */(parameters), parent, parentPosition);
+ /** @type {Tween} */
+ this._head;
+ /** @type {Tween} */
+ this._tail;
+
++JSAnimationId;
const parsedTargets = targets.registerTargets(targets$1);
@@ -232,6 +238,7 @@ class JSAnimation extends timer.Timer {
if (helpers.isKey(p)) {
const tweenType = values.getTweenType(target, p);
+ const adapterProp = registry.resolveAdapterEntry(target, p);
const propName = styles.sanitizePropertyName(p, target, tweenType);
@@ -315,7 +322,7 @@ class JSAnimation extends timer.Timer {
} else {
tweenToValue = computedToValue;
}
- const tweenFromValue = values.getFunctionValue(key.from, target, ti, tl, null, prevSiblingTween);
+ const tweenFromValue = values.getFunctionValue(key.from, target, ti, tl, fromFunctionStore, prevSiblingTween);
const easeToParse = key.ease || tEasing;
const easeFunctionResult = values.getFunctionValue(easeToParse, target, ti, tl, null, prevSiblingTween);
@@ -333,9 +340,13 @@ class JSAnimation extends timer.Timer {
const hasToValue = !helpers.isUnd(tweenToValue);
const isFromToArray = helpers.isArr(tweenToValue);
const isFromToValue = isFromToArray || (hasFromvalue && hasToValue);
+ // Capture the update-start in local time, the previous sibling's end for keyframes after the first, zero for the first keyframe. Used to derive a precision-matched _absoluteUpdateStartTime below.
+ const tweenUpdateStartLocal = prevTween ? lastTweenChangeEndTime : 0;
const tweenStartTime = prevTween ? lastTweenChangeEndTime + tweenDelay : tweenDelay;
// Rounding is necessary here to minimize floating point errors when working in seconds
const absoluteStartTime = helpers.round(absoluteOffsetTime + tweenStartTime, 12);
+ // Match the rounding pattern of prevSibling._absoluteEndTime so the composition overlap check compares cleanly when keyframes touch at a boundary.
+ const absoluteUpdateStartTime = helpers.round(absoluteOffsetTime + tweenUpdateStartLocal, 12);
// Force a onRender callback if the animation contains at least one from value and autoplay is set to false
if (!shouldTriggerRender && (hasFromvalue || isFromToArray)) shouldTriggerRender = 1;
@@ -344,9 +355,9 @@ class JSAnimation extends timer.Timer {
if (tweenComposition !== consts.compositionTypes.none) {
let nextSibling = siblings._head;
- // Iterate trough all the next siblings until we find a sibling with an equal or inferior start time
- while (nextSibling && !nextSibling._isOverridden && nextSibling._absoluteStartTime <= absoluteStartTime) {
- prevSibling = nextSibling;
+ // Walk prior siblings up to the new tween, skipping overridden ones so the chain resolves to the latest live value instead of stopping at the first override.
+ while (nextSibling && nextSibling._absoluteStartTime <= absoluteStartTime) {
+ if (!nextSibling._isOverridden) prevSibling = nextSibling;
nextSibling = nextSibling._nextRep;
// Overrides all the next siblings if the next sibling starts at the same time of after as the new tween start time
if (nextSibling && nextSibling._absoluteStartTime >= absoluteStartTime) {
@@ -400,8 +411,8 @@ class JSAnimation extends timer.Timer {
if (prevTween) {
values.decomposeTweenValue(prevTween, fromTargetObject);
} else {
- values.decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
// No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
+ values.decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
values.getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), fromTargetObject);
}
}
@@ -440,8 +451,7 @@ class JSAnimation extends timer.Timer {
const colorValue = fromTargetObject.t === consts.valueTypes.COLOR ? fromTargetObject : toTargetObject;
const notColorValue = fromTargetObject.t === consts.valueTypes.COLOR ? toTargetObject : fromTargetObject;
notColorValue.t = consts.valueTypes.COLOR;
- notColorValue.s = colorValue.s;
- notColorValue.d = [0, 0, 0, 1];
+ notColorValue.d = colorValue.d.map(() => 0);
}
}
@@ -471,6 +481,16 @@ class JSAnimation extends timer.Timer {
let inlineValue = inlineStylesStore[propName];
if (!helpers.isNil(inlineValue)) inlineStylesStore[propName] = null;
+ // Resolve the adapter setter once so render skips the lookup per frame.
+ const tweenSetter = adapterProp ? adapterProp.set : null;
+
+ // Rounding is necessary here to minimize floating point errors when working in seconds
+ lastTweenChangeEndTime = helpers.round(tweenStartTime + tweenUpdateDuration, 12);
+
+ const fromD = fromTargetObject.d;
+ const toD = toTargetObject.d;
+ const toS = toTargetObject.s;
+
/** @type {Tween} */
const tween = {
parent: this,
@@ -481,12 +501,12 @@ class JSAnimation extends timer.Timer {
_toFunc: toFunctionStore.func,
_fromFunc: fromFunctionStore.func,
_ease: parser.parseEase(tweenEasing),
- _fromNumbers: helpers.cloneArray(fromTargetObject.d),
- _toNumbers: helpers.cloneArray(toTargetObject.d),
- _strings: helpers.cloneArray(toTargetObject.s),
+ _fromNumbers: fromD ? helpers.cloneArray(fromD) : consts.emptyArray,
+ _toNumbers: toD ? helpers.cloneArray(toD) : consts.emptyArray,
+ _strings: toS ? helpers.cloneArray(toS) : consts.emptyArray,
_fromNumber: fromTargetObject.n,
_toNumber: toTargetObject.n,
- _numbers: helpers.cloneArray(fromTargetObject.d), // For additive tween and animatables
+ _numbers: fromD ? helpers.cloneArray(fromD) : consts.emptyArray, // For additive tween and animatables
_number: fromTargetObject.n, // For additive tween and animatables
_unit: toTargetObject.u,
_modifier: tweenModifier,
@@ -496,8 +516,12 @@ class JSAnimation extends timer.Timer {
_updateDuration: tweenUpdateDuration,
_changeDuration: tweenUpdateDuration,
_absoluteStartTime: absoluteStartTime,
+ _absoluteUpdateStartTime: absoluteUpdateStartTime,
+ _absoluteEndTime: helpers.round(absoluteOffsetTime + lastTweenChangeEndTime, 12),
+ _hasFromValue: hasFromvalue || isFromToArray ? 1 : 0,
// NOTE: Investigate bit packing to stores ENUM / BOOL
_tweenType: tweenType,
+ _setter: tweenSetter,
_valueType: toTargetObject.t,
_composition: tweenComposition,
_isOverlapped: 0,
@@ -520,10 +544,11 @@ class JSAnimation extends timer.Timer {
const vt = tween._valueType;
if (vt === consts.valueTypes.COMPLEX) {
tween._value = values.composeComplexValue(tween, 1, -1);
- } else if (vt === consts.valueTypes.COLOR) {
- tween._value = values.composeColorValue(tween, 1, -1);
} else if (vt === consts.valueTypes.UNIT) {
tween._value = `${tweenModifier(tween._toNumber)}${tween._unit}`;
+ } else if (vt === consts.valueTypes.COLOR) {
+ const d = toTargetObject.d;
+ tween._value = `rgba(${helpers.round(d[0], 0)},${helpers.round(d[1], 0)},${helpers.round(d[2], 0)},${d[3]})`;
} else {
tween._value = tweenModifier(tween._toNumber);
}
@@ -531,8 +556,7 @@ class JSAnimation extends timer.Timer {
if (isNaN(firstTweenChangeStartTime)) {
firstTweenChangeStartTime = tween._startTime;
}
- // Rounding is necessary here to minimize floating point errors when working in seconds
- lastTweenChangeEndTime = helpers.round(tweenStartTime + tweenUpdateDuration, 12);
+
prevTween = tween;
animationAnimationLength++;
@@ -638,8 +662,11 @@ class JSAnimation extends timer.Timer {
tween._updateDuration = helpers.normalizeTime(tween._updateDuration * timeScale);
tween._changeDuration = helpers.normalizeTime(tween._changeDuration * timeScale);
tween._currentTime *= timeScale;
+ tween._delay *= timeScale;
tween._startTime *= timeScale;
tween._absoluteStartTime *= timeScale;
+ tween._absoluteUpdateStartTime *= timeScale;
+ tween._absoluteEndTime *= timeScale;
});
return super.stretch(newDuration);
}
diff --git a/dist/modules/animation/animation.d.ts b/dist/modules/animation/animation.d.ts
index 9434ca72..21c37987 100644
--- a/dist/modules/animation/animation.d.ts
+++ b/dist/modules/animation/animation.d.ts
@@ -9,6 +9,10 @@ export class JSAnimation extends Timer {
* @param {TargetsArray} [allTargets]
*/
constructor(targets: TargetsParam, parameters: AnimationParams, parent?: Timeline, parentPosition?: number, fastSet?: boolean, index?: number, allTargets?: TargetsArray);
+ /** @type {Tween} */
+ _head: Tween;
+ /** @type {Tween} */
+ _tail: Tween;
/** @type {TargetsArray} */
targets: TargetsArray;
/** @type {Callback<this>} */
@@ -42,6 +46,7 @@ export class JSAnimation extends Timer {
}
export function animate(targets: TargetsParam, parameters: AnimationParams): JSAnimation;
import { Timer } from '../timer/timer.js';
+import type { Tween } from '../types/index.js';
import type { TargetsArray } from '../types/index.js';
import type { Callback } from '../types/index.js';
import type { EasingFunction } from '../types/index.js';
diff --git a/dist/modules/animation/animation.js b/dist/modules/animation/animation.js
index 58e08385..68afc02e 100644
--- a/dist/modules/animation/animation.js
+++ b/dist/modules/animation/animation.js
@@ -1,15 +1,16 @@
/**
* Anime.js - animation - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
-import { K, compositionTypes, valueTypes, minValue, isDomSymbol, tweenTypes } from '../core/consts.js';
+import { K, compositionTypes, valueTypes, emptyArray, minValue, isDomSymbol, tweenTypes } from '../core/consts.js';
import { mergeObjects, isUnd, isKey, isObj, cloneArray, isNil, round, addChild, forEachChildren, clampInfinity, normalizeTime, isArr, isNum, isFnc, isStr } from '../core/helpers.js';
import { globals } from '../core/globals.js';
import { registerTargets } from '../core/targets.js';
-import { setValue, getTweenType, getFunctionValue, decomposeRawValue, getOriginalAnimatableValue, createDecomposedValueTargetObject, decomposedOriginalValue, getRelativeValue, composeComplexValue, composeColorValue, decomposeTweenValue } from '../core/values.js';
+import { resolveAdapterEntry } from '../adapters/registry.js';
+import { setValue, getTweenType, getFunctionValue, decomposeRawValue, getOriginalAnimatableValue, createDecomposedValueTargetObject, decomposedOriginalValue, getRelativeValue, composeComplexValue, decomposeTweenValue } from '../core/values.js';
import { sanitizePropertyName, revertValues } from '../core/styles.js';
import { convertValueUnit } from '../core/units.js';
import { parseEase } from '../easings/eases/parser.js';
@@ -174,6 +175,11 @@ class JSAnimation extends Timer {
super(/** @type {TimerParams & AnimationParams} */(parameters), parent, parentPosition);
+ /** @type {Tween} */
+ this._head;
+ /** @type {Tween} */
+ this._tail;
+
++JSAnimationId;
const parsedTargets = registerTargets(targets);
@@ -230,6 +236,7 @@ class JSAnimation extends Timer {
if (isKey(p)) {
const tweenType = getTweenType(target, p);
+ const adapterProp = resolveAdapterEntry(target, p);
const propName = sanitizePropertyName(p, target, tweenType);
@@ -313,7 +320,7 @@ class JSAnimation extends Timer {
} else {
tweenToValue = computedToValue;
}
- const tweenFromValue = getFunctionValue(key.from, target, ti, tl, null, prevSiblingTween);
+ const tweenFromValue = getFunctionValue(key.from, target, ti, tl, fromFunctionStore, prevSiblingTween);
const easeToParse = key.ease || tEasing;
const easeFunctionResult = getFunctionValue(easeToParse, target, ti, tl, null, prevSiblingTween);
@@ -331,9 +338,13 @@ class JSAnimation extends Timer {
const hasToValue = !isUnd(tweenToValue);
const isFromToArray = isArr(tweenToValue);
const isFromToValue = isFromToArray || (hasFromvalue && hasToValue);
+ // Capture the update-start in local time, the previous sibling's end for keyframes after the first, zero for the first keyframe. Used to derive a precision-matched _absoluteUpdateStartTime below.
+ const tweenUpdateStartLocal = prevTween ? lastTweenChangeEndTime : 0;
const tweenStartTime = prevTween ? lastTweenChangeEndTime + tweenDelay : tweenDelay;
// Rounding is necessary here to minimize floating point errors when working in seconds
const absoluteStartTime = round(absoluteOffsetTime + tweenStartTime, 12);
+ // Match the rounding pattern of prevSibling._absoluteEndTime so the composition overlap check compares cleanly when keyframes touch at a boundary.
+ const absoluteUpdateStartTime = round(absoluteOffsetTime + tweenUpdateStartLocal, 12);
// Force a onRender callback if the animation contains at least one from value and autoplay is set to false
if (!shouldTriggerRender && (hasFromvalue || isFromToArray)) shouldTriggerRender = 1;
@@ -342,9 +353,9 @@ class JSAnimation extends Timer {
if (tweenComposition !== compositionTypes.none) {
let nextSibling = siblings._head;
- // Iterate trough all the next siblings until we find a sibling with an equal or inferior start time
- while (nextSibling && !nextSibling._isOverridden && nextSibling._absoluteStartTime <= absoluteStartTime) {
- prevSibling = nextSibling;
+ // Walk prior siblings up to the new tween, skipping overridden ones so the chain resolves to the latest live value instead of stopping at the first override.
+ while (nextSibling && nextSibling._absoluteStartTime <= absoluteStartTime) {
+ if (!nextSibling._isOverridden) prevSibling = nextSibling;
nextSibling = nextSibling._nextRep;
// Overrides all the next siblings if the next sibling starts at the same time of after as the new tween start time
if (nextSibling && nextSibling._absoluteStartTime >= absoluteStartTime) {
@@ -398,8 +409,8 @@ class JSAnimation extends Timer {
if (prevTween) {
decomposeTweenValue(prevTween, fromTargetObject);
} else {
- decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
// No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
+ decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), fromTargetObject);
}
}
@@ -438,8 +449,7 @@ class JSAnimation extends Timer {
const colorValue = fromTargetObject.t === valueTypes.COLOR ? fromTargetObject : toTargetObject;
const notColorValue = fromTargetObject.t === valueTypes.COLOR ? toTargetObject : fromTargetObject;
notColorValue.t = valueTypes.COLOR;
- notColorValue.s = colorValue.s;
- notColorValue.d = [0, 0, 0, 1];
+ notColorValue.d = colorValue.d.map(() => 0);
}
}
@@ -469,6 +479,16 @@ class JSAnimation extends Timer {
let inlineValue = inlineStylesStore[propName];
if (!isNil(inlineValue)) inlineStylesStore[propName] = null;
+ // Resolve the adapter setter once so render skips the lookup per frame.
+ const tweenSetter = adapterProp ? adapterProp.set : null;
+
+ // Rounding is necessary here to minimize floating point errors when working in seconds
+ lastTweenChangeEndTime = round(tweenStartTime + tweenUpdateDuration, 12);
+
+ const fromD = fromTargetObject.d;
+ const toD = toTargetObject.d;
+ const toS = toTargetObject.s;
+
/** @type {Tween} */
const tween = {
parent: this,
@@ -479,12 +499,12 @@ class JSAnimation extends Timer {
_toFunc: toFunctionStore.func,
_fromFunc: fromFunctionStore.func,
_ease: parseEase(tweenEasing),
- _fromNumbers: cloneArray(fromTargetObject.d),
- _toNumbers: cloneArray(toTargetObject.d),
- _strings: cloneArray(toTargetObject.s),
+ _fromNumbers: fromD ? cloneArray(fromD) : emptyArray,
+ _toNumbers: toD ? cloneArray(toD) : emptyArray,
+ _strings: toS ? cloneArray(toS) : emptyArray,
_fromNumber: fromTargetObject.n,
_toNumber: toTargetObject.n,
- _numbers: cloneArray(fromTargetObject.d), // For additive tween and animatables
+ _numbers: fromD ? cloneArray(fromD) : emptyArray, // For additive tween and animatables
_number: fromTargetObject.n, // For additive tween and animatables
_unit: toTargetObject.u,
_modifier: tweenModifier,
@@ -494,8 +514,12 @@ class JSAnimation extends Timer {
_updateDuration: tweenUpdateDuration,
_changeDuration: tweenUpdateDuration,
_absoluteStartTime: absoluteStartTime,
+ _absoluteUpdateStartTime: absoluteUpdateStartTime,
+ _absoluteEndTime: round(absoluteOffsetTime + lastTweenChangeEndTime, 12),
+ _hasFromValue: hasFromvalue || isFromToArray ? 1 : 0,
// NOTE: Investigate bit packing to stores ENUM / BOOL
_tweenType: tweenType,
+ _setter: tweenSetter,
_valueType: toTargetObject.t,
_composition: tweenComposition,
_isOverlapped: 0,
@@ -518,10 +542,11 @@ class JSAnimation extends Timer {
const vt = tween._valueType;
if (vt === valueTypes.COMPLEX) {
tween._value = composeComplexValue(tween, 1, -1);
- } else if (vt === valueTypes.COLOR) {
- tween._value = composeColorValue(tween, 1, -1);
} else if (vt === valueTypes.UNIT) {
tween._value = `${tweenModifier(tween._toNumber)}${tween._unit}`;
+ } else if (vt === valueTypes.COLOR) {
+ const d = toTargetObject.d;
+ tween._value = `rgba(${round(d[0], 0)},${round(d[1], 0)},${round(d[2], 0)},${d[3]})`;
} else {
tween._value = tweenModifier(tween._toNumber);
}
@@ -529,8 +554,7 @@ class JSAnimation extends Timer {
if (isNaN(firstTweenChangeStartTime)) {
firstTweenChangeStartTime = tween._startTime;
}
- // Rounding is necessary here to minimize floating point errors when working in seconds
- lastTweenChangeEndTime = round(tweenStartTime + tweenUpdateDuration, 12);
+
prevTween = tween;
animationAnimationLength++;
@@ -636,8 +660,11 @@ class JSAnimation extends Timer {
tween._updateDuration = normalizeTime(tween._updateDuration * timeScale);
tween._changeDuration = normalizeTime(tween._changeDuration * timeScale);
tween._currentTime *= timeScale;
+ tween._delay *= timeScale;
tween._startTime *= timeScale;
tween._absoluteStartTime *= timeScale;
+ tween._absoluteUpdateStartTime *= timeScale;
+ tween._absoluteEndTime *= timeScale;
});
return super.stretch(newDuration);
}
diff --git a/dist/modules/animation/composition.cjs b/dist/modules/animation/composition.cjs
index ffd13964..ce7f8f9e 100644
--- a/dist/modules/animation/composition.cjs
+++ b/dist/modules/animation/composition.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - animation - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -98,7 +98,7 @@ const composeTween = (tween, siblings) => {
if (prevSibling) {
const prevParent = prevSibling.parent;
- const prevAbsEndTime = prevSibling._absoluteStartTime + prevSibling._changeDuration;
+ const prevAbsEndTime = prevSibling._absoluteEndTime;
// Handle looped animations tween
@@ -124,7 +124,8 @@ const composeTween = (tween, siblings) => {
}
- const absoluteUpdateStartTime = tweenAbsStartTime - tween._delay;
+ // Read the precision-matched update-start instead of subtracting tween._delay live so sequential keyframes touching at a boundary don't trigger a phantom overlap from float drift.
+ const absoluteUpdateStartTime = tween._absoluteUpdateStartTime;
if (prevAbsEndTime > absoluteUpdateStartTime) {
@@ -144,37 +145,41 @@ const composeTween = (tween, siblings) => {
}
}
- // Pause (and cancel) the parent if it only contains overlapped tweens
+ // Skip the cancel cascade when both tweens share the same parent timeline, a timeline cannot replace itself.
+ const tweenParentTL = tween.parent.parent;
+ if (!tweenParentTL || tweenParentTL !== prevParent.parent) {
- let pausePrevParentAnimation = true;
+ let pausePrevParentAnimation = true;
- helpers.forEachChildren(prevParent, (/** @type Tween */t) => {
- if (!t._isOverlapped) pausePrevParentAnimation = false;
- });
+ helpers.forEachChildren(prevParent, (/** @type Tween */t) => {
+ if (!t._isOverlapped) pausePrevParentAnimation = false;
+ });
- if (pausePrevParentAnimation) {
- const prevParentTL = prevParent.parent;
- if (prevParentTL) {
- let pausePrevParentTL = true;
- helpers.forEachChildren(prevParentTL, (/** @type JSAnimation */a) => {
- if (a !== prevParent) {
- helpers.forEachChildren(a, (/** @type Tween */t) => {
- if (!t._isOverlapped) pausePrevParentTL = false;
- });
+ if (pausePrevParentAnimation) {
+ const prevParentTL = prevParent.parent;
+ if (prevParentTL) {
+ let pausePrevParentTL = true;
+ helpers.forEachChildren(prevParentTL, (/** @type JSAnimation */a) => {
+ if (a !== prevParent) {
+ helpers.forEachChildren(a, (/** @type Tween */t) => {
+ if (!t._isOverlapped) pausePrevParentTL = false;
+ });
+ }
+ });
+ if (pausePrevParentTL) {
+ prevParentTL.cancel();
}
- });
- if (pausePrevParentTL) {
- prevParentTL.cancel();
+ } else {
+ prevParent.cancel();
+ // Previously, calling .cancel() on a timeline child would affect the render order of other children
+ // Worked around this by marking it as .completed and using .pause() for safe removal in the engine loop
+ // This is no longer needed since timeline tween composition is now handled separately
+ // Keeping this here for reference
+ // prevParent.completed = true;
+ // prevParent.pause();
}
- } else {
- prevParent.cancel();
- // Previously, calling .cancel() on a timeline child would affect the render order of other children
- // Worked around this by marking it as .completed and using .pause() for safe removal in the engine loop
- // This is no longer needed since timeline tween composition is now handled separately
- // Keeping this here for reference
- // prevParent.completed = true;
- // prevParent.pause();
}
+
}
}
@@ -229,14 +234,12 @@ const composeTween = (tween, siblings) => {
tween._number = 0;
lookupTween._fromNumber = toNumber;
- if (tween._toNumbers) {
+ if (tween._toNumbers.length) {
const toNumbers = helpers.cloneArray(tween._toNumbers);
- if (toNumbers) {
- toNumbers.forEach((value, i) => {
- tween._fromNumbers[i] = lookupTween._fromNumbers[i] - value;
- tween._toNumbers[i] = 0;
- });
- }
+ toNumbers.forEach((value, i) => {
+ tween._fromNumbers[i] = lookupTween._fromNumbers[i] - value;
+ tween._toNumbers[i] = 0;
+ });
lookupTween._fromNumbers = toNumbers;
}
diff --git a/dist/modules/animation/composition.js b/dist/modules/animation/composition.js
index 5670afd1..344d561f 100644
--- a/dist/modules/animation/composition.js
+++ b/dist/modules/animation/composition.js
@@ -1,6 +1,6 @@
/**
* Anime.js - animation - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -96,7 +96,7 @@ const composeTween = (tween, siblings) => {
if (prevSibling) {
const prevParent = prevSibling.parent;
- const prevAbsEndTime = prevSibling._absoluteStartTime + prevSibling._changeDuration;
+ const prevAbsEndTime = prevSibling._absoluteEndTime;
// Handle looped animations tween
@@ -122,7 +122,8 @@ const composeTween = (tween, siblings) => {
}
- const absoluteUpdateStartTime = tweenAbsStartTime - tween._delay;
+ // Read the precision-matched update-start instead of subtracting tween._delay live so sequential keyframes touching at a boundary don't trigger a phantom overlap from float drift.
+ const absoluteUpdateStartTime = tween._absoluteUpdateStartTime;
if (prevAbsEndTime > absoluteUpdateStartTime) {
@@ -142,37 +143,41 @@ const composeTween = (tween, siblings) => {
}
}
- // Pause (and cancel) the parent if it only contains overlapped tweens
+ // Skip the cancel cascade when both tweens share the same parent timeline, a timeline cannot replace itself.
+ const tweenParentTL = tween.parent.parent;
+ if (!tweenParentTL || tweenParentTL !== prevParent.parent) {
- let pausePrevParentAnimation = true;
+ let pausePrevParentAnimation = true;
- forEachChildren(prevParent, (/** @type Tween */t) => {
- if (!t._isOverlapped) pausePrevParentAnimation = false;
- });
+ forEachChildren(prevParent, (/** @type Tween */t) => {
+ if (!t._isOverlapped) pausePrevParentAnimation = false;
+ });
- if (pausePrevParentAnimation) {
- const prevParentTL = prevParent.parent;
- if (prevParentTL) {
- let pausePrevParentTL = true;
- forEachChildren(prevParentTL, (/** @type JSAnimation */a) => {
- if (a !== prevParent) {
- forEachChildren(a, (/** @type Tween */t) => {
- if (!t._isOverlapped) pausePrevParentTL = false;
- });
+ if (pausePrevParentAnimation) {
+ const prevParentTL = prevParent.parent;
+ if (prevParentTL) {
+ let pausePrevParentTL = true;
+ forEachChildren(prevParentTL, (/** @type JSAnimation */a) => {
+ if (a !== prevParent) {
+ forEachChildren(a, (/** @type Tween */t) => {
+ if (!t._isOverlapped) pausePrevParentTL = false;
+ });
+ }
+ });
+ if (pausePrevParentTL) {
+ prevParentTL.cancel();
}
- });
- if (pausePrevParentTL) {
- prevParentTL.cancel();
+ } else {
+ prevParent.cancel();
+ // Previously, calling .cancel() on a timeline child would affect the render order of other children
+ // Worked around this by marking it as .completed and using .pause() for safe removal in the engine loop
+ // This is no longer needed since timeline tween composition is now handled separately
+ // Keeping this here for reference
+ // prevParent.completed = true;
+ // prevParent.pause();
}
- } else {
- prevParent.cancel();
- // Previously, calling .cancel() on a timeline child would affect the render order of other children
- // Worked around this by marking it as .completed and using .pause() for safe removal in the engine loop
- // This is no longer needed since timeline tween composition is now handled separately
- // Keeping this here for reference
- // prevParent.completed = true;
- // prevParent.pause();
}
+
}
}
@@ -227,14 +232,12 @@ const composeTween = (tween, siblings) => {
tween._number = 0;
lookupTween._fromNumber = toNumber;
- if (tween._toNumbers) {
+ if (tween._toNumbers.length) {
const toNumbers = cloneArray(tween._toNumbers);
- if (toNumbers) {
- toNumbers.forEach((value, i) => {
- tween._fromNumbers[i] = lookupTween._fromNumbers[i] - value;
- tween._toNumbers[i] = 0;
- });
- }
+ toNumbers.forEach((value, i) => {
+ tween._fromNumbers[i] = lookupTween._fromNumbers[i] - value;
+ tween._toNumbers[i] = 0;
+ });
lookupTween._fromNumbers = toNumbers;
}
diff --git a/dist/modules/animation/index.cjs b/dist/modules/animation/index.cjs
index 5b8a20d5..538882f4 100644
--- a/dist/modules/animation/index.cjs
+++ b/dist/modules/animation/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - animation - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/animation/index.js b/dist/modules/animation/index.js
index f66ce1ef..3545755f 100644
--- a/dist/modules/animation/index.js
+++ b/dist/modules/animation/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - animation - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/core/clock.cjs b/dist/modules/core/clock.cjs
index 3b40498a..3c8cbf40 100644
--- a/dist/modules/core/clock.cjs
+++ b/dist/modules/core/clock.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -36,8 +36,6 @@ class Clock {
/** @type {Number} */
this._lastTime = initTime;
/** @type {Number} */
- this._scheduledTime = 0;
- /** @type {Number} */
this._frameDuration = consts.K / consts.maxFps;
/** @type {Number} */
this._fps = consts.maxFps;
@@ -56,14 +54,12 @@ class Clock {
}
set fps(frameRate) {
- const previousFrameDuration = this._frameDuration;
const fr = +frameRate;
const fps = fr < consts.minValue ? consts.minValue : fr;
const frameDuration = consts.K / fps;
if (fps > globals.defaults.frameRate) globals.defaults.frameRate = fps;
this._fps = fps;
this._frameDuration = frameDuration;
- this._scheduledTime += frameDuration - previousFrameDuration;
}
get speed() {
@@ -80,17 +76,17 @@ class Clock {
* @return {tickModes}
*/
requestTick(time) {
- const scheduledTime = this._scheduledTime;
- this._lastTickTime = time;
- // If the current time is lower than the scheduled time
- // this means not enough time has passed to hit one frameDuration
- // so skip that frame
- if (time < scheduledTime) return consts.tickModes.NONE;
const frameDuration = this._frameDuration;
- const frameDelta = time - scheduledTime;
- // Ensures that _scheduledTime progresses in steps of at least 1 frameDuration.
- // Skips ahead if the actual elapsed time is higher.
- this._scheduledTime += frameDelta < frameDuration ? frameDuration : frameDelta;
+ const elapsed = time - this._lastTickTime;
+ const scaled = frameDuration * .25;
+ const tolerance = scaled < 4 ? scaled : 4;
+ // Tolerance prevents dropping frames that arrive a bit early due to RAF jitter
+ // typically <= ~25% of frame duration and capped at 4ms so it doesn't dominate at high fps.
+ // e.g. at 60fps (frameDuration=16.667ms) a frame arriving after 15ms:
+ // - without tolerance: 15 < 16.667 -> skip
+ // - with tolerance: 15 + 4 >= 16.667 -> tick
+ if (elapsed + tolerance < frameDuration) return consts.tickModes.NONE;
+ this._lastTickTime = elapsed >= frameDuration ? time - (elapsed % frameDuration) : time;
return consts.tickModes.AUTO;
}
diff --git a/dist/modules/core/clock.d.ts b/dist/modules/core/clock.d.ts
index 7669560c..b6eb9cda 100644
--- a/dist/modules/core/clock.d.ts
+++ b/dist/modules/core/clock.d.ts
@@ -18,8 +18,6 @@ export class Clock {
/** @type {Number} */
_lastTime: number;
/** @type {Number} */
- _scheduledTime: number;
- /** @type {Number} */
_frameDuration: number;
/** @type {Number} */
_fps: number;
diff --git a/dist/modules/core/clock.js b/dist/modules/core/clock.js
index cf28d2ba..edccc185 100644
--- a/dist/modules/core/clock.js
+++ b/dist/modules/core/clock.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -34,8 +34,6 @@ class Clock {
/** @type {Number} */
this._lastTime = initTime;
/** @type {Number} */
- this._scheduledTime = 0;
- /** @type {Number} */
this._frameDuration = K / maxFps;
/** @type {Number} */
this._fps = maxFps;
@@ -54,14 +52,12 @@ class Clock {
}
set fps(frameRate) {
- const previousFrameDuration = this._frameDuration;
const fr = +frameRate;
const fps = fr < minValue ? minValue : fr;
const frameDuration = K / fps;
if (fps > defaults.frameRate) defaults.frameRate = fps;
this._fps = fps;
this._frameDuration = frameDuration;
- this._scheduledTime += frameDuration - previousFrameDuration;
}
get speed() {
@@ -78,17 +74,17 @@ class Clock {
* @return {tickModes}
*/
requestTick(time) {
- const scheduledTime = this._scheduledTime;
- this._lastTickTime = time;
- // If the current time is lower than the scheduled time
- // this means not enough time has passed to hit one frameDuration
- // so skip that frame
- if (time < scheduledTime) return tickModes.NONE;
const frameDuration = this._frameDuration;
- const frameDelta = time - scheduledTime;
- // Ensures that _scheduledTime progresses in steps of at least 1 frameDuration.
- // Skips ahead if the actual elapsed time is higher.
- this._scheduledTime += frameDelta < frameDuration ? frameDuration : frameDelta;
+ const elapsed = time - this._lastTickTime;
+ const scaled = frameDuration * .25;
+ const tolerance = scaled < 4 ? scaled : 4;
+ // Tolerance prevents dropping frames that arrive a bit early due to RAF jitter
+ // typically <= ~25% of frame duration and capped at 4ms so it doesn't dominate at high fps.
+ // e.g. at 60fps (frameDuration=16.667ms) a frame arriving after 15ms:
+ // - without tolerance: 15 < 16.667 -> skip
+ // - with tolerance: 15 + 4 >= 16.667 -> tick
+ if (elapsed + tolerance < frameDuration) return tickModes.NONE;
+ this._lastTickTime = elapsed >= frameDuration ? time - (elapsed % frameDuration) : time;
return tickModes.AUTO;
}
diff --git a/dist/modules/core/colors.cjs b/dist/modules/core/colors.cjs
index a4a1ccce..fc121d1a 100644
--- a/dist/modules/core/colors.cjs
+++ b/dist/modules/core/colors.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/core/colors.js b/dist/modules/core/colors.js
index ee392ccb..b5f14f04 100644
--- a/dist/modules/core/colors.js
+++ b/dist/modules/core/colors.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/core/consts.cjs b/dist/modules/core/consts.cjs
index 777a249e..31fe854e 100644
--- a/dist/modules/core/consts.cjs
+++ b/dist/modules/core/consts.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -73,6 +73,11 @@ const maxFps = 240;
const emptyString = '';
const cssVarPrefix = 'var(';
+// Arrays
+
+// Shared sentinel for tween slots that don't hold array data. Never mutated, only read; COMPLEX and COLOR tweens always replace the slot before writing.
+const emptyArray = [];
+
const shortTransforms = /*#__PURE__*/ (() => {
const map = new Map();
map.set('x', 'translateX');
@@ -106,6 +111,13 @@ const transformsFragmentStrings = /*#__PURE__*/ validTransforms.reduce((a, v) =>
/** @return {void} */
const noop = () => {};
+/**
+ * @template T
+ * @param {T} v
+ * @return {T}
+ */
+const noopModifier = v => v;
+
// Regex
const validRgbHslRgx = /\)\s*[-.\d]/;
@@ -128,6 +140,7 @@ exports.cssVarPrefix = cssVarPrefix;
exports.cssVariableMatchRgx = cssVariableMatchRgx;
exports.digitWithExponentRgx = digitWithExponentRgx;
exports.doc = doc;
+exports.emptyArray = emptyArray;
exports.emptyString = emptyString;
exports.hexTestRgx = hexTestRgx;
exports.hslExecRgx = hslExecRgx;
@@ -141,6 +154,7 @@ exports.maxFps = maxFps;
exports.maxValue = maxValue;
exports.minValue = minValue;
exports.noop = noop;
+exports.noopModifier = noopModifier;
exports.proxyTargetSymbol = proxyTargetSymbol;
exports.relativeValuesExecRgx = relativeValuesExecRgx;
exports.rgbExecRgx = rgbExecRgx;
diff --git a/dist/modules/core/consts.d.ts b/dist/modules/core/consts.d.ts
index e4916e49..6608861d 100644
--- a/dist/modules/core/consts.d.ts
+++ b/dist/modules/core/consts.d.ts
@@ -43,10 +43,12 @@ export const K: 1000;
export const maxFps: 240;
export const emptyString: "";
export const cssVarPrefix: "var(";
+export const emptyArray: any[];
export const shortTransforms: Map<any, any>;
export const validTransforms: string[];
export const transformsFragmentStrings: {};
export function noop(): void;
+export function noopModifier<T>(v: T): T;
export const validRgbHslRgx: RegExp;
export const hexTestRgx: RegExp;
export const rgbExecRgx: RegExp;
diff --git a/dist/modules/core/consts.js b/dist/modules/core/consts.js
index 2ef9810a..a5505e57 100644
--- a/dist/modules/core/consts.js
+++ b/dist/modules/core/consts.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -71,6 +71,11 @@ const maxFps = 240;
const emptyString = '';
const cssVarPrefix = 'var(';
+// Arrays
+
+// Shared sentinel for tween slots that don't hold array data. Never mutated, only read; COMPLEX and COLOR tweens always replace the slot before writing.
+const emptyArray = [];
+
const shortTransforms = /*#__PURE__*/ (() => {
const map = new Map();
map.set('x', 'translateX');
@@ -104,6 +109,13 @@ const transformsFragmentStrings = /*#__PURE__*/ validTransforms.reduce((a, v) =>
/** @return {void} */
const noop = () => {};
+/**
+ * @template T
+ * @param {T} v
+ * @return {T}
+ */
+const noopModifier = v => v;
+
// Regex
const validRgbHslRgx = /\)\s*[-.\d]/;
@@ -120,4 +132,4 @@ const lowerCaseRgx = /([a-z])([A-Z])/g;
const relativeValuesExecRgx = /(\*=|\+=|-=)/;
const cssVariableMatchRgx = /var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/;
-export { K, compositionTypes, cssVarPrefix, cssVariableMatchRgx, digitWithExponentRgx, doc, emptyString, hexTestRgx, hslExecRgx, hslaExecRgx, isBrowser, isDomSymbol, isRegisteredTargetSymbol, isSvgSymbol, lowerCaseRgx, maxFps, maxValue, minValue, noop, proxyTargetSymbol, relativeValuesExecRgx, rgbExecRgx, rgbaExecRgx, shortTransforms, tickModes, transformsFragmentStrings, transformsSymbol, tweenTypes, unitsExecRgx, validRgbHslRgx, validTransforms, valueTypes, win };
+export { K, compositionTypes, cssVarPrefix, cssVariableMatchRgx, digitWithExponentRgx, doc, emptyArray, emptyString, hexTestRgx, hslExecRgx, hslaExecRgx, isBrowser, isDomSymbol, isRegisteredTargetSymbol, isSvgSymbol, lowerCaseRgx, maxFps, maxValue, minValue, noop, noopModifier, proxyTargetSymbol, relativeValuesExecRgx, rgbExecRgx, rgbaExecRgx, shortTransforms, tickModes, transformsFragmentStrings, transformsSymbol, tweenTypes, unitsExecRgx, validRgbHslRgx, validTransforms, valueTypes, win };
diff --git a/dist/modules/core/globals.cjs b/dist/modules/core/globals.cjs
index 1481252d..57378015 100644
--- a/dist/modules/core/globals.cjs
+++ b/dist/modules/core/globals.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -23,10 +23,13 @@ var consts = require('./consts.cjs');
/**
* @typedef {Object} EditorGlobals
* @property {boolean} showPanel
- * @property {boolean} synced
* @property {Function} addAnimation
+ * @property {Function} addSet
* @property {Function} addTimeline
* @property {Function} addTimelineChild
+ * @property {Function} addTimelineLabel
+ * @property {Function} addTimelineCall
+ * @property {Function} addTimelineSync
* @property {Function} resolveStagger
* @property {Object|null} _head
* @property {Object|null} _tail
@@ -49,7 +52,7 @@ const defaults = {
loopDelay: 0,
ease: 'out(2)',
composition: consts.compositionTypes.replace,
- modifier: v => v,
+ modifier: consts.noopModifier,
onBegin: consts.noop,
onBeforeUpdate: consts.noop,
onUpdate: consts.noop,
@@ -79,7 +82,7 @@ const globals = {
editor: null,
};
-const globalVersions = { version: '4.4.1', engine: null };
+const globalVersions = { version: '4.5.0', engine: null };
if (consts.isBrowser) {
if (!consts.win.AnimeJS) consts.win.AnimeJS = [];
diff --git a/dist/modules/core/globals.d.ts b/dist/modules/core/globals.d.ts
index 144aeef9..fa2944ef 100644
--- a/dist/modules/core/globals.d.ts
+++ b/dist/modules/core/globals.d.ts
@@ -11,10 +11,13 @@
/**
* @typedef {Object} EditorGlobals
* @property {boolean} showPanel
- * @property {boolean} synced
* @property {Function} addAnimation
+ * @property {Function} addSet
* @property {Function} addTimeline
* @property {Function} addTimelineChild
+ * @property {Function} addTimelineLabel
+ * @property {Function} addTimelineCall
+ * @property {Function} addTimelineSync
* @property {Function} resolveStagger
* @property {Object|null} _head
* @property {Object|null} _tail
@@ -38,10 +41,13 @@ export namespace globalVersions {
}
export type EditorGlobals = {
showPanel: boolean;
- synced: boolean;
addAnimation: Function;
+ addSet: Function;
addTimeline: Function;
addTimelineChild: Function;
+ addTimelineLabel: Function;
+ addTimelineCall: Function;
+ addTimelineSync: Function;
resolveStagger: Function;
_head: any | null;
_tail: any | null;
diff --git a/dist/modules/core/globals.js b/dist/modules/core/globals.js
index ef2fcebd..40f43d61 100644
--- a/dist/modules/core/globals.js
+++ b/dist/modules/core/globals.js
@@ -1,11 +1,11 @@
/**
* Anime.js - core - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
-import { isBrowser, win, noop, compositionTypes, K, maxFps, doc } from './consts.js';
+import { isBrowser, win, noop, noopModifier, compositionTypes, K, maxFps, doc } from './consts.js';
/**
* @import {
@@ -21,10 +21,13 @@ import { isBrowser, win, noop, compositionTypes, K, maxFps, doc } from './consts
/**
* @typedef {Object} EditorGlobals
* @property {boolean} showPanel
- * @property {boolean} synced
* @property {Function} addAnimation
+ * @property {Function} addSet
* @property {Function} addTimeline
* @property {Function} addTimelineChild
+ * @property {Function} addTimelineLabel
+ * @property {Function} addTimelineCall
+ * @property {Function} addTimelineSync
* @property {Function} resolveStagger
* @property {Object|null} _head
* @property {Object|null} _tail
@@ -47,7 +50,7 @@ const defaults = {
loopDelay: 0,
ease: 'out(2)',
composition: compositionTypes.replace,
- modifier: v => v,
+ modifier: noopModifier,
onBegin: noop,
onBeforeUpdate: noop,
onUpdate: noop,
@@ -77,7 +80,7 @@ const globals = {
editor: null,
};
-const globalVersions = { version: '4.4.1', engine: null };
+const globalVersions = { version: '4.5.0', engine: null };
if (isBrowser) {
if (!win.AnimeJS) win.AnimeJS = [];
diff --git a/dist/modules/core/helpers.cjs b/dist/modules/core/helpers.cjs
index 127970de..c8b6cfc3 100644
--- a/dist/modules/core/helpers.cjs
+++ b/dist/modules/core/helpers.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -155,7 +155,7 @@ const snap = (v, increment) => isArr(increment) ? increment.reduce((closest, cv)
* @param {Number} factor - Interpolation factor in the range [0, 1]
* @return {Number} The interpolated value
*/
-const lerp = (start, end, factor) => start + (end - start) * factor;
+const lerp = (start, end, factor) => factor === 1 ? end : factor === 0 ? start : start + (end - start) * factor;
/**
* Replaces infinity with maximum safe value
diff --git a/dist/modules/core/helpers.js b/dist/modules/core/helpers.js
index 1e5ecb82..590e5bcb 100644
--- a/dist/modules/core/helpers.js
+++ b/dist/modules/core/helpers.js
@@ -1,11 +1,11 @@
/**
* Anime.js - core - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
-import { isBrowser, maxValue, minValue, lowerCaseRgx, hexTestRgx, validRgbHslRgx } from './consts.js';
+import { isBrowser, maxValue, minValue, hexTestRgx, lowerCaseRgx, validRgbHslRgx } from './consts.js';
import { globals } from './globals.js';
/**
@@ -153,7 +153,7 @@ const snap = (v, increment) => isArr(increment) ? increment.reduce((closest, cv)
* @param {Number} factor - Interpolation factor in the range [0, 1]
* @return {Number} The interpolated value
*/
-const lerp = (start, end, factor) => start + (end - start) * factor;
+const lerp = (start, end, factor) => factor === 1 ? end : factor === 0 ? start : start + (end - start) * factor;
/**
* Replaces infinity with maximum safe value
diff --git a/dist/modules/core/render.cjs b/dist/modules/core/render.cjs
index ba2e5c9a..a42d0638 100644
--- a/dist/modules/core/render.cjs
+++ b/dist/modules/core/render.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -76,12 +76,14 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
// Execute the "expensive" iterations calculations only when necessary
if (iterationCount > 1) {
// bitwise NOT operator seems to be generally faster than Math.floor() across browsers
- const currentIteration = ~~(tickableCurrentTime / (iterationDuration + (isCurrentTimeEqualOrAboveDuration ? 0 : _loopDelay)));
+ const period = iterationDuration + (isCurrentTimeEqualOrAboveDuration ? 0 : _loopDelay);
+ const currentIteration = ~~(tickableCurrentTime / period);
tickable._currentIteration = helpers.clamp(currentIteration, 0, iterationCount);
// Prevent the iteration count to go above the max iterations when reaching the end of the animation
if (isCurrentTimeEqualOrAboveDuration) tickable._currentIteration--;
isOdd = tickable._currentIteration % 2;
- iterationElapsedTime = tickableCurrentTime % (iterationDuration + _loopDelay) || 0;
+ // Derive elapsed from the same `~~` truncation that gave currentIteration. Using `% period` here can disagree with `~~(/period)` under float drift at iteration boundaries and write the wrong end of the tween for one frame.
+ iterationElapsedTime = tickableCurrentTime - currentIteration * period || 0;
}
// Checks if exactly one of _reversed and (_alternate && isOdd) is true
@@ -113,12 +115,14 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
if (
forcedTick ||
tickMode === consts.tickModes.AUTO && (
- time >= tickableDelay && time <= tickableEndTime || // Normal render
+ // Timeline children render from their offset instead of their delay so the gap left by a truncated sibling is covered on seek.
+ time >= (parent && tickableDelay > 0 ? 0 : tickableDelay) && time <= tickableEndTime || // Normal render
time <= tickableDelay && tickablePrevTime > tickableDelay || // Playhead is before the animation start time so make sure the animation is at its initial state
time >= tickableEndTime && tickablePrevTime !== duration // Playhead is after the animation end time so make sure the animation is at its end state
) ||
iterationTime >= tickableEndTime && tickablePrevTime !== duration ||
- iterationTime <= tickableDelay && tickablePrevTime > 0 ||
+ // iterationTime is per-iteration, compared to the delay to catch a backward seek into a looped iteration's delay region. Exclude the final settled end, where iterationTime clamps to duration and would falsely match the delay region when the delay exceeds the duration.
+ iterationTime <= tickableDelay && tickablePrevTime > 0 && !isCurrentTimeEqualOrAboveDuration ||
time <= tickablePrevTime && tickablePrevTime === duration && completed || // Force a render if a seek occurs on an completed animation
isCurrentTimeEqualOrAboveDuration && !completed && isSetter // This prevents 0 duration tickables to be skipped
) {
@@ -134,7 +138,8 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
// Time has jumped more than globals.tickThreshold so consider this tick manual
const forcedRender = forcedTick || (isRunningBackwards ? deltaTime * -1 : deltaTime) >= globals.globals.tickThreshold;
- const absoluteTime = tickable._offset + (parent ? parent._offset : 0) + tickableDelay + iterationTime;
+ // Round to match the precision of tween._absoluteStartTime so equal-time boundary checks compare cleanly without floating point drift from the unrounded _offset.
+ const absoluteTime = helpers.round(tickable._offset + (parent ? parent._offset : 0) + tickableDelay + iterationTime, 12);
// Only Animation can have tweens, Timer returns undefined
let tween = /** @type {Tween} */(/** @type {JSAnimation} */(tickable)._head);
@@ -153,15 +158,38 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
const tweenNextRep = tween._nextRep;
const tweenPrevRep = tween._prevRep;
const tweenHasComposition = tweenComposition !== consts.compositionTypes.none;
+ // The previous sibling stops writing at its truncated end, so this tween takes over the hold from that point.
+ const tweenPrevRepEndTime = tweenPrevRep ? tweenPrevRep._absoluteStartTime + tweenPrevRep._changeDuration : 0;
+ const tweenPrevRepIsCrossParent = tweenPrevRep && tweenPrevRep.parent !== tween.parent;
+ // Same parent keyframes take over at their own start, end plus delay equals the next start by construction.
+ // Cross parent siblings take over at their update start.
+ // Negative delay siblings take over at their own start instead.
+ const tweenNextRepTakeover = !tweenNextRep || tweenNextRep._isOverridden ? tweenAbsEndTime :
+ tweenNextRep.parent === tween.parent ? tweenAbsEndTime + tweenNextRep._delay :
+ tweenNextRep._absoluteStartTime < tweenNextRep._absoluteUpdateStartTime ? tweenNextRep._absoluteStartTime : tweenNextRep._absoluteUpdateStartTime;
if ((forcedRender || (
- (tweenCurrentTime !== tweenChangeDuration || absoluteTime <= tweenAbsEndTime + (tweenNextRep ? tweenNextRep._delay : 0)) &&
- (tweenCurrentTime !== 0 || absoluteTime >= tween._absoluteStartTime)
- )) && (!tweenHasComposition || (
+ // Tail keyframes always re-evaluate the gate so an earlier keyframe cannot leave the target stale by writing past its own range after a backward seek.
+ (tweenCurrentTime !== tweenChangeDuration || absoluteTime <= tweenNextRepTakeover ||
+ (tweenPrevRep && !tweenPrevRepIsCrossParent && (!tweenNextRep || tweenNextRep.parent !== tween.parent))) &&
+ // A cross parent tween re-renders its from value from the previous sibling truncated end so the handoff gap holds.
+ // A keyframe re-renders its from revert while the next keyframe time is stale so a backward jump over its range cannot leave the next value in place.
+ (tweenCurrentTime !== 0 || absoluteTime >= tween._absoluteStartTime ||
+ (tweenPrevRepIsCrossParent && !tween._hasFromValue && !tweenPrevRep._isOverridden && absoluteTime >= tweenPrevRepEndTime) ||
+ (tweenNextRep && !tweenNextRep._isOverridden && tweenNextRep.parent === tween.parent && tweenNextRep._currentTime !== 0 && iterationTime < tweenNextRep._startTime))
+ )) &&
+ // Non-first keyframes wait until the iteration reaches their own start before rendering, so the previous keyframe can handle the from-revert when scrubbed backward past this tween's range.
+ (!tweenPrevRep || tweenPrevRepIsCrossParent || iterationTime >= tween._startTime) &&
+ (!tweenHasComposition || (
!tween._isOverridden &&
(!tween._isOverlapped || absoluteTime <= tweenAbsEndTime) &&
- (!tweenNextRep || (tweenNextRep._isOverridden || absoluteTime <= tweenNextRep._absoluteStartTime)) &&
- (!tweenPrevRep || (tweenPrevRep._isOverridden || (absoluteTime >= (tweenPrevRep._absoluteStartTime + tweenPrevRep._changeDuration) + tween._delay)))
+ // The next sibling owns the value past its takeover point, so yielding there keeps writes single owner in both directions.
+ (!tweenNextRep || tweenNextRep._isOverridden || absoluteTime <= tweenNextRepTakeover) &&
+ // The previous sibling owns the value up to its truncated end.
+ // Cross parent tweens take over the hold from that point, explicit from values wait for their own start.
+ (!tweenPrevRep || (tweenPrevRep._isOverridden || (!tweenPrevRepIsCrossParent ?
+ absoluteTime >= tweenPrevRepEndTime + tween._delay :
+ absoluteTime >= tween._absoluteStartTime || (!tween._hasFromValue && absoluteTime >= tweenPrevRepEndTime))))
))
) {
@@ -172,7 +200,7 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
const tweenType = tween._tweenType;
const tweenIsObject = tweenType === consts.tweenTypes.OBJECT;
const tweenIsNumber = tweenValueType === consts.valueTypes.NUMBER;
- // Only round the in-between frames values if the final value is a string
+ // Only round the in-between frames values if the final value is a string. Object targets consume raw numbers, so rounding is dead work there.
const tweenPrecision = (tweenIsNumber && tweenIsObject) || tweenProgress === 0 || tweenProgress === 1 ? -1 : globals.globals.precision;
// Recompose tween value
@@ -188,7 +216,22 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
number = /** @type {Number} */(tweenModifier(helpers.round(helpers.lerp(tween._fromNumber, tween._toNumber, tweenProgress), tweenPrecision)));
value = `${number}${tween._unit}`;
} else if (tweenValueType === consts.valueTypes.COLOR) {
- value = values.composeColorValue(tween, tweenProgress, tweenPrecision);
+ const ns = tween._numbers;
+ const fn = tween._fromNumbers;
+ const tn = tween._toNumbers;
+ const omt = 1 - tweenProgress;
+ const fr = fn[0], fg = fn[1], fb = fn[2];
+ const tr = tn[0], tg = tn[1], tb = tn[2];
+ // RGB channels lerp in pseudo-linear space (square inputs, sqrt result) to approximate gamma-correct blending.
+ // See https://developer.nvidia.com/gpugems/gpugems3/part-iv-image-effects/chapter-24-importance-being-linear.
+ ns[0] = /** @type {Number} */(tweenModifier(Math.sqrt(fr * fr * omt + tr * tr * tweenProgress)));
+ ns[1] = /** @type {Number} */(tweenModifier(Math.sqrt(fg * fg * omt + tg * tg * tweenProgress)));
+ ns[2] = /** @type {Number} */(tweenModifier(Math.sqrt(fb * fb * omt + tb * tb * tweenProgress)));
+ ns[3] = /** @type {Number} */(tweenModifier(helpers.lerp(fn[3], tn[3], tweenProgress)));
+ // The rgba string is built only for the dispatch path or the internalRender composition tick (setters handles the color comp)
+ if (!tween._setter || internalRender) {
+ value = `rgba(${helpers.round(ns[0], 0)},${helpers.round(ns[1], 0)},${helpers.round(ns[2], 0)},${ns[3]})`;
+ }
} else if (tweenValueType === consts.valueTypes.COMPLEX) {
value = values.composeComplexValue(tween, tweenProgress, tweenPrecision);
}
@@ -203,7 +246,9 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
const tweenProperty = tween.property;
tweenTarget = tween.target;
- if (tweenIsObject) {
+ if (tween._setter) {
+ tween._setter(tweenTarget, number, tween);
+ } else if (tweenIsObject) {
tweenTarget[tweenProperty] = value;
} else if (tweenType === consts.tweenTypes.ATTRIBUTE) {
/** @type {DOMTarget} */(tweenTarget).setAttribute(tweenProperty, /** @type {String} */(value));
@@ -231,6 +276,9 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
tween._value = value;
}
+ } else if (tweenCurrentTime && tweenPrevRep && !tweenPrevRepIsCrossParent && iterationTime < tween._startTime) {
+ // Mark the keyframe as reverted when the playhead moves before its start, the previous keyframe owns the from revert and writes it once.
+ tween._currentTime = 0;
}
if (tweenTransformsNeedUpdate && tween._renderTransforms) {
@@ -338,6 +386,8 @@ const tick = (tickable, time, muteCallbacks, internalRender, tickMode) => {
helpers.forEachChildren(tl, (/** @type {JSAnimation} */child) => {
const childTime = helpers.round((tlChildrenTime - child._offset) * child._speed, 12); // Rounding is needed when using seconds
+ // Skip past-end siblings on backward iteration so their progress=1 to-values don't render last and overwrite the active sibling's write. Compare against _delay + duration so children with a normalized delay are not skipped while still inside their active range.
+ if (tlIsRunningBackwards && childTime > child._delay + child.duration) return;
const childTickMode = child._fps < tl._fps ? child.requestTick(tlCildrenTickTime) : tickMode;
tlChildrenHasRendered += render(child, childTime, muteCallbacks, internalRender, childTickMode);
if (!child.completed && tlChildrenHaveCompleted) tlChildrenHaveCompleted = false;
diff --git a/dist/modules/core/render.js b/dist/modules/core/render.js
index c868673f..17d2efa3 100644
--- a/dist/modules/core/render.js
+++ b/dist/modules/core/render.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -9,7 +9,7 @@ import { globals } from './globals.js';
import { minValue, tickModes, valueTypes, compositionTypes, tweenTypes, transformsSymbol } from './consts.js';
import { forEachChildren, round, now, clamp, lerp } from './helpers.js';
import { buildTransformString } from './transforms.js';
-import { composeColorValue, composeComplexValue } from './values.js';
+import { composeComplexValue } from './values.js';
/**
* @import {
@@ -74,12 +74,14 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
// Execute the "expensive" iterations calculations only when necessary
if (iterationCount > 1) {
// bitwise NOT operator seems to be generally faster than Math.floor() across browsers
- const currentIteration = ~~(tickableCurrentTime / (iterationDuration + (isCurrentTimeEqualOrAboveDuration ? 0 : _loopDelay)));
+ const period = iterationDuration + (isCurrentTimeEqualOrAboveDuration ? 0 : _loopDelay);
+ const currentIteration = ~~(tickableCurrentTime / period);
tickable._currentIteration = clamp(currentIteration, 0, iterationCount);
// Prevent the iteration count to go above the max iterations when reaching the end of the animation
if (isCurrentTimeEqualOrAboveDuration) tickable._currentIteration--;
isOdd = tickable._currentIteration % 2;
- iterationElapsedTime = tickableCurrentTime % (iterationDuration + _loopDelay) || 0;
+ // Derive elapsed from the same `~~` truncation that gave currentIteration. Using `% period` here can disagree with `~~(/period)` under float drift at iteration boundaries and write the wrong end of the tween for one frame.
+ iterationElapsedTime = tickableCurrentTime - currentIteration * period || 0;
}
// Checks if exactly one of _reversed and (_alternate && isOdd) is true
@@ -111,12 +113,14 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
if (
forcedTick ||
tickMode === tickModes.AUTO && (
- time >= tickableDelay && time <= tickableEndTime || // Normal render
+ // Timeline children render from their offset instead of their delay so the gap left by a truncated sibling is covered on seek.
+ time >= (parent && tickableDelay > 0 ? 0 : tickableDelay) && time <= tickableEndTime || // Normal render
time <= tickableDelay && tickablePrevTime > tickableDelay || // Playhead is before the animation start time so make sure the animation is at its initial state
time >= tickableEndTime && tickablePrevTime !== duration // Playhead is after the animation end time so make sure the animation is at its end state
) ||
iterationTime >= tickableEndTime && tickablePrevTime !== duration ||
- iterationTime <= tickableDelay && tickablePrevTime > 0 ||
+ // iterationTime is per-iteration, compared to the delay to catch a backward seek into a looped iteration's delay region. Exclude the final settled end, where iterationTime clamps to duration and would falsely match the delay region when the delay exceeds the duration.
+ iterationTime <= tickableDelay && tickablePrevTime > 0 && !isCurrentTimeEqualOrAboveDuration ||
time <= tickablePrevTime && tickablePrevTime === duration && completed || // Force a render if a seek occurs on an completed animation
isCurrentTimeEqualOrAboveDuration && !completed && isSetter // This prevents 0 duration tickables to be skipped
) {
@@ -132,7 +136,8 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
// Time has jumped more than globals.tickThreshold so consider this tick manual
const forcedRender = forcedTick || (isRunningBackwards ? deltaTime * -1 : deltaTime) >= globals.tickThreshold;
- const absoluteTime = tickable._offset + (parent ? parent._offset : 0) + tickableDelay + iterationTime;
+ // Round to match the precision of tween._absoluteStartTime so equal-time boundary checks compare cleanly without floating point drift from the unrounded _offset.
+ const absoluteTime = round(tickable._offset + (parent ? parent._offset : 0) + tickableDelay + iterationTime, 12);
// Only Animation can have tweens, Timer returns undefined
let tween = /** @type {Tween} */(/** @type {JSAnimation} */(tickable)._head);
@@ -151,15 +156,38 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
const tweenNextRep = tween._nextRep;
const tweenPrevRep = tween._prevRep;
const tweenHasComposition = tweenComposition !== compositionTypes.none;
+ // The previous sibling stops writing at its truncated end, so this tween takes over the hold from that point.
+ const tweenPrevRepEndTime = tweenPrevRep ? tweenPrevRep._absoluteStartTime + tweenPrevRep._changeDuration : 0;
+ const tweenPrevRepIsCrossParent = tweenPrevRep && tweenPrevRep.parent !== tween.parent;
+ // Same parent keyframes take over at their own start, end plus delay equals the next start by construction.
+ // Cross parent siblings take over at their update start.
+ // Negative delay siblings take over at their own start instead.
+ const tweenNextRepTakeover = !tweenNextRep || tweenNextRep._isOverridden ? tweenAbsEndTime :
+ tweenNextRep.parent === tween.parent ? tweenAbsEndTime + tweenNextRep._delay :
+ tweenNextRep._absoluteStartTime < tweenNextRep._absoluteUpdateStartTime ? tweenNextRep._absoluteStartTime : tweenNextRep._absoluteUpdateStartTime;
if ((forcedRender || (
- (tweenCurrentTime !== tweenChangeDuration || absoluteTime <= tweenAbsEndTime + (tweenNextRep ? tweenNextRep._delay : 0)) &&
- (tweenCurrentTime !== 0 || absoluteTime >= tween._absoluteStartTime)
- )) && (!tweenHasComposition || (
+ // Tail keyframes always re-evaluate the gate so an earlier keyframe cannot leave the target stale by writing past its own range after a backward seek.
+ (tweenCurrentTime !== tweenChangeDuration || absoluteTime <= tweenNextRepTakeover ||
+ (tweenPrevRep && !tweenPrevRepIsCrossParent && (!tweenNextRep || tweenNextRep.parent !== tween.parent))) &&
+ // A cross parent tween re-renders its from value from the previous sibling truncated end so the handoff gap holds.
+ // A keyframe re-renders its from revert while the next keyframe time is stale so a backward jump over its range cannot leave the next value in place.
+ (tweenCurrentTime !== 0 || absoluteTime >= tween._absoluteStartTime ||
+ (tweenPrevRepIsCrossParent && !tween._hasFromValue && !tweenPrevRep._isOverridden && absoluteTime >= tweenPrevRepEndTime) ||
+ (tweenNextRep && !tweenNextRep._isOverridden && tweenNextRep.parent === tween.parent && tweenNextRep._currentTime !== 0 && iterationTime < tweenNextRep._startTime))
+ )) &&
+ // Non-first keyframes wait until the iteration reaches their own start before rendering, so the previous keyframe can handle the from-revert when scrubbed backward past this tween's range.
+ (!tweenPrevRep || tweenPrevRepIsCrossParent || iterationTime >= tween._startTime) &&
+ (!tweenHasComposition || (
!tween._isOverridden &&
(!tween._isOverlapped || absoluteTime <= tweenAbsEndTime) &&
- (!tweenNextRep || (tweenNextRep._isOverridden || absoluteTime <= tweenNextRep._absoluteStartTime)) &&
- (!tweenPrevRep || (tweenPrevRep._isOverridden || (absoluteTime >= (tweenPrevRep._absoluteStartTime + tweenPrevRep._changeDuration) + tween._delay)))
+ // The next sibling owns the value past its takeover point, so yielding there keeps writes single owner in both directions.
+ (!tweenNextRep || tweenNextRep._isOverridden || absoluteTime <= tweenNextRepTakeover) &&
+ // The previous sibling owns the value up to its truncated end.
+ // Cross parent tweens take over the hold from that point, explicit from values wait for their own start.
+ (!tweenPrevRep || (tweenPrevRep._isOverridden || (!tweenPrevRepIsCrossParent ?
+ absoluteTime >= tweenPrevRepEndTime + tween._delay :
+ absoluteTime >= tween._absoluteStartTime || (!tween._hasFromValue && absoluteTime >= tweenPrevRepEndTime))))
))
) {
@@ -170,7 +198,7 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
const tweenType = tween._tweenType;
const tweenIsObject = tweenType === tweenTypes.OBJECT;
const tweenIsNumber = tweenValueType === valueTypes.NUMBER;
- // Only round the in-between frames values if the final value is a string
+ // Only round the in-between frames values if the final value is a string. Object targets consume raw numbers, so rounding is dead work there.
const tweenPrecision = (tweenIsNumber && tweenIsObject) || tweenProgress === 0 || tweenProgress === 1 ? -1 : globals.precision;
// Recompose tween value
@@ -186,7 +214,22 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
number = /** @type {Number} */(tweenModifier(round(lerp(tween._fromNumber, tween._toNumber, tweenProgress), tweenPrecision)));
value = `${number}${tween._unit}`;
} else if (tweenValueType === valueTypes.COLOR) {
- value = composeColorValue(tween, tweenProgress, tweenPrecision);
+ const ns = tween._numbers;
+ const fn = tween._fromNumbers;
+ const tn = tween._toNumbers;
+ const omt = 1 - tweenProgress;
+ const fr = fn[0], fg = fn[1], fb = fn[2];
+ const tr = tn[0], tg = tn[1], tb = tn[2];
+ // RGB channels lerp in pseudo-linear space (square inputs, sqrt result) to approximate gamma-correct blending.
+ // See https://developer.nvidia.com/gpugems/gpugems3/part-iv-image-effects/chapter-24-importance-being-linear.
+ ns[0] = /** @type {Number} */(tweenModifier(Math.sqrt(fr * fr * omt + tr * tr * tweenProgress)));
+ ns[1] = /** @type {Number} */(tweenModifier(Math.sqrt(fg * fg * omt + tg * tg * tweenProgress)));
+ ns[2] = /** @type {Number} */(tweenModifier(Math.sqrt(fb * fb * omt + tb * tb * tweenProgress)));
+ ns[3] = /** @type {Number} */(tweenModifier(lerp(fn[3], tn[3], tweenProgress)));
+ // The rgba string is built only for the dispatch path or the internalRender composition tick (setters handles the color comp)
+ if (!tween._setter || internalRender) {
+ value = `rgba(${round(ns[0], 0)},${round(ns[1], 0)},${round(ns[2], 0)},${ns[3]})`;
+ }
} else if (tweenValueType === valueTypes.COMPLEX) {
value = composeComplexValue(tween, tweenProgress, tweenPrecision);
}
@@ -201,7 +244,9 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
const tweenProperty = tween.property;
tweenTarget = tween.target;
- if (tweenIsObject) {
+ if (tween._setter) {
+ tween._setter(tweenTarget, number, tween);
+ } else if (tweenIsObject) {
tweenTarget[tweenProperty] = value;
} else if (tweenType === tweenTypes.ATTRIBUTE) {
/** @type {DOMTarget} */(tweenTarget).setAttribute(tweenProperty, /** @type {String} */(value));
@@ -229,6 +274,9 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
tween._value = value;
}
+ } else if (tweenCurrentTime && tweenPrevRep && !tweenPrevRepIsCrossParent && iterationTime < tween._startTime) {
+ // Mark the keyframe as reverted when the playhead moves before its start, the previous keyframe owns the from revert and writes it once.
+ tween._currentTime = 0;
}
if (tweenTransformsNeedUpdate && tween._renderTransforms) {
@@ -336,6 +384,8 @@ const tick = (tickable, time, muteCallbacks, internalRender, tickMode) => {
forEachChildren(tl, (/** @type {JSAnimation} */child) => {
const childTime = round((tlChildrenTime - child._offset) * child._speed, 12); // Rounding is needed when using seconds
+ // Skip past-end siblings on backward iteration so their progress=1 to-values don't render last and overwrite the active sibling's write. Compare against _delay + duration so children with a normalized delay are not skipped while still inside their active range.
+ if (tlIsRunningBackwards && childTime > child._delay + child.duration) return;
const childTickMode = child._fps < tl._fps ? child.requestTick(tlCildrenTickTime) : tickMode;
tlChildrenHasRendered += render(child, childTime, muteCallbacks, internalRender, childTickMode);
if (!child.completed && tlChildrenHaveCompleted) tlChildrenHaveCompleted = false;
diff --git a/dist/modules/core/styles.cjs b/dist/modules/core/styles.cjs
index 5714cdc8..5c5e1ca5 100644
--- a/dist/modules/core/styles.cjs
+++ b/dist/modules/core/styles.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -10,6 +10,7 @@
var consts = require('./consts.cjs');
var helpers = require('./helpers.cjs');
var transforms = require('./transforms.cjs');
+var values = require('./values.cjs');
/**
* @import {
@@ -76,7 +77,20 @@ const revertValues = (renderable, inlineStylesOnly = false) => {
const tweenType = tween._tweenType;
const originalInlinedValue = tween._inlineValue;
const tweenHadNoInlineValue = helpers.isNil(originalInlinedValue) || originalInlinedValue === consts.emptyString;
- if (tweenType === consts.tweenTypes.OBJECT) {
+ if (tween._setter) {
+ if (!inlineStylesOnly && !tweenHadNoInlineValue) {
+ // Re-seed the original value to the _number / _numbers props so the setter can write the original state instead of re-applying the current frame.
+ values.decomposeRawValue(originalInlinedValue, values.decomposedOriginalValue);
+ if (values.decomposedOriginalValue.d) {
+ const src = values.decomposedOriginalValue.d;
+ const dst = tween._numbers;
+ for (let i = 0, l = src.length; i < l; i++) dst[i] = src[i];
+ } else {
+ tween._number = values.decomposedOriginalValue.n;
+ }
+ tween._setter(tween.target, tween._number, tween);
+ }
+ } else if (tweenType === consts.tweenTypes.OBJECT) {
if (!inlineStylesOnly && !tweenHadNoInlineValue) {
tweenTarget[tweenProperty] = originalInlinedValue;
}
diff --git a/dist/modules/core/styles.js b/dist/modules/core/styles.js
index 8940328d..a0cecc48 100644
--- a/dist/modules/core/styles.js
+++ b/dist/modules/core/styles.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -8,6 +8,7 @@
import { tweenTypes, isDomSymbol, transformsSymbol, emptyString, shortTransforms } from './consts.js';
import { forEachChildren, toLowerCase, isNil, isSvg } from './helpers.js';
import { buildTransformString } from './transforms.js';
+import { decomposeRawValue, decomposedOriginalValue } from './values.js';
/**
* @import {
@@ -74,7 +75,20 @@ const revertValues = (renderable, inlineStylesOnly = false) => {
const tweenType = tween._tweenType;
const originalInlinedValue = tween._inlineValue;
const tweenHadNoInlineValue = isNil(originalInlinedValue) || originalInlinedValue === emptyString;
- if (tweenType === tweenTypes.OBJECT) {
+ if (tween._setter) {
+ if (!inlineStylesOnly && !tweenHadNoInlineValue) {
+ // Re-seed the original value to the _number / _numbers props so the setter can write the original state instead of re-applying the current frame.
+ decomposeRawValue(originalInlinedValue, decomposedOriginalValue);
+ if (decomposedOriginalValue.d) {
+ const src = decomposedOriginalValue.d;
+ const dst = tween._numbers;
+ for (let i = 0, l = src.length; i < l; i++) dst[i] = src[i];
+ } else {
+ tween._number = decomposedOriginalValue.n;
+ }
+ tween._setter(tween.target, tween._number, tween);
+ }
+ } else if (tweenType === tweenTypes.OBJECT) {
if (!inlineStylesOnly && !tweenHadNoInlineValue) {
tweenTarget[tweenProperty] = originalInlinedValue;
}
diff --git a/dist/modules/core/targets.cjs b/dist/modules/core/targets.cjs
index e9aab732..6aabec94 100644
--- a/dist/modules/core/targets.cjs
+++ b/dist/modules/core/targets.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -113,18 +113,16 @@ function parseTargets(targets) {
function registerTargets(targets) {
const parsedTargetsArray = parseTargets(targets);
const parsedTargetsLength = parsedTargetsArray.length;
- if (parsedTargetsLength) {
- for (let i = 0; i < parsedTargetsLength; i++) {
- const target = parsedTargetsArray[i];
- if (!target[consts.isRegisteredTargetSymbol]) {
- target[consts.isRegisteredTargetSymbol] = true;
- const isSvgType = helpers.isSvg(target);
- const isDom = /** @type {DOMTarget} */(target).nodeType || isSvgType;
- if (isDom) {
- target[consts.isDomSymbol] = true;
- target[consts.isSvgSymbol] = isSvgType;
- target[consts.transformsSymbol] = {};
- }
+ for (let i = 0; i < parsedTargetsLength; i++) {
+ const target = parsedTargetsArray[i];
+ if (!target[consts.isRegisteredTargetSymbol]) {
+ target[consts.isRegisteredTargetSymbol] = true;
+ const isSvgType = helpers.isSvg(target);
+ const isDom = /** @type {DOMTarget} */(target).nodeType || isSvgType;
+ if (isDom) {
+ target[consts.isDomSymbol] = true;
+ target[consts.isSvgSymbol] = isSvgType;
+ target[consts.transformsSymbol] = {};
}
}
}
diff --git a/dist/modules/core/targets.js b/dist/modules/core/targets.js
index b87a88cb..3e0af712 100644
--- a/dist/modules/core/targets.js
+++ b/dist/modules/core/targets.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -111,18 +111,16 @@ function parseTargets(targets) {
function registerTargets(targets) {
const parsedTargetsArray = parseTargets(targets);
const parsedTargetsLength = parsedTargetsArray.length;
- if (parsedTargetsLength) {
- for (let i = 0; i < parsedTargetsLength; i++) {
- const target = parsedTargetsArray[i];
- if (!target[isRegisteredTargetSymbol]) {
- target[isRegisteredTargetSymbol] = true;
- const isSvgType = isSvg(target);
- const isDom = /** @type {DOMTarget} */(target).nodeType || isSvgType;
- if (isDom) {
- target[isDomSymbol] = true;
- target[isSvgSymbol] = isSvgType;
- target[transformsSymbol] = {};
- }
+ for (let i = 0; i < parsedTargetsLength; i++) {
+ const target = parsedTargetsArray[i];
+ if (!target[isRegisteredTargetSymbol]) {
+ target[isRegisteredTargetSymbol] = true;
+ const isSvgType = isSvg(target);
+ const isDom = /** @type {DOMTarget} */(target).nodeType || isSvgType;
+ if (isDom) {
+ target[isDomSymbol] = true;
+ target[isSvgSymbol] = isSvgType;
+ target[transformsSymbol] = {};
}
}
}
diff --git a/dist/modules/core/transforms.cjs b/dist/modules/core/transforms.cjs
index cb6a1b00..31010005 100644
--- a/dist/modules/core/transforms.cjs
+++ b/dist/modules/core/transforms.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/core/transforms.js b/dist/modules/core/transforms.js
index ea0e0578..4840945b 100644
--- a/dist/modules/core/transforms.js
+++ b/dist/modules/core/transforms.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/core/units.cjs b/dist/modules/core/units.cjs
index 91de18b8..03a194a3 100644
--- a/dist/modules/core/units.cjs
+++ b/dist/modules/core/units.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/core/units.js b/dist/modules/core/units.js
index ce21dc5a..5a6f7474 100644
--- a/dist/modules/core/units.js
+++ b/dist/modules/core/units.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/core/values.cjs b/dist/modules/core/values.cjs
index eeb1b158..c3033729 100644
--- a/dist/modules/core/values.cjs
+++ b/dist/modules/core/values.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -10,6 +10,7 @@
var consts = require('./consts.cjs');
var helpers = require('./helpers.cjs');
var transforms = require('./transforms.cjs');
+var registry = require('../adapters/registry.cjs');
var colors = require('./colors.cjs');
/**
@@ -33,6 +34,21 @@ const setValue = (targetValue, defaultValue) => {
return helpers.isUnd(targetValue) ? defaultValue : targetValue;
};
+/**
+ * Resolve against the target when it's a DOM element, otherwise fall back to :root so non-DOM targets like three.js meshes and custom adapters still pick up CSS variables defined on the document.
+ *
+ * @param {String} value
+ * @param {Target} target
+ * @return {String|Number}
+ */
+const resolveCssVar = (value, target) => {
+ const match = value.match(consts.cssVariableMatchRgx);
+ const el = target[consts.isDomSymbol] ? target : document.documentElement;
+ let computed = getComputedStyle(/** @type {HTMLElement} */(el))?.getPropertyValue(match[1]);
+ if ((!computed || computed.trim() === consts.emptyString) && match[2]) computed = match[2].trim();
+ return computed || 0;
+};
+
/**
* @param {TweenPropValue} value
* @param {Target} target
@@ -43,30 +59,26 @@ const setValue = (targetValue, defaultValue) => {
* @return {any}
*/
const getFunctionValue = (value, target, index, targets, store, prevTween) => {
- let func;
if (helpers.isFnc(value)) {
- func = () => {
+ if (!store) {
+ const computed = /** @type {Function} */(value)(target, index, targets, prevTween);
+ // Fallback to 0 if the function returns undefined, NaN, null, false or 0
+ return !isNaN(+computed) ? +computed : computed || 0;
+ }
+ const func = () => {
const computed = /** @type {Function} */(value)(target, index, targets, prevTween);
- // Fallback to 0 if the function returns undefined / NaN / null / false / 0
return !isNaN(+computed) ? +computed : computed || 0;
};
- } else if (helpers.isStr(value) && helpers.stringStartsWith(value, consts.cssVarPrefix)) {
- func = () => {
- const match = value.match(consts.cssVariableMatchRgx);
- const cssVarName = match[1];
- const fallbackValue = match[2];
- let computed = getComputedStyle(/** @type {HTMLElement} */(target))?.getPropertyValue(cssVarName);
- // Use fallback if CSS variable is not set or empty
- if ((!computed || computed.trim() === consts.emptyString) && fallbackValue) {
- computed = fallbackValue.trim();
- }
- return computed || 0;
- };
- } else {
- return value;
+ store.func = func;
+ return func();
}
- if (store) store.func = func;
- return func();
+ if (helpers.isStr(value) && helpers.stringStartsWith(value, consts.cssVarPrefix)) {
+ if (!store) return resolveCssVar(/** @type {String} */(value), target);
+ const func = () => resolveCssVar(/** @type {String} */(value), target);
+ store.func = func;
+ return func();
+ }
+ return value;
};
/**
@@ -113,6 +125,12 @@ const getCSSValue = (target, propName, animationInlineStyles) => {
*/
const getOriginalAnimatableValue = (target, propName, tweenType, animationInlineStyles) => {
const type = !helpers.isUnd(tweenType) ? tweenType : getTweenType(target, propName);
+ const adapterProp = registry.resolveAdapterEntry(target, propName);
+ if (adapterProp) {
+ const value = adapterProp.get(target);
+ if (value && animationInlineStyles) animationInlineStyles[propName] = value;
+ return value == null ? 0 : value;
+ }
if (type === consts.tweenTypes.OBJECT) {
const value = target[propName];
if (value && animationInlineStyles) animationInlineStyles[propName] = value;
@@ -154,7 +172,7 @@ const createDecomposedValueTargetObject = () => {
};
/**
- * @param {String|Number} rawValue
+ * @param {String|Number|Object} rawValue
* @param {TweenDecomposedValue} targetObject
* @return {TweenDecomposedValue}
*/
@@ -172,39 +190,38 @@ const decomposeRawValue = (rawValue, targetObject) => {
// It's a number
targetObject.n = num;
return targetObject;
+ }
+ // let str = /** @type {String} */(rawValue).trim();
+ let str = /** @type {String} */(rawValue);
+ // Parsing operators (+=, -=, *=) manually is much faster than using regex here
+ if (str[1] === '=') {
+ targetObject.o = str[0];
+ str = str.slice(2);
+ }
+ // Skip exec regex if the value type is complex or color to avoid long regex backtracking
+ const unitMatch = str.includes(' ') ? false : consts.unitsExecRgx.exec(str);
+ if (unitMatch) {
+ // Has a number and a unit
+ targetObject.t = consts.valueTypes.UNIT;
+ targetObject.n = +unitMatch[1];
+ targetObject.u = unitMatch[2];
+ return targetObject;
+ } else if (targetObject.o) {
+ // Has an operator (+=, -=, *=)
+ targetObject.n = +str;
+ return targetObject;
+ } else if (helpers.isCol(str)) {
+ // Color string
+ targetObject.t = consts.valueTypes.COLOR;
+ targetObject.d = colors.convertColorStringValuesToRgbaArray(str);
+ return targetObject;
} else {
- // let str = /** @type {String} */(rawValue).trim();
- let str = /** @type {String} */(rawValue);
- // Parsing operators (+=, -=, *=) manually is much faster than using regex here
- if (str[1] === '=') {
- targetObject.o = str[0];
- str = str.slice(2);
- }
- // Skip exec regex if the value type is complex or color to avoid long regex backtracking
- const unitMatch = str.includes(' ') ? false : consts.unitsExecRgx.exec(str);
- if (unitMatch) {
- // Has a number and a unit
- targetObject.t = consts.valueTypes.UNIT;
- targetObject.n = +unitMatch[1];
- targetObject.u = unitMatch[2];
- return targetObject;
- } else if (targetObject.o) {
- // Has an operator (+=, -=, *=)
- targetObject.n = +str;
- return targetObject;
- } else if (helpers.isCol(str)) {
- // Is a color
- targetObject.t = consts.valueTypes.COLOR;
- targetObject.d = colors.convertColorStringValuesToRgbaArray(str);
- return targetObject;
- } else {
- // Is a more complex string (generally svg coords, calc() or filters CSS values)
- const matchedNumbers = str.match(consts.digitWithExponentRgx);
- targetObject.t = consts.valueTypes.COMPLEX;
- targetObject.d = matchedNumbers ? matchedNumbers.map(Number) : [];
- targetObject.s = str.split(consts.digitWithExponentRgx) || [];
- return targetObject;
- }
+ // Is a more complex string (generally svg coords, calc() or filters CSS values)
+ const matchedNumbers = str.match(consts.digitWithExponentRgx);
+ targetObject.t = consts.valueTypes.COMPLEX;
+ targetObject.d = matchedNumbers ? matchedNumbers.map(Number) : [];
+ targetObject.s = str.split(consts.digitWithExponentRgx) || [];
+ return targetObject;
}
};
@@ -225,30 +242,6 @@ const decomposeTweenValue = (tween, targetObject) => {
const decomposedOriginalValue = createDecomposedValueTargetObject();
-/**
- * @param {Tween} tween
- * @param {Number} progress
- * @param {Number} precision
- * @return {String}
- */
-const composeColorValue = (tween, progress, precision) => {
- const mod = tween._modifier;
- const fn = tween._fromNumbers;
- const tn = tween._toNumbers;
- const r = helpers.round(helpers.clamp(/** @type {Number} */(mod(helpers.lerp(fn[0], tn[0], progress))), 0, 255), 0);
- const g = helpers.round(helpers.clamp(/** @type {Number} */(mod(helpers.lerp(fn[1], tn[1], progress))), 0, 255), 0);
- const b = helpers.round(helpers.clamp(/** @type {Number} */(mod(helpers.lerp(fn[2], tn[2], progress))), 0, 255), 0);
- const a = helpers.clamp(/** @type {Number} */(mod(helpers.round(helpers.lerp(fn[3], tn[3], progress), precision))), 0, 1);
- if (tween._composition !== consts.compositionTypes.none) {
- const ns = tween._numbers;
- ns[0] = r;
- ns[1] = g;
- ns[2] = b;
- ns[3] = a;
- }
- return `rgba(${r},${g},${b},${a})`;
-};
-
/**
* @param {Tween} tween
* @param {Number} progress
@@ -260,20 +253,18 @@ const composeComplexValue = (tween, progress, precision) => {
const fn = tween._fromNumbers;
const tn = tween._toNumbers;
const ts = tween._strings;
- const hasComposition = tween._composition !== consts.compositionTypes.none;
let v = ts[0];
for (let j = 0, l = tn.length; j < l; j++) {
const n = /** @type {Number} */(mod(helpers.round(helpers.lerp(fn[j], tn[j], progress), precision)));
const s = ts[j + 1];
v += `${s ? n + s : n}`;
- if (hasComposition) {
- tween._numbers[j] = n;
- }
+ // Keep _numbers fresh for every tween, not only composed ones, so a non-composition setter that reads the lerped triplet such as three transformOrigin still animates.
+ // Potential optimization, skip the write when nothing reads it: if (hasComposition || tween._setter) tween._numbers[j] = n;
+ tween._numbers[j] = n;
}
return v;
};
-exports.composeColorValue = composeColorValue;
exports.composeComplexValue = composeComplexValue;
exports.createDecomposedValueTargetObject = createDecomposedValueTargetObject;
exports.decomposeRawValue = decomposeRawValue;
diff --git a/dist/modules/core/values.d.ts b/dist/modules/core/values.d.ts
index e12fe2ef..1843cea2 100644
--- a/dist/modules/core/values.d.ts
+++ b/dist/modules/core/values.d.ts
@@ -4,10 +4,9 @@ export function getTweenType(target: Target, prop: string): tweenTypes;
export function getOriginalAnimatableValue(target: Target, propName: string, tweenType?: tweenTypes, animationInlineStyles?: any | void): string | number;
export function getRelativeValue(x: number, y: number, operator: string): number;
export function createDecomposedValueTargetObject(): TweenDecomposedValue;
-export function decomposeRawValue(rawValue: string | number, targetObject: TweenDecomposedValue): TweenDecomposedValue;
+export function decomposeRawValue(rawValue: string | number | any, targetObject: TweenDecomposedValue): TweenDecomposedValue;
export function decomposeTweenValue(tween: Tween, targetObject: TweenDecomposedValue): TweenDecomposedValue;
export const decomposedOriginalValue: TweenDecomposedValue;
-export function composeColorValue(tween: Tween, progress: number, precision: number): string;
export function composeComplexValue(tween: Tween, progress: number, precision: number): string;
import type { TweenPropValue } from '../types/index.js';
import type { Target } from '../types/index.js';
diff --git a/dist/modules/core/values.js b/dist/modules/core/values.js
index a3a75a07..a70cd3d5 100644
--- a/dist/modules/core/values.js
+++ b/dist/modules/core/values.js
@@ -1,13 +1,14 @@
/**
* Anime.js - core - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
-import { tweenTypes, isDomSymbol, isSvgSymbol, validTransforms, shortTransforms, valueTypes, unitsExecRgx, digitWithExponentRgx, compositionTypes, proxyTargetSymbol, cssVarPrefix, cssVariableMatchRgx, emptyString } from './consts.js';
-import { isUnd, isValidSVGAttribute, stringStartsWith, isCol, isFnc, isStr, round, lerp, clamp, cloneArray } from './helpers.js';
+import { valueTypes, unitsExecRgx, digitWithExponentRgx, tweenTypes, isDomSymbol, isSvgSymbol, validTransforms, shortTransforms, proxyTargetSymbol, cssVariableMatchRgx, emptyString, cssVarPrefix } from './consts.js';
+import { isUnd, isCol, isValidSVGAttribute, stringStartsWith, isFnc, isStr, round, lerp, cloneArray } from './helpers.js';
import { parseInlineTransforms } from './transforms.js';
+import { resolveAdapterEntry } from '../adapters/registry.js';
import { convertColorStringValuesToRgbaArray } from './colors.js';
/**
@@ -31,6 +32,21 @@ const setValue = (targetValue, defaultValue) => {
return isUnd(targetValue) ? defaultValue : targetValue;
};
+/**
+ * Resolve against the target when it's a DOM element, otherwise fall back to :root so non-DOM targets like three.js meshes and custom adapters still pick up CSS variables defined on the document.
+ *
+ * @param {String} value
+ * @param {Target} target
+ * @return {String|Number}
+ */
+const resolveCssVar = (value, target) => {
+ const match = value.match(cssVariableMatchRgx);
+ const el = target[isDomSymbol] ? target : document.documentElement;
+ let computed = getComputedStyle(/** @type {HTMLElement} */(el))?.getPropertyValue(match[1]);
+ if ((!computed || computed.trim() === emptyString) && match[2]) computed = match[2].trim();
+ return computed || 0;
+};
+
/**
* @param {TweenPropValue} value
* @param {Target} target
@@ -41,30 +57,26 @@ const setValue = (targetValue, defaultValue) => {
* @return {any}
*/
const getFunctionValue = (value, target, index, targets, store, prevTween) => {
- let func;
if (isFnc(value)) {
- func = () => {
+ if (!store) {
+ const computed = /** @type {Function} */(value)(target, index, targets, prevTween);
+ // Fallback to 0 if the function returns undefined, NaN, null, false or 0
+ return !isNaN(+computed) ? +computed : computed || 0;
+ }
+ const func = () => {
const computed = /** @type {Function} */(value)(target, index, targets, prevTween);
- // Fallback to 0 if the function returns undefined / NaN / null / false / 0
return !isNaN(+computed) ? +computed : computed || 0;
};
- } else if (isStr(value) && stringStartsWith(value, cssVarPrefix)) {
- func = () => {
- const match = value.match(cssVariableMatchRgx);
- const cssVarName = match[1];
- const fallbackValue = match[2];
- let computed = getComputedStyle(/** @type {HTMLElement} */(target))?.getPropertyValue(cssVarName);
- // Use fallback if CSS variable is not set or empty
- if ((!computed || computed.trim() === emptyString) && fallbackValue) {
- computed = fallbackValue.trim();
- }
- return computed || 0;
- };
- } else {
- return value;
+ store.func = func;
+ return func();
}
- if (store) store.func = func;
- return func();
+ if (isStr(value) && stringStartsWith(value, cssVarPrefix)) {
+ if (!store) return resolveCssVar(/** @type {String} */(value), target);
+ const func = () => resolveCssVar(/** @type {String} */(value), target);
+ store.func = func;
+ return func();
+ }
+ return value;
};
/**
@@ -111,6 +123,12 @@ const getCSSValue = (target, propName, animationInlineStyles) => {
*/
const getOriginalAnimatableValue = (target, propName, tweenType, animationInlineStyles) => {
const type = !isUnd(tweenType) ? tweenType : getTweenType(target, propName);
+ const adapterProp = resolveAdapterEntry(target, propName);
+ if (adapterProp) {
+ const value = adapterProp.get(target);
+ if (value && animationInlineStyles) animationInlineStyles[propName] = value;
+ return value == null ? 0 : value;
+ }
if (type === tweenTypes.OBJECT) {
const value = target[propName];
if (value && animationInlineStyles) animationInlineStyles[propName] = value;
@@ -152,7 +170,7 @@ const createDecomposedValueTargetObject = () => {
};
/**
- * @param {String|Number} rawValue
+ * @param {String|Number|Object} rawValue
* @param {TweenDecomposedValue} targetObject
* @return {TweenDecomposedValue}
*/
@@ -170,39 +188,38 @@ const decomposeRawValue = (rawValue, targetObject) => {
// It's a number
targetObject.n = num;
return targetObject;
+ }
+ // let str = /** @type {String} */(rawValue).trim();
+ let str = /** @type {String} */(rawValue);
+ // Parsing operators (+=, -=, *=) manually is much faster than using regex here
+ if (str[1] === '=') {
+ targetObject.o = str[0];
+ str = str.slice(2);
+ }
+ // Skip exec regex if the value type is complex or color to avoid long regex backtracking
+ const unitMatch = str.includes(' ') ? false : unitsExecRgx.exec(str);
+ if (unitMatch) {
+ // Has a number and a unit
+ targetObject.t = valueTypes.UNIT;
+ targetObject.n = +unitMatch[1];
+ targetObject.u = unitMatch[2];
+ return targetObject;
+ } else if (targetObject.o) {
+ // Has an operator (+=, -=, *=)
+ targetObject.n = +str;
+ return targetObject;
+ } else if (isCol(str)) {
+ // Color string
+ targetObject.t = valueTypes.COLOR;
+ targetObject.d = convertColorStringValuesToRgbaArray(str);
+ return targetObject;
} else {
- // let str = /** @type {String} */(rawValue).trim();
- let str = /** @type {String} */(rawValue);
- // Parsing operators (+=, -=, *=) manually is much faster than using regex here
- if (str[1] === '=') {
- targetObject.o = str[0];
- str = str.slice(2);
- }
- // Skip exec regex if the value type is complex or color to avoid long regex backtracking
- const unitMatch = str.includes(' ') ? false : unitsExecRgx.exec(str);
- if (unitMatch) {
- // Has a number and a unit
- targetObject.t = valueTypes.UNIT;
- targetObject.n = +unitMatch[1];
- targetObject.u = unitMatch[2];
- return targetObject;
- } else if (targetObject.o) {
- // Has an operator (+=, -=, *=)
- targetObject.n = +str;
- return targetObject;
- } else if (isCol(str)) {
- // Is a color
- targetObject.t = valueTypes.COLOR;
- targetObject.d = convertColorStringValuesToRgbaArray(str);
- return targetObject;
- } else {
- // Is a more complex string (generally svg coords, calc() or filters CSS values)
- const matchedNumbers = str.match(digitWithExponentRgx);
- targetObject.t = valueTypes.COMPLEX;
- targetObject.d = matchedNumbers ? matchedNumbers.map(Number) : [];
- targetObject.s = str.split(digitWithExponentRgx) || [];
- return targetObject;
- }
+ // Is a more complex string (generally svg coords, calc() or filters CSS values)
+ const matchedNumbers = str.match(digitWithExponentRgx);
+ targetObject.t = valueTypes.COMPLEX;
+ targetObject.d = matchedNumbers ? matchedNumbers.map(Number) : [];
+ targetObject.s = str.split(digitWithExponentRgx) || [];
+ return targetObject;
}
};
@@ -223,30 +240,6 @@ const decomposeTweenValue = (tween, targetObject) => {
const decomposedOriginalValue = createDecomposedValueTargetObject();
-/**
- * @param {Tween} tween
- * @param {Number} progress
- * @param {Number} precision
- * @return {String}
- */
-const composeColorValue = (tween, progress, precision) => {
- const mod = tween._modifier;
- const fn = tween._fromNumbers;
- const tn = tween._toNumbers;
- const r = round(clamp(/** @type {Number} */(mod(lerp(fn[0], tn[0], progress))), 0, 255), 0);
- const g = round(clamp(/** @type {Number} */(mod(lerp(fn[1], tn[1], progress))), 0, 255), 0);
- const b = round(clamp(/** @type {Number} */(mod(lerp(fn[2], tn[2], progress))), 0, 255), 0);
- const a = clamp(/** @type {Number} */(mod(round(lerp(fn[3], tn[3], progress), precision))), 0, 1);
- if (tween._composition !== compositionTypes.none) {
- const ns = tween._numbers;
- ns[0] = r;
- ns[1] = g;
- ns[2] = b;
- ns[3] = a;
- }
- return `rgba(${r},${g},${b},${a})`;
-};
-
/**
* @param {Tween} tween
* @param {Number} progress
@@ -258,17 +251,16 @@ const composeComplexValue = (tween, progress, precision) => {
const fn = tween._fromNumbers;
const tn = tween._toNumbers;
const ts = tween._strings;
- const hasComposition = tween._composition !== compositionTypes.none;
let v = ts[0];
for (let j = 0, l = tn.length; j < l; j++) {
const n = /** @type {Number} */(mod(round(lerp(fn[j], tn[j], progress), precision)));
const s = ts[j + 1];
v += `${s ? n + s : n}`;
- if (hasComposition) {
- tween._numbers[j] = n;
- }
+ // Keep _numbers fresh for every tween, not only composed ones, so a non-composition setter that reads the lerped triplet such as three transformOrigin still animates.
+ // Potential optimization, skip the write when nothing reads it: if (hasComposition || tween._setter) tween._numbers[j] = n;
+ tween._numbers[j] = n;
}
return v;
};
-export { composeColorValue, composeComplexValue, createDecomposedValueTargetObject, decomposeRawValue, decomposeTweenValue, decomposedOriginalValue, getFunctionValue, getOriginalAnimatableValue, getRelativeValue, getTweenType, setValue };
+export { composeComplexValue, createDecomposedValueTargetObject, decomposeRawValue, decomposeTweenValue, decomposedOriginalValue, getFunctionValue, getOriginalAnimatableValue, getRelativeValue, getTweenType, setValue };
diff --git a/dist/modules/draggable/draggable.cjs b/dist/modules/draggable/draggable.cjs
index 2b4fa10a..f086a370 100644
--- a/dist/modules/draggable/draggable.cjs
+++ b/dist/modules/draggable/draggable.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - draggable - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/draggable/draggable.js b/dist/modules/draggable/draggable.js
index dea03df4..d2666446 100644
--- a/dist/modules/draggable/draggable.js
+++ b/dist/modules/draggable/draggable.js
@@ -1,6 +1,6 @@
/**
* Anime.js - draggable - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/draggable/index.cjs b/dist/modules/draggable/index.cjs
index 55e03311..2c0c3b1c 100644
--- a/dist/modules/draggable/index.cjs
+++ b/dist/modules/draggable/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - draggable - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/draggable/index.js b/dist/modules/draggable/index.js
index e2abc97e..1698c917 100644
--- a/dist/modules/draggable/index.js
+++ b/dist/modules/draggable/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - draggable - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/cubic-bezier/index.cjs b/dist/modules/easings/cubic-bezier/index.cjs
index a3c764b9..813c2565 100644
--- a/dist/modules/easings/cubic-bezier/index.cjs
+++ b/dist/modules/easings/cubic-bezier/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/cubic-bezier/index.js b/dist/modules/easings/cubic-bezier/index.js
index 97302b7c..836684c2 100644
--- a/dist/modules/easings/cubic-bezier/index.js
+++ b/dist/modules/easings/cubic-bezier/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/eases/index.cjs b/dist/modules/easings/eases/index.cjs
index 8d97ef14..9e1a11fe 100644
--- a/dist/modules/easings/eases/index.cjs
+++ b/dist/modules/easings/eases/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/eases/index.js b/dist/modules/easings/eases/index.js
index 350ec226..0419f2a6 100644
--- a/dist/modules/easings/eases/index.js
+++ b/dist/modules/easings/eases/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/eases/parser.cjs b/dist/modules/easings/eases/parser.cjs
index 5e6ec605..15b67240 100644
--- a/dist/modules/easings/eases/parser.cjs
+++ b/dist/modules/easings/eases/parser.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -81,8 +81,8 @@ const easeInFunctions = {
/**
* @typedef {Object} EasesFunctions
- * @property {typeof none} linear
- * @property {typeof none} none
+ * @property {EasingFunction} linear
+ * @property {EasingFunction} none
* @property {PowerEasing} in
* @property {PowerEasing} out
* @property {PowerEasing} inOut
diff --git a/dist/modules/easings/eases/parser.d.ts b/dist/modules/easings/eases/parser.d.ts
index de449643..7470f4a8 100644
--- a/dist/modules/easings/eases/parser.d.ts
+++ b/dist/modules/easings/eases/parser.d.ts
@@ -18,8 +18,8 @@ export const easeInPower: PowerEasing;
/** @type {Record<String, EaseType>} */
export const easeTypes: Record<string, EaseType>;
export namespace eases {
- export let linear: typeof import("../none.js").none;
- export let none: typeof import("../none.js").none;
+ export let linear: EasingFunction;
+ export let none: EasingFunction;
let _in: PowerEasing;
export { _in as in };
export let out: PowerEasing;
@@ -70,8 +70,8 @@ export function parseEaseString(string: string): EasingFunction;
export function parseEase(ease: EasingParam): EasingFunction;
export type EaseType = (Ease: EasingFunction) => EasingFunction;
export type EasesFunctions = {
- linear: typeof none;
- none: typeof none;
+ linear: EasingFunction;
+ none: EasingFunction;
in: PowerEasing;
out: PowerEasing;
inOut: PowerEasing;
@@ -122,4 +122,3 @@ import type { EasingFunction } from '../../types/index.js';
import type { BackEasing } from '../../types/index.js';
import type { ElasticEasing } from '../../types/index.js';
import type { EasingParam } from '../../types/index.js';
-import { none as none_1 } from '../none.js';
diff --git a/dist/modules/easings/eases/parser.js b/dist/modules/easings/eases/parser.js
index 4392b5dc..1e3cb1fe 100644
--- a/dist/modules/easings/eases/parser.js
+++ b/dist/modules/easings/eases/parser.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -79,8 +79,8 @@ const easeInFunctions = {
/**
* @typedef {Object} EasesFunctions
- * @property {typeof none} linear
- * @property {typeof none} none
+ * @property {EasingFunction} linear
+ * @property {EasingFunction} none
* @property {PowerEasing} in
* @property {PowerEasing} out
* @property {PowerEasing} inOut
diff --git a/dist/modules/easings/index.cjs b/dist/modules/easings/index.cjs
index 0e355d91..e175073b 100644
--- a/dist/modules/easings/index.cjs
+++ b/dist/modules/easings/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/index.js b/dist/modules/easings/index.js
index dcaf566e..85a6ff8c 100644
--- a/dist/modules/easings/index.js
+++ b/dist/modules/easings/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/irregular/index.cjs b/dist/modules/easings/irregular/index.cjs
index a61f9a4c..bb788456 100644
--- a/dist/modules/easings/irregular/index.cjs
+++ b/dist/modules/easings/irregular/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/irregular/index.js b/dist/modules/easings/irregular/index.js
index e712ef1c..e703a23a 100644
--- a/dist/modules/easings/irregular/index.js
+++ b/dist/modules/easings/irregular/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/linear/index.cjs b/dist/modules/easings/linear/index.cjs
index 27e21708..e75ecda3 100644
--- a/dist/modules/easings/linear/index.cjs
+++ b/dist/modules/easings/linear/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/linear/index.js b/dist/modules/easings/linear/index.js
index 5ffb36a0..a76e5374 100644
--- a/dist/modules/easings/linear/index.js
+++ b/dist/modules/easings/linear/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/none.cjs b/dist/modules/easings/none.cjs
index ed29c207..030ce805 100644
--- a/dist/modules/easings/none.cjs
+++ b/dist/modules/easings/none.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/none.js b/dist/modules/easings/none.js
index 4267710c..0c31701f 100644
--- a/dist/modules/easings/none.js
+++ b/dist/modules/easings/none.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/spring/index.cjs b/dist/modules/easings/spring/index.cjs
index e8583149..1e96665e 100644
--- a/dist/modules/easings/spring/index.cjs
+++ b/dist/modules/easings/spring/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/spring/index.js b/dist/modules/easings/spring/index.js
index e4616dc5..0f8221ba 100644
--- a/dist/modules/easings/spring/index.js
+++ b/dist/modules/easings/spring/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/steps/index.cjs b/dist/modules/easings/steps/index.cjs
index 2c2a75d8..cc4497f2 100644
--- a/dist/modules/easings/steps/index.cjs
+++ b/dist/modules/easings/steps/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/easings/steps/index.js b/dist/modules/easings/steps/index.js
index 069171a6..e9ad0d6e 100644
--- a/dist/modules/easings/steps/index.js
+++ b/dist/modules/easings/steps/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/engine/engine.cjs b/dist/modules/engine/engine.cjs
index 7f26b1f5..1ebb4ef3 100644
--- a/dist/modules/engine/engine.cjs
+++ b/dist/modules/engine/engine.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - engine - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -103,7 +103,9 @@ class Engine extends clock.Clock {
}
set speed(playbackRate) {
- this._speed = playbackRate * globals.globals.timeScale;
+ const speed = playbackRate * globals.globals.timeScale;
+ if (this._speed === speed) return;
+ this._speed = speed;
helpers.forEachChildren(this, (/** @type {Tickable} */child) => child.speed = child._speed);
}
diff --git a/dist/modules/engine/engine.js b/dist/modules/engine/engine.js
index 746c3d3e..fb349497 100644
--- a/dist/modules/engine/engine.js
+++ b/dist/modules/engine/engine.js
@@ -1,6 +1,6 @@
/**
* Anime.js - engine - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -101,7 +101,9 @@ class Engine extends Clock {
}
set speed(playbackRate) {
- this._speed = playbackRate * globals.timeScale;
+ const speed = playbackRate * globals.timeScale;
+ if (this._speed === speed) return;
+ this._speed = speed;
forEachChildren(this, (/** @type {Tickable} */child) => child.speed = child._speed);
}
diff --git a/dist/modules/engine/index.cjs b/dist/modules/engine/index.cjs
index 4c5d89af..41461511 100644
--- a/dist/modules/engine/index.cjs
+++ b/dist/modules/engine/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - engine - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/engine/index.js b/dist/modules/engine/index.js
index ad2a5a45..0a96eb91 100644
--- a/dist/modules/engine/index.js
+++ b/dist/modules/engine/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - engine - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/events/index.cjs b/dist/modules/events/index.cjs
index fc83b391..df87558e 100644
--- a/dist/modules/events/index.cjs
+++ b/dist/modules/events/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - events - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/events/index.js b/dist/modules/events/index.js
index b365ab29..c5b0999e 100644
--- a/dist/modules/events/index.js
+++ b/dist/modules/events/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - events - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/events/scroll.cjs b/dist/modules/events/scroll.cjs
index 3ffa59a5..176a0708 100644
--- a/dist/modules/events/scroll.cjs
+++ b/dist/modules/events/scroll.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - events - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -216,12 +216,14 @@ class ScrollContainer {
refreshScrollObservers() {
helpers.forEachChildren(this, (/** @type {ScrollObserver} */child) => {
+ if (!child.ready) return;
if (child._debug) {
child.removeDebug();
}
});
this.updateBounds();
helpers.forEachChildren(this, (/** @type {ScrollObserver} */child) => {
+ if (!child.ready) return;
child.refresh();
child.onResize(child);
if (child._debug) {
diff --git a/dist/modules/events/scroll.js b/dist/modules/events/scroll.js
index 88c29427..20996d55 100644
--- a/dist/modules/events/scroll.js
+++ b/dist/modules/events/scroll.js
@@ -1,6 +1,6 @@
/**
* Anime.js - events - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -214,12 +214,14 @@ class ScrollContainer {
refreshScrollObservers() {
forEachChildren(this, (/** @type {ScrollObserver} */child) => {
+ if (!child.ready) return;
if (child._debug) {
child.removeDebug();
}
});
this.updateBounds();
forEachChildren(this, (/** @type {ScrollObserver} */child) => {
+ if (!child.ready) return;
child.refresh();
child.onResize(child);
if (child._debug) {
diff --git a/dist/modules/index.cjs b/dist/modules/index.cjs
index ace7cd33..d7e21551 100644
--- a/dist/modules/index.cjs
+++ b/dist/modules/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/index.js b/dist/modules/index.js
index 1debd2fb..3f705725 100644
--- a/dist/modules/index.js
+++ b/dist/modules/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/layout/index.cjs b/dist/modules/layout/index.cjs
index 73cee66f..ee05fe02 100644
--- a/dist/modules/layout/index.cjs
+++ b/dist/modules/layout/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - layout - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/layout/index.js b/dist/modules/layout/index.js
index c7402a11..755d2929 100644
--- a/dist/modules/layout/index.js
+++ b/dist/modules/layout/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - layout - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/layout/layout.cjs b/dist/modules/layout/layout.cjs
index 671fe78d..e15a3d0f 100644
--- a/dist/modules/layout/layout.cjs
+++ b/dist/modules/layout/layout.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - layout - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/layout/layout.js b/dist/modules/layout/layout.js
index b6336c4b..832a637f 100644
--- a/dist/modules/layout/layout.js
+++ b/dist/modules/layout/layout.js
@@ -1,6 +1,6 @@
/**
* Anime.js - layout - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/scope/index.cjs b/dist/modules/scope/index.cjs
index 938faf7b..5e2f692e 100644
--- a/dist/modules/scope/index.cjs
+++ b/dist/modules/scope/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - scope - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/scope/index.js b/dist/modules/scope/index.js
index ee31220d..60acf0da 100644
--- a/dist/modules/scope/index.js
+++ b/dist/modules/scope/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - scope - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/scope/scope.cjs b/dist/modules/scope/scope.cjs
index 9a6ed9d8..330c2faa 100644
--- a/dist/modules/scope/scope.cjs
+++ b/dist/modules/scope/scope.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - scope - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/scope/scope.js b/dist/modules/scope/scope.js
index 86f80e1e..b30d0eaa 100644
--- a/dist/modules/scope/scope.js
+++ b/dist/modules/scope/scope.js
@@ -1,6 +1,6 @@
/**
* Anime.js - scope - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/svg/drawable.cjs b/dist/modules/svg/drawable.cjs
index 59e8977d..f1decf7f 100644
--- a/dist/modules/svg/drawable.cjs
+++ b/dist/modules/svg/drawable.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/svg/drawable.js b/dist/modules/svg/drawable.js
index 5ce0328d..3b00d6c8 100644
--- a/dist/modules/svg/drawable.js
+++ b/dist/modules/svg/drawable.js
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/svg/helpers.cjs b/dist/modules/svg/helpers.cjs
index f796306c..d021405e 100644
--- a/dist/modules/svg/helpers.cjs
+++ b/dist/modules/svg/helpers.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/svg/helpers.js b/dist/modules/svg/helpers.js
index a1bce9ef..5b199bc3 100644
--- a/dist/modules/svg/helpers.js
+++ b/dist/modules/svg/helpers.js
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/svg/index.cjs b/dist/modules/svg/index.cjs
index a5f6fb79..92fc707a 100644
--- a/dist/modules/svg/index.cjs
+++ b/dist/modules/svg/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/svg/index.js b/dist/modules/svg/index.js
index 54bb90fb..46a1bf3f 100644
--- a/dist/modules/svg/index.js
+++ b/dist/modules/svg/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/svg/morphto.cjs b/dist/modules/svg/morphto.cjs
index 2a4c3f3d..b0d0fb0a 100644
--- a/dist/modules/svg/morphto.cjs
+++ b/dist/modules/svg/morphto.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/svg/morphto.js b/dist/modules/svg/morphto.js
index 8482a381..f0e613dc 100644
--- a/dist/modules/svg/morphto.js
+++ b/dist/modules/svg/morphto.js
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/svg/motionpath.cjs b/dist/modules/svg/motionpath.cjs
index b97afb01..b23a4a0f 100644
--- a/dist/modules/svg/motionpath.cjs
+++ b/dist/modules/svg/motionpath.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/svg/motionpath.js b/dist/modules/svg/motionpath.js
index 81eb6747..da5a6a9f 100644
--- a/dist/modules/svg/motionpath.js
+++ b/dist/modules/svg/motionpath.js
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/text/index.cjs b/dist/modules/text/index.cjs
index 2cd15534..159e680f 100644
--- a/dist/modules/text/index.cjs
+++ b/dist/modules/text/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - text - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/text/index.js b/dist/modules/text/index.js
index 08cbcb84..dd5edcc6 100644
--- a/dist/modules/text/index.js
+++ b/dist/modules/text/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - text - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/text/scramble.cjs b/dist/modules/text/scramble.cjs
index 21c76a56..82e39d9e 100644
--- a/dist/modules/text/scramble.cjs
+++ b/dist/modules/text/scramble.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - text - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -20,6 +20,16 @@ var consts = require('../core/consts.cjs');
* } from '../types/index.js'
*/
+/**
+ * @typedef {Object} ScrambleTextTween
+ * @property {Number} from
+ * @property {Number} to
+ * @property {Number} duration
+ * @property {Number} delay
+ * @property {String} ease
+ * @property {(v: Number) => String} modifier
+ */
+
/**
* '-' is the range operator; place it at the start or end of the string to use it as a literal (e.g. '-abc' or 'abc-')
* @param {String} str
@@ -57,7 +67,7 @@ const originalTexts = new WeakMap();
* progressively revealing the original text.
*
* @param {ScrambleTextParams} [params]
- * @return {FunctionValue}
+ * @return {FunctionValue<ScrambleTextTween>}
*/
const scrambleText = (params = {}) => {
if (!params) params = {};
diff --git a/dist/modules/text/scramble.d.ts b/dist/modules/text/scramble.d.ts
index 4c48f8e1..e9fee042 100644
--- a/dist/modules/text/scramble.d.ts
+++ b/dist/modules/text/scramble.d.ts
@@ -1,3 +1,11 @@
-export function scrambleText(params?: ScrambleTextParams): FunctionValue;
+export function scrambleText(params?: ScrambleTextParams): FunctionValue<ScrambleTextTween>;
+export type ScrambleTextTween = {
+ from: number;
+ to: number;
+ duration: number;
+ delay: number;
+ ease: string;
+ modifier: (v: number) => string;
+};
import type { ScrambleTextParams } from '../types/index.js';
import type { FunctionValue } from '../types/index.js';
diff --git a/dist/modules/text/scramble.js b/dist/modules/text/scramble.js
index 86ec9fbc..92ff18a5 100644
--- a/dist/modules/text/scramble.js
+++ b/dist/modules/text/scramble.js
@@ -1,6 +1,6 @@
/**
* Anime.js - text - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -18,6 +18,16 @@ import { noop } from '../core/consts.js';
* } from '../types/index.js'
*/
+/**
+ * @typedef {Object} ScrambleTextTween
+ * @property {Number} from
+ * @property {Number} to
+ * @property {Number} duration
+ * @property {Number} delay
+ * @property {String} ease
+ * @property {(v: Number) => String} modifier
+ */
+
/**
* '-' is the range operator; place it at the start or end of the string to use it as a literal (e.g. '-abc' or 'abc-')
* @param {String} str
@@ -55,7 +65,7 @@ const originalTexts = new WeakMap();
* progressively revealing the original text.
*
* @param {ScrambleTextParams} [params]
- * @return {FunctionValue}
+ * @return {FunctionValue<ScrambleTextTween>}
*/
const scrambleText = (params = {}) => {
if (!params) params = {};
diff --git a/dist/modules/text/split.cjs b/dist/modules/text/split.cjs
index 3b36f3b3..9e888522 100644
--- a/dist/modules/text/split.cjs
+++ b/dist/modules/text/split.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - text - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -118,6 +118,7 @@ const filterLineElements = ($el, lineIndex, bin) => {
*/
const generateTemplate = (type, params = {}) => {
let template = ``;
+ if (!params) params = {};
const classString = helpers.isStr(params.class) ? ` class="${params.class}"` : '';
const cloneType = values.setValue(params.clone, false);
const wrapType = values.setValue(params.wrap, false);
diff --git a/dist/modules/text/split.js b/dist/modules/text/split.js
index 9c72a3d3..1263635d 100644
--- a/dist/modules/text/split.js
+++ b/dist/modules/text/split.js
@@ -1,6 +1,6 @@
/**
* Anime.js - text - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -116,6 +116,7 @@ const filterLineElements = ($el, lineIndex, bin) => {
*/
const generateTemplate = (type, params = {}) => {
let template = ``;
+ if (!params) params = {};
const classString = isStr(params.class) ? ` class="${params.class}"` : '';
const cloneType = setValue(params.clone, false);
const wrapType = setValue(params.wrap, false);
diff --git a/dist/modules/timeline/index.cjs b/dist/modules/timeline/index.cjs
index 147fa282..9a287bc0 100644
--- a/dist/modules/timeline/index.cjs
+++ b/dist/modules/timeline/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - timeline - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/timeline/index.js b/dist/modules/timeline/index.js
index 88f38382..c8979f66 100644
--- a/dist/modules/timeline/index.js
+++ b/dist/modules/timeline/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - timeline - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/timeline/position.cjs b/dist/modules/timeline/position.cjs
index ba5e3578..e8112bac 100644
--- a/dist/modules/timeline/position.cjs
+++ b/dist/modules/timeline/position.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - timeline - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/timeline/position.js b/dist/modules/timeline/position.js
index 67c827ad..41a5f865 100644
--- a/dist/modules/timeline/position.js
+++ b/dist/modules/timeline/position.js
@@ -1,6 +1,6 @@
/**
* Anime.js - timeline - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/timeline/timeline.cjs b/dist/modules/timeline/timeline.cjs
index c595babb..bac7358e 100644
--- a/dist/modules/timeline/timeline.cjs
+++ b/dist/modules/timeline/timeline.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - timeline - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -34,6 +34,7 @@ var position = require('./position.cjs');
* TimelinePosition,
* StaggerFunction,
* TargetsArray,
+ * TweakRegister,
* } from '../types/index.js'
*/
@@ -43,8 +44,6 @@ var position = require('./position.cjs');
* } from '../waapi/waapi.js'
*/
-/** @import {TweakRegister} from 'tweaks' */
-
/**
* @param {Timeline} tl
* @return {Number}
@@ -237,13 +236,21 @@ class Timeline extends timer.Timer {
if (!helpers.isUnd(synced) && !helpers.isUnd(/** @type {WAAPIAnimation} */(synced).persist)) {
/** @type {WAAPIAnimation} */(synced).persist = true;
}
- return this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
+ const editor = globals.globals.editor;
+ const childHook = editor && editor.addTimelineChild;
+ if (editor && editor.addTimelineSync) {
+ position = editor.addTimelineSync(synced, position, this.id);
+ editor.addTimelineChild = null; // Suppress the per-child hook for the internal .add, sync already registered.
+ }
+ const result = this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
+ if (editor) editor.addTimelineChild = childHook;
+ return result;
}
/**
* @param {TargetsParam} targets
* @param {AnimationParams} parameters
- * @param {TimelinePosition} [position]
+ * @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [position]
* @return {this}
*/
set(targets, parameters, position) {
@@ -260,6 +267,7 @@ class Timeline extends timer.Timer {
*/
call(callback, position) {
if (helpers.isUnd(callback) || callback && !helpers.isFnc(callback)) return this;
+ if (globals.globals.editor && globals.globals.editor.addTimelineCall) position = globals.globals.editor.addTimelineCall(callback, position, this.id);
return this.add({ duration: 0, delay: 0, onComplete: () => callback(this) }, position);
}
@@ -271,6 +279,7 @@ class Timeline extends timer.Timer {
*/
label(labelName, position$1) {
if (helpers.isUnd(labelName) || labelName && !helpers.isStr(labelName)) return this;
+ if (globals.globals.editor && globals.globals.editor.addTimelineLabel) position$1 = globals.globals.editor.addTimelineLabel(labelName, position$1, this.id);
this.labels[labelName] = position.parseTimelinePosition(this, position$1);
return this;
}
diff --git a/dist/modules/timeline/timeline.d.ts b/dist/modules/timeline/timeline.d.ts
index 774fd079..26d5080e 100644
--- a/dist/modules/timeline/timeline.d.ts
+++ b/dist/modules/timeline/timeline.d.ts
@@ -109,10 +109,10 @@ export class Timeline extends Timer {
/**
* @param {TargetsParam} targets
* @param {AnimationParams} parameters
- * @param {TimelinePosition} [position]
+ * @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [position]
* @return {this}
*/
- set(targets: TargetsParam, parameters: AnimationParams, position?: TimelinePosition): this;
+ set(targets: TargetsParam, parameters: AnimationParams, position?: TimelinePosition | StaggerFunction<number | string> | TweakRegister): this;
/**
* @param {Callback<Timer>} callback
* @param {TimelinePosition} [position]
@@ -164,7 +164,7 @@ import type { TargetsParam } from '../types/index.js';
import type { AnimationParams } from '../types/index.js';
import type { TimelinePosition } from '../types/index.js';
import type { StaggerFunction } from '../types/index.js';
-import type { TweakRegister } from 'tweaks';
+import type { TweakRegister } from '../types/index.js';
import type { TimerParams } from '../types/index.js';
import type { Tickable } from '../types/index.js';
import type { WAAPIAnimation } from '../waapi/waapi.js';
diff --git a/dist/modules/timeline/timeline.js b/dist/modules/timeline/timeline.js
index 42a38ef4..ebe9f5ae 100644
--- a/dist/modules/timeline/timeline.js
+++ b/dist/modules/timeline/timeline.js
@@ -1,6 +1,6 @@
/**
* Anime.js - timeline - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -32,6 +32,7 @@ import { parseTimelinePosition } from './position.js';
* TimelinePosition,
* StaggerFunction,
* TargetsArray,
+ * TweakRegister,
* } from '../types/index.js'
*/
@@ -41,8 +42,6 @@ import { parseTimelinePosition } from './position.js';
* } from '../waapi/waapi.js'
*/
-/** @import {TweakRegister} from 'tweaks' */
-
/**
* @param {Timeline} tl
* @return {Number}
@@ -235,13 +234,21 @@ class Timeline extends Timer {
if (!isUnd(synced) && !isUnd(/** @type {WAAPIAnimation} */(synced).persist)) {
/** @type {WAAPIAnimation} */(synced).persist = true;
}
- return this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
+ const editor = globals.editor;
+ const childHook = editor && editor.addTimelineChild;
+ if (editor && editor.addTimelineSync) {
+ position = editor.addTimelineSync(synced, position, this.id);
+ editor.addTimelineChild = null; // Suppress the per-child hook for the internal .add, sync already registered.
+ }
+ const result = this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
+ if (editor) editor.addTimelineChild = childHook;
+ return result;
}
/**
* @param {TargetsParam} targets
* @param {AnimationParams} parameters
- * @param {TimelinePosition} [position]
+ * @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [position]
* @return {this}
*/
set(targets, parameters, position) {
@@ -258,6 +265,7 @@ class Timeline extends Timer {
*/
call(callback, position) {
if (isUnd(callback) || callback && !isFnc(callback)) return this;
+ if (globals.editor && globals.editor.addTimelineCall) position = globals.editor.addTimelineCall(callback, position, this.id);
return this.add({ duration: 0, delay: 0, onComplete: () => callback(this) }, position);
}
@@ -269,6 +277,7 @@ class Timeline extends Timer {
*/
label(labelName, position) {
if (isUnd(labelName) || labelName && !isStr(labelName)) return this;
+ if (globals.editor && globals.editor.addTimelineLabel) position = globals.editor.addTimelineLabel(labelName, position, this.id);
this.labels[labelName] = parseTimelinePosition(this, position);
return this;
}
diff --git a/dist/modules/timer/index.cjs b/dist/modules/timer/index.cjs
index d1ed2d05..b0d25df2 100644
--- a/dist/modules/timer/index.cjs
+++ b/dist/modules/timer/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - timer - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/timer/index.js b/dist/modules/timer/index.js
index 09ce2cb8..c768c332 100644
--- a/dist/modules/timer/index.js
+++ b/dist/modules/timer/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - timer - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/timer/timer.cjs b/dist/modules/timer/timer.cjs
index f9b433b4..ba53f859 100644
--- a/dist/modules/timer/timer.cjs
+++ b/dist/modules/timer/timer.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - timer - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/timer/timer.js b/dist/modules/timer/timer.js
index 4d2ac69c..d5f4c151 100644
--- a/dist/modules/timer/timer.js
+++ b/dist/modules/timer/timer.js
@@ -1,6 +1,6 @@
/**
* Anime.js - timer - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/types/index.d.ts b/dist/modules/types/index.d.ts
index 93f20de5..bc838b82 100644
--- a/dist/modules/types/index.d.ts
+++ b/dist/modules/types/index.d.ts
@@ -27,17 +27,36 @@ export type Renderable = JSAnimation | Timeline;
export type Tickable = Timer | Renderable;
export type CallbackArgument = Timer & JSAnimation & Timeline;
export type Revertible = Animatable | Tickable | WAAPIAnimation | Draggable | ScrollObserver | TextSplitter | Scope | AutoLayout;
+export type TweakRegister = {
+ type: string;
+ defaultValue: any;
+};
export type StaggerFunction<T> = (target?: Target, index?: number, targets?: TargetsArray, prevTween?: Tween | null, tl?: Timeline) => T;
export type StaggerParams = {
start?: number | string;
from?: number | "first" | "center" | "last" | "random" | Array<number>;
reversed?: boolean;
grid?: Array<number> | boolean;
- axis?: ("x" | "y");
- use?: string | ((target: Target, i: number, length: number) => number);
+ axis?: ("x" | "y" | "z");
+ use?: string | {
+ method(target: Target, i: number, length: number): number;
+ }["method"];
total?: number;
ease?: EasingParam;
modifier?: TweenModifier;
+ /**
+ * Additive uniform noise on the
+ * computed stagger value. Number form gives flat `+/-jitter`; tuple form
+ * ramps the magnitude `start -> end` across the from/axis/grid ordering
+ * and respects `ease`.
+ */
+ jitter?: number | [number, number];
+ /**
+ * Seed for jitter draws and `from: 'random'`
+ * shuffling. `false` (default) uses Math.random. `true` seeds with `0`. A
+ * number is used directly as the seed.
+ */
+ seed?: boolean | number;
};
export type DOMTarget = HTMLElement | SVGElement;
export type JSTarget = Record<string, any>;
@@ -89,7 +108,9 @@ export type SpringParams = {
*/
onComplete?: Callback<JSAnimation>;
};
-export type Callback<T> = (self: T, e?: PointerEvent) => any;
+export type Callback<T> = {
+ method(self: T): any;
+}["method"];
export type TickableCallbacks<T extends unknown> = {
onBegin?: Callback<T>;
onBeforeUpdate?: Callback<T>;
@@ -115,7 +136,8 @@ export type TimerOptions = {
priority?: number;
};
export type TimerParams = TimerOptions & TickableCallbacks<Timer>;
-export type FunctionValue = (target?: Target, index?: number, targets?: TargetsArray, prevTween?: Tween | null) => number | string | TweenObjectValue | EasingParam | Array<number | string | TweenObjectValue>;
+export type FunctionValueReturn = number | string | TweenKeyValue | EasingParam | Array<number | string | TweenKeyValue>;
+export type FunctionValue<T = FunctionValueReturn> = (target?: Target, index?: number, targets?: TargetsArray, prevTween?: Tween | null) => T;
export type TweenModifier = (value: number) => number | string;
export type ColorArray = [number, number, number, number];
export type Tween = {
@@ -123,7 +145,7 @@ export type Tween = {
parent: JSAnimation;
property: string;
target: Target;
- _value: string | number;
+ _value: string | number | any;
_toFunc: Function | null;
_fromFunc: Function | null;
_ease: EasingFunction;
@@ -142,7 +164,11 @@ export type Tween = {
_startTime: number;
_changeDuration: number;
_absoluteStartTime: number;
+ _absoluteUpdateStartTime: number;
+ _absoluteEndTime: number;
+ _hasFromValue: number;
_tweenType: tweenTypes;
+ _setter: ((target: any, value: number, tween: Tween) => void) | null;
_valueType: valueTypes;
_composition: number;
_isOverlapped: number;
@@ -174,11 +200,11 @@ export type TweenDecomposedValue = {
*/
o: string;
/**
- * - Array of Numbers (in case of complex value type)
+ * - Array of Numbers (complex / color value type)
*/
d: Array<number>;
/**
- * - Strings (in case of complex value type)
+ * - Strings (complex value type)
*/
s: Array<string>;
};
@@ -189,7 +215,7 @@ export type TweenPropertySiblings = {
export type TweenLookups = Record<string, TweenPropertySiblings>;
export type TweenReplaceLookups = WeakMap<Target, TweenLookups>;
export type TweenAdditiveLookups = Map<Target, TweenLookups>;
-export type TweenParamValue = number | string | FunctionValue | EasingParam;
+export type TweenParamValue = number | string | FunctionValue | EasingParam | TweakRegister;
export type TweenPropValue = TweenParamValue | [TweenParamValue, TweenParamValue];
export type TweenComposition = (string & {}) | "none" | "replace" | "blend" | compositionTypes;
export type TweenParamsOptions = {
@@ -290,7 +316,7 @@ export type AnimatablePropertyParamsOptions = {
modifier?: TweenModifier;
composition?: TweenComposition;
};
-export type AnimatableParams = Record<string, TweenParamValue | EasingParam | TweenModifier | TweenComposition | AnimatablePropertyParamsOptions> & AnimatablePropertyParamsOptions;
+export type AnimatableParams = Record<string, TweenParamValue | EasingParam | TweenModifier | TweenComposition | AnimatablePropertyParamsOptions | Callback<JSAnimation>> & AnimatablePropertyParamsOptions & TickableCallbacks<JSAnimation> & RenderableCallbacks<JSAnimation>;
export type ReactRef = {
current?: HTMLElement | SVGElement | null;
};
@@ -305,7 +331,7 @@ export type ScopeParams = {
export type ScopedCallback<T> = (scope: Scope) => T;
export type ScopeCleanupCallback = (scope?: Scope) => any;
export type ScopeConstructorCallback = (scope?: Scope) => ScopeCleanupCallback | void;
-export type ScopeMethod = (...args: any[]) => ScopeCleanupCallback | void;
+export type ScopeMethod = (...args: any[]) => any;
export type ScrollThresholdValue = string | number;
export type ScrollThresholdParam = {
target?: ScrollThresholdValue;
@@ -475,6 +501,5 @@ import type { TextSplitter } from '../text/split.js';
import type { Scope } from '../scope/scope.js';
import type { AutoLayout } from '../layout/layout.js';
import type { Spring } from '../easings/spring/index.js';
-import type { TweakRegister } from 'tweaks';
import type { tweenTypes } from '../core/consts.js';
import type { valueTypes } from '../core/consts.js';
diff --git a/dist/modules/utils/chainable.cjs b/dist/modules/utils/chainable.cjs
index e79d895d..1a4097a4 100644
--- a/dist/modules/utils/chainable.cjs
+++ b/dist/modules/utils/chainable.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/utils/chainable.js b/dist/modules/utils/chainable.js
index e54843ac..a375bb8b 100644
--- a/dist/modules/utils/chainable.js
+++ b/dist/modules/utils/chainable.js
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/utils/index.cjs b/dist/modules/utils/index.cjs
index 85a9f54a..1d945c22 100644
--- a/dist/modules/utils/index.cjs
+++ b/dist/modules/utils/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/utils/index.js b/dist/modules/utils/index.js
index f686d3bc..12bc5596 100644
--- a/dist/modules/utils/index.js
+++ b/dist/modules/utils/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/utils/number.cjs b/dist/modules/utils/number.cjs
index 67b30e52..dc845b8f 100644
--- a/dist/modules/utils/number.cjs
+++ b/dist/modules/utils/number.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/utils/number.js b/dist/modules/utils/number.js
index 3f392565..da44d4f0 100644
--- a/dist/modules/utils/number.js
+++ b/dist/modules/utils/number.js
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/utils/random.cjs b/dist/modules/utils/random.cjs
index 86d215fe..e760cfda 100644
--- a/dist/modules/utils/random.cjs
+++ b/dist/modules/utils/random.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -63,11 +63,12 @@ const randomPick = items => items[random(0, items.length - 1)];
* Adapted from https://bost.ocks.org/mike/shuffle/
*
* @param {Array} items - The array to shuffle (will be modified in-place)
+ * @param {RandomNumberGenerator} [rnd] - Optional RNG matching the random() signature (defaults to random)
* @return {Array} The same array reference, now shuffled
*/
-const shuffle = items => {
+const shuffle = (items, rnd = random) => {
let m = items.length, t, i;
- while (m) { i = random(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
+ while (m) { i = rnd(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
return items;
};
diff --git a/dist/modules/utils/random.d.ts b/dist/modules/utils/random.d.ts
index 813a5844..c5f70252 100644
--- a/dist/modules/utils/random.d.ts
+++ b/dist/modules/utils/random.d.ts
@@ -15,7 +15,7 @@
export const random: RandomNumberGenerator;
export function createSeededRandom(seed?: number, seededMin?: number, seededMax?: number, seededDecimalLength?: number): RandomNumberGenerator;
export function randomPick<T>(items: string | Array<T>): string | T;
-export function shuffle(items: any[]): any[];
+export function shuffle(items: any[], rnd?: RandomNumberGenerator): any[];
/**
* Generate a random number between optional min and max (inclusive) and decimal precision
*/
diff --git a/dist/modules/utils/random.js b/dist/modules/utils/random.js
index fc973556..734cc0b7 100644
--- a/dist/modules/utils/random.js
+++ b/dist/modules/utils/random.js
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -61,11 +61,12 @@ const randomPick = items => items[random(0, items.length - 1)];
* Adapted from https://bost.ocks.org/mike/shuffle/
*
* @param {Array} items - The array to shuffle (will be modified in-place)
+ * @param {RandomNumberGenerator} [rnd] - Optional RNG matching the random() signature (defaults to random)
* @return {Array} The same array reference, now shuffled
*/
-const shuffle = items => {
+const shuffle = (items, rnd = random) => {
let m = items.length, t, i;
- while (m) { i = random(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
+ while (m) { i = rnd(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
return items;
};
diff --git a/dist/modules/utils/stagger.cjs b/dist/modules/utils/stagger.cjs
index d44ee191..0e0782a9 100644
--- a/dist/modules/utils/stagger.cjs
+++ b/dist/modules/utils/stagger.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -66,6 +66,7 @@ const stagger = (val, params = {}) => {
let values$1 = [];
let maxValue = 0;
let cachedOffset;
+ let jitterSamples = null;
const from = params.from;
const reversed = params.reversed;
const ease = params.ease;
@@ -87,27 +88,42 @@ const stagger = (val, params = {}) => {
const val2 = isRange ? helpers.parseNumber(val[1]) : 0;
const unitMatch = consts.unitsExecRgx.exec((isRange ? val[1] : val) + consts.emptyString);
const start = params.start || 0 + (isRange ? val1 : 0);
+ const seed = params.seed;
+ const hasSeed = !helpers.isUnd(seed) && seed !== false;
+ const rng = hasSeed ? random.createSeededRandom(seed === true ? 0 : /** @type {Number} */(seed)) : random.random;
+ const jitter = params.jitter;
+ const hasJitter = !helpers.isUnd(jitter);
+ const jitterIsArr = helpers.isArr(jitter);
+ const jitterStart = jitterIsArr ? /** @type {[Number,Number]} */(jitter)[0] : /** @type {Number} */(jitter) || 0;
+ const jitterEnd = jitterIsArr ? /** @type {[Number,Number]} */(jitter)[1] : /** @type {Number} */(jitter) || 0;
let fromIndex = fromFirst ? 0 : helpers.isNum(from) ? from : 0;
return (target, i, t, _, tl) => {
const [ registeredTarget ] = targets.registerTargets(target);
const total = helpers.isUnd(customTotal) ? t.length : customTotal;
const customIndex = !helpers.isUnd(useProp) ? helpers.isFnc(useProp) ? useProp(registeredTarget, i, total) : values.getOriginalAnimatableValue(registeredTarget, useProp) : false;
- const staggerIndex = helpers.isNum(customIndex) || helpers.isStr(customIndex) && helpers.isNum(+customIndex) ? +customIndex : i;
+ const customIdx = helpers.isNum(customIndex) || helpers.isStr(customIndex) && helpers.isNum(+customIndex) ? +customIndex : i;
+ // Fall back to the natural index when the resolved value lands outside [0, total) so values[staggerIndex] never reads undefined.
+ const staggerIndex = customIdx >= 0 && customIdx < total ? customIdx : i;
if (fromCenter) fromIndex = (total - 1) / 2;
if (fromLast) fromIndex = total - 1;
if (!values$1.length) {
if (autoGrid) {
let hasPositions = true;
+ let has3D = false;
let minPosX = Infinity;
let minPosY = Infinity;
+ let minPosZ = Infinity;
let maxPosX = -Infinity;
let maxPosY = -Infinity;
+ let maxPosZ = -Infinity;
const pxArr = [];
const pyArr = [];
+ const pzArr = [];
for (let index = 0; index < total; index++) {
const el = t[index];
let px = 0;
let py = 0;
+ let pz = 0;
let found = false;
if (el && helpers.isFnc(el.getBoundingClientRect)) {
const rect = el.getBoundingClientRect();
@@ -119,6 +135,10 @@ const stagger = (val, params = {}) => {
if (obj && helpers.isNum(obj.x) && helpers.isNum(obj.y)) {
px = obj.x;
py = obj.y;
+ if (helpers.isNum(obj.z)) {
+ pz = obj.z;
+ has3D = true;
+ }
found = true;
}
}
@@ -128,42 +148,52 @@ const stagger = (val, params = {}) => {
}
pxArr.push(px);
pyArr.push(py);
+ pzArr.push(pz);
if (px < minPosX) minPosX = px;
if (py < minPosY) minPosY = py;
+ if (pz < minPosZ) minPosZ = pz;
if (px > maxPosX) maxPosX = px;
if (py > maxPosY) maxPosY = py;
+ if (pz > maxPosZ) maxPosZ = pz;
}
if (hasPositions) {
let fX = pxArr[0];
let fY = pyArr[0];
+ let fZ = pzArr[0];
if (fromArr) {
fX = minPosX + from[0] * (maxPosX - minPosX);
fY = minPosY + from[1] * (maxPosY - minPosY);
+ fZ = has3D ? minPosZ + (from.length >= 3 ? from[2] : 0.5) * (maxPosZ - minPosZ) : 0;
} else if (fromCenter) {
fX = (minPosX + maxPosX) / 2;
fY = (minPosY + maxPosY) / 2;
+ fZ = (minPosZ + maxPosZ) / 2;
} else if (fromLast) {
fX = pxArr[total - 1];
fY = pyArr[total - 1];
+ fZ = pzArr[total - 1];
} else if (helpers.isNum(from)) {
fX = pxArr[from];
fY = pyArr[from];
+ fZ = pzArr[from];
}
for (let index = 0; index < total; index++) {
const distanceX = fX - pxArr[index];
const distanceY = fY - pyArr[index];
- let value = helpers.sqrt(distanceX * distanceX + distanceY * distanceY);
+ const distanceZ = fZ - pzArr[index];
+ let value = helpers.sqrt(distanceX * distanceX + distanceY * distanceY + (has3D ? distanceZ * distanceZ : 0));
if (axis === 'x') value = -distanceX;
if (axis === 'y') value = -distanceY;
+ if (axis === 'z') value = -distanceZ;
values$1.push(value);
}
let minDist = Infinity;
- for (let index = 0, l = values$1.length; index < l; index++) {
+ for (let index = 0; index < total; index++) {
const absVal = helpers.abs(values$1[index]);
if (absVal > 0 && absVal < minDist) minDist = absVal;
}
if (minDist > 0 && minDist < Infinity) {
- for (let index = 0, l = values$1.length; index < l; index++) {
+ for (let index = 0; index < total; index++) {
values$1[index] = values$1[index] / minDist;
}
}
@@ -177,32 +207,51 @@ const stagger = (val, params = {}) => {
if (!grid) {
values$1.push(helpers.abs(fromIndex - index));
} else {
- let fromX, fromY;
+ const dims = grid.length;
+ const wh = grid[0] * grid[1];
+ let fromX, fromY, fromZ;
if (fromArr) {
fromX = from[0] * (grid[0] - 1);
fromY = from[1] * (grid[1] - 1);
+ fromZ = dims === 3 ? (from.length >= 3 ? from[2] : 0.5) * (grid[2] - 1) : 0;
} else if (fromCenter) {
fromX = (grid[0] - 1) / 2;
fromY = (grid[1] - 1) / 2;
+ fromZ = dims === 3 ? (grid[2] - 1) / 2 : 0;
} else {
fromX = fromIndex % grid[0];
- fromY = helpers.floor(fromIndex / grid[0]);
+ fromY = helpers.floor(fromIndex / grid[0]) % grid[1];
+ fromZ = dims === 3 ? helpers.floor(fromIndex / wh) : 0;
}
const toX = index % grid[0];
- const toY = helpers.floor(index / grid[0]);
+ const toY = helpers.floor(index / grid[0]) % grid[1];
+ const toZ = dims === 3 ? helpers.floor(index / wh) : 0;
const distanceX = fromX - toX;
const distanceY = fromY - toY;
- let value = helpers.sqrt(distanceX * distanceX + distanceY * distanceY);
+ const distanceZ = fromZ - toZ;
+ let value = helpers.sqrt(distanceX * distanceX + distanceY * distanceY + (dims === 3 ? distanceZ * distanceZ : 0));
if (axis === 'x') value = -distanceX;
if (axis === 'y') value = -distanceY;
+ if (axis === 'z') value = -distanceZ;
values$1.push(value);
}
}
}
- maxValue = helpers.max(...values$1);
- if (staggerEase) values$1 = values$1.map(val => staggerEase(val / maxValue) * maxValue);
- if (reversed) values$1 = values$1.map(val => axis ? (val < 0) ? val * -1 : -val : helpers.abs(maxValue - val));
- if (fromRandom) values$1 = random.shuffle(values$1);
+ maxValue = values$1[0];
+ for (let k = 1; k < total; k++) if (values$1[k] > maxValue) maxValue = values$1[k];
+ if (staggerEase || reversed) {
+ for (let k = 0; k < total; k++) {
+ let v = values$1[k];
+ if (staggerEase) v = staggerEase(v / maxValue) * maxValue;
+ if (reversed) v = axis ? -v : helpers.abs(maxValue - v);
+ values$1[k] = v;
+ }
+ }
+ if (hasJitter) {
+ jitterSamples = new Array(total);
+ for (let k = 0; k < total; k++) jitterSamples[k] = rng(-1, 1, 4);
+ }
+ if (fromRandom) values$1 = random.shuffle(values$1, rng);
}
const spacing = isRange ? (val2 - val1) / maxValue : val1;
if (helpers.isUnd(cachedOffset)) {
@@ -210,6 +259,11 @@ const stagger = (val, params = {}) => {
}
/** @type {String|Number} */
let output = cachedOffset + ((spacing * helpers.round(values$1[staggerIndex], 2)) || 0);
+ if (hasJitter) {
+ const progress = maxValue ? values$1[staggerIndex] / maxValue : 0;
+ const mag = jitterStart + (jitterEnd - jitterStart) * progress;
+ output = /** @type {Number} */(output) + jitterSamples[staggerIndex] * mag;
+ }
if (params.modifier) output = params.modifier(/** @type {Number} */(output));
if (unitMatch) output = `${output}${unitMatch[2]}`;
return output;
diff --git a/dist/modules/utils/stagger.js b/dist/modules/utils/stagger.js
index 5691a5e8..8a5b687d 100644
--- a/dist/modules/utils/stagger.js
+++ b/dist/modules/utils/stagger.js
@@ -1,17 +1,17 @@
/**
* Anime.js - utils - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
import { unitsExecRgx, emptyString } from '../core/consts.js';
-import { isUnd, parseNumber, isFnc, isNum, sqrt, abs, floor, max, round, isArr, isStr } from '../core/helpers.js';
+import { isUnd, parseNumber, isFnc, isNum, sqrt, abs, floor, round, isArr, isStr } from '../core/helpers.js';
import { parseEase } from '../easings/eases/parser.js';
import { parseTimelinePosition } from '../timeline/position.js';
import { getOriginalAnimatableValue } from '../core/values.js';
import { registerTargets } from '../core/targets.js';
-import { shuffle } from './random.js';
+import { createSeededRandom, random, shuffle } from './random.js';
/**
* @import {
@@ -64,6 +64,7 @@ const stagger = (val, params = {}) => {
let values = [];
let maxValue = 0;
let cachedOffset;
+ let jitterSamples = null;
const from = params.from;
const reversed = params.reversed;
const ease = params.ease;
@@ -85,27 +86,42 @@ const stagger = (val, params = {}) => {
const val2 = isRange ? parseNumber(val[1]) : 0;
const unitMatch = unitsExecRgx.exec((isRange ? val[1] : val) + emptyString);
const start = params.start || 0 + (isRange ? val1 : 0);
+ const seed = params.seed;
+ const hasSeed = !isUnd(seed) && seed !== false;
+ const rng = hasSeed ? createSeededRandom(seed === true ? 0 : /** @type {Number} */(seed)) : random;
+ const jitter = params.jitter;
+ const hasJitter = !isUnd(jitter);
+ const jitterIsArr = isArr(jitter);
+ const jitterStart = jitterIsArr ? /** @type {[Number,Number]} */(jitter)[0] : /** @type {Number} */(jitter) || 0;
+ const jitterEnd = jitterIsArr ? /** @type {[Number,Number]} */(jitter)[1] : /** @type {Number} */(jitter) || 0;
let fromIndex = fromFirst ? 0 : isNum(from) ? from : 0;
return (target, i, t, _, tl) => {
const [ registeredTarget ] = registerTargets(target);
const total = isUnd(customTotal) ? t.length : customTotal;
const customIndex = !isUnd(useProp) ? isFnc(useProp) ? useProp(registeredTarget, i, total) : getOriginalAnimatableValue(registeredTarget, useProp) : false;
- const staggerIndex = isNum(customIndex) || isStr(customIndex) && isNum(+customIndex) ? +customIndex : i;
+ const customIdx = isNum(customIndex) || isStr(customIndex) && isNum(+customIndex) ? +customIndex : i;
+ // Fall back to the natural index when the resolved value lands outside [0, total) so values[staggerIndex] never reads undefined.
+ const staggerIndex = customIdx >= 0 && customIdx < total ? customIdx : i;
if (fromCenter) fromIndex = (total - 1) / 2;
if (fromLast) fromIndex = total - 1;
if (!values.length) {
if (autoGrid) {
let hasPositions = true;
+ let has3D = false;
let minPosX = Infinity;
let minPosY = Infinity;
+ let minPosZ = Infinity;
let maxPosX = -Infinity;
let maxPosY = -Infinity;
+ let maxPosZ = -Infinity;
const pxArr = [];
const pyArr = [];
+ const pzArr = [];
for (let index = 0; index < total; index++) {
const el = t[index];
let px = 0;
let py = 0;
+ let pz = 0;
let found = false;
if (el && isFnc(el.getBoundingClientRect)) {
const rect = el.getBoundingClientRect();
@@ -117,6 +133,10 @@ const stagger = (val, params = {}) => {
if (obj && isNum(obj.x) && isNum(obj.y)) {
px = obj.x;
py = obj.y;
+ if (isNum(obj.z)) {
+ pz = obj.z;
+ has3D = true;
+ }
found = true;
}
}
@@ -126,42 +146,52 @@ const stagger = (val, params = {}) => {
}
pxArr.push(px);
pyArr.push(py);
+ pzArr.push(pz);
if (px < minPosX) minPosX = px;
if (py < minPosY) minPosY = py;
+ if (pz < minPosZ) minPosZ = pz;
if (px > maxPosX) maxPosX = px;
if (py > maxPosY) maxPosY = py;
+ if (pz > maxPosZ) maxPosZ = pz;
}
if (hasPositions) {
let fX = pxArr[0];
let fY = pyArr[0];
+ let fZ = pzArr[0];
if (fromArr) {
fX = minPosX + from[0] * (maxPosX - minPosX);
fY = minPosY + from[1] * (maxPosY - minPosY);
+ fZ = has3D ? minPosZ + (from.length >= 3 ? from[2] : 0.5) * (maxPosZ - minPosZ) : 0;
} else if (fromCenter) {
fX = (minPosX + maxPosX) / 2;
fY = (minPosY + maxPosY) / 2;
+ fZ = (minPosZ + maxPosZ) / 2;
} else if (fromLast) {
fX = pxArr[total - 1];
fY = pyArr[total - 1];
+ fZ = pzArr[total - 1];
} else if (isNum(from)) {
fX = pxArr[from];
fY = pyArr[from];
+ fZ = pzArr[from];
}
for (let index = 0; index < total; index++) {
const distanceX = fX - pxArr[index];
const distanceY = fY - pyArr[index];
- let value = sqrt(distanceX * distanceX + distanceY * distanceY);
+ const distanceZ = fZ - pzArr[index];
+ let value = sqrt(distanceX * distanceX + distanceY * distanceY + (has3D ? distanceZ * distanceZ : 0));
if (axis === 'x') value = -distanceX;
if (axis === 'y') value = -distanceY;
+ if (axis === 'z') value = -distanceZ;
values.push(value);
}
let minDist = Infinity;
- for (let index = 0, l = values.length; index < l; index++) {
+ for (let index = 0; index < total; index++) {
const absVal = abs(values[index]);
if (absVal > 0 && absVal < minDist) minDist = absVal;
}
if (minDist > 0 && minDist < Infinity) {
- for (let index = 0, l = values.length; index < l; index++) {
+ for (let index = 0; index < total; index++) {
values[index] = values[index] / minDist;
}
}
@@ -175,32 +205,51 @@ const stagger = (val, params = {}) => {
if (!grid) {
values.push(abs(fromIndex - index));
} else {
- let fromX, fromY;
+ const dims = grid.length;
+ const wh = grid[0] * grid[1];
+ let fromX, fromY, fromZ;
if (fromArr) {
fromX = from[0] * (grid[0] - 1);
fromY = from[1] * (grid[1] - 1);
+ fromZ = dims === 3 ? (from.length >= 3 ? from[2] : 0.5) * (grid[2] - 1) : 0;
} else if (fromCenter) {
fromX = (grid[0] - 1) / 2;
fromY = (grid[1] - 1) / 2;
+ fromZ = dims === 3 ? (grid[2] - 1) / 2 : 0;
} else {
fromX = fromIndex % grid[0];
- fromY = floor(fromIndex / grid[0]);
+ fromY = floor(fromIndex / grid[0]) % grid[1];
+ fromZ = dims === 3 ? floor(fromIndex / wh) : 0;
}
const toX = index % grid[0];
- const toY = floor(index / grid[0]);
+ const toY = floor(index / grid[0]) % grid[1];
+ const toZ = dims === 3 ? floor(index / wh) : 0;
const distanceX = fromX - toX;
const distanceY = fromY - toY;
- let value = sqrt(distanceX * distanceX + distanceY * distanceY);
+ const distanceZ = fromZ - toZ;
+ let value = sqrt(distanceX * distanceX + distanceY * distanceY + (dims === 3 ? distanceZ * distanceZ : 0));
if (axis === 'x') value = -distanceX;
if (axis === 'y') value = -distanceY;
+ if (axis === 'z') value = -distanceZ;
values.push(value);
}
}
}
- maxValue = max(...values);
- if (staggerEase) values = values.map(val => staggerEase(val / maxValue) * maxValue);
- if (reversed) values = values.map(val => axis ? (val < 0) ? val * -1 : -val : abs(maxValue - val));
- if (fromRandom) values = shuffle(values);
+ maxValue = values[0];
+ for (let k = 1; k < total; k++) if (values[k] > maxValue) maxValue = values[k];
+ if (staggerEase || reversed) {
+ for (let k = 0; k < total; k++) {
+ let v = values[k];
+ if (staggerEase) v = staggerEase(v / maxValue) * maxValue;
+ if (reversed) v = axis ? -v : abs(maxValue - v);
+ values[k] = v;
+ }
+ }
+ if (hasJitter) {
+ jitterSamples = new Array(total);
+ for (let k = 0; k < total; k++) jitterSamples[k] = rng(-1, 1, 4);
+ }
+ if (fromRandom) values = shuffle(values, rng);
}
const spacing = isRange ? (val2 - val1) / maxValue : val1;
if (isUnd(cachedOffset)) {
@@ -208,6 +257,11 @@ const stagger = (val, params = {}) => {
}
/** @type {String|Number} */
let output = cachedOffset + ((spacing * round(values[staggerIndex], 2)) || 0);
+ if (hasJitter) {
+ const progress = maxValue ? values[staggerIndex] / maxValue : 0;
+ const mag = jitterStart + (jitterEnd - jitterStart) * progress;
+ output = /** @type {Number} */(output) + jitterSamples[staggerIndex] * mag;
+ }
if (params.modifier) output = params.modifier(/** @type {Number} */(output));
if (unitMatch) output = `${output}${unitMatch[2]}`;
return output;
diff --git a/dist/modules/utils/target.cjs b/dist/modules/utils/target.cjs
index e04fcc38..d9347217 100644
--- a/dist/modules/utils/target.cjs
+++ b/dist/modules/utils/target.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -93,6 +93,9 @@ function get(targetSelector, propName, unit) {
*/
const set = (targets, parameters) => {
if (helpers.isUnd(parameters)) return;
+ if (globals.globals.editor && globals.globals.editor.addSet) {
+ return globals.globals.editor.addSet(targets, parameters);
+ }
parameters.duration = consts.minValue;
// Do not overrides currently active tweens by default
parameters.composition = values.setValue(parameters.composition, consts.compositionTypes.none);
diff --git a/dist/modules/utils/target.js b/dist/modules/utils/target.js
index b8e1f74f..1cff7a00 100644
--- a/dist/modules/utils/target.js
+++ b/dist/modules/utils/target.js
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -92,6 +92,9 @@ function get(targetSelector, propName, unit) {
*/
const set = (targets, parameters) => {
if (isUnd(parameters)) return;
+ if (globals.editor && globals.editor.addSet) {
+ return globals.editor.addSet(targets, parameters);
+ }
parameters.duration = minValue;
// Do not overrides currently active tweens by default
parameters.composition = setValue(parameters.composition, compositionTypes.none);
diff --git a/dist/modules/utils/time.cjs b/dist/modules/utils/time.cjs
index 45caa96c..9e4f754d 100644
--- a/dist/modules/utils/time.cjs
+++ b/dist/modules/utils/time.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -28,13 +28,14 @@ const sync = (callback = consts.noop) => {
};
/**
- * @param {(...args: any[]) => Tickable | ((...args: any[]) => void) | void} constructor
- * @return {(...args: any[]) => Tickable | ((...args: any[]) => void)}
+ * @template {Tickable | ((...args: any[]) => void) | void} T
+ * @param {(...args: any[]) => T} constructor
+ * @return {(...args: any[]) => T extends void ? () => void : T}
*/
const keepTime = constructor => {
/** @type {Tickable} */
let tracked;
- return (...args) => {
+ return /** @type {(...args: any[]) => T extends void ? () => void : T} */(/** @type {*} */((...args) => {
let currentIteration, currentIterationProgress, reversed, alternate, startTime;
if (tracked) {
currentIteration = tracked.currentIteration;
@@ -52,7 +53,7 @@ const keepTime = constructor => {
/** @type {Tickable} */(tracked)._startTime = startTime;
}
return cleanup || consts.noop;
- }
+ }));
};
exports.keepTime = keepTime;
diff --git a/dist/modules/utils/time.d.ts b/dist/modules/utils/time.d.ts
index 1e527907..56436c8f 100644
--- a/dist/modules/utils/time.d.ts
+++ b/dist/modules/utils/time.d.ts
@@ -1,5 +1,5 @@
export function sync(callback?: Callback<Timer>): Timer;
-export function keepTime(constructor: (...args: any[]) => Tickable | ((...args: any[]) => void) | void): (...args: any[]) => Tickable | ((...args: any[]) => void);
+export function keepTime<T extends Tickable | ((...args: any[]) => void) | void>(constructor: (...args: any[]) => T): (...args: any[]) => T extends void ? () => void : T;
import { Timer } from '../timer/timer.js';
import type { Callback } from '../types/index.js';
import type { Tickable } from '../types/index.js';
diff --git a/dist/modules/utils/time.js b/dist/modules/utils/time.js
index 5b349901..c09e05be 100644
--- a/dist/modules/utils/time.js
+++ b/dist/modules/utils/time.js
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
@@ -26,13 +26,14 @@ const sync = (callback = noop) => {
};
/**
- * @param {(...args: any[]) => Tickable | ((...args: any[]) => void) | void} constructor
- * @return {(...args: any[]) => Tickable | ((...args: any[]) => void)}
+ * @template {Tickable | ((...args: any[]) => void) | void} T
+ * @param {(...args: any[]) => T} constructor
+ * @return {(...args: any[]) => T extends void ? () => void : T}
*/
const keepTime = constructor => {
/** @type {Tickable} */
let tracked;
- return (...args) => {
+ return /** @type {(...args: any[]) => T extends void ? () => void : T} */(/** @type {*} */((...args) => {
let currentIteration, currentIterationProgress, reversed, alternate, startTime;
if (tracked) {
currentIteration = tracked.currentIteration;
@@ -50,7 +51,7 @@ const keepTime = constructor => {
/** @type {Tickable} */(tracked)._startTime = startTime;
}
return cleanup || noop;
- }
+ }));
};
export { keepTime, sync };
diff --git a/dist/modules/waapi/composition.cjs b/dist/modules/waapi/composition.cjs
index 536c72fd..b398179c 100644
--- a/dist/modules/waapi/composition.cjs
+++ b/dist/modules/waapi/composition.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - waapi - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/waapi/composition.js b/dist/modules/waapi/composition.js
index bcdc7d2b..48503c44 100644
--- a/dist/modules/waapi/composition.js
+++ b/dist/modules/waapi/composition.js
@@ -1,6 +1,6 @@
/**
* Anime.js - waapi - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/waapi/index.cjs b/dist/modules/waapi/index.cjs
index 15fd44e7..dbda292c 100644
--- a/dist/modules/waapi/index.cjs
+++ b/dist/modules/waapi/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - waapi - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/waapi/index.js b/dist/modules/waapi/index.js
index 44597f70..ec761bf7 100644
--- a/dist/modules/waapi/index.js
+++ b/dist/modules/waapi/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - waapi - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/waapi/waapi.cjs b/dist/modules/waapi/waapi.cjs
index 0bd3b4dc..dd42c2a6 100644
--- a/dist/modules/waapi/waapi.cjs
+++ b/dist/modules/waapi/waapi.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - waapi - CJS
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/dist/modules/waapi/waapi.js b/dist/modules/waapi/waapi.js
index 7cff7171..09702a39 100644
--- a/dist/modules/waapi/waapi.js
+++ b/dist/modules/waapi/waapi.js
@@ -1,6 +1,6 @@
/**
* Anime.js - waapi - ESM
- * @version v4.4.1
+ * @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
diff --git a/examples/additive-fireflies/index.html b/examples/additive-fireflies/index.html
index d2b27a7d..6bbe8704 100644
--- a/examples/additive-fireflies/index.html
+++ b/examples/additive-fireflies/index.html
@@ -29,7 +29,7 @@
overflow: hidden;
width: 100%;
height: 100%;
- color: var(--red);
+ color: var(--red-1);
}
#circle {
opacity: .3;
diff --git a/examples/additive-fireflies/index.js b/examples/additive-fireflies/index.js
index 8c286e21..70b184a2 100644
--- a/examples/additive-fireflies/index.js
+++ b/examples/additive-fireflies/index.js
@@ -1,7 +1,7 @@
import { animate, createTimer, utils } from '../../dist/modules/index.js';
-const $animationWrapper = document.querySelector('#animation-wrapper');
-const $circle = document.querySelector('#circle');
+const $animationWrapper = /** @type {HTMLElement} */ (document.querySelector('#animation-wrapper'));
+const $circle = /** @type {HTMLElement} */ (document.querySelector('#circle'));
const viewport = {w: window.innerWidth * .5, h: window.innerHeight * .5};
const rows = 15;
const baseRadius = $circle.offsetWidth / 1.85;
@@ -49,7 +49,7 @@ document.addEventListener('mouseup', e => {
animate($circle, { scale: 1, opacity: .3, filter: 'saturate(1)' });
});
-const colors = ['red', 'orange', 'lightorange'];
+const colors = ['red-1', 'corail-1', 'orange-1'];
for (let i = 0; i < (rows * rows); i++) {
const $particle = document.createElement('div');
diff --git a/examples/animatable-follow-cursor/index.html b/examples/animatable-follow-cursor/index.html
index 67b21fb4..f9edc66f 100644
--- a/examples/animatable-follow-cursor/index.html
+++ b/examples/animatable-follow-cursor/index.html
@@ -36,9 +36,9 @@
width: calc(var(--diameter) - var(--margin) * 2);
height: calc(var(--diameter) - var(--margin) * 2);
margin: var(--margin);
- background: var(--red);
+ background: var(--red-1);
mix-blend-mode: plus-lighter;
- box-shadow: 0 0 10px 0 var(--red);
+ box-shadow: 0 0 10px 0 var(--red-1);
border-radius: .5rem;
opacity: .75;
}
diff --git a/examples/animejs-v4-logo-animation/index.js b/examples/animejs-v4-logo-animation/index.js
index 11abf575..83cdbdfa 100644
--- a/examples/animejs-v4-logo-animation/index.js
+++ b/examples/animejs-v4-logo-animation/index.js
@@ -4,7 +4,7 @@ const [ $dot1 ] = utils.$('#dot-1');
const onions = [];
for (let i = 0; i < 4; i++) {
- const $clone = $dot1.cloneNode();
+ const $clone = /** @type {HTMLElement} */ ($dot1.cloneNode());
$clone.id = 'dot-1-' + i;
utils.set($clone, { opacity: 0 });
$dot1.parentNode.appendChild($clone);
diff --git a/examples/assets/css/styles.css b/examples/assets/css/styles.css
index 49e595b2..c5b2f6c9 100644
--- a/examples/assets/css/styles.css
+++ b/examples/assets/css/styles.css
@@ -286,7 +286,9 @@ button {
select:disabled,
button:disabled {
- background-color: var(--grey);
+ background-color: var(--bg-3);
+ color: var(--fg-4);
+ cursor: not-allowed;
}
select:not(:disabled):hover,
diff --git a/examples/auto-layout/accordion/index.js b/examples/auto-layout/accordion/index.js
index 11d13182..361b0e6f 100644
--- a/examples/auto-layout/accordion/index.js
+++ b/examples/auto-layout/accordion/index.js
@@ -3,11 +3,11 @@ import { createLayout, spring } from '../../../dist/modules/index.js';
const accordion = createLayout('.accordion', {
properties: ['background-color'],
ease: spring({ bounce: .2, duration: 450 }),
- added: { opacity: 0, filter: 'blur(5px)' },
- removed: { opacity: 0, filter: 'blur(5px)' }
+ enterFrom: { opacity: 0, filter: 'blur(5px)' },
+ leaveTo: { opacity: 0, filter: 'blur(5px)' }
});
document.addEventListener('click', event => {
- const $toggled = event.target.closest('.accordion button');
+ const $toggled = /** @type {HTMLElement} */(event.target).closest('.accordion button');
if ($toggled) accordion.update(() => $toggled.parentElement.classList.toggle('is-open'))
});
diff --git a/examples/auto-layout/cards/index.html b/examples/auto-layout/cards/index.html
index 39389c5f..1daf136d 100644
--- a/examples/auto-layout/cards/index.html
+++ b/examples/auto-layout/cards/index.html
@@ -1,47 +1,73 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>Cards</title>
- <style>
- * { margin: 0; padding: 0; box-sizing: border-box; }
- body { font-family: system-ui; padding: 20px; max-width: 1000px; margin: 0 auto; }
- nav { margin-bottom: 20px; }
- nav button { padding: 8px 16px; margin-right: 8px; cursor: pointer; }
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Auto layout / Cards / Anime.js</title>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+ <link href="../../assets/css/styles.css" rel="stylesheet">
+ <style>
+ body {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ width: 100%;
+ padding: 4rem 1rem;
+ min-height: 100lvh;
+ gap: 2rem;
+ font-family: system-ui;
+ background-color: var(--fg-2);
+ }
+ .controls fieldset button {
+ width: 5rem;
+ background-color: var(--bg-4);
+ color: var(--fg-1);
+ }
+ .controls fieldset button:hover {
+ background-color: var(--bg-5);
+ }
+ .controls fieldset button.is-active {
+ background-color: var(--fg-1);
+ color: var(--bg-3);
+ }
+ .container {
+ width: 100%;
+ max-width: 60rem;
+ }
- #cards { display: grid; gap: 16px; }
- .card { position: relative; overflow: hidden; border-radius: 8px; }
- .card img { width: 100%; height: 100%; object-fit: cover; }
- .card .info { padding: 12px; }
- .card h3 { margin-bottom: 4px; }
+ #cards { display: grid; gap: 16px; }
+ .card { position: relative; overflow: hidden; border-radius: 8px; }
+ .card img { width: 100%; height: 100%; object-fit: cover; }
+ .card .info { padding: 12px; }
+ .card h3 { margin-bottom: 4px; }
- /* Tiles: 4-column grid with overlay text */
- .tiles { grid-template-columns: repeat(4, 1fr); grid-auto-rows: 200px; }
- .tiles .card:nth-child(3n) { grid-row: span 2; }
- .tiles .card:nth-child(5n) { grid-column: span 2; }
- .tiles .card .info { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.6); color: white; }
+ /* Tiles: 4-column grid with overlay text */
+ .tiles { grid-template-columns: repeat(4, 1fr); grid-auto-rows: 200px; }
+ .tiles .card:nth-child(3n) { grid-row: span 2; }
+ .tiles .card:nth-child(5n) { grid-column: span 2; }
+ .tiles .card .info { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.35); color: var(--fg-1); }
- /* List: vertical list with side-by-side layout */
- /*.list { grid-template-columns: 1fr; width: 400px; margin: 0 auto; }*/
- #cards.list { display: flex; flex-direction: column; align-items: center; }
- .list .card { display: flex; background: #eee; width: 400px; }
- .list .card img { width: 120px; height: 120px; flex-shrink: 0; }
- .list .card .info { color: black; }
+ /* List: vertical list with side-by-side layout */
+ #cards.list { display: flex; flex-direction: column; align-items: center; }
+ .list .card { display: flex; background: var(--fg-1); width: 400px; color: var(--bg-1); }
+ .list .card img { width: 120px; height: 120px; flex-shrink: 0; }
- /* Grid: uniform rectangular cards with overlay */
- .grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
- .grid .card { aspect-ratio: 4/3; }
- .grid .card .info { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.6); color: white; }
- </style>
- </head>
- <body>
- <nav>
+ /* Grid: uniform rectangular cards with overlay */
+ .uniform { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
+ .uniform .card { aspect-ratio: 4/3; }
+ .uniform .card .info { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.35); color: var(--fg-1); }
+ </style>
+</head>
+<body>
+ <div class="controls">
+ <fieldset>
<button data-view="tiles">Tiles</button>
- <button data-view="list">List</button>
- <button data-view="grid">Grid</button>
- </nav>
+ <button data-view="list" class="is-active">List</button>
+ <button data-view="uniform">Grid</button>
+ </fieldset>
+ </div>
+ <div class="container">
<div id="cards" class="list"></div>
- <script type="module" src="./index.js"></script>
- </body>
+ </div>
+ <script type="module" src="./index.js"></script>
+</body>
</html>
diff --git a/examples/auto-layout/cards/index.js b/examples/auto-layout/cards/index.js
index 4140b3b9..bf2ba00a 100644
--- a/examples/auto-layout/cards/index.js
+++ b/examples/auto-layout/cards/index.js
@@ -1,6 +1,7 @@
-import { createLayout } from '../../../dist/modules/index.js';
+import { createLayout, utils, stagger } from '../../../dist/modules/index.js';
-const cards = document.getElementById('cards')
+const $cards = /** @type {HTMLElement} */(document.getElementById('cards'));
+const $buttons = utils.$('.controls fieldset button');
const lorem = [
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -9,11 +10,10 @@ const lorem = [
'Duis aute irure dolor in reprehenderit in voluptate velit.',
'Excepteur sint occaecat cupidatat non proident sunt in culpa.',
'Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut.',
-]
+];
-// Generate 12 cards
for (let i = 1; i <= 12; i++) {
- cards.innerHTML += `
+ $cards.innerHTML += `
<div class="card">
<img src="https://picsum.photos/400/300?random=${i}" alt="Photo ${i}">
<div class="info">
@@ -21,17 +21,30 @@ for (let i = 1; i <= 12; i++) {
<p>${lorem[i % lorem.length]}</p>
</div>
</div>
- `
+ `;
}
-const layout = createLayout('#cards', {
- duration: 1000
+const layout = createLayout($cards, {
+ duration: 750,
+ ease: 'inOutExpo',
});
-document.querySelectorAll('nav button').forEach(btn => {
- btn.onclick = () => {
+const views = ['tiles', 'list', 'uniform'];
+let currentView = views.indexOf('list');
+
+$buttons.forEach($btn => {
+ $btn.onclick = () => {
+ const newView = views.indexOf($btn.dataset.view || '');
+ if (newView === -1 || newView === currentView) return;
+ const reversed = newView < currentView;
+ currentView = newView;
layout.update(() => {
- cards.className = btn.dataset.view;
- })
- }
-})
+ $buttons.forEach($b => $b.classList.remove('is-active'));
+ $btn.classList.add('is-active');
+ $cards.classList.remove(...views);
+ $cards.classList.add(views[newView]);
+ }, {
+ delay: stagger([0, 500], { reversed }),
+ });
+ };
+});
diff --git a/examples/auto-layout/grid-columns/index.html b/examples/auto-layout/grid-columns/index.html
new file mode 100644
index 00000000..fdd82d58
--- /dev/null
+++ b/examples/auto-layout/grid-columns/index.html
@@ -0,0 +1,80 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Auto layout / Grid columns / Anime.js</title>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+ <link href="../../assets/css/styles.css" rel="stylesheet">
+ <style>
+ body {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ width: 100%;
+ padding: 4rem 1rem;
+ min-height: 100lvh;
+ gap: 2rem;
+ }
+ .controls fieldset button {
+ width: 3rem;
+ background-color: var(--bg-4);
+ color: var(--fg-1);
+ }
+ .controls fieldset button:hover {
+ background-color: var(--bg-5);
+ }
+ .controls fieldset button.is-active {
+ background-color: var(--fg-1);
+ color: var(--bg-3);
+ }
+ .container {
+ width: 100%;
+ max-width: 48rem;
+ }
+ .grid-cards {
+ --cols: 4;
+ display: grid;
+ grid-template-columns: repeat(var(--cols), 1fr);
+ gap: 1rem;
+ }
+ .card {
+ aspect-ratio: 1 / 1;
+ border-radius: 1rem;
+ padding: 1rem;
+ background-color: var(--color-5);
+ border: 1px solid var(--color-4);
+ color: var(--color-1);
+ display: flex;
+ flex-direction: column;
+ justify-content: flex-end;
+ }
+ .card h3 {
+ font-size: 1rem;
+ font-weight: 700;
+ margin-bottom: .25rem;
+ }
+ .card p {
+ display: none;
+ font-size: .75rem;
+ color: var(--color-2);
+ line-height: 1.3;
+ }
+ .grid-cards.cols-3 .card p {
+ display: block;
+ }
+ </style>
+</head>
+<body>
+ <div class="controls">
+ <fieldset>
+ <button data-cols="3">3</button>
+ <button data-cols="4" class="is-active">4</button>
+ <button data-cols="5">5</button>
+ </fieldset>
+ </div>
+ <div class="container">
+ <div class="grid-cards cols-4" id="cards"></div>
+ </div>
+ <script type="module" src="./index.js"></script>
+</body>
+</html>
diff --git a/examples/auto-layout/grid-columns/index.js b/examples/auto-layout/grid-columns/index.js
new file mode 100644
index 00000000..31f48f61
--- /dev/null
+++ b/examples/auto-layout/grid-columns/index.js
@@ -0,0 +1,51 @@
+import { createLayout, utils, stagger } from '../../../dist/modules/index.js';
+
+const $cards = /** @type {HTMLElement} */(document.getElementById('cards'));
+const $buttons = utils.$('.controls fieldset button');
+
+const colors = [
+ 'Red', 'Corail', 'Orange', 'Yellow',
+ 'Citrus', 'Lime', 'Green', 'Emerald',
+ 'Turquoise', 'Aqua', 'Cyan', 'Sky',
+ 'Indigo', 'Lavender', 'Purple', 'Magenta',
+];
+
+const lorem = [
+ 'Lorem ipsum dolor sit amet.',
+ 'Sed do eiusmod tempor incididunt.',
+ 'Ut enim ad minim veniam.',
+ 'Duis aute irure dolor.',
+];
+
+for (let i = 0; i < colors.length; i++) {
+ $cards.innerHTML += `
+ <div class="card" data-color="${i}">
+ <h3>${colors[i]}</h3>
+ <p>${lorem[i % lorem.length]}</p>
+ </div>
+ `;
+}
+
+const layout = createLayout($cards, {
+ duration: 750,
+ ease: 'inOutExpo',
+});
+
+let currentCols = 4;
+
+$buttons.forEach($btn => {
+ $btn.onclick = () => {
+ const newCols = $btn.dataset.cols ? +$btn.dataset.cols : 0;
+ const reversed = newCols < currentCols;
+ currentCols = newCols;
+ layout.update(() => {
+ $buttons.forEach($b => $b.classList.remove('is-active'));
+ $btn.classList.add('is-active');
+ $cards.style.setProperty('--cols', String(newCols));
+ $cards.classList.remove('cols-3', 'cols-4', 'cols-5');
+ $cards.classList.add(`cols-${newCols}`);
+ }, {
+ delay: stagger([0, 500], { reversed }),
+ });
+ };
+});
diff --git a/examples/auto-layout/nav/index.js b/examples/auto-layout/nav/index.js
index c39b938a..80c8c36c 100644
--- a/examples/auto-layout/nav/index.js
+++ b/examples/auto-layout/nav/index.js
@@ -19,7 +19,7 @@ const content = createLayout('.content', {
});
document.onclick = e => {
- const $button = e.target.closest('button');
+ const $button = /** @type {HTMLElement} */(e.target).closest('button');
if ($button) {
nav.update(() => {
content.record();
diff --git a/examples/auto-layout/periodic-table/index.js b/examples/auto-layout/periodic-table/index.js
index ba38485c..8c689d7c 100644
--- a/examples/auto-layout/periodic-table/index.js
+++ b/examples/auto-layout/periodic-table/index.js
@@ -140,22 +140,22 @@ const elements = [
// Genetate the table html
const [ $sceneContent ] = utils.$('#scene-content');
-const [ $template ] = utils.$('#element');
+const [ $template ] = /** @type {[HTMLTemplateElement]} */(utils.$('#element'));
for (let i = 0, l = elements.length / ELEMENT_STRIDE; i < l; i += 1) {
const offset = i * ELEMENT_STRIDE;
- const $el = $template.content.cloneNode(true);
- const $element = $el.querySelector('.element');
+ const $el = /** @type {DocumentFragment} */($template.content.cloneNode(true));
+ const $element = /** @type {HTMLElement} */($el.querySelector('.element'));
const $number = $element.querySelector('.element-number');
const $symbol = $element.querySelector('.element-symbol');
const $title = $element.querySelector('.element-title');
const $description = $element.querySelector('.element-description');
- $number.textContent = i + 1;
- $symbol.textContent = elements[offset + ELEMENT_FIELDS.SYMBOL];
- $title.textContent = elements[offset + ELEMENT_FIELDS.NAME];
- $element.dataset.color = elements[offset + ELEMENT_FIELDS.COLOR];
- $element.style.gridColumn = elements[offset + ELEMENT_FIELDS.COLUMN];
- $element.style.gridRow = elements[offset + ELEMENT_FIELDS.ROW];
+ $number.textContent = `${i + 1}`;
+ $symbol.textContent = `${elements[offset + ELEMENT_FIELDS.SYMBOL]}`;
+ $title.textContent = `${elements[offset + ELEMENT_FIELDS.NAME]}`;
+ $element.dataset.color = `${elements[offset + ELEMENT_FIELDS.COLOR]}`;
+ $element.style.gridColumn = `${elements[offset + ELEMENT_FIELDS.COLUMN]}`;
+ $element.style.gridRow = `${elements[offset + ELEMENT_FIELDS.ROW]}`;
$description.innerHTML = [
`Atomic mass: ${elements[offset + ELEMENT_FIELDS.ATOMIC_MASS]} u`,
`Density: ${elements[offset + ELEMENT_FIELDS.DENSITY]} g/cm3`,
@@ -194,7 +194,7 @@ const transformLayout = {
pointer.rotateX = 15;
pointer.rotateY = 20;
cards.forEach($el => {
- $el.style.opacity = 1;
+ $el.style.opacity = '1';
$el.style.transform = $el.classList.contains('is-expanded') ? 'translateZ(50px)' : 'translateZ(10px)';
});
},
@@ -272,7 +272,7 @@ document.addEventListener('pointermove', event => {
const toggles = utils.$('.controls button.toggle');
document.addEventListener('click', event => {
- const $toggle = event.target.closest('.controls button.toggle');
+ const $toggle = /** @type {HTMLElement} */(event.target).closest('.controls button.toggle');
if ($toggle) {
toggles.forEach(button => button.classList.remove('is-active'));
$toggle.classList.add('is-active');
@@ -286,7 +286,7 @@ document.addEventListener('click', event => {
});
return;
}
- const $card = event.target.closest('#scene-content .element');
+ const $card = /** @type {HTMLElement} */(event.target).closest('#scene-content .element');
const shouldExpand = $card && !$card.classList.contains('is-expanded');
elementsLayout.update(() => {
cards.forEach($el => $el.classList.remove('is-expanded'));
diff --git a/examples/auto-layout/planets/index.js b/examples/auto-layout/planets/index.js
index aa379dc3..80dd035b 100644
--- a/examples/auto-layout/planets/index.js
+++ b/examples/auto-layout/planets/index.js
@@ -38,7 +38,7 @@ let nextPlanetIndex = 0;
const initialPlanets = 4;
const toggles = utils.$('.controls button.toggle');
const [ $root ] = utils.$('#root');
-const [ $overlay ] = utils.$('#overlay');
+const [ $overlay ] = /** @type {[HTMLDialogElement]} */(utils.$('#overlay'));
const actions = {
add: () => {
@@ -47,12 +47,12 @@ const actions = {
if (visibleCardsLength) utils.set($visibleCards, { '--total': visibleCardsLength + 1 });
nextPlanetIndex = visibleCardsLength * 8;
if (nextPlanetIndex >= planets.length) return;
- const template = utils.$('#card')[0];
+ const template = /** @type {HTMLTemplateElement} */(utils.$('#card')[0]);
const $removed = utils.$('#root .card.is-removed')[0];
let $cardTarget = $removed;
if (!$cardTarget) {
- const clone = template.content.cloneNode(true);
- const $card = clone.querySelector('.card');
+ const clone = /** @type {DocumentFragment} */(template.content.cloneNode(true));
+ const $card = /** @type {HTMLElement} */(clone.querySelector('.card'));
if (!$card) return;
const $image = $card.querySelector('.card-image');
const $title = $card.querySelector('.card-title');
@@ -64,14 +64,14 @@ const actions = {
`;
$image.innerHTML += `
<svg class="rings" viewBox="0 0 600 600">
- ${planets[nextPlanetIndex + 7].map(r => `<circle cx="300" cy="300" r="${r}"/>`).join('')}
+ ${/** @type {Number[]} */(planets[nextPlanetIndex + 7]).map(r => `<circle cx="300" cy="300" r="${r}"/>`).join('')}
</svg>
`;
utils.set($card, { '--index': visibleCardsLength + 1 });
- $card.dataset.title = $title.textContent = planets[nextPlanetIndex + 1];
- $type.textContent = planetTypes[planets[nextPlanetIndex + 3]];
- $intro.textContent = planets[nextPlanetIndex + 2];
- $card.dataset.color = planets[nextPlanetIndex + 6];
+ $card.dataset.title = $title.textContent = `${planets[nextPlanetIndex + 1]}`;
+ $type.textContent = planetTypes[/** @type {Number} */(planets[nextPlanetIndex + 3])];
+ $intro.textContent = `${planets[nextPlanetIndex + 2]}`;
+ $card.dataset.color = `${planets[nextPlanetIndex + 6]}`;
$description.textContent = loremIpsum(utils.random(100, 150));
$cardTarget = $card;
$root.appendChild(clone);
diff --git a/examples/auto-layout/todo-list/index.js b/examples/auto-layout/todo-list/index.js
index 288b04b9..e04dca7c 100644
--- a/examples/auto-layout/todo-list/index.js
+++ b/examples/auto-layout/todo-list/index.js
@@ -1,5 +1,13 @@
import { createLayout, spring, stagger, $ } from '../../../dist/modules/index.js';
+const $container = /** @type {HTMLElement} */(document.getElementById('$container'));
+const $todoTemplate = /** @type {HTMLTemplateElement} */(document.getElementById('$todoTemplate'));
+const $new = /** @type {HTMLElement} */(document.getElementById('$new'));
+const $pending = /** @type {HTMLElement} */(document.getElementById('$pending'));
+const $completed = /** @type {HTMLElement} */(document.getElementById('$completed'));
+const $addInput = /** @type {HTMLInputElement} */(document.getElementById('$addInput'));
+const $createForm = /** @type {HTMLFormElement} */(document.getElementById('$createForm'));
+
const layout = createLayout($container, {
properties: ['backgroundColor', 'color', 'accent-color'],
ease: spring({ bounce: .3, duration: 450 }),
@@ -67,5 +75,5 @@ $createForm.addEventListener('submit', event => {
});
document.addEventListener('click', event => {
- if (event.target.classList.contains('action')) handleAction(event);
+ if (/** @type {HTMLElement} */(event.target).classList.contains('action')) handleAction(event);
});
\ No newline at end of file
diff --git a/examples/clock-playback-controls/index.html b/examples/clock-playback-controls/index.html
index a22321df..0f364cb9 100644
--- a/examples/clock-playback-controls/index.html
+++ b/examples/clock-playback-controls/index.html
@@ -15,8 +15,7 @@
overflow: hidden;
width: 100%;
height: 100%;
- background: #1a1a1a;
- font-family: BerkeleyMono-Regular, monospace;
+ background: var(--bg-1);
}
#clock {
font-size: 32px;
@@ -46,13 +45,13 @@
left: -50%;
width: 200%;
height: 400%;
- background-image: linear-gradient(180deg, #1a1a1a 10%, #1a1a1a66 30%, #1a1a1a00 40%, #1a1a1a00 60%,#1a1a1a66 70%, #1a1a1a 90%);
+ background-image: linear-gradient(180deg, var(--bg-1) 10%, rgba(37,36,35,.4) 30%, transparent 40%, transparent 60%, rgba(37,36,35,.4) 70%, var(--bg-1) 90%);
}
.slot {
position: relative;
width: 1ch;
height: 2ch;
- color: #fff;
+ color: var(--fg-1);
display: flex;
transform-style: preserve-3d;
align-items: center;
@@ -91,8 +90,8 @@
fieldset > input {
min-width: 0;
border-radius: .1ch;
- accent-color: white;
- color: white;
+ accent-color: var(--fg-1);
+ color: var(--fg-1);
text-align: right;
background: transparent;
}
@@ -124,15 +123,15 @@
min-width: 0;
border-radius: 1ch;
margin: .5ch;
- background-color: #2A2A2A;
- color: #FFF;
+ background-color: var(--bg-4);
+ color: var(--fg-1);
}
#controls button:hover {
- background-color: #3A3A3A;
+ background-color: var(--bg-5);
}
#controls button:focus {
- background-color: #FFF;
- color: #2A2A2A;
+ background-color: var(--fg-1);
+ color: var(--bg-3);
}
</style>
</head>
diff --git a/examples/clock-playback-controls/index.js b/examples/clock-playback-controls/index.js
index 3cd76030..7d2f2d08 100644
--- a/examples/clock-playback-controls/index.js
+++ b/examples/clock-playback-controls/index.js
@@ -21,7 +21,13 @@ const masterTL = createTimeline({ defaults: { ease: 'linear' }, autoplay: false
for (let i = 0; i < 10; i++) {
const $num = document.createElement('div');
$num.textContent = `${i}`;
- utils.set($num, { rotateX: (i * 36), z: '3ch' });
+ const angle = i * 36;
+ const a = utils.degToRad(angle);
+ utils.set($num, {
+ translateY: -3 * Math.sin(a) + 'ch',
+ z: 3 * Math.cos(a) + 'ch',
+ rotateX: angle,
+ });
$el.appendChild($num);
}
const canStop = d > 100;
diff --git a/examples/draggable-infinite-auto-carousel/index.html b/examples/draggable-infinite-auto-carousel/index.html
index 779a8e01..64900f17 100644
--- a/examples/draggable-infinite-auto-carousel/index.html
+++ b/examples/draggable-infinite-auto-carousel/index.html
@@ -15,7 +15,7 @@
}
body, html {
overflow: hidden;
- background: #000;
+ background: var(--bg-1);
}
#infinite-carousel {
--spacing: 30px;
@@ -42,7 +42,7 @@
width: 100%;
height: 100%;
margin-right: var(--spacing);
- background-color: var(--red);
+ background-color: var(--red-1);
border-radius: var(--spacing);
list-style: none;
}
diff --git a/examples/draggable-mouse-scroll-snap-carousel/index.html b/examples/draggable-mouse-scroll-snap-carousel/index.html
index dbbb8369..e39e5140 100644
--- a/examples/draggable-mouse-scroll-snap-carousel/index.html
+++ b/examples/draggable-mouse-scroll-snap-carousel/index.html
@@ -15,7 +15,7 @@
}
body, html {
overflow: hidden;
- background: #000;
+ background: var(--bg-1);
}
#snap-carousel {
@@ -44,7 +44,7 @@
width: calc(50% - (var(--spacing) * 1.5));
height: 100%;
margin-left: var(--spacing);
- background-color: var(--red);
+ background-color: var(--red-1);
border-radius: var(--spacing);
list-style: none;
will-change: transform;
diff --git a/examples/draggable-playground/index.js b/examples/draggable-playground/index.js
index 43a74e07..28f5843f 100644
--- a/examples/draggable-playground/index.js
+++ b/examples/draggable-playground/index.js
@@ -209,15 +209,24 @@ const flickAnimatable = createAnimatable($flickCarousel, {
const flickDraggable = createDraggable(flickData, {
trigger: '#infinite-flick',
y: false,
- onGrab: () => animate(flickData, { speedX: 0, duration: 500 }),
- onRelease: () => animate(flickData, { speedX: 2, duration: 500 }),
- releaseStiffness: 10,
+ onGrab: () => {
+ isGrabbing = true;
+ animate(flickData, { speedX: 0, duration: 200, ease: 'out(2)' });
+ },
+ onRelease: self => {
+ isGrabbing = false;
+ flickData.speedX = -self.deltaX;
+ animate(flickData, { speedX: 2, duration: 2000, ease: 'out(3)' });
+ },
});
+let isGrabbing = false;
+
createTimer({
onUpdate: () => {
const { x } = flickAnimatable;
- x(/** @type {Number} */(x()) - flickData.speedX + flickDraggable.deltaX - flickData.wheelY);
+ const drag = isGrabbing ? flickDraggable.deltaX : 0;
+ x(/** @type {Number} */(x()) - flickData.speedX + drag - flickData.wheelY);
}
});
diff --git a/examples/easings-visualizer/index.html b/examples/easings-visualizer/index.html
deleted file mode 100644
index 5db0dc61..00000000
--- a/examples/easings-visualizer/index.html
+++ /dev/null
@@ -1,506 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Easings visualizer</title>
- <link href="../assets/css/styles.css" rel="stylesheet">
- <style>
- body {
- display: flex;
- justify-content: center;
- align-items: center;
- min-width: 100dvw;
- min-height: 100dvh;
- }
-
- polyline {
- vector-effect: non-scaling-stroke;
- }
-
- input[type=number] {
- -moz-appearance: textfield;
- appearance: textfield;
- margin: 0;
- }
-
- input[type=number]::-webkit-inner-spin-button,
- input[type=number]::-webkit-outer-spin-button {
- -webkit-appearance: none;
- margin: 0;
- }
-
- #eases-visualizer {
- --unit: 1dvw;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- width: 100dvw;
- min-height: 100dvh;
- }
-
- @media (min-width: 640px) {
- #eases-visualizer {
- --unit: .7125dvw;
- }
- }
-
- #eases-editor {
- position: fixed;
- right: 0;
- display: flex;
- flex-direction: row;
- justify-content: center;
- align-items: center;
- width: 100%;
- height: 70vw;
- }
-
- @media (min-width: 640px) {
- #eases-editor {
- width: 50%;
- height: 100%;
- }
- }
-
- #eases-container {
- --one-cell: calc(var(--unit) * 10);
- position: relative;
- width: calc(var(--one-cell) * 5);
- height: calc(var(--one-cell) * 5);
- display: grid;
- grid-template-columns: 3fr 1fr 1fr;
- grid-template-rows: 1fr 1fr 3fr;
- gap: 0px 0px;
- grid-auto-flow: row;
- grid-template-areas:
- "time time ."
- "graph graph preview"
- "graph graph preview";
- }
-
- .eases-editor-cell {
- position: relative;
- }
-
- #eases-graph {
- grid-area: graph;
- border: 1px dotted rgba(255, 255, 255, .5);
- }
-
- #eases-container:before {
- content: "";
- position: absolute;
- left: -100%;
- top: -100%;
- display: block;
- width: 300%;
- height: 300%;
- background:
- linear-gradient(-90deg, rgba(255,255,255,.05) 1px, transparent 1px),
- linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
- linear-gradient(-90deg, rgba(255,255,255,.04) 1px, transparent 1px),
- linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
- linear-gradient(transparent 3px, var(--black-1) 3px, var(--black-1) calc(var(--one-cell) - 2px), transparent calc(var(--one-cell) - 2px)),
- linear-gradient(-90deg, var(--white-1) 1px, transparent 1px),
- linear-gradient(-90deg, transparent 3px, var(--black-1) 3px, var(--black-1) calc(var(--one-cell) - 2px), transparent calc(var(--one-cell) - 2px)),
- linear-gradient(var(--white-1) 1px, transparent 1px), var(--black-1);
- background-size:
- calc(var(--one-cell) / 10) calc(var(--one-cell) / 10),
- calc(var(--one-cell) / 10) calc(var(--one-cell) / 10),
- var(--one-cell) var(--one-cell),
- var(--one-cell) var(--one-cell),
- var(--one-cell) var(--one-cell),
- var(--one-cell) var(--one-cell),
- var(--one-cell) var(--one-cell),
- var(--one-cell) var(--one-cell);
- }
-
- #eases-graph svg {
- overflow: visible;
- position: absolute;
- width: 100%;
- height: 100%;
- stroke-width: 1px;
- will-change: transform;
- }
-
- #eases-time {
- grid-area: time;
- border-top: 1px dashed rgba(255, 255, 255, .5);
- }
-
- #eases-preview {
- grid-area: preview;
- border-right: 1px dashed rgba(255, 255, 255, .5);
- }
-
- .axis {
- z-index: 1;
- position: absolute;
- }
-
- .axis:after {
- content: "";
- display: block;
- position: absolute;
- top: -1.25rem;
- right: -1.25rem;
- width: calc(2.5rem + 1px);
- height: calc(2.5rem + 1px);
- }
-
- .axis-x {
- bottom: -1px;
- right: -1px;
- width: calc(var(--unit) * 50);
- height: 1px;
- background-color: var(--red);
- z-index: 1;
- }
-
- .axis-x:not(:first-child) {
- z-index: 0;
- }
-
- .axis-x:first-child:after {
- background-color: var(--red);
- box-shadow: 0 0 0 1px var(--black-1);
- }
-
- .axis-x:not(:first-child):after {
- background-color: var(--red);
- }
-
- .axis-y {
- top: 0;
- left: -1px;
- width: 1px;
- height: calc(var(--unit) * 50);
- background-color: rgba(255, 255, 255, .25);
- }
-
- .axis-y:after {
- content: attr(data-value);
- top: -1.5rem;
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: .75rem;
- font-weight: bold;
- color: var(--white-1);
- background-color: var(--black-1);
- border: 1px solid rgba(255, 255, 255, .25);
- }
-
- /* Easings config */
-
- #eases-config {
- position: sticky;
- z-index: 2;
- top: 0;
- width: 100%;
- min-height: 100dvh;
- margin-top: 70vw;
- background: var(--black-1);
- }
-
- @media (min-width: 640px) {
- #eases-config {
- width: 50%;
- margin-top: 0;
- }
- }
-
- #ease-controls {
- position: sticky;
- z-index: 2;
- top: 0;
- display: flex;
- flex-wrap: wrap;
- justify-content: flex-start;
- width: 100%;
- padding: .75rem;
- padding-bottom: 0;
- background: var(--black-1);
- box-shadow: 0 10px 10px 0 var(--black-1);
- border-radius: 1rem 1rem 0 0;
- }
-
- #ease-name {
- background: transparent;
- color: var(--red);
- width: 100%;
- margin: 0.125rem;
- font-size: 2rem;
- }
-
- @media (min-width: 1280px) {
- #ease-controls {
- padding: 1.5rem;
- padding-bottom: 0;
- }
-
- #ease-name {
- margin: 0.5rem;
- }
- }
-
- #ease-parameters {
- display: flex;
- flex-wrap: wrap;
- justify-content: flex-start;
- width: 100%;
- }
-
- .ease-parameter {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- width: calc(25% - .25rem);
- margin: .125rem;
- }
-
- .parameter-legend {
- display: block;
- height: 1rem;
- font-size: .75rem;
- margin-bottom: .5rem;
- }
-
- .ease-parameter input[type="number"] {
- display: none;
- }
-
- .ease-parameter input[type="range"] {
- width: 100%;
- }
-
- @media (min-width: 1280px) {
- .ease-parameter input[type="number"] {
- display: block;
- width: 2.75rem;
- background-color: transparent;
- color: var(--white-1);
- }
- .ease-parameter input[type="range"] {
- width: calc(100% - 2.75rem);
- }
- }
-
- .ease-parameter input:disabled {
- opacity: .25;
- }
-
- input[type="range"][value] {
- position: relative;
- height: 2rem;
- -webkit-appearance: none;
- background-color: transparent;
- color: currentColor;
- }
-
- input[type="range"][value]:focus {
- outline: none;
- }
-
- input[type="range"][value]:after {
- content: "";
- position: absolute;
- top: 1rem;
- left: 0;
- width: 100%;
- height: 1px;
- background-color: currentColor;
- }
-
- input[type="range"][value]::-webkit-slider-thumb {
- position: relative;
- z-index: 2;
- -webkit-appearance: none;
- border-radius: 4px;
- border: 1px solid currentColor;
- width: 16px;
- height: 29px;
- background-color: var(--black-1);
- background-image: radial-gradient(transparent 1px, rgba(0, 0, 0, .7) 0), radial-gradient(transparent 1px, currentColor 0), radial-gradient(currentColor 1px, transparent 0);
- background-size: 3px 3px, 3px 3px, 3px 3px;
- background-position: -2px -2px, -2px -2px, -2px -2px;
- box-shadow: inset 0 0 0 4.5px rgba(0, 0, 0, .7), inset 0 0 0 4.5px currentColor;
- }
-
- /* Ease buttons */
-
- #eases-list {
- position: relative;
- z-index: 1;
- display: flex;
- flex-wrap: wrap;
- justify-content: flex-start;
- width: 100%;
- min-height: 100%;
- padding: .75rem;
- background-color: var(--black-1);
- }
-
- @media (min-width: 1280px) {
- #eases-list {
- padding: 1.5rem;
- }
- }
-
- button.ease-button {
- position: relative;
- display: flex;
- flex-shrink: 0;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- width: calc(25% - .25rem);
- height: auto;
- margin: .125rem;
- padding: .5rem;
- background-color: rgba(255, 255, 255, .05);
- color: var(--white-1);
- cursor: pointer;
- border-radius: .6rem;
- transition: background-color .25s ease-in-out;
- font-size: .75rem;
- }
-
- @media (min-width: 1280px) {
- button.ease-button {
- width: calc(12.5% - .25rem);
- }
- }
-
- button.ease-button:hover {
- background-color: rgba(255, 255, 255, .1);
- transition: background-color .05s ease-out;
- }
-
- button.ease-button.is-active {
- background: var(--red);
- color: var(--black-1);
- }
-
- button.ease-button .ease-config {
- position: absolute;
- top: .25rem;
- right: .41rem;
- font-size: .75rem;
- }
-
- button.ease-button svg {
- overflow: visible;
- width: calc(100% - 3rem);
- margin-top: 0.25rem;
- margin-bottom: 0.5rem;
- }
-
- @media (min-width: 640px) {
- button.ease-button svg {
- width: calc(100% - 2rem);
- margin-top: 1rem;
- margin-bottom: 1rem;
- }
- }
-
- button.ease-button svg polyline {
- stroke: var(--red);
- }
-
- button.ease-button.is-active svg polyline {
- stroke: var(--black-1);
- }
-
- </style>
-</head>
-<body>
- <div id="eases-visualizer">
- <div id="eases-editor">
- <div id="eases-container">
- <div id="eases-graph" class="eases-editor-cell">
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" class="grid-small">
- <polyline id="ease-curve" stroke="#FF4B4B" stroke-width="4" points="0 100 50 50 100 0" stroke-linecap="round" stroke-linejoin="round" fill="none" fill-rule="evenodd"/>
- </svg>
- </div>
- <div id="eases-time" class="eases-editor-cell"><div class="axis axis-y" data-value="1.0"></div></div>
- <div id="eases-preview" class="eases-editor-cell">
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- <div class="axis axis-x"></div>
- </div>
- </div>
- </div>
- <div id="eases-config">
- <div id="ease-controls" class="ease-visualizer-section">
- <input type="text" id="ease-name" value="easeName" readonly/>
- <div id="ease-parameters">
- <fieldset class="ease-parameter">
- <legend id="legend-p1" class="parameter-legend">P1</legend>
- <input data-parameters="p1" type="number" value="1.0" min="0" max="2" step="0.1"/>
- <input data-parameters="p1" type="range" value="1.0" min="0" max="2" step="0.1"/>
- </fieldset>
- <fieldset class="ease-parameter">
- <legend id="legend-p2" class="parameter-legend">P2</legend>
- <input data-parameters="p2" type="number" value="1.0" min="0" max="2" step="0.1"/>
- <input data-parameters="p2" type="range" value="1.0" min="0" max="2" step="0.1"/>
- </fieldset>
- <fieldset class="ease-parameter">
- <legend id="legend-p3" class="parameter-legend">P3</legend>
- <input data-parameters="p3" type="number" value="1.0" min="0" max="2" step="0.1"/>
- <input data-parameters="p3" type="range" value="1.0" min="0" max="2" step="0.1"/>
- </fieldset>
- <fieldset class="ease-parameter">
- <legend id="legend-p4" class="parameter-legend">P4</legend>
- <input data-parameters="p4" type="number" value="1.0" min="0" max="2" step="0.1"/>
- <input data-parameters="p4" type="range" value="1.0" min="0" max="2" step="0.1"/>
- </fieldset>
- </div>
- </div>
- <div id="eases-list" class="ease-visualizer-section"></div>
- </div>
- </div>
- <script type="module" src="index.js"></script>
-</body>
-</html>
diff --git a/examples/easings-visualizer/index.js b/examples/easings-visualizer/index.js
deleted file mode 100644
index 846509bb..00000000
--- a/examples/easings-visualizer/index.js
+++ /dev/null
@@ -1,304 +0,0 @@
-import { animate, createTimeline, eases, createSpring, utils, stagger } from '../../dist/modules/index.js';
-
-function bindInputsToObject(name, obj, onChange = () => {}) {
- const $bindedInputs = document.querySelectorAll(`[data-${ name }]`);
- $bindedInputs.forEach($input => $input.addEventListener('input', event => {
- const prop = event.currentTarget.dataset[name];
- const value = event.currentTarget.value;
- const $sibling = document.querySelectorAll(`[data-${ name }="${ prop }"]`);
- $sibling.forEach($bind => $bind.value = value);
- obj[prop] = value;
- onChange(obj, prop, value);
- }));
- return $bindedInputs;
-}
-
-// SVG curve stuff
-
-function createSvgCurve(strokeWidth = 1) {
- const $svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
- const $curve = document.createElementNS('http://www.w3.org/2000/svg', 'polyline');
- $svg.setAttribute('viewBox', '0 0 100 100');
- $curve.setAttribute('stroke-width', strokeWidth);
- $curve.setAttribute('points', '0 100 50 50 100 0');
- $curve.setAttribute('stroke-linecap', 'round');
- $curve.setAttribute('stroke-linejoin', 'round');
- $curve.setAttribute('fill', 'none');
- $curve.setAttribute('fill-rule', 'evenodd');
- $svg.appendChild($curve);
- return $svg;
-}
-
-function createCurvePoints(maxPoints = 100) {
- const points = [];
- for (let i = 0; i < maxPoints + 1; i++) {
- points.push({
- x: utils.round((i / maxPoints) * 100, 10),
- y: utils.round(100 - ((i / maxPoints) * 100), 10),
- });
- }
- return points;
-}
-
-const $easesEditor = document.querySelector('#eases-editor');
-const $mainCurve = document.querySelector('#ease-curve');
-const $easeName = document.querySelector('#ease-name');
-const $easeList = document.querySelector('#eases-list');
-const mainCurvePoints = createCurvePoints(400);
-const buttonCurvePoints = createCurvePoints(100);
-const buttons = [];
-
-utils.set($mainCurve, { points: coordsToPoints(mainCurvePoints) });
-
-const easesLookup = { createSpring, ...eases };
-
-const easesList = {
- in: [{ name: 'power', value: 1.675, min: 1, max: 10, step: .1 }],
- out: [{ name: 'power', value: 1.675, min: 1, max: 10, step: .1 }],
- inOut: [{ name: 'power', value: 1.675, min: 1, max: 10, step: .1 }],
- inSine: null,
- outSine: null,
- inOutSine: null,
- inQuad: null,
- outQuad: null,
- inOutQuad: null,
- inCubic: null,
- outCubic: null,
- inOutCubic: null,
- inQuart: null,
- outQuart: null,
- inOutQuart: null,
- inQuint: null,
- outQuint: null,
- inOutQuint: null,
- inExpo: null,
- outExpo: null,
- inOutExpo: null,
- inCirc: null,
- outCirc: null,
- inOutCirc: null,
- inBack: [{ name: 'overshoot', value: 1.70158, min: 0, max: 5, step: .01 }],
- outBack: [{ name: 'overshoot', value: 1.70158, min: 0, max: 5, step: .01 }],
- inOutBack: [{ name: 'overshoot', value: 1.70158, min: 0, max: 5, step: .01 }],
- inBounce: null,
- outBounce: null,
- inOutBounce: null,
- inElastic: [
- { name: 'amplitude', value: 1, min: 1, max: 3, step: .01 },
- { name: 'period', value: .3, min: 0, max: 2, step: .01 }
- ],
- outElastic: [
- { name: 'amplitude', value: 1, min: 1, max: 3, step: .01 },
- { name: 'period', value: .3, min: 0, max: 2, step: .01 }
- ],
- inOutElastic: [
- { name: 'amplitude', value: 1, min: 1, max: 3, step: .01 },
- { name: 'period', value: .3, min: 0, max: 2, step: .01 }
- ],
- createSpring: [
- { name: 'mass', value: 1, min: 0, max: 10, step: .01 },
- { name: 'stiffness', value: 100, min: 1, max: 1000, step: 1 },
- { name: 'damping', value: 10, min: .1, max: 50, step: .1 },
- { name: 'velocity', value: 0, min: 0, max: 100, step: .1 },
- ],
- steps: [
- { name: 'steps', value: 10, min: 0, max: 50, step: 1 },
- { name: 'jumpterm', value: 0, min: 0, max: 1, step: 1 }
- ],
- irregular: [
- { name: 'steps', value: 10, min: 0, max: 50, step: 1 },
- { name: 'randomness', value: 1, min: 0, max: 4, step: .001 },
- ],
- cubicBezier: [
- { name: 'x1', value: 0.2, min: 0, max: 1, step: .01 },
- { name: 'y1', value: 2.0, min: -2, max: 3, step: .01 },
- { name: 'x2', value: 0.6, min: 0, max: 1, step: .01 },
- { name: 'y2', value: 0.4, min: -2, max: 3, step: .01 },
- ],
- linear: [
- { name: 'p1', value: 0.00, min: -.5, max: 1.5, step: .01 },
- { name: 'p2', value: 0.50, min: -.5, max: 1.5, step: .01 },
- { name: 'p3', value: 1.00, min: -.5, max: 1.5, step: .01 },
- ],
-}
-
-function createElement(tag, className = null, innerHTML = null) {
- const el = document.createElement(tag);
- if (className) el.className = className;
- if (innerHTML) el.innerHTML = innerHTML;
- return el;
-}
-
-function coordsToPoints(mainCurvePoints) {
- let points = '';
- mainCurvePoints.forEach(p => points += `${p.x} ${p.y} `);
- return points;
-}
-
-const parameters = {
- ease: eases.out,
- name: 'out',
- computedEasing: null,
- easeDuration: 450,
- transitionEasing: 'inOut(3)',
- p1: null,
- p2: null,
- p3: null,
- p4: null,
-}
-
-function animateEasing() {
- const totalDuration = 1250;
- utils.set('.axis-x:not(:first-child)', { opacity: 0 });
- createTimeline({
- defaults: {
- duration: totalDuration,
- ease: 'linear',
- },
- })
- .add('.axis-y', {
- translateX: ['calc(var,(--unit) * 0)', 'calc(var(--unit) * 40)'],
- onUpdate: self => self.targets[0].dataset.value = utils.round(self.progress, 1),
- }, 0)
- .add('.axis-x:first-child', {
- translateY: ['calc(var(--unit) * 0)', 'calc(var(--unit) * -40)'],
- ease: parameters.computedEasing,
- }, 0)
- .set('.axis-x:not(:first-child)', {
- opacity: [0, .2],
- }, stagger([0, totalDuration], { start: 0 }))
-}
-
-function updateCurve($curve, points, ease, params, duration = parameters.easeDuration) {
- const parsedEasing = params ? ease(...params) : ease;
- parameters.computedEasing = parsedEasing;
- utils.set(points, { y: stagger([100, 0], { ease: parsedEasing }) });
- animate($curve, {
- points: coordsToPoints(points),
- duration,
- ease: parameters.transitionEasing,
- composition: duration ? 'add' : 'none',
- modifier: v => utils.round(v, 2)
- });
-}
-
-function updateName(name, ease, params) {
- let easeName = name;
- if (params) {
- easeName += '(';
- params.forEach((p, i) => {
- easeName += p + (i === params.length - 1 ? ')' : ', ');
- });
- }
- $easeName.value = easeName;
-}
-
-function updateParameters(state) {
- let params;
- for (let p in state) {
- if (p === 'p1' || p === 'p2' || p === 'p3' || p === 'p4') {
- const pVal = state[p];
- if (pVal !== null) {
- if (!params) params = [];
- params.push(+pVal);
- }
- }
- }
- const ease = state.name === 'spring' ? params ? state.ease(...params).ease : state.ease().ease : state.ease
- updateCurve($mainCurve, mainCurvePoints, ease, state.name === 'spring' ? undefined : params);
- updateName(state.name, ease, params);
-
- animate('.axis-x:not(:first-child)', {
- translateY: stagger([0, -40], {
- ease: parameters.computedEasing,
- modifier: v => `calc(var(--unit) * ${v}`,
- }),
- duration: parameters.easeDuration,
- ease: parameters.transitionEasing,
- composition: 'add',
- });
-}
-
-const $parameters = bindInputsToObject('parameters', parameters, updateParameters);
-
-function selectEase(name) {
- const easeFunction = easesLookup[name];
- const easeParams = easesList[name];
- parameters.ease = easeFunction;
- parameters.name = name;
- parameters.p1 = null;
- parameters.p2 = null;
- parameters.p3 = null;
- parameters.p4 = null;
- const $legends = document.querySelectorAll('.parameter-legend');
- $parameters.forEach($el => $el.disabled = true);
- $legends.forEach(($el, i) => {$el.disabled = true; $el.textContent = '--'});
- if (easeParams) {
- easeParams.forEach((p, i) => {
- const propName = 'p' + (i + 1);
- const $ps = document.querySelectorAll(`[data-parameters=${ propName }]`);
- $ps.forEach($p => {
- $p.disabled = false;
- $p.min = p.min;
- $p.max = p.max;
- $p.step = p.step;
- $p.value = p.value;
- });
- $legends[i].innerHTML = '&#9881;&#xFE0E; ' + p.name;
- parameters[propName] = p.value;
- });
- }
- const $button = document.querySelector('.ease-' + name);
- buttons.forEach($el => $el.classList.remove('is-active'));
- $button.classList.add('is-active');
- utils.set('.axis-x:not(:first-child)', { opacity: 0 });
- updateParameters(parameters);
-}
-
-function createEaseButton(name, ease, hasParams) {
- const $button = createElement('button', 'ease-button');
- const $name = createElement('span', 'ease-name', name);
- const $svgCurve = createSvgCurve(2);
- updateCurve($svgCurve.querySelector('polyline'), buttonCurvePoints, ease, null, 0);
- $button.classList.add('ease-' + name);
- $button.appendChild($svgCurve);
- $button.appendChild($name);
- if (hasParams) {
- $button.appendChild(createElement('span', 'ease-config', '&#9881;&#xFE0E;'));
- }
- $button.onclick = () => {
- if (name !== parameters.name) {
- selectEase(name);
- }
- if (window.innerWidth < 639) {
- window.scroll({
- top: 0,
- left: 0,
- behavior: 'smooth'
- });
- }
- animateEasing();
-
- }
- return $button;
-}
-
-for (let easeName in easesList) {
- const params = easesList[easeName];
- let ease = easesLookup[easeName];
- if (easeName === 'spring') {
- ease = ease().solver;
- } else if (easeName === 'cubicBezier') {
- ease = ease(0.2, 2.0, 0.6, 0.4);
- } else if (params) {
- ease = ease();
- }
- const $button = createEaseButton(easeName, ease, params);
- $easeList.appendChild($button);
- buttons.push($button);
-}
-
-selectEase('out');
-animateEasing();
-
-$easesEditor.onclick = animateEasing;
diff --git a/examples/irregular-playback-typewriter/index.html b/examples/irregular-playback-typewriter/index.html
index 22083c41..abe92365 100644
--- a/examples/irregular-playback-typewriter/index.html
+++ b/examples/irregular-playback-typewriter/index.html
@@ -41,7 +41,7 @@
bottom: 0px;
left: 1ch;
width: 2px;
- background-color: var(--red);
+ background-color: var(--red-1);
}
</style>
</head>
diff --git a/examples/onscroll-sticky/index.js b/examples/onscroll-sticky/index.js
index 66d3a5f4..0bfd06eb 100644
--- a/examples/onscroll-sticky/index.js
+++ b/examples/onscroll-sticky/index.js
@@ -6,11 +6,27 @@ import {
animate,
} from '../../dist/modules/index.js';
-utils.set('.card', {
- rotate: () => utils.random(-1, 1, 2),
- rotateZ: () => utils.random(-1, 1, 2),
- y: stagger(-.5, { from: 'last' }),
- z: stagger(1),
+const $cards = utils.$('.card');
+const $spinners = $cards.map($card => {
+ const $spinner = document.createElement('div');
+ $spinner.className = 'spinner';
+ $spinner.style.position = 'absolute';
+ $spinner.style.top = '0';
+ $spinner.style.left = '0';
+ $spinner.style.width = '100%';
+ $spinner.style.height = '100%';
+ $spinner.style.transformStyle = 'preserve-3d';
+ $card.parentElement?.insertBefore($spinner, $card);
+ $spinner.appendChild($card);
+ return $spinner;
+});
+
+$spinners.forEach(($spinner, i) => {
+ const rotate = utils.random(-1, 1, 2);
+ const rotateZ = utils.random(-1, 1, 2);
+ const yOffset = -.5 * ($spinners.length - 1 - i);
+ utils.set($spinner, { rotate, rotateZ, z: i });
+ utils.set($cards[i], { translateY: yOffset });
});
const brightness = v => `brightness(${v})`;
@@ -36,16 +52,19 @@ createTimeline({
rotateY: [-180, 0],
ease: 'in(2)',
}, 0)
-.add('.card', {
+.add('.spinner', {
rotate: 0,
rotateZ: { to: stagger([0, -360], { from: 'last' }), ease: 'inOut(2)' },
- y: { to: '-60%', duration: 400 },
transformOrigin: ['50% 100%', '50% 50%'],
delay: stagger(1, { from: 'first' }),
}, 0)
+.add('.card', {
+ y: { to: '-60%', duration: 400 },
+ delay: stagger(1, { from: 'first' }),
+}, 0)
.init()
-utils.$('.card').forEach($card => {
+$cards.forEach($card => {
$card.onmouseenter = () => animate($card, {
y: '-70%', duration: 350, composition: 'blend',
});
diff --git a/examples/text/scramble-tl/index.html b/examples/text/scramble-tl/index.html
index c3647fbc..ea853958 100644
--- a/examples/text/scramble-tl/index.html
+++ b/examples/text/scramble-tl/index.html
@@ -10,7 +10,7 @@
"imports": {
"animejs": "../../../dist/modules/index.js",
"tweaks": "../../../node_modules/tweaks/tweaks.js",
- "tweaks/gui": "../../../node_modules/tweaks/gui.js"
+ "tweaks/gui": "../../../node_modules/tweaks/gui/index.js"
}
}
</script>
diff --git a/examples/text/scramble/index.html b/examples/text/scramble/index.html
index 916dba1c..20631dcc 100644
--- a/examples/text/scramble/index.html
+++ b/examples/text/scramble/index.html
@@ -9,7 +9,7 @@
{
"imports": {
"tweaks": "../../../node_modules/tweaks/tweaks.js",
- "tweaks/gui": "../../../node_modules/tweaks/gui.js"
+ "tweaks/gui": "../../../node_modules/tweaks/gui/index.js"
}
}
</script>
@@ -28,6 +28,7 @@
display: flex;
flex-direction: column;
gap: 24px;
+ backface-visibility: hidden;
}
h1 {
diff --git a/examples/text/scramble/index.js b/examples/text/scramble/index.js
index af577d03..9a036c35 100644
--- a/examples/text/scramble/index.js
+++ b/examples/text/scramble/index.js
@@ -9,7 +9,7 @@ syncTweaks('localStorage');
const Override = registerType('Override', false);
const overrideModes = { false: 0, true: 0, string: 0 };
-registerTypeGUI('Override', (prop, labelKey) => {
+registerTypeGUI('Override', (/** @type {any} */prop, labelKey) => {
if (!prop.list) prop.list = { mode: 'false', text: '', src: undefined };
const s = prop.list;
if (s.src !== prop.value) {
diff --git a/examples/text/split-effects/index.html b/examples/text/split-effects/index.html
index cbb40d51..0f5822d8 100644
--- a/examples/text/split-effects/index.html
+++ b/examples/text/split-effects/index.html
@@ -5,6 +5,14 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="../../assets/css/styles.css" rel="stylesheet">
+ <script type="importmap">
+ {
+ "imports": {
+ "tweaks": "../../../node_modules/tweaks/tweaks.js",
+ "tweaks/gui": "../../../node_modules/tweaks/gui/index.js"
+ }
+ }
+ </script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:[email protected]&display=swap" rel="stylesheet">
@@ -51,12 +59,7 @@
Wave propagation and fluid dynamics encompass several interconnected physical phenomena that govern how water moves through oceanic systems, demonstrating the fundamental principles of energy transfer and momentum conservation. Wave "continuation" describes how energy persists through water long after the initial disturbance has passed, with individual water particles following elliptical orbital paths that decrease in amplitude with depth, creating the illusion of forward motion while actually moving in circular patterns. "Differential flow" occurs because various layers of water move at different velocities—surface currents respond to wind stress differently than deeper thermohaline circulation, and coastal waters behave distinctly from open ocean systems. A related phenomenon is "hydrodynamic lag," where water masses respond gradually to driving forces, whether from atmospheric pressure, gravitational pull, or temperature gradients. This lag affects everything from floating objects like debris and marine organisms to distinct water bodies themselves, such as upwelling zones and convergence areas. In oceanic circulation, deep water acts as the primary driver, with surface waves, spray, and foam representing secondary responses to local conditions. Water masses with different densities, such as warm surface layers and cold deep currents, or areas with varying salinity, exhibit more independent behavior than uniform water columns. Extreme manifestations of these forces create phenomena like rogue waves and storm surges, while calmer conditions require precise balance between competing forces to maintain stable patterns. Even apparently static water bodies demonstrate constant motion through molecular vibration, thermal convection, and microscopic currents that prevent true stagnation and maintain the ocean's dynamic equilibrium.
</p>
</main>
- <fieldset>
- <button id="revert">REVERT</button>
- <button id="split">SPLIT & ANIMATE</button>
- <button id="reorder">TIDY UP</button>
- <button id="debug">SHOW DEBUG</button>
- </fieldset>
+
<script type="module" src="./index.js"></script>
</body>
</html>
\ No newline at end of file
diff --git a/examples/text/split-effects/index.js b/examples/text/split-effects/index.js
index 8ae0f738..c1671b38 100644
--- a/examples/text/split-effects/index.js
+++ b/examples/text/split-effects/index.js
@@ -6,28 +6,24 @@ import {
utils,
} from '../../../dist/modules/index.js';
-const coords = [];
-const [ $revert ] = utils.$('#revert');
-const [ $split ] = utils.$('#split');
-const [ $reorder ] = utils.$('#reorder');
-const [ $debug ] = utils.$('#debug');
+import { GUI } from 'tweaks/gui';
-$revert.disabled = true;
-$split.disabled = false;
-$reorder.disabled = true;
+const coords = [];
let split;
+let isSplit = false;
+let canReorder = false;
-const splitAndAnimate = () => {
- $revert.disabled = false;
- $split.disabled = true;
+const splitAndAnimate = (debug = false) => {
+ isSplit = true;
+ canReorder = false;
split = splitText('p', {
lines: true,
+ debug,
});
split.addEffect(split => {
- // Returning the timeline syncs it with the splitter between lines split
return createTimeline({
defaults: {
alternate: true,
@@ -38,7 +34,7 @@ const splitAndAnimate = () => {
},
})
.add(split.lines, {
- color: { from: '#61C3FF' },
+ color: { from: 'var(--sega-1)' },
y: -10,
scale: 1.1,
}, stagger(100, { start: 0 }))
@@ -53,7 +49,7 @@ const splitAndAnimate = () => {
const c = coords[i];
if (c) utils.set($el, { x: c.x, y: c.y });
$el.addEventListener('pointerenter', () => {
- $reorder.disabled = false;
+ canReorder = true;
animate($el, {
x: utils.random(-50, 50),
y: utils.random(-50, 50),
@@ -61,32 +57,43 @@ const splitAndAnimate = () => {
});
});
return () => {
- // Store the words coordinates before the new split
split.words.forEach((w, i) => coords[i] = { x: utils.get(w, 'x'), y: utils.get(w, 'y') });
}
});
-}
-
-splitAndAnimate();
+};
-$revert.addEventListener('click', () => {
+const revert = () => {
+ if (!split) return;
split.revert();
coords.length = 0;
- $revert.disabled = true;
- $split.disabled = false;
-});
+ isSplit = false;
+ canReorder = false;
+};
-$split.addEventListener('click', splitAndAnimate);
+const reorder = () => {
+ if (!split) return;
+ animate(split.words, { x: 0, y: 0, ease: 'inOutExpo' });
+ canReorder = false;
+};
-$reorder.addEventListener('click', () => {
- animate(split.words, {
- x: 0, y: 0, ease: 'inOutExpo'
- });
- $reorder.disabled = true;
-});
+splitAndAnimate();
-$debug.addEventListener('click', () => {
- split.debug = !split.debug;
- split.refresh();
- $debug.innerText = split.debug ? 'HIDE DEBUG' : 'SHOW DEBUG';
+GUI.render(() => {
+ if (!GUI.BeginPanel('Split effects')) return;
+ const debugRef = GUI.Ref('debug', false);
+ GUI.BeginGroup('actions', 'div.row');
+ if (isSplit) {
+ if (GUI.ButtonInput('Revert')) revert();
+ } else {
+ if (GUI.ButtonInput('Split')) splitAndAnimate(debugRef());
+ }
+ if (canReorder) {
+ if (GUI.ButtonInput('Tidy up')) reorder();
+ }
+ if (GUI.ToggleButtonInput('Debug', debugRef) && split) {
+ split.debug = debugRef();
+ split.refresh();
+ }
+ GUI.EndGroup('actions');
+ GUI.EndPanel();
});
diff --git a/examples/text/split-playground/index.html b/examples/text/split-playground/index.html
index 85f9e954..b495b63d 100644
--- a/examples/text/split-playground/index.html
+++ b/examples/text/split-playground/index.html
@@ -8,11 +8,20 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:[email protected]&display=swap" rel="stylesheet">
+ <script type="importmap">
+ {
+ "imports": {
+ "tweaks": "../../../node_modules/tweaks/tweaks.js",
+ "tweaks/gui": "../../../node_modules/tweaks/gui/index.js"
+ }
+ }
+ </script>
<style>
body {
opacity: 0;
display: flex;
flex-direction: row;
+ justify-content: center;
gap: 2rem;
width: 100%;
min-height: 100dvh;
@@ -23,52 +32,11 @@
opacity: 1;
}
- aside {
- --border-radius: .75rem;
- justify-self: flex-end;
- width: 12rem;
- border-radius: var(--border-radius);
- }
-
- aside li {
- list-style: none;
- padding: 1rem;
- background-color: #404040;
- margin-bottom: 1px;
- }
-
- aside li:first-child {
- border-top-left-radius: var(--border-radius);
- border-top-right-radius: var(--border-radius);
- }
-
- aside li:last-child {
- border-bottom-left-radius: var(--border-radius);
- border-bottom-right-radius: var(--border-radius);
- }
-
- .field input,
- .field select {
- width: 50%;
- }
-
- .field {
- width: 100%;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
-
- fieldset:disabled .field {
- opacity: .5;
- }
-
main {
display: flex;
flex-direction: row;
justify-content: center;
- gap: 2rem;
- width: calc(100% - 12rem);
+ width: 100%;
}
article {
@@ -101,7 +69,7 @@
}
article a {
- color: var(--red);
+ color: var(--red-1);
text-decoration: underline;
}
@@ -129,10 +97,9 @@
article span:has(p) + span:has(ul) {
margin-top: 1rem;
}
-
</style>
</head>
-<body class="is-debug">
+<body>
<main>
<article>
<h1>An all-in-one text splitter function to easily split, wrap, and clone text<br></h1>
@@ -155,155 +122,6 @@
</p>
</article>
</main>
- <aside id="parameters">
- <form id="splitForm">
- <ul>
- <li>
- <fieldset class="vertical" id="lines-options">
- <legend>
- <label for="lines"><input type="checkbox" id="lines" name="lines"> lines</label>
- </legend>
- <div class="field">
- <label for="lines-wrap">wrap</label>
- <select id="lines-wrap" name="lines-wrap">
- <option value="false">false</option>
- <option value="clip">clip</option>
- <option value="visible">visible</option>
- </select>
- </div>
- <div class="field">
- <label for="lines-clone">clone</label>
- <select id="lines-clone" name="lines-clone">
- <option value="false">false</option>
- <option value="top">top</option>
- <option value="right">right</option>
- <option value="bottom">bottom</option>
- <option value="left">left</option>
- </select>
- </div>
- <div class="field">
- <label for="lines-animate">animate</label>
- <select id="lines-animate" name="lines-animate">
- <option value="false">false</option>
- <option value="250">200ms</option>
- <option value="500">500ms</option>
- <option value="750">750ms</option>
- <option value="1000">1000ms</option>
- </select>
- </div>
- <div class="field">
- <label for="lines-stagger">stagger</label>
- <select id="lines-stagger" name="lines-stagger">
- <option value="10">10</option>
- <option value="50">50</option>
- <option value="200">200</option>
- <option value="random">random</option>
- </select>
- </div>
- </fieldset>
- </li>
- <li>
- <fieldset class="vertical" id="words-options">
- <legend>
- <label for="words"><input type="checkbox" id="words" name="words" checked> words</label>
- </legend>
- <div class="field">
- <label for="words-wrap">wrap</label>
- <select id="words-wrap" name="words-wrap">
- <option value="false">false</option>
- <option value="clip">clip</option>
- <option value="visible">visible</option>
- </select>
- </div>
- <div class="field">
- <label for="words-clone">clone</label>
- <select id="words-clone" name="words-clone">
- <option value="false">false</option>
- <option value="top">top</option>
- <option value="right">right</option>
- <option value="bottom">bottom</option>
- <option value="left">left</option>
- </select>
- </div>
- <div class="field">
- <label for="words-animate">animate</label>
- <select id="words-animate" name="words-animate">
- <option value="false">false</option>
- <option value="250">250ms</option>
- <option value="500">500ms</option>
- <option value="750">750ms</option>
- <option value="1000">1000ms</option>
- </select>
- </div>
- <div class="field">
- <label for="words-stagger">stagger</label>
- <select id="words-stagger" name="words-stagger">
- <option value="10">10</option>
- <option value="50">50</option>
- <option value="200">200</option>
- <option value="random">random</option>
- </select>
- </div>
- </fieldset>
- </li>
- <li>
- <fieldset class="vertical" id="chars-options">
- <legend>
- <label for="chars"><input type="checkbox" id="chars" name="chars"> chars</label>
- </legend>
- <div class="field">
- <label for="chars-wrap">wrap</label>
- <select id="chars-wrap" name="chars-wrap">
- <option value="false">false</option>
- <option value="clip">clip</option>
- <option value="visible">visible</option>
- </select>
- </div>
- <div class="field">
- <label for="chars-clone">clone</label>
- <select id="chars-clone" name="chars-clone">
- <option value="false">false</option>
- <option value="top">top</option>
- <option value="right">right</option>
- <option value="bottom">bottom</option>
- <option value="left">left</option>
- </select>
- </div>
- <div class="field">
- <label for="chars-animate">animate</label>
- <select id="chars-animate" name="chars-animate">
- <option value="false">false</option>
- <option value="250">250ms</option>
- <option value="500">500ms</option>
- <option value="750">750ms</option>
- <option value="1000">1000ms</option>
- </select>
- </div>
- <div class="field">
- <label for="chars-stagger">stagger</label>
- <select id="chars-stagger" name="chars-stagger">
- <option value="10">10</option>
- <option value="50">50</option>
- <option value="200">200</option>
- <option value="random">random</option>
- </select>
- </div>
- </fieldset>
- </li>
- <li>
- <label for="includeSpaces"><input type="checkbox" id="includeSpaces" name="includeSpaces"> includeSpaces</label>
- <label for="accessible"><input type="checkbox" id="accessible" name="accessible" checked> accessible</label>
- <label for="debug"><input type="checkbox" id="debug" name="debug" checked> debug</label>
- </li>
- <li>
- <fieldset>
- <button type="button" class="button" id="revert" name="revert">Revert</button>
- <button type="button" class="button" id="split" name="revert">Split</button>
- </fieldset>
- </li>
- </ul>
- </form>
- </aside>
<script type="module" src="./index.js"></script>
</body>
-</html>
\ No newline at end of file
+</html>
diff --git a/examples/text/split-playground/index.js b/examples/text/split-playground/index.js
index 77297d03..cd773b51 100644
--- a/examples/text/split-playground/index.js
+++ b/examples/text/split-playground/index.js
@@ -1,93 +1,114 @@
import {
animate,
- createTimeline,
- createScope,
stagger,
splitText,
- utils,
- Scope,
} from '../../../dist/modules/index.js';
+import { createTweaks, syncTweaks, Bool, Select } from 'tweaks';
+import { GUI } from 'tweaks/gui';
-let split;
+syncTweaks('localStorage');
+
+const wrapOptions = ['false', 'clip', 'visible'];
+const cloneOptions = ['false', 'top', 'right', 'bottom', 'left'];
+const animateOptions = ['false', '250', '500', '750', '1000'];
+const staggerOptions = ['10', '50', '200', 'random'];
-const form = document.getElementById('splitForm');
-const $revert = document.getElementById('revert');
-const $split = document.getElementById('split');
+const typeSchema = (enabled) => ({
+ enabled: Bool(enabled),
+ wrap: Select(wrapOptions),
+ clone: Select(cloneOptions),
+ animate: Select(animateOptions),
+ stagger: Select(staggerOptions),
+});
-const config = {
- split: {
- lines: false,
- words: false,
- chars: false,
- includeSpaces: false,
- accessible: false,
- debug: false
- },
- animation: {
- lines: false,
- words: false,
- chars: false,
+const splitTweaks = createTweaks('Split', {
+ lines: typeSchema(false),
+ words: typeSchema(true),
+ chars: typeSchema(false),
+ config: {
+ includeSpaces: Bool(false),
+ accessible: Bool(true),
+ debug: Bool(true),
}
-};
+});
-const animateSplit = (targets, type) => {
- const param = config.split[type];
- const anim = config.animation[type];
- const dir = param.clone;
- const randomStagger = anim.stagger === 'random';
+let split;
+
+const animateSplit = (targets, opts) => {
+ const dir = opts.clone;
+ const randomStagger = opts.stagger === 'random';
return animate(targets, {
x: dir === 'left' ? '100%' : dir === 'right' ? '-100%' : 0,
- y: dir === 'top' ? '100%' : dir === 'bottom' ? '-100%' : !dir ? '-100%' : 0,
+ y: dir === 'top' ? '100%' : dir === 'bottom' ? '-100%' : !dir ? '-100%' : 0,
loop: true,
alternate: true,
- duration: anim.duration,
- delay: stagger(randomStagger ? 10 : anim.stagger, { from: randomStagger ? 'random' : 0 }),
+ duration: opts.duration,
+ delay: stagger(randomStagger ? 10 : +opts.stagger, { from: randomStagger ? 'random' : 0 }),
});
-}
-
-function updateSplitConfig() {
- const data = new FormData(/** @type {HTMLFormElement} */(document.getElementById('splitForm')));
+};
- ['lines', 'words', 'chars'].forEach(type => {
- config.split[type] = false;
- if (data.has(type)) {
- const wrap = data.get(`${type}-wrap`);
- const clone = data.get(`${type}-clone`);
- const animate = data.get(`${type}-animate`);
- config.split[type] = {
- wrap: wrap === 'false' ? false : wrap,
- clone: clone === 'false' ? false : clone
- };
- config.animation[type] = !+animate ? false : {
- duration: +animate,
- stagger: data.get(`${type}-stagger`)
- };
- }
- });
+const buildTypeOptions = (group) => {
+ if (!group.enabled) return false;
+ const wrap = group.wrap;
+ const clone = group.clone;
+ return {
+ wrap: wrap === 'false' ? false : wrap,
+ clone: clone === 'false' ? false : clone,
+ };
+};
- config.split.includeSpaces = data.has('includeSpaces');
- config.split.accessible = data.has('accessible');
- config.split.debug = data.has('debug');
+const buildAnimOptions = (group) => {
+ if (!group.enabled || group.animate === 'false') return false;
+ return {
+ duration: +group.animate,
+ stagger: group.stagger,
+ clone: group.clone === 'false' ? false : group.clone,
+ };
+};
+const apply = () => {
if (split) split.revert();
-
- split = splitText('article', { ...config.split })
- .addEffect(self => config.animation.lines && self.lines.length && animateSplit(self.lines, 'lines'))
- .addEffect(self => config.animation.words && self.words.length && animateSplit(self.words, 'words'))
- .addEffect(self => config.animation.chars && self.chars.length && animateSplit(self.chars, 'chars'))
- $revert.removeAttribute('disabled');
-}
+ const params = {
+ lines: buildTypeOptions(splitTweaks.lines),
+ words: buildTypeOptions(splitTweaks.words),
+ chars: buildTypeOptions(splitTweaks.chars),
+ includeSpaces: splitTweaks.includeSpaces,
+ accessible: splitTweaks.accessible,
+ debug: splitTweaks.debug,
+ };
+ split = splitText('article', params);
+ const linesAnim = buildAnimOptions(splitTweaks.lines);
+ const wordsAnim = buildAnimOptions(splitTweaks.words);
+ const charsAnim = buildAnimOptions(splitTweaks.chars);
+ if (linesAnim) split.addEffect(self => self.lines.length && animateSplit(self.lines, linesAnim));
+ if (wordsAnim) split.addEffect(self => self.words.length && animateSplit(self.words, wordsAnim));
+ if (charsAnim) split.addEffect(self => self.chars.length && animateSplit(self.chars, charsAnim));
+};
document.fonts.ready.then(() => {
document.body.classList.add('is-ready');
- ['lines', 'words', 'chars'].forEach(type => {
- const checkbox = /** @type {HTMLInputElement} */(document.getElementById(type));
- const fieldset = /** @type {HTMLInputElement} */(document.getElementById(`${type}-options`));
- checkbox.addEventListener('change', () => fieldset.disabled = !checkbox.checked);
- fieldset.disabled = !checkbox.checked;
- });
- form.addEventListener('change', updateSplitConfig);
- $revert.addEventListener('click', () => {split && split.revert(); $revert.setAttribute('disabled', 'false'); });
- $split.addEventListener('click', updateSplitConfig);
- updateSplitConfig();
+ apply();
+ const serialize = () => JSON.stringify(splitTweaks);
+ let lastKey = serialize();
+ function tick() {
+ const key = serialize();
+ if (key !== lastKey) {
+ lastKey = key;
+ apply();
+ }
+ requestAnimationFrame(tick);
+ }
+ tick();
+});
+
+GUI.render(() => {
+ if (!GUI.BeginPanel('Split playground')) return;
+ GUI.Tweaks(splitTweaks);
+ GUI.BeginGroup('actions', 'div.row');
+ if (GUI.ButtonInput('Revert')) {
+ if (split) split.revert();
+ }
+ if (GUI.ButtonInput('Re-split')) apply();
+ GUI.EndGroup('actions');
+ GUI.EndPanel();
});
diff --git a/examples/threejs/transforms/index.html b/examples/threejs/transforms/index.html
new file mode 100644
index 00000000..f66a6a9e
--- /dev/null
+++ b/examples/threejs/transforms/index.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>three.js transforms / Anime.js</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+ <link href="../../assets/css/styles.css" rel="stylesheet">
+ <style>
+ html, body { margin: 0; padding: 0; height: 100%; background: var(--bg-1); overflow: hidden; }
+ canvas { display: block; }
+ </style>
+ <script type="importmap">
+ {
+ "imports": {
+ "three": "https://unpkg.com/[email protected]/build/three.module.js",
+ "three/addons/": "https://unpkg.com/[email protected]/examples/jsm/",
+ "tweaks": "../../../node_modules/tweaks/tweaks.js",
+ "tweaks/gui": "../../../node_modules/tweaks/gui/index.js"
+ }
+ }
+ </script>
+</head>
+<body>
+<script type="module" src="./index.js"></script>
+</body>
+</html>
diff --git a/examples/threejs/transforms/index.js b/examples/threejs/transforms/index.js
new file mode 100644
index 00000000..5726b73b
--- /dev/null
+++ b/examples/threejs/transforms/index.js
@@ -0,0 +1,220 @@
+import {
+ Scene, WebGLRenderer, PerspectiveCamera, GridHelper,
+ Mesh, BoxGeometry, MeshStandardMaterial, InstancedMesh,
+ AmbientLight, DirectionalLight,
+} from 'three';
+import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
+
+import { animate, createTimer, utils } from '../../../dist/modules/index.js';
+
+// Side-effect import: registers the Object3D / Material / Instance adapters so
+// animate() / utils.set() accept raw three.js meshes and per-instance adapters.
+import { getInstances } from '../../../dist/modules/adapters/three/index.js';
+
+import { syncTweaks } from 'tweaks';
+import { GUI } from 'tweaks/gui';
+
+syncTweaks('localStorage');
+
+// Scene + renderer. Colors come from the shared `examples/assets/css/styles.css` palette via `utils.set` and the engine's `var()` resolution path.
+
+const scene = new Scene();
+utils.set(scene, { background: 'var(--bg-1)' });
+
+const camera = new PerspectiveCamera(45, innerWidth / innerHeight, 0.1, 100);
+camera.position.set(0, 7, 14);
+
+const renderer = new WebGLRenderer({ antialias: true });
+renderer.setSize(innerWidth, innerHeight);
+renderer.setPixelRatio(window.devicePixelRatio || 1);
+document.body.appendChild(renderer.domElement);
+addEventListener('resize', () => {
+ camera.aspect = innerWidth / innerHeight;
+ camera.updateProjectionMatrix();
+ renderer.setSize(innerWidth, innerHeight);
+});
+
+const controls = new OrbitControls(camera, renderer.domElement);
+controls.target.set(0, 1, 0);
+controls.enableDamping = true;
+controls.update();
+
+// Floor: 20x20 grid, 1 unit per square. Vertex colors are white so `material.color` acts as the effective color (it multiplies vertex colors in the shader).
+// Offset by 0.5 in x and z so the grid lines align with the cube faces.
+const grid = new GridHelper(20, 20, 0xffffff, 0xffffff);
+grid.position.set(0.5, -0.5, 0.5);
+scene.add(grid);
+utils.set(grid, { color: 'var(--fg-4)' });
+
+// Lights
+scene.add(new AmbientLight(0xffffff, 0.5));
+const dir = new DirectionalLight(0xffffff, 1.4);
+dir.position.set(6, 12, 8);
+scene.add(dir);
+
+// Shared animation defaults
+const D = { duration: 2000, loop: true, alternate: true, ease: 'inOutSine' };
+const ROT_D = { duration: 3000, loop: true, ease: 'linear' };
+
+const SHOWCASE_ANIM = {
+ x: [0, -1, 1, 0],
+ y: [3, 2, 4, 3],
+ z: [0, -1, 1, 0],
+ rotateX: [0, -180, 180, 0],
+ rotateY: [0, -180, 180, 0],
+ rotateZ: [0, -180, 180, 0],
+ scaleX: [1, 2, -2, 1],
+ scaleY: [1, 2, -2, 1],
+ scaleZ: [1, 2, -2, 1],
+ skewX: [0, -30, 30, 0],
+ skewY: [0, -30, 30, 0],
+ skewZ: [0, -30, 30, 0],
+ transformOrigin: ['0 0 0', '-0.5 -0.5 -0.5', '0.5 0.5 0.5', '0 0 0'],
+ color: ['var(--orange-1)', 'var(--red-1)', 'var(--lime-1)', 'var(--orange-1)'],
+ duration: 4000,
+ loop: true,
+ ease: 'inOutSine',
+};
+
+// Cube specs: one entry per cube. Used identically by both modes; only the
+// underlying target type (Mesh vs Instance) differs.
+const cubeSpecs = [
+ // Row 1 (z = -4): position x / y / z / all
+ { pos: [-3, 0, -4], color: '--red-1', anim: { x: [-4, -2], ...D } },
+ { pos: [-1, 0, -4], color: '--red-1', anim: { y: [0, 2], ...D } },
+ { pos: [ 1, 0, -4], color: '--red-1', anim: { z: [-5, -3], ...D } },
+ { pos: [ 3, 0, -4], color: '--red-1', anim: { x: [2, 4], y: [0, 2], z: [-5, -3], ...D } },
+
+ // Row 2 (z = -2): rotateX / rotateY / rotateZ / all
+ { pos: [-3, 0, -2], color: '--red-1', anim: { rotateX: 360, ...ROT_D } },
+ { pos: [-1, 0, -2], color: '--red-1', anim: { rotateY: 360, ...ROT_D } },
+ { pos: [ 1, 0, -2], color: '--red-1', anim: { rotateZ: 360, ...ROT_D } },
+ { pos: [ 3, 0, -2], color: '--red-1', anim: { rotateX: 360, rotateY: 360, rotateZ: 360, ...ROT_D } },
+
+ // Row 3 (z = 0): scaleX / scaleY / scaleZ / scale
+ { pos: [-3, 0, 0], color: '--red-1', anim: { scaleX: [0.5, 1.5], ...D } },
+ { pos: [-1, 0, 0], color: '--red-1', anim: { scaleY: [0.5, 1.5], ...D } },
+ { pos: [ 1, 0, 0], color: '--red-1', anim: { scaleZ: [0.5, 1.5], ...D } },
+ { pos: [ 3, 0, 0], color: '--red-1', anim: { scale: [0.5, 1.5], ...D } },
+
+ // Row 4 (z = 2): skewX / skewY / skewZ / all
+ { pos: [-3, 0, 2], color: '--red-1', anim: { skewX: [-30, 30], ...D } },
+ { pos: [-1, 0, 2], color: '--red-1', anim: { skewY: [-30, 30], ...D } },
+ { pos: [ 1, 0, 2], color: '--red-1', anim: { skewZ: [-30, 30], ...D } },
+ { pos: [ 3, 0, 2], color: '--red-1', anim: { skewX: [-30, 30], skewY: [30, -30], skewZ: [-30, 30], ...D } },
+
+ // Row 5 (z = 4): transformOrigin in combination with scale
+ { pos: [-3, 0, 4], color: '--red-1', staticOrigin: [-0.5, 0, 0], anim: { scaleX: [0.2, 1.2], ...D } },
+ { pos: [-1, 0, 4], color: '--red-1', staticOrigin: [0, -0.5, 0], anim: { scaleY: [0.2, 1.2], ...D } },
+ { pos: [ 1, 0, 4], color: '--red-1', staticOrigin: [0, 0, -0.5], anim: { scaleZ: [0.2, 1.2], ...D } },
+ { pos: [ 3, 0, 4], color: '--red-1', staticScale: 0.5, anim: { transformOriginX: [-1, 1], ...D } },
+
+ // Showcase (above the grid): combines every transform.
+ { pos: [0, 3, 0], color: '--orange-1', anim: SHOWCASE_ANIM },
+];
+
+// Per-spec target setup. `target` is either a Mesh or an Instance; both expose
+// the same flat properties through the adapter system.
+const setupTarget = (target, spec) => {
+ utils.set(target, {
+ x: spec.pos[0],
+ y: spec.pos[1],
+ z: spec.pos[2],
+ color: `var(${spec.color})`,
+ });
+ if (spec.staticOrigin) {
+ utils.set(target, {
+ transformOriginX: spec.staticOrigin[0],
+ transformOriginY: spec.staticOrigin[1],
+ transformOriginZ: spec.staticOrigin[2],
+ });
+ }
+ if (spec.staticScale != null) {
+ utils.set(target, { scale: spec.staticScale });
+ }
+};
+
+// Per-mode scene state. Holds whatever was added to the scene + the live tween
+// handles, so `tearDown()` can dispose / cancel cleanly between mode swaps.
+const state = {
+ added: /** @type {import('three').Object3D[]} */([]),
+ geometries: /** @type {import('three').BufferGeometry[]} */([]),
+ materials: /** @type {import('three').Material[]} */([]),
+ animations: /** @type {Array<ReturnType<typeof animate>>} */([]),
+};
+
+const tearDown = () => {
+ for (let i = 0; i < state.animations.length; i++) state.animations[i].cancel();
+ state.animations.length = 0;
+ for (let i = 0; i < state.added.length; i++) scene.remove(state.added[i]);
+ state.added.length = 0;
+ for (let i = 0; i < state.geometries.length; i++) state.geometries[i].dispose();
+ state.geometries.length = 0;
+ for (let i = 0; i < state.materials.length; i++) state.materials[i].dispose();
+ state.materials.length = 0;
+};
+
+const buildMeshMode = () => {
+ for (let i = 0; i < cubeSpecs.length; i++) {
+ const spec = cubeSpecs[i];
+ const geo = new BoxGeometry(1, 1, 1);
+ // Fresh material per mesh so `utils.set(cube, { color })` writes don't collide.
+ const mat = new MeshStandardMaterial({ color: 0xffffff, roughness: 0.5, metalness: 0.05 });
+ const cube = new Mesh(geo, mat);
+ scene.add(cube);
+ state.added.push(cube);
+ state.geometries.push(geo);
+ state.materials.push(mat);
+ setupTarget(cube, spec);
+ state.animations.push(animate(cube, spec.anim));
+ }
+};
+
+const buildInstancedMode = () => {
+ // Single InstancedMesh hosts every cube. Geometry and material shared; per-instance
+ // colors flow through `instanceColor` (uploaded via setColorAt by the Instance adapter).
+ const geo = new BoxGeometry(1, 1, 1);
+ const mat = new MeshStandardMaterial({ color: 0xffffff, roughness: 0.5, metalness: 0.05 });
+ const im = new InstancedMesh(geo, mat, cubeSpecs.length);
+ scene.add(im);
+ state.added.push(im);
+ state.geometries.push(geo);
+ state.materials.push(mat);
+ const instances = getInstances(im);
+ for (let i = 0; i < cubeSpecs.length; i++) {
+ setupTarget(instances[i], cubeSpecs[i]);
+ state.animations.push(animate(instances[i], cubeSpecs[i].anim));
+ }
+};
+
+const setMode = (mode) => {
+ tearDown();
+ if (mode === 'InstancedMesh') buildInstancedMode();
+ else buildMeshMode();
+};
+
+let activeMode = 'Mesh';
+setMode(activeMode);
+
+GUI.render(() => {
+ if (!GUI.BeginPanel('Transforms')) return;
+ const modeRef = GUI.Ref('@mode', 'Mesh');
+ const next = modeRef();
+ GUI.BeginToggleGroup('mode::.width_full', modeRef);
+ GUI.ToggleButtonInput('Mesh');
+ GUI.ToggleButtonInput('InstancedMesh');
+ GUI.EndToggleGroup();
+ if (next !== activeMode) {
+ activeMode = next;
+ setMode(activeMode);
+ }
+ GUI.EndPanel();
+});
+
+createTimer({
+ priority: 0,
+ onUpdate: () => {
+ controls.update();
+ renderer.render(scene, camera);
+ },
+});
diff --git a/examples/timeline-refresh-starlings/index.js b/examples/timeline-refresh-starlings/index.js
index f94cb28c..cf98d315 100644
--- a/examples/timeline-refresh-starlings/index.js
+++ b/examples/timeline-refresh-starlings/index.js
@@ -4,6 +4,12 @@ import {
utils,
} from '../../dist/modules/index.js';
+/**
+ * @import {
+ * JSAnimation,
+ * } from '../../dist/modules/index.js'
+ */
+
const { random, cos, sin, sqrt, PI } = Math;
const count = 2500;
const duration = 3000;
@@ -26,7 +32,7 @@ const tl = createTimeline({
defaults: {
loop: true,
ease: 'inOut(1.3)',
- onLoop: self => self.refresh(),
+ onLoop: self => /** @type {JSAnimation} */(self).refresh(),
},
});
diff --git a/examples/timeline-seamless-loop/index.js b/examples/timeline-seamless-loop/index.js
index bd0f8510..cb7da30d 100644
--- a/examples/timeline-seamless-loop/index.js
+++ b/examples/timeline-seamless-loop/index.js
@@ -5,57 +5,76 @@ const numberOfEls = 500;
const loopDuration = 6000;
const animDuration = loopDuration * .2;
const delay = loopDuration / numberOfEls;
+const RADIUS_VH = 26;
-let tl = createTimeline({
+const posOnCircle = (angleDeg, radiusVh) => {
+ const a = utils.degToRad(angleDeg);
+ return {
+ x: radiusVh * Math.sin(a),
+ y: -radiusVh * Math.cos(a),
+ };
+};
+
+const els = [];
+for (let i = 0; i < numberOfEls; i++) {
+ const el = document.createElement('div');
+ el.classList.add('el');
+ wrapperEl.appendChild(el);
+ els.push(el);
+}
+
+const strengthFn = stagger([0, 1], { ease: 'inOutSine', reversed: true, from: 'center' });
+const angles = els.map((_, i) => (360 / numberOfEls) * i);
+const hues = els.map((_, i) => utils.round(360 / numberOfEls * i, 2));
+const strengths = els.map((el, i) => utils.round(+strengthFn(el, i, els), 100));
+const restPositions = angles.map(a => posOnCircle(a, RADIUS_VH));
+const peakPositions = angles.map((a, i) => posOnCircle(a + 10 * strengths[i], RADIUS_VH * 1.1));
+
+els.forEach((el, i) => {
+ utils.set(el, {
+ backgroundColor: `hsl(${hues[i]},40%,60%)`,
+ translateX: restPositions[i].x + 'vh',
+ translateY: restPositions[i].y + 'vh',
+ rotate: angles[i],
+ scale: 1,
+ });
+});
+
+const tl = createTimeline({
defaults: {
- ease: 'inOutSine',
- loopDelay: (loopDuration * .2) - animDuration,
- duration: animDuration
+ ease: 'inOut(2)',
+ loopDelay: loopDuration - animDuration,
+ duration: animDuration,
},
})
.add(wrapperEl, {
- rotate: -360,
+ // rotate: -360,
loop: true,
duration: 24000,
ease: 'linear',
})
+.add(els, {
+ backgroundColor: [
+ { to: (_, i) => `hsl(${hues[i]},${40 + 20 * strengths[i]}%,${60 + 20 * strengths[i]}%)` },
+ { to: (_, i) => `hsl(${hues[i]},40%,60%)` },
+ ],
+ translateX: [
+ { to: (_, i) => peakPositions[i].x + 'vh' },
+ { to: (_, i) => restPositions[i].x + 'vh' },
+ ],
+ translateY: [
+ { to: (_, i) => peakPositions[i].y + 'vh' },
+ { to: (_, i) => restPositions[i].y + 'vh' },
+ ],
+ rotate: [
+ { to: (_, i) => angles[i] + 10 * strengths[i] },
+ { to: (_, i) => angles[i] },
+ ],
+ scale: [
+ { to: (_, i) => [1, 1 + .25 * strengths[i]] },
+ { to: 1 },
+ ],
+ loop: -1,
+}, stagger(delay, { start: 0 }));
-function createEl(i) {
- let el = document.createElement('div');
- const strength = utils.round(+stagger([0, 1], {
- ease: 'inOutSine',
- reversed: true,
- from: 'center',
- })(el, i, numberOfEls), 100);
- const hue = utils.round(360 / numberOfEls * i, 2);
- const bgColor = 'hsl('+hue+',40%,60%)';
- const rotate = (360 / numberOfEls) * i;
- const translateY = '-100%';
- const scale = 1;
- el.classList.add('el');
- utils.set(el, { backgroundColor: bgColor, rotate, translateY, scale });
- tl.add(el, {
- backgroundColor: [
- {to: 'hsl('+hue+','+(40+(20*strength))+'%,'+(60+(20*strength))+'%)'},
- {to: bgColor}
- ],
- rotate: [
- {to: rotate+(10*strength)},
- {to: rotate}
- ],
- translateY: [
- {to: '-100' - (10 * strength) + '%'},
- {to: translateY}
- ],
- scale: [
- {to: [scale, scale+(.25*strength)]},
- {to: scale}
- ],
- loop: -1,
- }, delay * i);
- wrapperEl.appendChild(el);
-};
-
-for (let i = 0; i < numberOfEls; i++) createEl(i);
-
-tl.seek(10000);
\ No newline at end of file
+tl.seek(0);
diff --git a/examples/tsconfig.json b/examples/tsconfig.json
new file mode 100644
index 00000000..09b4bb0d
--- /dev/null
+++ b/examples/tsconfig.json
@@ -0,0 +1,10 @@
+{
+ "extends": "../tsconfig.json",
+ "compilerOptions": {
+ "baseUrl": ".",
+ "strictFunctionTypes": true,
+ "noImplicitReturns": true
+ },
+ "include": ["**/*.js"]
+
+}
diff --git a/package.json b/package.json
index 42829100..7ebe3997 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "animejs",
- "version": "4.4.1",
+ "version": "4.5.0",
"description": "JavaScript animation engine",
"homepage": "https://animejs.com",
"author": "Julian Garnier <[email protected]>",
@@ -36,12 +36,17 @@
"SVG",
"WAAPI",
"Canvas",
- "WebGL"
+ "WebGL",
+ "treejs",
+ "tree.js"
],
"files": [
"dist"
],
- "sideEffects": false,
+ "sideEffects": [
+ "./dist/modules/adapters/**",
+ "./src/adapters/**"
+ ],
"type": "module",
"main": "./dist/modules/index.cjs",
"module": "./dist/modules/index.js",
@@ -175,6 +180,30 @@
"require": "./dist/modules/waapi/index.cjs",
"import": "./dist/modules/waapi/index.js",
"default": "./dist/modules/waapi/index.cjs"
+ },
+ "./adapters": {
+ "types": "./dist/modules/adapters/index.d.ts",
+ "require": "./dist/modules/adapters/index.cjs",
+ "import": "./dist/modules/adapters/index.js",
+ "default": "./dist/modules/adapters/index.cjs"
+ },
+ "./adapters/three": {
+ "types": "./dist/modules/adapters/three/index.d.ts",
+ "require": "./dist/modules/adapters/three/index.cjs",
+ "import": "./dist/modules/adapters/three/index.js",
+ "default": "./dist/modules/adapters/three/index.cjs"
+ }
+ },
+ "peerDependencies": {
+ "three": ">=0.150.0",
+ "@types/three": ">=0.150.0"
+ },
+ "peerDependenciesMeta": {
+ "three": {
+ "optional": true
+ },
+ "@types/three": {
+ "optional": true
}
},
"devDependencies": {
@@ -186,7 +215,8 @@
"mocha": "^10.2.0",
"nodemon": "^3.1.10",
"rollup": "^4.9.1",
- "three": "^0.160.0",
+ "three": "^0.184.0",
+ "@types/three": "^0.184.0",
"tweaks": "^0.3.4",
"typescript": "^5.9.2"
},
@@ -196,6 +226,9 @@
"build": "rm -rf dist && build=true rollup -c && tsc -p tsconfig.types.json && echo '\\n\\033[32m✓ build completed\\n\\033[0m'",
"test:browser": "browser-sync start --startPath tests/index.html --server --files 'dist/modules/**/*.js' 'tests/suites/**/*.js' --no-notify --directory",
"test:node": "node --allow-natives-syntax \"node_modules/.bin/mocha\" -u tdd --timeout 20000 \"./tests/suites/node.test.js\"",
- "open:examples": "browser-sync start --startPath examples --server --no-notify --directory --files '**/*.js'"
+ "open:examples": "browser-sync start --startPath examples --server --no-notify --directory --files '**/*.js'",
+ "typecheck": "tsc -p . && tsc -p tests && tsc -p examples",
+ "typecheck:examples": "tsc -p examples",
+ "typecheck:tests": "tsc -p tests"
}
}
diff --git a/rollup.config.js b/rollup.config.js
index c249aa8a..d1a036b5 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -38,6 +38,7 @@ console.log(inputs);
const tasks = [{
input: inputs,
+ external: ['three'],
output: [
{
dir: 'dist/modules/',
diff --git a/src/adapters/index.js b/src/adapters/index.js
new file mode 100644
index 00000000..53203187
--- /dev/null
+++ b/src/adapters/index.js
@@ -0,0 +1 @@
+export { registerAdapter } from './registry.js';
diff --git a/src/adapters/registry.js b/src/adapters/registry.js
new file mode 100644
index 00000000..7723c377
--- /dev/null
+++ b/src/adapters/registry.js
@@ -0,0 +1,137 @@
+/**
+ * Anime.js adapter API. Each library or class group that wants to extend `animate()` and `utils.set()` calls `registerAdapter()` to create its own `Adapter`. The returned `Adapter` exposes `registerTargetAdapter(detect)` for per-class detection and `registerPropertyResolver(fn)` for global Color / Vector / pattern-based fallbacks.
+ *
+ * import { registerAdapter } from 'animejs/adapters';
+ *
+ * const myAdapter = registerAdapter();
+ * const widget = myAdapter.registerTargetAdapter((t) => t instanceof MyWidget);
+ * widget.registerProperty('value',
+ * (t) => t.getValue(),
+ * (target, value) => target.setValue(value),
+ * );
+ *
+ * For scalar tweens, `value` is the interpolated number. For color and complex tweens it is `undefined`; read `tween._numbers` instead. `gate(target)` scopes the prop to a subset of matching targets.
+ *
+ * Resolution order: every Adapter's target adapters in registration order (first match wins) then every Adapter's property resolvers (first non-null wins) then engine direct property path.
+ */
+
+/**
+ * @typedef TargetAdapterEntry
+ * @property {(t: any) => any} get
+ * @property {(target: any, value: number, tween: any) => void} set
+ * @property {(t: any) => boolean} [gate]
+ */
+
+const alwaysTrue = () => true;
+
+class TargetAdapter {
+ /**
+ * @param {(t: any) => boolean} detect
+ */
+ constructor(detect) {
+ this.detect = detect;
+ /** @type {Record<string, TargetAdapterEntry>} */
+ this.props = {};
+ }
+
+ /**
+ * Registers a property the adapter handles. `setter` receives `(target, value, tween)`. For color and complex tweens `value` is `undefined`, read `tween._numbers` instead. `gate(target)` scopes the prop to a subset of matching targets.
+ *
+ * @param {string} name
+ * @param {(t: any) => any} getter
+ * @param {(target: any, value: number, tween: any) => void} setter
+ * @param {(t: any) => boolean} [gate]
+ */
+ registerProperty(name, getter, setter, gate) {
+ this.props[name] = {
+ get: getter,
+ set: setter,
+ gate: gate || alwaysTrue,
+ };
+ }
+}
+
+class Adapter {
+ /**
+ * @param {((t: any) => boolean) | null} [detect]
+ * Optional gate. When provided, every lookup against this Adapter's target adapters and resolvers is skipped if `detect(target)` returns falsy. Lets the Adapter as a whole short-circuit on unrelated targets.
+ */
+ constructor(detect) {
+ /** @type {((t: any) => boolean) | null} */
+ this.detect = detect || null;
+ /** @type {TargetAdapter[]} */
+ this.targetAdapters = [];
+ /** @type {((target: any, name: string) => TargetAdapterEntry | null)[]} */
+ this.propertyResolvers = [];
+ }
+
+ /**
+ * Creates and registers a `TargetAdapter` scoped to this Adapter.
+ *
+ * @param {(t: any) => boolean} detect
+ * @return {TargetAdapter}
+ */
+ registerTargetAdapter(detect) {
+ const ta = new TargetAdapter(detect);
+ this.targetAdapters.push(ta);
+ return ta;
+ }
+
+ /**
+ * Registers a property resolver scoped to this Adapter. Resolvers are functions invoked at tween creation when no target adapter has claimed the name; the function returns an entry for names it handles or `null` to defer. Use for runtime-matched patterns (Color / Vector axis detection, name-prefix conventions, etc.).
+ *
+ * @param {(target: any, name: string) => TargetAdapterEntry | null} resolver
+ */
+ registerPropertyResolver(resolver) {
+ if (this.propertyResolvers.indexOf(resolver) === -1) this.propertyResolvers.push(resolver);
+ }
+}
+
+const adapters = /** @type {Adapter[]} */([]);
+
+/**
+ * Creates and registers an Adapter. Each library extending `animate()` calls this once and uses the returned Adapter to wire up its target adapters and property resolvers. The optional `detect` short-circuits all lookups against the Adapter when the target is unrelated.
+ *
+ * @param {(t: any) => boolean} [detect]
+ * @return {Adapter}
+ */
+export function registerAdapter(detect) {
+ const a = new Adapter(detect);
+ adapters.push(a);
+ return a;
+}
+
+/**
+ * Internal resolution. Tries every Adapter's target adapters first (in registration order, first match wins), then every Adapter's property resolvers.
+ *
+ * @param {any} target
+ * @param {string} name
+ * @return {TargetAdapterEntry | null}
+ */
+export function resolveAdapterEntry(target, name) {
+ if (!target) return null;
+ const al = adapters.length;
+ outer: for (let i = 0; i < al; i++) {
+ const a = adapters[i];
+ if (a.detect && !a.detect(target)) continue;
+ const tas = a.targetAdapters;
+ for (let j = 0, m = tas.length; j < m; j++) {
+ const ta = tas[j];
+ if (ta.detect(target)) {
+ const entry = ta.props[name];
+ if (entry && (!entry.gate || entry.gate(target))) return entry;
+ break outer;
+ }
+ }
+ }
+ for (let i = 0; i < al; i++) {
+ const a = adapters[i];
+ if (a.detect && !a.detect(target)) continue;
+ const rs = a.propertyResolvers;
+ for (let j = 0, m = rs.length; j < m; j++) {
+ const entry = rs[j](target, name);
+ if (entry) return entry;
+ }
+ }
+ return null;
+}
diff --git a/src/adapters/three/adapter.js b/src/adapters/three/adapter.js
new file mode 100644
index 00000000..ee9890a2
--- /dev/null
+++ b/src/adapters/three/adapter.js
@@ -0,0 +1,15 @@
+import { registerAdapter } from '../registry.js';
+
+// Duck-typed gate for three.js targets, used as threeAdapter's Adapter-level detect.
+// Early-rejects DOM nodes via nodeType so the OR chain only runs on non-DOM objects.
+// Includes the isAnimejsInstanceProxy marker set in instance.js for per-instance wrappers.
+const isThreeTarget = (t) => !!(
+ t && !t.nodeType && (
+ t.isObject3D || t.isMaterial || t.isTexture ||
+ t.isFog || t.isFogExp2 || t.isUniformNode ||
+ t.isColor || t.isVector2 || t.isVector3 || t.isVector4 ||
+ t.isAnimejsInstanceProxy
+ )
+);
+
+export const threeAdapter = registerAdapter(isThreeTarget);
diff --git a/src/adapters/three/helpers.js b/src/adapters/three/helpers.js
new file mode 100644
index 00000000..8d883812
--- /dev/null
+++ b/src/adapters/three/helpers.js
@@ -0,0 +1,270 @@
+/**
+ * Generic read/write helpers for the three.js bindings. Each operates on a target (or target array) and walks to the leaf via a path tag - direct (`target[name]`), uniform (`target.uniforms[name].value`), or TSL node (`target[name].value`). Adapter and resolver files pass the matching `PATH_*` constant; the JIT specializes each call site so the branch in `leafAt` / `writeLeafScalar` constant-folds.
+ */
+
+import { SRGBColorSpace } from 'three';
+import { degToRad } from '../../utils/number.js';
+
+export const COLOR_NORM = 1 / 255;
+
+export const AXIS_MAP = /** @type {Record<string, 'x' | 'y' | 'z' | 'w'>} */({ X: 'x', Y: 'y', Z: 'z', W: 'w' });
+
+export const PATH_DIRECT = 0;
+const PATH_UNIFORM = 1;
+const PATH_NODE = 2;
+
+export const KIND_COLOR = 0;
+export const KIND_SCALAR = 1;
+export const KIND_VECTOR = 2;
+
+// Reuse one mutable descriptor across calls, callers must consume immediately since the next call mutates it.
+const desc = { kind: 0, path: 0, base: '', axis: /** @type {'x' | 'y' | 'z' | 'w'} */('x') };
+
+/**
+ * Patches a column-major `Matrix4.elements` array in place with CSS-style `skewX(α)` / `skewY(β)`, the 3D extension `skewZ(γ)` (shears z by x), and a `transform-origin` shift.
+ *
+ * @param {number[]} e
+ * @param {number} skewX
+ * @param {number} skewY
+ * @param {number} skewZ
+ * @param {number} ox
+ * @param {number} oy
+ * @param {number} oz
+ */
+export function applySkewOrigin(e, skewX, skewY, skewZ, ox, oy, oz) {
+ if (skewX !== 0) {
+ const t = Math.tan(degToRad(skewX));
+ e[4] += e[0] * t;
+ e[5] += e[1] * t;
+ e[6] += e[2] * t;
+ }
+ if (skewY !== 0) {
+ const t = Math.tan(degToRad(skewY));
+ e[0] += e[4] * t;
+ e[1] += e[5] * t;
+ e[2] += e[6] * t;
+ }
+ if (skewZ !== 0) {
+ const t = Math.tan(degToRad(skewZ));
+ e[0] += e[8] * t;
+ e[1] += e[9] * t;
+ e[2] += e[10] * t;
+ }
+ if (ox !== 0 || oy !== 0 || oz !== 0) {
+ e[12] += ox - (e[0] * ox + e[4] * oy + e[8] * oz);
+ e[13] += oy - (e[1] * ox + e[5] * oy + e[9] * oz);
+ e[14] += oz - (e[2] * ox + e[6] * oy + e[10] * oz);
+ }
+}
+
+/**
+ * @param {any} c
+ * @return {String | null}
+ */
+export function readColorHex(c) {
+ return c ? `#${c.getHexString(SRGBColorSpace)}` : null;
+}
+
+/**
+ * Returns `true` when `v` is a `Vector2/3/4` instance whose dimension covers `axis`. `Quaternion` and plain `{x,y,z,w}`-shaped objects are intentionally rejected.
+ *
+ * @param {any} v
+ * @param {'x' | 'y' | 'z' | 'w'} axis
+ * @return {boolean}
+ */
+export function isVectorWith(v, axis) {
+ if (!v) return false;
+ if (axis === 'x' || axis === 'y') return !!(v.isVector2 || v.isVector3 || v.isVector4);
+ if (axis === 'z') return !!(v.isVector3 || v.isVector4);
+ return !!v.isVector4;
+}
+
+/**
+ * Classifies `target[name]` and returns a descriptor `{ kind, path, base, axis }` (or `null`). Used by the resolver entries in `resolvers.js` and by the `Object3D` adapter to build the matching access pattern for any three.js target (Object3D, Material, Texture, Fog, UniformNode).
+ *
+ * @param {any} target
+ * @param {string} name
+ * @return {{ kind: number, path: number, base: string, axis: 'x' | 'y' | 'z' | 'w' } | null}
+ */
+export function classifyTargetProp(target, name) {
+ const value = target[name];
+ if (value !== undefined) {
+ if (value && value.isColor) {
+ desc.kind = KIND_COLOR; desc.path = PATH_DIRECT;
+ return desc;
+ }
+ if (value && value.isUniformNode) {
+ // Route TSL slot writes through node value, booleans share the scalar entry.
+ const v = value.value;
+ if (v && v.isColor) {
+ desc.kind = KIND_COLOR; desc.path = PATH_NODE;
+ return desc;
+ }
+ if (typeof v === 'number' || typeof v === 'boolean') {
+ desc.kind = KIND_SCALAR; desc.path = PATH_NODE;
+ return desc;
+ }
+ return null;
+ }
+ if (typeof value === 'number' || typeof value === 'boolean') {
+ desc.kind = KIND_SCALAR; desc.path = PATH_DIRECT;
+ return desc;
+ }
+ return null;
+ }
+ const uniforms = target.uniforms;
+ const u = uniforms && uniforms[name];
+ if (u) {
+ const uv = u.value;
+ if (uv && uv.isColor) {
+ desc.kind = KIND_COLOR; desc.path = PATH_UNIFORM;
+ return desc;
+ }
+ if (typeof uv === 'number') {
+ desc.kind = KIND_SCALAR; desc.path = PATH_UNIFORM;
+ return desc;
+ }
+ }
+ // Decompose vector axis for names like posX, uOffsetY, uVec4W, colorNodeX.
+ const axis = AXIS_MAP[name[name.length - 1]];
+ if (axis) {
+ const base = name.slice(0, -1);
+ if (isVectorWith(target[base], axis)) {
+ desc.kind = KIND_VECTOR; desc.path = PATH_DIRECT; desc.base = base; desc.axis = axis;
+ return desc;
+ }
+ const baseSlot = target[base];
+ if (baseSlot && baseSlot.isUniformNode && isVectorWith(baseSlot.value, axis)) {
+ desc.kind = KIND_VECTOR; desc.path = PATH_NODE; desc.base = base; desc.axis = axis;
+ return desc;
+ }
+ const ub = uniforms && uniforms[base];
+ if (ub && isVectorWith(ub.value, axis)) {
+ desc.kind = KIND_VECTOR; desc.path = PATH_UNIFORM; desc.base = base; desc.axis = axis;
+ return desc;
+ }
+ }
+ return null;
+}
+
+function leafAt(target, name, path) {
+ if (path === PATH_DIRECT) return target[name];
+ if (path === PATH_UNIFORM) {
+ const u = target.uniforms;
+ const e = u && u[name];
+ return e ? e.value : null;
+ }
+ const n = target[name];
+ return n ? n.value : null;
+}
+
+function writeLeafScalar(target, name, v, path) {
+ if (path === PATH_DIRECT) { target[name] = v; return; }
+ if (path === PATH_UNIFORM) {
+ const u = target.uniforms;
+ const e = u && u[name];
+ if (e) e.value = v;
+ return;
+ }
+ const n = target[name];
+ if (n) n.value = v;
+}
+
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {number} path
+ * @param {number} [defaultValue]
+ * @return {number}
+ */
+export function readScalar(target, name, path, defaultValue) {
+ if (defaultValue === undefined) defaultValue = 0;
+ if (!target) return defaultValue;
+ const first = Array.isArray(target) ? target[0] : target;
+ if (!first) return defaultValue;
+ const v = leafAt(first, name, path);
+ return v === undefined || v === null ? defaultValue : v;
+}
+
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {number} v
+ * @param {number} path
+ */
+export function writeScalar(target, name, v, path) {
+ if (!target) return;
+ if (Array.isArray(target)) {
+ for (let i = 0, l = target.length; i < l; i++) writeLeafScalar(target[i], name, v, path);
+ } else {
+ writeLeafScalar(target, name, v, path);
+ }
+}
+
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {number} path
+ * @return {String | null}
+ */
+export function readColorAt(target, name, path) {
+ if (!target) return null;
+ const first = Array.isArray(target) ? target[0] : target;
+ return readColorHex(first ? leafAt(first, name, path) : null);
+}
+
+/**
+ * @param {any} target
+ * @param {string} name
+ * @param {Array.<Number>} ns
+ * @param {number} path
+ */
+export function writeColorAt(target, name, ns, path) {
+ if (!target) return;
+ const r = ns[0] * COLOR_NORM;
+ const g = ns[1] * COLOR_NORM;
+ const b = ns[2] * COLOR_NORM;
+ if (Array.isArray(target)) {
+ for (let i = 0, l = target.length; i < l; i++) {
+ const c = leafAt(target[i], name, path);
+ if (c) c.setRGB(r, g, b, SRGBColorSpace);
+ }
+ } else {
+ const c = leafAt(target, name, path);
+ if (c) c.setRGB(r, g, b, SRGBColorSpace);
+ }
+}
+
+/**
+ * @param {any} target
+ * @param {string} base
+ * @param {'x' | 'y' | 'z' | 'w'} axis
+ * @param {number} path
+ * @return {number}
+ */
+export function readVectorAt(target, base, axis, path) {
+ if (!target) return 0;
+ const first = Array.isArray(target) ? target[0] : target;
+ const vec = first ? leafAt(first, base, path) : null;
+ return vec ? vec[axis] : 0;
+}
+
+/**
+ * @param {any} target
+ * @param {string} base
+ * @param {'x' | 'y' | 'z' | 'w'} axis
+ * @param {number} v
+ * @param {number} path
+ */
+export function writeVectorAt(target, base, axis, v, path) {
+ if (!target) return;
+ if (Array.isArray(target)) {
+ for (let i = 0, l = target.length; i < l; i++) {
+ const vec = leafAt(target[i], base, path);
+ if (vec) vec[axis] = v;
+ }
+ } else {
+ const vec = leafAt(target, base, path);
+ if (vec) vec[axis] = v;
+ }
+}
diff --git a/src/adapters/three/index.js b/src/adapters/three/index.js
new file mode 100644
index 00000000..1f1da206
--- /dev/null
+++ b/src/adapters/three/index.js
@@ -0,0 +1,47 @@
+/**
+ * anime.js / three.js bindings. Side-effect import: registers adapters so `animate()` and `utils.set()` accept raw three.js objects.
+ *
+ * import 'animejs/adapters/three';
+ * import { animate } from 'animejs';
+ * animate(mesh, { x: 100, rotateY: 360, opacity: 0.3, color: '#f0a' });
+ * animate(camera, { fov: [50, 30], focalLength: 35 });
+ * animate(light, { intensity: [0, 2], color: '#f0a' });
+ *
+ * Mapped properties:
+ * x / y / z, rotateX / Y / Z (degrees), scaleX / Y / Z, scale (uniform), opacity, color, visible
+ *
+ * Class-specific:
+ * groundColor (HemisphereLight)
+ * volume (Audio, PositionalAudio)
+ * refDistance / rolloffFactor / maxDistance (PositionalAudio)
+ * focalLength (PerspectiveCamera)
+ * fov / aspect / near / far / zoom (PerspectiveCamera)
+ * left / right / top / bottom / near / far / zoom (OrthographicCamera)
+ *
+ * Unmapped names on a mesh are auto-detected against `target.material` at tween creation. Numeric, boolean, and `Color`-typed props on the material (e.g. `metalness`, `roughness`, `emissive`, `wireframe`) become animatable on the mesh directly without a static registration. Material instances can also be animated directly via the `Material` adapter. Use `getInstances(mesh)` for per-instance animation of `InstancedMesh` / `BatchedMesh`.
+ *
+ * TSL `NodeMaterial` slots assigned a `UniformNode` are auto-detected the same way. Number, boolean, `Color`, and `Vector2/3/4` uniforms become animatable on the mesh and on the material directly. Bare uniforms accept `value` (scalar / bool), `color`, and `x` / `y` / `z` / `w` axes.
+ *
+ * const mat = new MeshStandardNodeMaterial();
+ * mat.colorNode = uniform(new Color('#f00'));
+ * mat.offsetNode = uniform(new Vector3());
+ * animate(mesh, { colorNode: '#0ff', offsetNodeY: 0.5 });
+ * animate(mat.colorNode, { color: '#0f0' });
+ * animate(uniform(0), { value: 1 });
+ *
+ * Caveats:
+ * - Rotation assumes Euler order `'XYZ'`.
+ * - `opacity` writes `material.opacity`. Set `material.transparent = true` on materials meant to fade. `opacity = 0` flips `visible = false`.
+ * - `scaleX` / `Y` / `Z` / `scale` = 0 flips `visible = false`. Direct mutation of `mesh.scale.x` does not.
+ * - Material-routed writes target `mesh.material` only (single material or array). Group / nested-mesh fades are not propagated, animate the materials directly or pass an array of meshes.
+ * - Auto-detected names that also exist on the mesh itself (e.g. `mesh.foo = 1` and `mesh.material.foo = 2`) take the mesh value, leaving the material untouched.
+ */
+
+export { threeAdapter } from './adapter.js';
+
+import './resolvers.js';
+import './uniform.js';
+import './object3d.js';
+import './instance.js';
+
+export { getInstances, commitChanges } from './instance.js';
\ No newline at end of file
diff --git a/src/adapters/three/instance.js b/src/adapters/three/instance.js
new file mode 100644
index 00000000..d1b2e843
--- /dev/null
+++ b/src/adapters/three/instance.js
@@ -0,0 +1,356 @@
+import { Matrix4, Vector3, Euler, Quaternion, Color, BatchedMesh, SRGBColorSpace } from 'three';
+import { degToRad, radToDeg } from '../../utils/number.js';
+import { threeAdapter } from './adapter.js';
+import { COLOR_NORM, applySkewOrigin, readScalar, writeScalar, readColorHex, PATH_DIRECT } from './helpers.js';
+
+const hasSkewOrigin = (t) => !!(t._skewX || t._skewY || t._skewZ || t._originX || t._originY || t._originZ);
+
+/**
+ * @import { Object3D, InstancedMesh } from 'three'
+ *
+ * @typedef {InstancedMesh | BatchedMesh} InstanceParent
+ */
+
+const DIRTY_POS = 1;
+const DIRTY_ROT = 2;
+const DIRTY_SCALE = 4;
+const DIRTY_SKEW = 8;
+
+/** @type {WeakMap<InstanceParent, InstanceBinding>} */
+const bindings = new WeakMap();
+
+/**
+ * Per-mesh state for `InstancedMesh` / `BatchedMesh` animations. Holds the instance array, the dirty queue, and the chained `onBeforeRender` closure.
+ */
+class InstanceBinding {
+
+ /** @param {InstanceParent} mesh */
+ constructor(mesh) {
+ this.mesh = mesh;
+ this.hasInstanceMatrix = 'instanceMatrix' in mesh;
+ /** @type {(Instance | null)[]} */
+ this.instances = [];
+ /** @type {Instance[]} */
+ this.dirtyList = [];
+ /** @type {Object3D['onBeforeRender'] | null} */
+ this.userOnBeforeRender = mesh.onBeforeRender || null;
+ this.chainedHandler = makeChainedHandler(this);
+ Object.defineProperty(mesh, 'onBeforeRender', {
+ configurable: true,
+ get: () => this.chainedHandler,
+ set: (fn) => { this.userOnBeforeRender = fn; },
+ });
+ }
+
+ flush() {
+ const list = this.dirtyList;
+ if (list.length === 0) return;
+ for (let i = 0, l = list.length; i < l; i++) list[i]._flush();
+ if (this.hasInstanceMatrix) /** @type {InstancedMesh} */(this.mesh).instanceMatrix.needsUpdate = true;
+ list.length = 0;
+ }
+
+}
+
+/**
+ * @param {InstanceBinding} binding
+ * @return {Object3D['onBeforeRender']}
+ */
+function makeChainedHandler(binding) {
+ return function (renderer, scene, camera, geometry, material, group) {
+ binding.flush();
+ const u = binding.userOnBeforeRender;
+ if (u) u.call(binding.mesh, renderer, scene, camera, geometry, material, group);
+ };
+}
+
+/**
+ * Per-instance adapter for `InstancedMesh` or `BatchedMesh`. Returned by `getInstances(mesh)`. Exposes the same flat properties as the mesh adapter, applied to a single instance id. Writes are coalesced and flushed before each render via `onBeforeRender`; call `commitChanges(mesh)` if you need to read `mesh.instanceMatrix` between a tick and a render.
+ *
+ * Caveats:
+ * - `opacity` writes the parent's shared material, every instance is affected.
+ * - `visible` is backed by `BatchedMesh.setVisibleAt`. On `InstancedMesh` it is a no-op, use `scale = 0` to hide an instance.
+ */
+class Instance {
+
+ /**
+ * @param {InstanceBinding} binding
+ * @param {number} id
+ */
+ constructor(binding, id) {
+ this.isAnimejsInstanceProxy = true;
+ this.parent = binding.mesh;
+ this.id = id;
+ this._position = new Vector3();
+ this._rotation = new Euler(0, 0, 0, 'XYZ');
+ this._scale = new Vector3(1, 1, 1);
+ this._matrix = new Matrix4();
+ this._quat = new Quaternion();
+ // Pre-allocate _color so the hidden class stays stable, set color mutates it in place rather than re-binding the field.
+ this._color = new Color();
+ this._dirty = 0;
+ // Skew in degrees and transform-origin in object-space.
+ // applySkewOrigin computes Math.tan inline per non-zero axis, so we only carry the user-facing angle here.
+ this._skewX = 0;
+ this._skewY = 0;
+ this._skewZ = 0;
+ this._originX = 0;
+ this._originY = 0;
+ this._originZ = 0;
+ // Skip the position-only fast path in _flush whenever any skew or origin is non-zero, since both modify the matrix beyond pure translation.
+ this._hasSkewOrigin = false;
+ // Cache the binding dirty queue once so per-frame setters skip a property hop.
+ /** @type {Instance[]} */
+ this._dirtyList = binding.dirtyList;
+ // Cache parent capability flags once so per-frame setters skip prototype-chain in checks.
+ const parent = binding.mesh;
+ this._hasSetColor = 'setColorAt' in parent;
+ this._hasSetVisible = 'setVisibleAt' in parent;
+ this._hasGetVisible = 'getVisibleAt' in parent;
+
+ parent.getMatrixAt(id, this._matrix);
+ if (this._matrix.elements[15] === 0) this._matrix.identity();
+ this._matrix.decompose(this._position, this._quat, this._scale);
+ this._rotation.setFromQuaternion(this._quat, 'XYZ');
+
+ if ('getColorAt' in parent && 'instanceColor' in parent && parent.instanceColor) {
+ parent.getColorAt(id, this._color);
+ }
+ }
+
+ /**
+ * @param {number} flag
+ */
+ _markDirty(flag) {
+ // Enqueue once per frame, later flags only OR into _dirty without re-pushing to the queue.
+ if (this._dirty === 0) this._dirtyList.push(this);
+ this._dirty |= flag;
+ }
+
+ _flush() {
+ const d = this._dirty;
+ if (!d) return;
+ const m = this._matrix;
+ const p = this._position;
+ if (d === DIRTY_POS && !this._hasSkewOrigin) {
+ const e = m.elements;
+ e[12] = p.x; e[13] = p.y; e[14] = p.z;
+ } else {
+ const q = this._quat;
+ if (d & DIRTY_ROT) q.setFromEuler(this._rotation);
+ m.compose(p, q, this._scale);
+ if (this._hasSkewOrigin) {
+ applySkewOrigin(m.elements, this._skewX, this._skewY, this._skewZ, this._originX, this._originY, this._originZ);
+ }
+ }
+ this.parent.setMatrixAt(this.id, m);
+ this._dirty = 0;
+ }
+
+ get x() { return this._position.x; }
+ set x(v) { this._position.x = v; this._markDirty(DIRTY_POS); }
+
+ get y() { return this._position.y; }
+ set y(v) { this._position.y = v; this._markDirty(DIRTY_POS); }
+
+ get z() { return this._position.z; }
+ set z(v) { this._position.z = v; this._markDirty(DIRTY_POS); }
+
+ get rotateX() { return radToDeg(this._rotation.x); }
+ set rotateX(v) { this._rotation.x = degToRad(v); this._markDirty(DIRTY_ROT); }
+
+ get rotateY() { return radToDeg(this._rotation.y); }
+ set rotateY(v) { this._rotation.y = degToRad(v); this._markDirty(DIRTY_ROT); }
+
+ get rotateZ() { return radToDeg(this._rotation.z); }
+ set rotateZ(v) { this._rotation.z = degToRad(v); this._markDirty(DIRTY_ROT); }
+
+ get scaleX() { return this._scale.x; }
+ set scaleX(v) { this._scale.x = v; this._markDirty(DIRTY_SCALE); }
+
+ get scaleY() { return this._scale.y; }
+ set scaleY(v) { this._scale.y = v; this._markDirty(DIRTY_SCALE); }
+
+ get scaleZ() { return this._scale.z; }
+ set scaleZ(v) { this._scale.z = v; this._markDirty(DIRTY_SCALE); }
+
+ get scale() { return this._scale.x; }
+ set scale(v) {
+ const s = this._scale;
+ s.x = v; s.y = v; s.z = v;
+ this._markDirty(DIRTY_SCALE);
+ }
+
+ get skewX() { return this._skewX; }
+ set skewX(v) {
+ this._skewX = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get skewY() { return this._skewY; }
+ set skewY(v) {
+ this._skewY = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get skewZ() { return this._skewZ; }
+ set skewZ(v) {
+ this._skewZ = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get transformOriginX() { return this._originX; }
+ set transformOriginX(v) {
+ this._originX = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get transformOriginY() { return this._originY; }
+ set transformOriginY(v) {
+ this._originY = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get transformOriginZ() { return this._originZ; }
+ set transformOriginZ(v) {
+ this._originZ = v;
+ this._hasSkewOrigin = hasSkewOrigin(this);
+ this._markDirty(DIRTY_SKEW);
+ }
+
+ get opacity() {
+ return readScalar(/** @type {any} */(this.parent).material, 'opacity', PATH_DIRECT, 1);
+ }
+ /** @param {number} v */
+ set opacity(v) {
+ writeScalar(/** @type {any} */(this.parent).material, 'opacity', v, PATH_DIRECT);
+ }
+
+ get visible() {
+ return this._hasGetVisible ? /** @type {any} */(this.parent).getVisibleAt(this.id) : true;
+ }
+ /** @param {boolean} v */
+ set visible(v) {
+ if (this._hasSetVisible) /** @type {any} */(this.parent).setVisibleAt(this.id, v);
+ }
+
+}
+
+/**
+ * Flushes pending matrix writes for every dirty instance of `mesh`.
+ * Called automatically before each render. Call it yourself if you read
+ * `mesh.instanceMatrix` between an animation tick and the next render.
+ *
+ * @param {InstanceParent} mesh
+ */
+export function commitChanges(mesh) {
+ const binding = bindings.get(mesh);
+ if (binding) binding.flush();
+}
+
+/**
+ * Returns an array of per-instance adapters for `mesh`. Index by id, deleted slots on `BatchedMesh` are `null`. Pass the array (or a slice / a single element) to `animate()`.
+ *
+ * animate(getInstances(mesh), { x: 100, delay: stagger(5) });
+ * animate(getInstances(mesh)[42], { scale: 2 });
+ *
+ * The same array reference is preserved across `mesh.count` / `addInstance` / `deleteInstance` calls. Entries are pushed, nulled, or truncated in place. Animations bound to an outdated reference keep tweening their original adapters.
+ *
+ * `mesh.onBeforeRender` is replaced with an accessor that flushes
+ * pending instance writes before each render and forwards to your
+ * handler. Assigning your own `mesh.onBeforeRender = fn` keeps the
+ * auto-flush, but reading `mesh.onBeforeRender` afterwards returns the
+ * chained dispatcher rather than `fn` itself, so identity checks
+ * (`mesh.onBeforeRender === fn`) will not match.
+ *
+ * @param {InstanceParent} mesh
+ * @return {(Instance | null)[]}
+ */
+export function getInstances(mesh) {
+ let binding = bindings.get(mesh);
+ if (!binding) {
+ binding = new InstanceBinding(mesh);
+ bindings.set(mesh, binding);
+ }
+ if (mesh instanceof BatchedMesh) {
+ return refreshBatched(binding);
+ }
+ return refreshInstanced(binding);
+}
+
+/**
+ * @param {InstanceBinding} binding
+ * @return {(Instance | null)[]}
+ */
+function refreshInstanced(binding) {
+ const mesh = /** @type {InstancedMesh} */(binding.mesh);
+ const count = mesh.count;
+ const arr = binding.instances;
+ if (arr.length === 0 && count > 0) {
+ arr.length = count;
+ for (let i = 0; i < count; i++) arr[i] = new Instance(binding, i);
+ return arr;
+ }
+ if (arr.length < count) {
+ for (let i = arr.length; i < count; i++) arr.push(new Instance(binding, i));
+ } else if (arr.length > count) {
+ arr.length = count;
+ }
+ return arr;
+}
+
+/**
+ * @param {InstanceBinding} binding
+ * @return {(Instance | null)[]}
+ */
+function refreshBatched(binding) {
+ const mesh = /** @type {BatchedMesh} */(binding.mesh);
+ const arr = binding.instances;
+ // Read three internal _instanceInfo to skip slots marked inactive by deleteInstance.
+ // Iterate the full slot count, not instanceCount, since deleted slots leave gaps but live ids past them must still be visited.
+ const instanceInfo = /** @type {{ _instanceInfo?: { active: boolean }[] }} */(mesh)._instanceInfo ?? [];
+ const len = instanceInfo.length;
+ if (arr.length < len) arr.length = len;
+ for (let i = 0; i < len; i++) {
+ const info = instanceInfo[i];
+ const inactive = info && info.active === false;
+ if (inactive) {
+ arr[i] = null;
+ } else if (!arr[i]) {
+ arr[i] = new Instance(binding, i);
+ }
+ }
+ if (arr.length > len) arr.length = len;
+ return arr;
+}
+
+const instanceAdapter = threeAdapter.registerTargetAdapter((t) => t instanceof Instance);
+instanceAdapter.registerProperty('color',
+ (t) => readColorHex(t._color),
+ (t, _, tw) => {
+ if (!t._hasSetColor) return;
+ const ns = tw._numbers;
+ t._color.setRGB(ns[0] * COLOR_NORM, ns[1] * COLOR_NORM, ns[2] * COLOR_NORM, SRGBColorSpace);
+ const p = /** @type {any} */(t.parent);
+ p.setColorAt(t.id, t._color);
+ if (p.instanceColor) p.instanceColor.needsUpdate = true;
+ },
+);
+// Shorthand 3-token string x y z routed via the engine COMPLEX path.
+// The setter reads tween _numbers for the per-frame lerped triplet.
+instanceAdapter.registerProperty('transformOrigin',
+ (t) => `${t._originX} ${t._originY} ${t._originZ}`,
+ (t, _, tw) => {
+ const ns = tw._numbers;
+ t._originX = ns[0];
+ t._originY = ns[1];
+ t._originZ = ns[2];
+ t._hasSkewOrigin = hasSkewOrigin(t);
+ t._markDirty(DIRTY_SKEW);
+ },
+);
diff --git a/src/adapters/three/object3d.js b/src/adapters/three/object3d.js
new file mode 100644
index 00000000..073be360
--- /dev/null
+++ b/src/adapters/three/object3d.js
@@ -0,0 +1,213 @@
+/**
+ * `Object3D` adapter. Maps flat properties (position, rotation, scale, opacity, color, visible, light / audio / camera specifics) onto the matching three.js fields, and auto-detects material props (direct / uniform / TSL `UniformNode`) on the target's `material` at tween creation.
+ */
+
+import { Color, Object3D, SRGBColorSpace } from 'three';
+import { degToRad, radToDeg } from '../../utils/number.js';
+import { threeAdapter } from './adapter.js';
+import {
+ COLOR_NORM,
+ PATH_DIRECT,
+ applySkewOrigin,
+ readScalar,
+ writeScalar,
+ readColorAt,
+ writeColorAt,
+ readColorHex,
+} from './helpers.js';
+
+const colorTarget = (t) => t.isLight ? t : t.material;
+
+// Per-mesh skew and transformOrigin state, stored under a private symbol so we add one hidden property instead of polluting the Object3D surface with seven underscored fields.
+const skewSymbol = Symbol('animejs.skewOrigin');
+
+// Fallback opacity storage for Object3D targets without a material such as Groups or CSS2DObjects.
+// Without it reads always return the default 1, so reverse-direction tweens between two non-default values collapse to a no-op delta and the visibility flip never fires on the way back.
+const opacitySymbol = Symbol('animejs.opacity');
+
+/**
+ * Sets `o.visible` based on opacity and current scale. If `opacity` is omitted, reads it from `o.material` (defaults to `1` when no material is present).
+ *
+ * @param {Object3D & { material?: import('three').Material | import('three').Material[] }} o
+ * @param {number} [opacity]
+ */
+function setVisibility(o, opacity) {
+ if (opacity === undefined) {
+ if (o.material) {
+ opacity = readScalar(o.material, 'opacity', PATH_DIRECT, 1);
+ } else {
+ const v = o[opacitySymbol];
+ opacity = v === undefined ? 1 : v;
+ }
+ }
+ const s = o.scale;
+ o.visible = !!(opacity && s.x && s.y && s.z);
+}
+
+/**
+ * Installs a per-mesh `updateMatrix` override on first skew / transformOrigin write. The override calls the original three.js compose, then patches the result with `applySkewOrigin` whenever any axis is non-zero. Idempotent.
+ *
+ * @param {any} mesh
+ * @return {{ skewX: number, skewY: number, skewZ: number, originX: number, originY: number, originZ: number }}
+ */
+function installSkewMatrix(mesh) {
+ let s = mesh[skewSymbol];
+ if (s) return s;
+ s = mesh[skewSymbol] = { skewX: 0, skewY: 0, skewZ: 0, originX: 0, originY: 0, originZ: 0 };
+ const original = mesh.updateMatrix;
+ mesh.updateMatrix = function () {
+ original.call(this);
+ const st = this[skewSymbol];
+ if (st.skewX !== 0 || st.skewY !== 0 || st.skewZ !== 0 || st.originX !== 0 || st.originY !== 0 || st.originZ !== 0) {
+ applySkewOrigin(this.matrix.elements, st.skewX, st.skewY, st.skewZ, st.originX, st.originY, st.originZ);
+ }
+ };
+ return s;
+}
+
+const threeObject3D = threeAdapter.registerTargetAdapter((t) => t instanceof Object3D);
+
+// Position
+threeObject3D.registerProperty('x', (t) => t.position.x, (t, v) => { t.position.x = v; });
+threeObject3D.registerProperty('y', (t) => t.position.y, (t, v) => { t.position.y = v; });
+threeObject3D.registerProperty('z', (t) => t.position.z, (t, v) => { t.position.z = v; });
+
+// Rotation in degrees
+threeObject3D.registerProperty('rotateX', (t) => radToDeg(t.rotation.x), (t, v) => { t.rotation.x = degToRad(v); });
+threeObject3D.registerProperty('rotateY', (t) => radToDeg(t.rotation.y), (t, v) => { t.rotation.y = degToRad(v); });
+threeObject3D.registerProperty('rotateZ', (t) => radToDeg(t.rotation.z), (t, v) => { t.rotation.z = degToRad(v); });
+
+// Scale per-axis and uniform
+threeObject3D.registerProperty('scaleX', (t) => t.scale.x, (t, v) => { t.scale.x = v; setVisibility(t); });
+threeObject3D.registerProperty('scaleY', (t) => t.scale.y, (t, v) => { t.scale.y = v; setVisibility(t); });
+threeObject3D.registerProperty('scaleZ', (t) => t.scale.z, (t, v) => { t.scale.z = v; setVisibility(t); });
+threeObject3D.registerProperty('scale',
+ (t) => t.scale.x,
+ (t, v) => {
+ t.scale.x = v; t.scale.y = v; t.scale.z = v;
+ setVisibility(t);
+ },
+);
+
+// Material
+threeObject3D.registerProperty('visible', (t) => t.visible, (t, v) => { t.visible = !!v; });
+threeObject3D.registerProperty('opacity',
+ (t) => {
+ if (t.material) return readScalar(t.material, 'opacity', PATH_DIRECT, 1);
+ const v = t[opacitySymbol];
+ return v === undefined ? 1 : v;
+ },
+ (t, v) => {
+ if (t.material) writeScalar(t.material, 'opacity', v, PATH_DIRECT);
+ else t[opacitySymbol] = v;
+ setVisibility(t, v);
+ },
+ (t) => !t.isLight,
+);
+threeObject3D.registerProperty('color',
+ (t) => readColorAt(colorTarget(t), 'color', PATH_DIRECT),
+ (t, _, tw) => writeColorAt(colorTarget(t), 'color', tw._numbers, PATH_DIRECT),
+);
+
+// HemisphereLight
+threeObject3D.registerProperty('groundColor',
+ (t) => readColorAt(t, 'groundColor', PATH_DIRECT),
+ (t, _, tw) => writeColorAt(t, 'groundColor', tw._numbers, PATH_DIRECT),
+ (t) => !!t.groundColor,
+);
+
+// Scene background, lazily initializes scene background to a Color on first write so the user does not have to set one upfront.
+threeObject3D.registerProperty('background',
+ (t) => {
+ const bg = /** @type {any} */(t).background;
+ return bg && bg.isColor ? readColorHex(bg) : '#000000';
+ },
+ (t, _, tw) => {
+ const scene = /** @type {any} */(t);
+ let bg = scene.background;
+ if (!bg || !bg.isColor) {
+ bg = new Color();
+ scene.background = bg;
+ }
+ const ns = tw._numbers;
+ bg.setRGB(ns[0] * COLOR_NORM, ns[1] * COLOR_NORM, ns[2] * COLOR_NORM, SRGBColorSpace);
+ },
+ (t) => !!t.isScene,
+);
+
+// Method-bridged props for Audio and PerspectiveCamera focalLength, read via getXxx and write via setXxx.
+const registerMethodProp = (apiName, getter, setter, gate) => {
+ threeObject3D.registerProperty(apiName,
+ (t) => t[getter](),
+ (t, v) => { t[setter](v); },
+ (t) => !!t[gate],
+ );
+};
+registerMethodProp('volume', 'getVolume', 'setVolume', 'setVolume');
+// PositionalAudio
+registerMethodProp('refDistance', 'getRefDistance', 'setRefDistance', 'setRefDistance');
+registerMethodProp('rolloffFactor', 'getRolloffFactor', 'setRolloffFactor', 'setRefDistance');
+registerMethodProp('maxDistance', 'getMaxDistance', 'setMaxDistance', 'setRefDistance');
+// PerspectiveCamera
+registerMethodProp('focalLength', 'getFocalLength', 'setFocalLength', 'setFocalLength');
+
+// Camera projection-update props, setter writes the value then calls updateProjectionMatrix.
+const registerCameraProp = (apiName, gate) => {
+ threeObject3D.registerProperty(apiName,
+ (t) => t[apiName],
+ (t, v) => { t[apiName] = v; t.updateProjectionMatrix(); },
+ gate,
+ );
+};
+const isPersp = (t) => !!t.isPerspectiveCamera;
+const isOrtho = (t) => !!t.isOrthographicCamera;
+registerCameraProp('fov', isPersp);
+registerCameraProp('aspect', isPersp);
+registerCameraProp('left', isOrtho);
+registerCameraProp('right', isOrtho);
+registerCameraProp('top', isOrtho);
+registerCameraProp('bottom', isOrtho);
+
+// Skew in degrees and transform-origin in object-space.
+// Patches mesh updateMatrix on first write so the standard PRS compose is followed by an in-place skew and origin shift.
+// Reads default to 0 for meshes that have never been written.
+/**
+ * @param {String} apiName
+ * @param {String} key
+ */
+const registerSkewProp = (apiName, key) => {
+ threeObject3D.registerProperty(apiName,
+ (t) => { const s = /** @type {any} */(t)[skewSymbol]; return s ? s[key] : 0; },
+ (t, v) => { installSkewMatrix(t)[key] = v; },
+ );
+};
+registerSkewProp('skewX', 'skewX');
+registerSkewProp('skewY', 'skewY');
+registerSkewProp('skewZ', 'skewZ');
+registerSkewProp('transformOriginX', 'originX');
+registerSkewProp('transformOriginY', 'originY');
+registerSkewProp('transformOriginZ', 'originZ');
+
+// Shorthand 3-token string x y z or 2-string from-to array routed via the engine COMPLEX path.
+// The setter reads tween _numbers for the per-frame lerped triplet.
+threeObject3D.registerProperty('transformOrigin',
+ (t) => {
+ const s = /** @type {any} */(t)[skewSymbol];
+ return s ? `${s.originX} ${s.originY} ${s.originZ}` : '0 0 0';
+ },
+ (t, _, tw) => {
+ const s = installSkewMatrix(t);
+ const ns = tw._numbers;
+ s.originX = ns[0];
+ s.originY = ns[1];
+ s.originZ = ns[2];
+ },
+);
+
+// Shared by both camera types.
+const isCamera = (t) => !!t.isPerspectiveCamera || !!t.isOrthographicCamera;
+registerCameraProp('near', isCamera);
+registerCameraProp('far', isCamera);
+registerCameraProp('zoom', isCamera);
+
+// Auto-detection for material props on meshes and direct Vector / Color fields on the target is provided by the shared resolvers in resolvers.js.
diff --git a/src/adapters/three/resolvers.js b/src/adapters/three/resolvers.js
new file mode 100644
index 00000000..dbf4f626
--- /dev/null
+++ b/src/adapters/three/resolvers.js
@@ -0,0 +1,107 @@
+/**
+ * Global property resolvers for three.js targets. Auto-detect `Color`-typed properties, `Vector2/3/4` axis components, shader uniforms, and TSL `UniformNode` slots on any three.js object. For mesh-like targets, a second resolver walks to `target.material` and runs the same detection there.
+ */
+
+import { threeAdapter } from './adapter.js';
+import { degToRad, radToDeg } from '../../utils/number.js';
+import {
+ AXIS_MAP,
+ PATH_DIRECT,
+ KIND_COLOR,
+ KIND_SCALAR,
+ classifyTargetProp,
+ readColorAt,
+ writeColorAt,
+ readScalar,
+ writeScalar,
+ readVectorAt,
+ writeVectorAt,
+} from './helpers.js';
+
+const identity = (t) => t;
+const getMaterial = (t) => t.material;
+
+const directColorCache = [{}, {}, {}];
+const directScalarCache = [{}, {}, {}];
+const directVectorCache = [{}, {}, {}];
+
+const materialColorCache = [{}, {}, {}];
+const materialScalarCache = [{}, {}, {}];
+const materialVectorCache = [{}, {}, {}];
+
+const buildEntry = (name, d, getHost, colorCaches, scalarCaches, vectorCaches) => {
+ const path = d.path;
+ if (d.kind === KIND_COLOR) {
+ const cache = colorCaches[path];
+ return cache[name] || (cache[name] = {
+ get: (t) => readColorAt(getHost(t), name, path),
+ set: (t, _, tw) => writeColorAt(getHost(t), name, tw._numbers, path),
+ });
+ }
+ if (d.kind === KIND_SCALAR) {
+ const cache = scalarCaches[path];
+ return cache[name] || (cache[name] = {
+ get: (t) => readScalar(getHost(t), name, path),
+ set: (t, v) => writeScalar(getHost(t), name, v, path),
+ });
+ }
+ // KIND_VECTOR
+ const base = d.base;
+ const axis = d.axis;
+ const cache = vectorCaches[path];
+ return cache[name] || (cache[name] = {
+ get: (t) => readVectorAt(getHost(t), base, axis, path),
+ set: (t, v) => writeVectorAt(getHost(t), base, axis, v, path),
+ });
+};
+
+// Detect direct Color, Vector axis, uniforms, and UniformNode slots on the target.
+// Numeric or boolean direct fields fall through to the engine OBJECT path.
+threeAdapter.registerPropertyResolver((target, name) => {
+ const d = classifyTargetProp(target, name);
+ if (!d) return null;
+ if (d.kind === KIND_SCALAR && d.path === PATH_DIRECT) return null;
+ return buildEntry(name, d, identity, directColorCache, directScalarCache, directVectorCache);
+});
+
+// Walk to target.material for meshes and other Object3D subclasses with a material field.
+// Skip when the target already exposes the name directly so a mesh-level mapping wins.
+threeAdapter.registerPropertyResolver((target, name) => {
+ if (target[name] !== undefined) return null;
+ const m = target.material;
+ if (!m) return null;
+ const first = Array.isArray(m) ? m[0] : m;
+ if (!first) return null;
+ const d = classifyTargetProp(first, name);
+ if (!d) return null;
+ return buildEntry(name, d, getMaterial, materialColorCache, materialScalarCache, materialVectorCache);
+});
+
+// Convert angle-named scalar fields between degrees and radians so users animate in degrees on any three.js target.
+// Object3D Euler rotation is excluded because Euler is not a number, the rotateX/Y/Z mappings handle it.
+const ANGLE_NAMES = { rotation: 1, angle: 1 };
+const angleEntries = {};
+threeAdapter.registerPropertyResolver((target, name) => {
+ if (!ANGLE_NAMES[name]) return null;
+ if (typeof target[name] !== 'number') return null;
+ return angleEntries[name] || (angleEntries[name] = {
+ get: (t) => radToDeg(t[name]),
+ set: (t, v) => { t[name] = degToRad(v); },
+ });
+});
+
+// Decompose Euler-typed angle fields to axis components in degrees, like rotationX, rotationY, rotationZ when rotation is an Euler.
+// Object3D mappings win because static adapter props beat resolvers, so this only catches non-Object3D targets with an Euler rotation field.
+const eulerAxisEntries = {};
+threeAdapter.registerPropertyResolver((target, name) => {
+ const axis = AXIS_MAP[name[name.length - 1]];
+ if (!axis) return null;
+ const base = name.slice(0, -1);
+ if (!ANGLE_NAMES[base]) return null;
+ const v = target[base];
+ if (!v || !v.isEuler) return null;
+ return eulerAxisEntries[name] || (eulerAxisEntries[name] = {
+ get: (t) => radToDeg(t[base][axis]),
+ set: (t, v) => { t[base][axis] = degToRad(v); },
+ });
+});
diff --git a/src/adapters/three/uniform.js b/src/adapters/three/uniform.js
new file mode 100644
index 00000000..a837a9e8
--- /dev/null
+++ b/src/adapters/three/uniform.js
@@ -0,0 +1,31 @@
+/**
+ * Bare `UniformNode` adapter. Auto-detects `UniformNode` instances and exposes their `.value` for animation. Scalars and booleans animate via `value`, `Color` uniforms via `color`, and `Vector2/3/4` uniforms via `x` / `y` / `z` / `w` axes.
+ *
+ * import 'animejs/bindings/three';
+ * import { uniform } from 'three/tsl';
+ * animate(uniform(0), { value: 1 });
+ * animate(uniform(new Color()), { color: '#0f0' });
+ * animate(uniform(new Vector3()), { x: 1, y: 0.5 });
+ *
+ * `UniformNode` slots assigned to `NodeMaterial` (`material.colorNode`, `material.offsetNode`, ...) are auto-detected by the shared resolvers in `resolvers.js`. Non-uniform nodes (`mix`, `add`, computed expressions), `Matrix3/4` and `Texture` valued uniforms, and `UniformArrayNode` / `BufferNode` are out of scope and fall through to the engine's direct property path.
+ */
+
+import { SRGBColorSpace } from 'three';
+import { threeAdapter } from './adapter.js';
+import { COLOR_NORM, isVectorWith, readColorHex } from './helpers.js';
+
+const uniformNode = threeAdapter.registerTargetAdapter((t) => !!(t && t.isUniformNode));
+
+// Scalar and bool uniforms animate via the engine OBJECT fallthrough on value, no adapter prop needed since the engine writes uniform value natively.
+uniformNode.registerProperty('color',
+ (t) => readColorHex(t.value),
+ (t, _, tw) => {
+ const ns = tw._numbers;
+ t.value.setRGB(ns[0] * COLOR_NORM, ns[1] * COLOR_NORM, ns[2] * COLOR_NORM, SRGBColorSpace);
+ },
+ (t) => !!(t.value && t.value.isColor),
+);
+uniformNode.registerProperty('x', (t) => t.value.x, (t, v) => { t.value.x = v; }, (t) => isVectorWith(t.value, 'x'));
+uniformNode.registerProperty('y', (t) => t.value.y, (t, v) => { t.value.y = v; }, (t) => isVectorWith(t.value, 'y'));
+uniformNode.registerProperty('z', (t) => t.value.z, (t, v) => { t.value.z = v; }, (t) => isVectorWith(t.value, 'z'));
+uniformNode.registerProperty('w', (t) => t.value.w, (t, v) => { t.value.w = v; }, (t) => isVectorWith(t.value, 'w'));
diff --git a/src/animatable/animatable.js b/src/animatable/animatable.js
index 9b570572..0b859e8e 100644
--- a/src/animatable/animatable.js
+++ b/src/animatable/animatable.js
@@ -73,6 +73,7 @@ export class Animatable {
const callbacksAnimationParams = { v: 1, autoplay: false };
const properties = {};
this.targets = [];
+ /** @type {Record<String, JSAnimation>} */
this.animations = {};
/** @type {JSAnimation|null} */
this.callbacks = null;
diff --git a/src/animation/animation.js b/src/animation/animation.js
index 93f3ceec..523fc78a 100644
--- a/src/animation/animation.js
+++ b/src/animation/animation.js
@@ -1,6 +1,7 @@
import {
K,
minValue,
+ emptyArray,
tweenTypes,
valueTypes,
compositionTypes,
@@ -33,6 +34,10 @@ import {
registerTargets,
} from '../core/targets.js';
+import {
+ resolveAdapterEntry,
+} from '../adapters/registry.js';
+
import {
getRelativeValue,
getFunctionValue,
@@ -43,7 +48,6 @@ import {
decomposeTweenValue,
decomposedOriginalValue,
createDecomposedValueTargetObject,
- composeColorValue,
composeComplexValue,
} from '../core/values.js';
@@ -231,6 +235,11 @@ export class JSAnimation extends Timer {
super(/** @type {TimerParams & AnimationParams} */(parameters), parent, parentPosition);
+ /** @type {Tween} */
+ this._head;
+ /** @type {Tween} */
+ this._tail;
+
++JSAnimationId;
const parsedTargets = registerTargets(targets);
@@ -287,6 +296,7 @@ export class JSAnimation extends Timer {
if (isKey(p)) {
const tweenType = getTweenType(target, p);
+ const adapterProp = resolveAdapterEntry(target, p);
const propName = sanitizePropertyName(p, target, tweenType);
@@ -370,7 +380,7 @@ export class JSAnimation extends Timer {
} else {
tweenToValue = computedToValue;
}
- const tweenFromValue = getFunctionValue(key.from, target, ti, tl, null, prevSiblingTween);
+ const tweenFromValue = getFunctionValue(key.from, target, ti, tl, fromFunctionStore, prevSiblingTween);
const easeToParse = key.ease || tEasing;
const easeFunctionResult = getFunctionValue(easeToParse, target, ti, tl, null, prevSiblingTween);
@@ -388,9 +398,13 @@ export class JSAnimation extends Timer {
const hasToValue = !isUnd(tweenToValue);
const isFromToArray = isArr(tweenToValue);
const isFromToValue = isFromToArray || (hasFromvalue && hasToValue);
+ // Capture the update-start in local time, the previous sibling's end for keyframes after the first, zero for the first keyframe. Used to derive a precision-matched _absoluteUpdateStartTime below.
+ const tweenUpdateStartLocal = prevTween ? lastTweenChangeEndTime : 0;
const tweenStartTime = prevTween ? lastTweenChangeEndTime + tweenDelay : tweenDelay;
// Rounding is necessary here to minimize floating point errors when working in seconds
const absoluteStartTime = round(absoluteOffsetTime + tweenStartTime, 12);
+ // Match the rounding pattern of prevSibling._absoluteEndTime so the composition overlap check compares cleanly when keyframes touch at a boundary.
+ const absoluteUpdateStartTime = round(absoluteOffsetTime + tweenUpdateStartLocal, 12);
// Force a onRender callback if the animation contains at least one from value and autoplay is set to false
if (!shouldTriggerRender && (hasFromvalue || isFromToArray)) shouldTriggerRender = 1;
@@ -399,9 +413,9 @@ export class JSAnimation extends Timer {
if (tweenComposition !== compositionTypes.none) {
let nextSibling = siblings._head;
- // Iterate trough all the next siblings until we find a sibling with an equal or inferior start time
- while (nextSibling && !nextSibling._isOverridden && nextSibling._absoluteStartTime <= absoluteStartTime) {
- prevSibling = nextSibling;
+ // Walk prior siblings up to the new tween, skipping overridden ones so the chain resolves to the latest live value instead of stopping at the first override.
+ while (nextSibling && nextSibling._absoluteStartTime <= absoluteStartTime) {
+ if (!nextSibling._isOverridden) prevSibling = nextSibling;
nextSibling = nextSibling._nextRep;
// Overrides all the next siblings if the next sibling starts at the same time of after as the new tween start time
if (nextSibling && nextSibling._absoluteStartTime >= absoluteStartTime) {
@@ -455,8 +469,8 @@ export class JSAnimation extends Timer {
if (prevTween) {
decomposeTweenValue(prevTween, fromTargetObject);
} else {
- decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
// No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
+ decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), fromTargetObject);
}
}
@@ -495,8 +509,7 @@ export class JSAnimation extends Timer {
const colorValue = fromTargetObject.t === valueTypes.COLOR ? fromTargetObject : toTargetObject;
const notColorValue = fromTargetObject.t === valueTypes.COLOR ? toTargetObject : fromTargetObject;
notColorValue.t = valueTypes.COLOR;
- notColorValue.s = colorValue.s;
- notColorValue.d = [0, 0, 0, 1];
+ notColorValue.d = colorValue.d.map(() => 0);
}
}
@@ -526,6 +539,16 @@ export class JSAnimation extends Timer {
let inlineValue = inlineStylesStore[propName];
if (!isNil(inlineValue)) inlineStylesStore[propName] = null;
+ // Resolve the adapter setter once so render skips the lookup per frame.
+ const tweenSetter = adapterProp ? adapterProp.set : null;
+
+ // Rounding is necessary here to minimize floating point errors when working in seconds
+ lastTweenChangeEndTime = round(tweenStartTime + tweenUpdateDuration, 12);
+
+ const fromD = fromTargetObject.d;
+ const toD = toTargetObject.d;
+ const toS = toTargetObject.s;
+
/** @type {Tween} */
const tween = {
parent: this,
@@ -536,12 +559,12 @@ export class JSAnimation extends Timer {
_toFunc: toFunctionStore.func,
_fromFunc: fromFunctionStore.func,
_ease: parseEase(tweenEasing),
- _fromNumbers: cloneArray(fromTargetObject.d),
- _toNumbers: cloneArray(toTargetObject.d),
- _strings: cloneArray(toTargetObject.s),
+ _fromNumbers: fromD ? cloneArray(fromD) : emptyArray,
+ _toNumbers: toD ? cloneArray(toD) : emptyArray,
+ _strings: toS ? cloneArray(toS) : emptyArray,
_fromNumber: fromTargetObject.n,
_toNumber: toTargetObject.n,
- _numbers: cloneArray(fromTargetObject.d), // For additive tween and animatables
+ _numbers: fromD ? cloneArray(fromD) : emptyArray, // For additive tween and animatables
_number: fromTargetObject.n, // For additive tween and animatables
_unit: toTargetObject.u,
_modifier: tweenModifier,
@@ -551,8 +574,12 @@ export class JSAnimation extends Timer {
_updateDuration: tweenUpdateDuration,
_changeDuration: tweenUpdateDuration,
_absoluteStartTime: absoluteStartTime,
+ _absoluteUpdateStartTime: absoluteUpdateStartTime,
+ _absoluteEndTime: round(absoluteOffsetTime + lastTweenChangeEndTime, 12),
+ _hasFromValue: hasFromvalue || isFromToArray ? 1 : 0,
// NOTE: Investigate bit packing to stores ENUM / BOOL
_tweenType: tweenType,
+ _setter: tweenSetter,
_valueType: toTargetObject.t,
_composition: tweenComposition,
_isOverlapped: 0,
@@ -575,10 +602,11 @@ export class JSAnimation extends Timer {
const vt = tween._valueType;
if (vt === valueTypes.COMPLEX) {
tween._value = composeComplexValue(tween, 1, -1);
- } else if (vt === valueTypes.COLOR) {
- tween._value = composeColorValue(tween, 1, -1);
} else if (vt === valueTypes.UNIT) {
tween._value = `${tweenModifier(tween._toNumber)}${tween._unit}`;
+ } else if (vt === valueTypes.COLOR) {
+ const d = toTargetObject.d;
+ tween._value = `rgba(${round(d[0], 0)},${round(d[1], 0)},${round(d[2], 0)},${d[3]})`;
} else {
tween._value = tweenModifier(tween._toNumber);
}
@@ -586,8 +614,7 @@ export class JSAnimation extends Timer {
if (isNaN(firstTweenChangeStartTime)) {
firstTweenChangeStartTime = tween._startTime;
}
- // Rounding is necessary here to minimize floating point errors when working in seconds
- lastTweenChangeEndTime = round(tweenStartTime + tweenUpdateDuration, 12);
+
prevTween = tween;
animationAnimationLength++;
@@ -693,8 +720,11 @@ export class JSAnimation extends Timer {
tween._updateDuration = normalizeTime(tween._updateDuration * timeScale);
tween._changeDuration = normalizeTime(tween._changeDuration * timeScale);
tween._currentTime *= timeScale;
+ tween._delay *= timeScale;
tween._startTime *= timeScale;
tween._absoluteStartTime *= timeScale;
+ tween._absoluteUpdateStartTime *= timeScale;
+ tween._absoluteEndTime *= timeScale;
});
return super.stretch(newDuration);
}
diff --git a/src/animation/composition.js b/src/animation/composition.js
index 695120ef..2b0ef5de 100644
--- a/src/animation/composition.js
+++ b/src/animation/composition.js
@@ -111,7 +111,7 @@ export const composeTween = (tween, siblings) => {
if (prevSibling) {
const prevParent = prevSibling.parent;
- const prevAbsEndTime = prevSibling._absoluteStartTime + prevSibling._changeDuration;
+ const prevAbsEndTime = prevSibling._absoluteEndTime;
// Handle looped animations tween
@@ -137,7 +137,8 @@ export const composeTween = (tween, siblings) => {
}
- const absoluteUpdateStartTime = tweenAbsStartTime - tween._delay;
+ // Read the precision-matched update-start instead of subtracting tween._delay live so sequential keyframes touching at a boundary don't trigger a phantom overlap from float drift.
+ const absoluteUpdateStartTime = tween._absoluteUpdateStartTime;
if (prevAbsEndTime > absoluteUpdateStartTime) {
@@ -157,37 +158,41 @@ export const composeTween = (tween, siblings) => {
}
}
- // Pause (and cancel) the parent if it only contains overlapped tweens
+ // Skip the cancel cascade when both tweens share the same parent timeline, a timeline cannot replace itself.
+ const tweenParentTL = tween.parent.parent;
+ if (!tweenParentTL || tweenParentTL !== prevParent.parent) {
- let pausePrevParentAnimation = true;
+ let pausePrevParentAnimation = true;
- forEachChildren(prevParent, (/** @type Tween */t) => {
- if (!t._isOverlapped) pausePrevParentAnimation = false;
- });
+ forEachChildren(prevParent, (/** @type Tween */t) => {
+ if (!t._isOverlapped) pausePrevParentAnimation = false;
+ });
- if (pausePrevParentAnimation) {
- const prevParentTL = prevParent.parent;
- if (prevParentTL) {
- let pausePrevParentTL = true;
- forEachChildren(prevParentTL, (/** @type JSAnimation */a) => {
- if (a !== prevParent) {
- forEachChildren(a, (/** @type Tween */t) => {
- if (!t._isOverlapped) pausePrevParentTL = false;
- });
+ if (pausePrevParentAnimation) {
+ const prevParentTL = prevParent.parent;
+ if (prevParentTL) {
+ let pausePrevParentTL = true;
+ forEachChildren(prevParentTL, (/** @type JSAnimation */a) => {
+ if (a !== prevParent) {
+ forEachChildren(a, (/** @type Tween */t) => {
+ if (!t._isOverlapped) pausePrevParentTL = false;
+ });
+ }
+ });
+ if (pausePrevParentTL) {
+ prevParentTL.cancel();
}
- });
- if (pausePrevParentTL) {
- prevParentTL.cancel();
+ } else {
+ prevParent.cancel();
+ // Previously, calling .cancel() on a timeline child would affect the render order of other children
+ // Worked around this by marking it as .completed and using .pause() for safe removal in the engine loop
+ // This is no longer needed since timeline tween composition is now handled separately
+ // Keeping this here for reference
+ // prevParent.completed = true;
+ // prevParent.pause();
}
- } else {
- prevParent.cancel();
- // Previously, calling .cancel() on a timeline child would affect the render order of other children
- // Worked around this by marking it as .completed and using .pause() for safe removal in the engine loop
- // This is no longer needed since timeline tween composition is now handled separately
- // Keeping this here for reference
- // prevParent.completed = true;
- // prevParent.pause();
}
+
}
}
@@ -242,14 +247,12 @@ export const composeTween = (tween, siblings) => {
tween._number = 0;
lookupTween._fromNumber = toNumber;
- if (tween._toNumbers) {
+ if (tween._toNumbers.length) {
const toNumbers = cloneArray(tween._toNumbers);
- if (toNumbers) {
- toNumbers.forEach((value, i) => {
- tween._fromNumbers[i] = lookupTween._fromNumbers[i] - value;
- tween._toNumbers[i] = 0;
- });
- }
+ toNumbers.forEach((value, i) => {
+ tween._fromNumbers[i] = lookupTween._fromNumbers[i] - value;
+ tween._toNumbers[i] = 0;
+ });
lookupTween._fromNumbers = toNumbers;
}
diff --git a/src/core/clock.js b/src/core/clock.js
index 0f43f93f..695eac19 100644
--- a/src/core/clock.js
+++ b/src/core/clock.js
@@ -35,8 +35,6 @@ export class Clock {
/** @type {Number} */
this._lastTime = initTime;
/** @type {Number} */
- this._scheduledTime = 0;
- /** @type {Number} */
this._frameDuration = K / maxFps;
/** @type {Number} */
this._fps = maxFps;
@@ -55,14 +53,12 @@ export class Clock {
}
set fps(frameRate) {
- const previousFrameDuration = this._frameDuration;
const fr = +frameRate;
const fps = fr < minValue ? minValue : fr;
const frameDuration = K / fps;
if (fps > defaults.frameRate) defaults.frameRate = fps;
this._fps = fps;
this._frameDuration = frameDuration;
- this._scheduledTime += frameDuration - previousFrameDuration;
}
get speed() {
@@ -79,17 +75,17 @@ export class Clock {
* @return {tickModes}
*/
requestTick(time) {
- const scheduledTime = this._scheduledTime;
- this._lastTickTime = time;
- // If the current time is lower than the scheduled time
- // this means not enough time has passed to hit one frameDuration
- // so skip that frame
- if (time < scheduledTime) return tickModes.NONE;
const frameDuration = this._frameDuration;
- const frameDelta = time - scheduledTime;
- // Ensures that _scheduledTime progresses in steps of at least 1 frameDuration.
- // Skips ahead if the actual elapsed time is higher.
- this._scheduledTime += frameDelta < frameDuration ? frameDuration : frameDelta;
+ const elapsed = time - this._lastTickTime;
+ const scaled = frameDuration * .25;
+ const tolerance = scaled < 4 ? scaled : 4;
+ // Tolerance prevents dropping frames that arrive a bit early due to RAF jitter
+ // typically <= ~25% of frame duration and capped at 4ms so it doesn't dominate at high fps.
+ // e.g. at 60fps (frameDuration=16.667ms) a frame arriving after 15ms:
+ // - without tolerance: 15 < 16.667 -> skip
+ // - with tolerance: 15 + 4 >= 16.667 -> tick
+ if (elapsed + tolerance < frameDuration) return tickModes.NONE;
+ this._lastTickTime = elapsed >= frameDuration ? time - (elapsed % frameDuration) : time;
return tickModes.AUTO;
}
diff --git a/src/core/colors.js b/src/core/colors.js
index 2a83459d..bc70b6cf 100644
--- a/src/core/colors.js
+++ b/src/core/colors.js
@@ -101,3 +101,4 @@ export const convertColorStringValuesToRgbaArray = colorString => {
isHsl(colorString) ? hslToRgba(colorString) :
[0, 0, 0, 1];
}
+
diff --git a/src/core/consts.js b/src/core/consts.js
index cf297dcb..aaef2d1a 100644
--- a/src/core/consts.js
+++ b/src/core/consts.js
@@ -64,6 +64,11 @@ export const maxFps = 240;
export const emptyString = '';
export const cssVarPrefix = 'var(';
+// Arrays
+
+// Shared sentinel for tween slots that don't hold array data. Never mutated, only read; COMPLEX and COLOR tweens always replace the slot before writing.
+export const emptyArray = [];
+
export const shortTransforms = /*#__PURE__*/ (() => {
const map = new Map();
map.set('x', 'translateX');
@@ -97,6 +102,13 @@ export const transformsFragmentStrings = /*#__PURE__*/ validTransforms.reduce((a
/** @return {void} */
export const noop = () => {};
+/**
+ * @template T
+ * @param {T} v
+ * @return {T}
+ */
+export const noopModifier = v => v;
+
// Regex
export const validRgbHslRgx = /\)\s*[-.\d]/;
diff --git a/src/core/globals.js b/src/core/globals.js
index 730cf631..bf1cb6e0 100644
--- a/src/core/globals.js
+++ b/src/core/globals.js
@@ -1,6 +1,7 @@
import {
K,
noop,
+ noopModifier,
maxFps,
compositionTypes,
win,
@@ -22,10 +23,13 @@ import {
/**
* @typedef {Object} EditorGlobals
* @property {boolean} showPanel
- * @property {boolean} synced
* @property {Function} addAnimation
+ * @property {Function} addSet
* @property {Function} addTimeline
* @property {Function} addTimelineChild
+ * @property {Function} addTimelineLabel
+ * @property {Function} addTimelineCall
+ * @property {Function} addTimelineSync
* @property {Function} resolveStagger
* @property {Object|null} _head
* @property {Object|null} _tail
@@ -48,7 +52,7 @@ export const defaults = {
loopDelay: 0,
ease: 'out(2)',
composition: compositionTypes.replace,
- modifier: v => v,
+ modifier: noopModifier,
onBegin: noop,
onBeforeUpdate: noop,
onUpdate: noop,
diff --git a/src/core/helpers.js b/src/core/helpers.js
index 0cbbdd1a..8b7c84e6 100644
--- a/src/core/helpers.js
+++ b/src/core/helpers.js
@@ -156,7 +156,7 @@ export const snap = (v, increment) => isArr(increment) ? increment.reduce((close
* @param {Number} factor - Interpolation factor in the range [0, 1]
* @return {Number} The interpolated value
*/
-export const lerp = (start, end, factor) => start + (end - start) * factor;
+export const lerp = (start, end, factor) => factor === 1 ? end : factor === 0 ? start : start + (end - start) * factor;
/**
* Replaces infinity with maximum safe value
diff --git a/src/core/render.js b/src/core/render.js
index d647b71b..d9e0b73e 100644
--- a/src/core/render.js
+++ b/src/core/render.js
@@ -24,7 +24,6 @@ import {
} from './transforms.js';
import {
- composeColorValue,
composeComplexValue,
} from './values.js';
@@ -91,12 +90,14 @@ export const render = (tickable, time, muteCallbacks, internalRender, tickMode)
// Execute the "expensive" iterations calculations only when necessary
if (iterationCount > 1) {
// bitwise NOT operator seems to be generally faster than Math.floor() across browsers
- const currentIteration = ~~(tickableCurrentTime / (iterationDuration + (isCurrentTimeEqualOrAboveDuration ? 0 : _loopDelay)));
+ const period = iterationDuration + (isCurrentTimeEqualOrAboveDuration ? 0 : _loopDelay);
+ const currentIteration = ~~(tickableCurrentTime / period);
tickable._currentIteration = clamp(currentIteration, 0, iterationCount);
// Prevent the iteration count to go above the max iterations when reaching the end of the animation
if (isCurrentTimeEqualOrAboveDuration) tickable._currentIteration--;
isOdd = tickable._currentIteration % 2;
- iterationElapsedTime = tickableCurrentTime % (iterationDuration + _loopDelay) || 0;
+ // Derive elapsed from the same `~~` truncation that gave currentIteration. Using `% period` here can disagree with `~~(/period)` under float drift at iteration boundaries and write the wrong end of the tween for one frame.
+ iterationElapsedTime = tickableCurrentTime - currentIteration * period || 0;
}
// Checks if exactly one of _reversed and (_alternate && isOdd) is true
@@ -128,12 +129,14 @@ export const render = (tickable, time, muteCallbacks, internalRender, tickMode)
if (
forcedTick ||
tickMode === tickModes.AUTO && (
- time >= tickableDelay && time <= tickableEndTime || // Normal render
+ // Timeline children render from their offset instead of their delay so the gap left by a truncated sibling is covered on seek.
+ time >= (parent && tickableDelay > 0 ? 0 : tickableDelay) && time <= tickableEndTime || // Normal render
time <= tickableDelay && tickablePrevTime > tickableDelay || // Playhead is before the animation start time so make sure the animation is at its initial state
time >= tickableEndTime && tickablePrevTime !== duration // Playhead is after the animation end time so make sure the animation is at its end state
) ||
iterationTime >= tickableEndTime && tickablePrevTime !== duration ||
- iterationTime <= tickableDelay && tickablePrevTime > 0 ||
+ // iterationTime is per-iteration, compared to the delay to catch a backward seek into a looped iteration's delay region. Exclude the final settled end, where iterationTime clamps to duration and would falsely match the delay region when the delay exceeds the duration.
+ iterationTime <= tickableDelay && tickablePrevTime > 0 && !isCurrentTimeEqualOrAboveDuration ||
time <= tickablePrevTime && tickablePrevTime === duration && completed || // Force a render if a seek occurs on an completed animation
isCurrentTimeEqualOrAboveDuration && !completed && isSetter // This prevents 0 duration tickables to be skipped
) {
@@ -149,7 +152,8 @@ export const render = (tickable, time, muteCallbacks, internalRender, tickMode)
// Time has jumped more than globals.tickThreshold so consider this tick manual
const forcedRender = forcedTick || (isRunningBackwards ? deltaTime * -1 : deltaTime) >= globals.tickThreshold;
- const absoluteTime = tickable._offset + (parent ? parent._offset : 0) + tickableDelay + iterationTime;
+ // Round to match the precision of tween._absoluteStartTime so equal-time boundary checks compare cleanly without floating point drift from the unrounded _offset.
+ const absoluteTime = round(tickable._offset + (parent ? parent._offset : 0) + tickableDelay + iterationTime, 12);
// Only Animation can have tweens, Timer returns undefined
let tween = /** @type {Tween} */(/** @type {JSAnimation} */(tickable)._head);
@@ -168,15 +172,38 @@ export const render = (tickable, time, muteCallbacks, internalRender, tickMode)
const tweenNextRep = tween._nextRep;
const tweenPrevRep = tween._prevRep;
const tweenHasComposition = tweenComposition !== compositionTypes.none;
+ // The previous sibling stops writing at its truncated end, so this tween takes over the hold from that point.
+ const tweenPrevRepEndTime = tweenPrevRep ? tweenPrevRep._absoluteStartTime + tweenPrevRep._changeDuration : 0;
+ const tweenPrevRepIsCrossParent = tweenPrevRep && tweenPrevRep.parent !== tween.parent;
+ // Same parent keyframes take over at their own start, end plus delay equals the next start by construction.
+ // Cross parent siblings take over at their update start.
+ // Negative delay siblings take over at their own start instead.
+ const tweenNextRepTakeover = !tweenNextRep || tweenNextRep._isOverridden ? tweenAbsEndTime :
+ tweenNextRep.parent === tween.parent ? tweenAbsEndTime + tweenNextRep._delay :
+ tweenNextRep._absoluteStartTime < tweenNextRep._absoluteUpdateStartTime ? tweenNextRep._absoluteStartTime : tweenNextRep._absoluteUpdateStartTime;
if ((forcedRender || (
- (tweenCurrentTime !== tweenChangeDuration || absoluteTime <= tweenAbsEndTime + (tweenNextRep ? tweenNextRep._delay : 0)) &&
- (tweenCurrentTime !== 0 || absoluteTime >= tween._absoluteStartTime)
- )) && (!tweenHasComposition || (
+ // Tail keyframes always re-evaluate the gate so an earlier keyframe cannot leave the target stale by writing past its own range after a backward seek.
+ (tweenCurrentTime !== tweenChangeDuration || absoluteTime <= tweenNextRepTakeover ||
+ (tweenPrevRep && !tweenPrevRepIsCrossParent && (!tweenNextRep || tweenNextRep.parent !== tween.parent))) &&
+ // A cross parent tween re-renders its from value from the previous sibling truncated end so the handoff gap holds.
+ // A keyframe re-renders its from revert while the next keyframe time is stale so a backward jump over its range cannot leave the next value in place.
+ (tweenCurrentTime !== 0 || absoluteTime >= tween._absoluteStartTime ||
+ (tweenPrevRepIsCrossParent && !tween._hasFromValue && !tweenPrevRep._isOverridden && absoluteTime >= tweenPrevRepEndTime) ||
+ (tweenNextRep && !tweenNextRep._isOverridden && tweenNextRep.parent === tween.parent && tweenNextRep._currentTime !== 0 && iterationTime < tweenNextRep._startTime))
+ )) &&
+ // Non-first keyframes wait until the iteration reaches their own start before rendering, so the previous keyframe can handle the from-revert when scrubbed backward past this tween's range.
+ (!tweenPrevRep || tweenPrevRepIsCrossParent || iterationTime >= tween._startTime) &&
+ (!tweenHasComposition || (
!tween._isOverridden &&
(!tween._isOverlapped || absoluteTime <= tweenAbsEndTime) &&
- (!tweenNextRep || (tweenNextRep._isOverridden || absoluteTime <= tweenNextRep._absoluteStartTime)) &&
- (!tweenPrevRep || (tweenPrevRep._isOverridden || (absoluteTime >= (tweenPrevRep._absoluteStartTime + tweenPrevRep._changeDuration) + tween._delay)))
+ // The next sibling owns the value past its takeover point, so yielding there keeps writes single owner in both directions.
+ (!tweenNextRep || tweenNextRep._isOverridden || absoluteTime <= tweenNextRepTakeover) &&
+ // The previous sibling owns the value up to its truncated end.
+ // Cross parent tweens take over the hold from that point, explicit from values wait for their own start.
+ (!tweenPrevRep || (tweenPrevRep._isOverridden || (!tweenPrevRepIsCrossParent ?
+ absoluteTime >= tweenPrevRepEndTime + tween._delay :
+ absoluteTime >= tween._absoluteStartTime || (!tween._hasFromValue && absoluteTime >= tweenPrevRepEndTime))))
))
) {
@@ -187,7 +214,7 @@ export const render = (tickable, time, muteCallbacks, internalRender, tickMode)
const tweenType = tween._tweenType;
const tweenIsObject = tweenType === tweenTypes.OBJECT;
const tweenIsNumber = tweenValueType === valueTypes.NUMBER;
- // Only round the in-between frames values if the final value is a string
+ // Only round the in-between frames values if the final value is a string. Object targets consume raw numbers, so rounding is dead work there.
const tweenPrecision = (tweenIsNumber && tweenIsObject) || tweenProgress === 0 || tweenProgress === 1 ? -1 : globals.precision;
// Recompose tween value
@@ -203,7 +230,22 @@ export const render = (tickable, time, muteCallbacks, internalRender, tickMode)
number = /** @type {Number} */(tweenModifier(round(lerp(tween._fromNumber, tween._toNumber, tweenProgress), tweenPrecision)));
value = `${number}${tween._unit}`;
} else if (tweenValueType === valueTypes.COLOR) {
- value = composeColorValue(tween, tweenProgress, tweenPrecision);
+ const ns = tween._numbers;
+ const fn = tween._fromNumbers;
+ const tn = tween._toNumbers;
+ const omt = 1 - tweenProgress;
+ const fr = fn[0], fg = fn[1], fb = fn[2];
+ const tr = tn[0], tg = tn[1], tb = tn[2];
+ // RGB channels lerp in pseudo-linear space (square inputs, sqrt result) to approximate gamma-correct blending.
+ // See https://developer.nvidia.com/gpugems/gpugems3/part-iv-image-effects/chapter-24-importance-being-linear.
+ ns[0] = /** @type {Number} */(tweenModifier(Math.sqrt(fr * fr * omt + tr * tr * tweenProgress)));
+ ns[1] = /** @type {Number} */(tweenModifier(Math.sqrt(fg * fg * omt + tg * tg * tweenProgress)));
+ ns[2] = /** @type {Number} */(tweenModifier(Math.sqrt(fb * fb * omt + tb * tb * tweenProgress)));
+ ns[3] = /** @type {Number} */(tweenModifier(lerp(fn[3], tn[3], tweenProgress)));
+ // The rgba string is built only for the dispatch path or the internalRender composition tick (setters handles the color comp)
+ if (!tween._setter || internalRender) {
+ value = `rgba(${round(ns[0], 0)},${round(ns[1], 0)},${round(ns[2], 0)},${ns[3]})`;
+ }
} else if (tweenValueType === valueTypes.COMPLEX) {
value = composeComplexValue(tween, tweenProgress, tweenPrecision);
}
@@ -218,7 +260,9 @@ export const render = (tickable, time, muteCallbacks, internalRender, tickMode)
const tweenProperty = tween.property;
tweenTarget = tween.target;
- if (tweenIsObject) {
+ if (tween._setter) {
+ tween._setter(tweenTarget, number, tween);
+ } else if (tweenIsObject) {
tweenTarget[tweenProperty] = value;
} else if (tweenType === tweenTypes.ATTRIBUTE) {
/** @type {DOMTarget} */(tweenTarget).setAttribute(tweenProperty, /** @type {String} */(value));
@@ -246,6 +290,9 @@ export const render = (tickable, time, muteCallbacks, internalRender, tickMode)
tween._value = value;
}
+ } else if (tweenCurrentTime && tweenPrevRep && !tweenPrevRepIsCrossParent && iterationTime < tween._startTime) {
+ // Mark the keyframe as reverted when the playhead moves before its start, the previous keyframe owns the from revert and writes it once.
+ tween._currentTime = 0;
}
if (tweenTransformsNeedUpdate && tween._renderTransforms) {
@@ -353,6 +400,8 @@ export const tick = (tickable, time, muteCallbacks, internalRender, tickMode) =>
forEachChildren(tl, (/** @type {JSAnimation} */child) => {
const childTime = round((tlChildrenTime - child._offset) * child._speed, 12); // Rounding is needed when using seconds
+ // Skip past-end siblings on backward iteration so their progress=1 to-values don't render last and overwrite the active sibling's write. Compare against _delay + duration so children with a normalized delay are not skipped while still inside their active range.
+ if (tlIsRunningBackwards && childTime > child._delay + child.duration) return;
const childTickMode = child._fps < tl._fps ? child.requestTick(tlCildrenTickTime) : tickMode;
tlChildrenHasRendered += render(child, childTime, muteCallbacks, internalRender, childTickMode);
if (!child.completed && tlChildrenHaveCompleted) tlChildrenHaveCompleted = false;
diff --git a/src/core/styles.js b/src/core/styles.js
index a2bfb50e..a872e334 100644
--- a/src/core/styles.js
+++ b/src/core/styles.js
@@ -17,6 +17,11 @@ import {
buildTransformString,
} from './transforms.js';
+import {
+ decomposeRawValue,
+ decomposedOriginalValue,
+} from './values.js';
+
/**
* @import {
* JSAnimation,
@@ -82,7 +87,20 @@ export const revertValues = (renderable, inlineStylesOnly = false) => {
const tweenType = tween._tweenType;
const originalInlinedValue = tween._inlineValue;
const tweenHadNoInlineValue = isNil(originalInlinedValue) || originalInlinedValue === emptyString;
- if (tweenType === tweenTypes.OBJECT) {
+ if (tween._setter) {
+ if (!inlineStylesOnly && !tweenHadNoInlineValue) {
+ // Re-seed the original value to the _number / _numbers props so the setter can write the original state instead of re-applying the current frame.
+ decomposeRawValue(originalInlinedValue, decomposedOriginalValue);
+ if (decomposedOriginalValue.d) {
+ const src = decomposedOriginalValue.d;
+ const dst = tween._numbers;
+ for (let i = 0, l = src.length; i < l; i++) dst[i] = src[i];
+ } else {
+ tween._number = decomposedOriginalValue.n;
+ }
+ tween._setter(tween.target, tween._number, tween);
+ }
+ } else if (tweenType === tweenTypes.OBJECT) {
if (!inlineStylesOnly && !tweenHadNoInlineValue) {
tweenTarget[tweenProperty] = originalInlinedValue;
}
diff --git a/src/core/targets.js b/src/core/targets.js
index 71bc0305..177c162d 100644
--- a/src/core/targets.js
+++ b/src/core/targets.js
@@ -119,18 +119,16 @@ export function parseTargets(targets) {
export function registerTargets(targets) {
const parsedTargetsArray = parseTargets(targets);
const parsedTargetsLength = parsedTargetsArray.length;
- if (parsedTargetsLength) {
- for (let i = 0; i < parsedTargetsLength; i++) {
- const target = parsedTargetsArray[i];
- if (!target[isRegisteredTargetSymbol]) {
- target[isRegisteredTargetSymbol] = true;
- const isSvgType = isSvg(target);
- const isDom = /** @type {DOMTarget} */(target).nodeType || isSvgType;
- if (isDom) {
- target[isDomSymbol] = true;
- target[isSvgSymbol] = isSvgType;
- target[transformsSymbol] = {};
- }
+ for (let i = 0; i < parsedTargetsLength; i++) {
+ const target = parsedTargetsArray[i];
+ if (!target[isRegisteredTargetSymbol]) {
+ target[isRegisteredTargetSymbol] = true;
+ const isSvgType = isSvg(target);
+ const isDom = /** @type {DOMTarget} */(target).nodeType || isSvgType;
+ if (isDom) {
+ target[isDomSymbol] = true;
+ target[isSvgSymbol] = isSvgType;
+ target[transformsSymbol] = {};
}
}
}
diff --git a/src/core/values.js b/src/core/values.js
index d669d53e..98e80176 100644
--- a/src/core/values.js
+++ b/src/core/values.js
@@ -3,7 +3,6 @@ import {
validTransforms,
tweenTypes,
valueTypes,
- compositionTypes,
digitWithExponentRgx,
unitsExecRgx,
isDomSymbol,
@@ -24,7 +23,6 @@ import {
isStr,
round,
lerp,
- clamp,
} from './helpers.js';
import {
@@ -32,7 +30,11 @@ import {
} from './transforms.js';
import {
- convertColorStringValuesToRgbaArray
+ resolveAdapterEntry,
+} from '../adapters/registry.js';
+
+import {
+ convertColorStringValuesToRgbaArray,
} from './colors.js';
/**
@@ -56,6 +58,21 @@ export const setValue = (targetValue, defaultValue) => {
return isUnd(targetValue) ? defaultValue : targetValue;
}
+/**
+ * Resolve against the target when it's a DOM element, otherwise fall back to :root so non-DOM targets like three.js meshes and custom adapters still pick up CSS variables defined on the document.
+ *
+ * @param {String} value
+ * @param {Target} target
+ * @return {String|Number}
+ */
+const resolveCssVar = (value, target) => {
+ const match = value.match(cssVariableMatchRgx);
+ const el = target[isDomSymbol] ? target : document.documentElement;
+ let computed = getComputedStyle(/** @type {HTMLElement} */(el))?.getPropertyValue(match[1]);
+ if ((!computed || computed.trim() === emptyString) && match[2]) computed = match[2].trim();
+ return computed || 0;
+}
+
/**
* @param {TweenPropValue} value
* @param {Target} target
@@ -66,30 +83,26 @@ export const setValue = (targetValue, defaultValue) => {
* @return {any}
*/
export const getFunctionValue = (value, target, index, targets, store, prevTween) => {
- let func;
if (isFnc(value)) {
- func = () => {
+ if (!store) {
const computed = /** @type {Function} */(value)(target, index, targets, prevTween);
- // Fallback to 0 if the function returns undefined / NaN / null / false / 0
+ // Fallback to 0 if the function returns undefined, NaN, null, false or 0
return !isNaN(+computed) ? +computed : computed || 0;
}
- } else if (isStr(value) && stringStartsWith(value, cssVarPrefix)) {
- func = () => {
- const match = value.match(cssVariableMatchRgx);
- const cssVarName = match[1];
- const fallbackValue = match[2];
- let computed = getComputedStyle(/** @type {HTMLElement} */(target))?.getPropertyValue(cssVarName);
- // Use fallback if CSS variable is not set or empty
- if ((!computed || computed.trim() === emptyString) && fallbackValue) {
- computed = fallbackValue.trim();
- }
- return computed || 0;
+ const func = () => {
+ const computed = /** @type {Function} */(value)(target, index, targets, prevTween);
+ return !isNaN(+computed) ? +computed : computed || 0;
}
- } else {
- return value;
+ store.func = func;
+ return func();
}
- if (store) store.func = func;
- return func();
+ if (isStr(value) && stringStartsWith(value, cssVarPrefix)) {
+ if (!store) return resolveCssVar(/** @type {String} */(value), target);
+ const func = () => resolveCssVar(/** @type {String} */(value), target);
+ store.func = func;
+ return func();
+ }
+ return value;
}
/**
@@ -136,6 +149,12 @@ const getCSSValue = (target, propName, animationInlineStyles) => {
*/
export const getOriginalAnimatableValue = (target, propName, tweenType, animationInlineStyles) => {
const type = !isUnd(tweenType) ? tweenType : getTweenType(target, propName);
+ const adapterProp = resolveAdapterEntry(target, propName);
+ if (adapterProp) {
+ const value = adapterProp.get(target);
+ if (value && animationInlineStyles) animationInlineStyles[propName] = value;
+ return value == null ? 0 : value;
+ }
if (type === tweenTypes.OBJECT) {
const value = target[propName];
if (value && animationInlineStyles) animationInlineStyles[propName] = value;
@@ -177,7 +196,7 @@ export const createDecomposedValueTargetObject = () => {
}
/**
- * @param {String|Number} rawValue
+ * @param {String|Number|Object} rawValue
* @param {TweenDecomposedValue} targetObject
* @return {TweenDecomposedValue}
*/
@@ -195,39 +214,38 @@ export const decomposeRawValue = (rawValue, targetObject) => {
// It's a number
targetObject.n = num;
return targetObject;
+ }
+ // let str = /** @type {String} */(rawValue).trim();
+ let str = /** @type {String} */(rawValue);
+ // Parsing operators (+=, -=, *=) manually is much faster than using regex here
+ if (str[1] === '=') {
+ targetObject.o = str[0];
+ str = str.slice(2);
+ }
+ // Skip exec regex if the value type is complex or color to avoid long regex backtracking
+ const unitMatch = str.includes(' ') ? false : unitsExecRgx.exec(str);
+ if (unitMatch) {
+ // Has a number and a unit
+ targetObject.t = valueTypes.UNIT;
+ targetObject.n = +unitMatch[1];
+ targetObject.u = unitMatch[2];
+ return targetObject;
+ } else if (targetObject.o) {
+ // Has an operator (+=, -=, *=)
+ targetObject.n = +str;
+ return targetObject;
+ } else if (isCol(str)) {
+ // Color string
+ targetObject.t = valueTypes.COLOR;
+ targetObject.d = convertColorStringValuesToRgbaArray(str);
+ return targetObject;
} else {
- // let str = /** @type {String} */(rawValue).trim();
- let str = /** @type {String} */(rawValue);
- // Parsing operators (+=, -=, *=) manually is much faster than using regex here
- if (str[1] === '=') {
- targetObject.o = str[0];
- str = str.slice(2);
- }
- // Skip exec regex if the value type is complex or color to avoid long regex backtracking
- const unitMatch = str.includes(' ') ? false : unitsExecRgx.exec(str);
- if (unitMatch) {
- // Has a number and a unit
- targetObject.t = valueTypes.UNIT;
- targetObject.n = +unitMatch[1];
- targetObject.u = unitMatch[2];
- return targetObject;
- } else if (targetObject.o) {
- // Has an operator (+=, -=, *=)
- targetObject.n = +str;
- return targetObject;
- } else if (isCol(str)) {
- // Is a color
- targetObject.t = valueTypes.COLOR;
- targetObject.d = convertColorStringValuesToRgbaArray(str);
- return targetObject;
- } else {
- // Is a more complex string (generally svg coords, calc() or filters CSS values)
- const matchedNumbers = str.match(digitWithExponentRgx);
- targetObject.t = valueTypes.COMPLEX;
- targetObject.d = matchedNumbers ? matchedNumbers.map(Number) : [];
- targetObject.s = str.split(digitWithExponentRgx) || [];
- return targetObject;
- }
+ // Is a more complex string (generally svg coords, calc() or filters CSS values)
+ const matchedNumbers = str.match(digitWithExponentRgx);
+ targetObject.t = valueTypes.COMPLEX;
+ targetObject.d = matchedNumbers ? matchedNumbers.map(Number) : [];
+ targetObject.s = str.split(digitWithExponentRgx) || [];
+ return targetObject;
}
}
@@ -248,30 +266,6 @@ export const decomposeTweenValue = (tween, targetObject) => {
export const decomposedOriginalValue = createDecomposedValueTargetObject();
-/**
- * @param {Tween} tween
- * @param {Number} progress
- * @param {Number} precision
- * @return {String}
- */
-export const composeColorValue = (tween, progress, precision) => {
- const mod = tween._modifier;
- const fn = tween._fromNumbers;
- const tn = tween._toNumbers;
- const r = round(clamp(/** @type {Number} */(mod(lerp(fn[0], tn[0], progress))), 0, 255), 0);
- const g = round(clamp(/** @type {Number} */(mod(lerp(fn[1], tn[1], progress))), 0, 255), 0);
- const b = round(clamp(/** @type {Number} */(mod(lerp(fn[2], tn[2], progress))), 0, 255), 0);
- const a = clamp(/** @type {Number} */(mod(round(lerp(fn[3], tn[3], progress), precision))), 0, 1);
- if (tween._composition !== compositionTypes.none) {
- const ns = tween._numbers;
- ns[0] = r;
- ns[1] = g;
- ns[2] = b;
- ns[3] = a;
- }
- return `rgba(${r},${g},${b},${a})`;
-}
-
/**
* @param {Tween} tween
* @param {Number} progress
@@ -283,15 +277,14 @@ export const composeComplexValue = (tween, progress, precision) => {
const fn = tween._fromNumbers;
const tn = tween._toNumbers;
const ts = tween._strings;
- const hasComposition = tween._composition !== compositionTypes.none;
let v = ts[0];
for (let j = 0, l = tn.length; j < l; j++) {
const n = /** @type {Number} */(mod(round(lerp(fn[j], tn[j], progress), precision)));
const s = ts[j + 1];
v += `${s ? n + s : n}`;
- if (hasComposition) {
- tween._numbers[j] = n;
- }
+ // Keep _numbers fresh for every tween, not only composed ones, so a non-composition setter that reads the lerped triplet such as three transformOrigin still animates.
+ // Potential optimization, skip the write when nothing reads it: if (hasComposition || tween._setter) tween._numbers[j] = n;
+ tween._numbers[j] = n;
}
return v;
}
diff --git a/src/easings/eases/parser.js b/src/easings/eases/parser.js
index 823d9d36..8ccc89d5 100644
--- a/src/easings/eases/parser.js
+++ b/src/easings/eases/parser.js
@@ -88,8 +88,8 @@ const easeInFunctions = {
/**
* @typedef {Object} EasesFunctions
- * @property {typeof none} linear
- * @property {typeof none} none
+ * @property {EasingFunction} linear
+ * @property {EasingFunction} none
* @property {PowerEasing} in
* @property {PowerEasing} out
* @property {PowerEasing} inOut
diff --git a/src/engine/engine.js b/src/engine/engine.js
index be23ef3f..451082c9 100644
--- a/src/engine/engine.js
+++ b/src/engine/engine.js
@@ -118,7 +118,9 @@ class Engine extends Clock {
}
set speed(playbackRate) {
- this._speed = playbackRate * globals.timeScale;
+ const speed = playbackRate * globals.timeScale;
+ if (this._speed === speed) return;
+ this._speed = speed;
forEachChildren(this, (/** @type {Tickable} */child) => child.speed = child._speed);
}
diff --git a/src/events/scroll.js b/src/events/scroll.js
index 4d6ad5cb..4d589388 100644
--- a/src/events/scroll.js
+++ b/src/events/scroll.js
@@ -258,12 +258,14 @@ class ScrollContainer {
refreshScrollObservers() {
forEachChildren(this, (/** @type {ScrollObserver} */child) => {
+ if (!child.ready) return;
if (child._debug) {
child.removeDebug();
}
});
this.updateBounds();
forEachChildren(this, (/** @type {ScrollObserver} */child) => {
+ if (!child.ready) return;
child.refresh();
child.onResize(child);
if (child._debug) {
diff --git a/src/text/scramble.js b/src/text/scramble.js
index e690b6f2..27690c41 100644
--- a/src/text/scramble.js
+++ b/src/text/scramble.js
@@ -26,6 +26,16 @@ import {
* } from '../types/index.js'
*/
+/**
+ * @typedef {Object} ScrambleTextTween
+ * @property {Number} from
+ * @property {Number} to
+ * @property {Number} duration
+ * @property {Number} delay
+ * @property {String} ease
+ * @property {(v: Number) => String} modifier
+ */
+
/**
* '-' is the range operator; place it at the start or end of the string to use it as a literal (e.g. '-abc' or 'abc-')
* @param {String} str
@@ -63,7 +73,7 @@ const originalTexts = new WeakMap();
* progressively revealing the original text.
*
* @param {ScrambleTextParams} [params]
- * @return {FunctionValue}
+ * @return {FunctionValue<ScrambleTextTween>}
*/
export const scrambleText = (params = {}) => {
if (!params) params = {};
diff --git a/src/text/split.js b/src/text/split.js
index c397e9ff..1f039680 100644
--- a/src/text/split.js
+++ b/src/text/split.js
@@ -132,6 +132,7 @@ const filterLineElements = ($el, lineIndex, bin) => {
*/
const generateTemplate = (type, params = {}) => {
let template = ``;
+ if (!params) params = {};
const classString = isStr(params.class) ? ` class="${params.class}"` : '';
const cloneType = setValue(params.clone, false);
const wrapType = setValue(params.wrap, false);
diff --git a/src/timeline/timeline.js b/src/timeline/timeline.js
index 5c23d5fe..c13edb99 100644
--- a/src/timeline/timeline.js
+++ b/src/timeline/timeline.js
@@ -71,6 +71,7 @@ import {
* TimelinePosition,
* StaggerFunction,
* TargetsArray,
+ * TweakRegister,
* } from '../types/index.js'
*/
@@ -80,8 +81,6 @@ import {
* } from '../waapi/waapi.js'
*/
-/** @import {TweakRegister} from 'tweaks' */
-
/**
* @param {Timeline} tl
* @return {Number}
@@ -274,13 +273,21 @@ export class Timeline extends Timer {
if (!isUnd(synced) && !isUnd(/** @type {WAAPIAnimation} */(synced).persist)) {
/** @type {WAAPIAnimation} */(synced).persist = true;
}
- return this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
+ const editor = globals.editor;
+ const childHook = editor && editor.addTimelineChild;
+ if (editor && editor.addTimelineSync) {
+ position = editor.addTimelineSync(synced, position, this.id);
+ editor.addTimelineChild = null; // Suppress the per-child hook for the internal .add, sync already registered.
+ }
+ const result = this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
+ if (editor) editor.addTimelineChild = childHook;
+ return result;
}
/**
* @param {TargetsParam} targets
* @param {AnimationParams} parameters
- * @param {TimelinePosition} [position]
+ * @param {TimelinePosition|StaggerFunction<Number|String>|TweakRegister} [position]
* @return {this}
*/
set(targets, parameters, position) {
@@ -297,6 +304,7 @@ export class Timeline extends Timer {
*/
call(callback, position) {
if (isUnd(callback) || callback && !isFnc(callback)) return this;
+ if (globals.editor && globals.editor.addTimelineCall) position = globals.editor.addTimelineCall(callback, position, this.id);
return this.add({ duration: 0, delay: 0, onComplete: () => callback(this) }, position);
}
@@ -308,6 +316,7 @@ export class Timeline extends Timer {
*/
label(labelName, position) {
if (isUnd(labelName) || labelName && !isStr(labelName)) return this;
+ if (globals.editor && globals.editor.addTimelineLabel) position = globals.editor.addTimelineLabel(labelName, position, this.id);
this.labels[labelName] = parseTimelinePosition(this, position);
return this;
}
diff --git a/src/types/index.js b/src/types/index.js
index 71def3ab..85b0c167 100644
--- a/src/types/index.js
+++ b/src/types/index.js
@@ -5,7 +5,6 @@ export {}
// Private types
/**
- * @import { TweakRegister } from 'tweaks';
* @import { ScrollObserver } from '../events/scroll.js';
* @import { JSAnimation } from '../animation/animation.js';
* @import { Animatable } from '../animatable/animatable.js';
@@ -56,6 +55,12 @@ export {}
/** @typedef {Timer&JSAnimation&Timeline} CallbackArgument */
/** @typedef {Animatable|Tickable|WAAPIAnimation|Draggable|ScrollObserver|TextSplitter|Scope|AutoLayout} Revertible */
+/**
+ * @typedef {Object} TweakRegister
+ * @property {String} type
+ * @property {*} defaultValue
+ */
+
// Stagger types
/**
@@ -75,11 +80,18 @@ export {}
* @property {Number|'first'|'center'|'last'|'random'|Array.<Number>} [from]
* @property {Boolean} [reversed]
* @property {Array.<Number>|Boolean} [grid]
- * @property {('x'|'y')} [axis]
- * @property {String|((target: Target, i: Number, length: Number) => Number)} [use]
+ * @property {('x'|'y'|'z')} [axis]
+ * @property {String | { method(target: Target, i: Number, length: Number): Number }['method']} [use]
* @property {Number} [total]
* @property {EasingParam} [ease]
* @property {TweenModifier} [modifier]
+ * @property {Number|[Number, Number]} [jitter] Additive uniform noise on the
+ * computed stagger value. Number form gives flat `+/-jitter`; tuple form
+ * ramps the magnitude `start -> end` across the from/axis/grid ordering
+ * and respects `ease`.
+ * @property {Boolean|Number} [seed] Seed for jitter draws and `from: 'random'`
+ * shuffling. `false` (default) uses Math.random. `true` seeds with `0`. A
+ * number is used directly as the seed.
*/
// Targets types
@@ -155,10 +167,7 @@ export {}
/**
* @template T
- * @callback Callback
- * @param {T} self - Returns itself
- * @param {PointerEvent} [e]
- * @return {*}
+ * @typedef {{ method(self: T): * }['method']} Callback
*/
/**
@@ -202,12 +211,17 @@ export {}
// Tween types
/**
+ * @typedef {Number|String|TweenKeyValue|EasingParam|Array.<Number|String|TweenKeyValue>} FunctionValueReturn
+ */
+
+/**
+ * @template [T=FunctionValueReturn]
* @callback FunctionValue
* @param {Target} [target] - The animated target
* @param {Number} [index] - The target index
* @param {TargetsArray} [targets] - The array of all animated targets
* @param {Tween|null} [prevTween] - The previous sibling tween for the same target and property
- * @return {Number|String|TweenObjectValue|EasingParam|Array.<Number|String|TweenObjectValue>}
+ * @return {T}
*/
/**
@@ -224,7 +238,7 @@ export {}
* @property {JSAnimation} parent
* @property {String} property
* @property {Target} target
- * @property {String|Number} _value
+ * @property {String|Number|Object} _value
* @property {Function|null} _toFunc
* @property {Function|null} _fromFunc
* @property {EasingFunction} _ease
@@ -243,7 +257,11 @@ export {}
* @property {Number} _startTime
* @property {Number} _changeDuration
* @property {Number} _absoluteStartTime
+ * @property {Number} _absoluteUpdateStartTime
+ * @property {Number} _absoluteEndTime
+ * @property {Number} _hasFromValue
* @property {tweenTypes} _tweenType
+ * @property {((target: any, value: number, tween: Tween) => void) | null} _setter
* @property {valueTypes} _valueType
* @property {Number} _composition
* @property {Number} _isOverlapped
@@ -264,8 +282,8 @@ export {}
* @property {Number} n - Single number value
* @property {String} u - Value unit
* @property {String} o - Value operator
- * @property {Array.<Number>} d - Array of Numbers (in case of complex value type)
- * @property {Array.<String>} s - Strings (in case of complex value type)
+ * @property {Array.<Number>} d - Array of Numbers (complex / color value type)
+ * @property {Array.<String>} s - Strings (complex value type)
*/
/** @typedef {{_head: null|Tween, _tail: null|Tween}} TweenPropertySiblings */
@@ -276,7 +294,7 @@ export {}
// JSAnimation types
/**
- * @typedef {Number|String|FunctionValue|EasingParam} TweenParamValue
+ * @typedef {Number|String|FunctionValue|EasingParam|TweakRegister} TweenParamValue
*/
/**
@@ -469,7 +487,7 @@ export {}
*/
/**
- * @typedef {Record<String, TweenParamValue | EasingParam | TweenModifier | TweenComposition | AnimatablePropertyParamsOptions> & AnimatablePropertyParamsOptions} AnimatableParams
+ * @typedef {Record<String, TweenParamValue | EasingParam | TweenModifier | TweenComposition | AnimatablePropertyParamsOptions | Callback<JSAnimation>> & AnimatablePropertyParamsOptions & TickableCallbacks<JSAnimation> & RenderableCallbacks<JSAnimation>} AnimatableParams
*/
// Scope types
@@ -512,7 +530,7 @@ export {}
/**
* @callback ScopeMethod
* @param {...*} args
- * @return {ScopeCleanupCallback|void}
+ * @return {*}
*/
// Scroll types
diff --git a/src/utils/random.js b/src/utils/random.js
index 8cbe31e7..fd2f7ed4 100644
--- a/src/utils/random.js
+++ b/src/utils/random.js
@@ -54,10 +54,11 @@ export const randomPick = items => items[random(0, items.length - 1)];
* Adapted from https://bost.ocks.org/mike/shuffle/
*
* @param {Array} items - The array to shuffle (will be modified in-place)
+ * @param {RandomNumberGenerator} [rnd] - Optional RNG matching the random() signature (defaults to random)
* @return {Array} The same array reference, now shuffled
*/
-export const shuffle = items => {
+export const shuffle = (items, rnd = random) => {
let m = items.length, t, i;
- while (m) { i = random(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
+ while (m) { i = rnd(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
return items;
}
diff --git a/src/utils/stagger.js b/src/utils/stagger.js
index 46f2d59b..ce12a806 100644
--- a/src/utils/stagger.js
+++ b/src/utils/stagger.js
@@ -12,7 +12,6 @@ import {
abs,
floor,
sqrt,
- max,
isStr,
isFnc,
} from '../core/helpers.js';
@@ -34,6 +33,8 @@ import {
} from '../core/targets.js';
import {
+ random,
+ createSeededRandom,
shuffle,
} from './random.js';
@@ -88,6 +89,7 @@ export const stagger = (val, params = {}) => {
let values = [];
let maxValue = 0;
let cachedOffset;
+ let jitterSamples = null;
const from = params.from;
const reversed = params.reversed;
const ease = params.ease;
@@ -109,27 +111,42 @@ export const stagger = (val, params = {}) => {
const val2 = isRange ? parseNumber(val[1]) : 0;
const unitMatch = unitsExecRgx.exec((isRange ? val[1] : val) + emptyString);
const start = params.start || 0 + (isRange ? val1 : 0);
+ const seed = params.seed;
+ const hasSeed = !isUnd(seed) && seed !== false;
+ const rng = hasSeed ? createSeededRandom(seed === true ? 0 : /** @type {Number} */(seed)) : random;
+ const jitter = params.jitter;
+ const hasJitter = !isUnd(jitter);
+ const jitterIsArr = isArr(jitter);
+ const jitterStart = jitterIsArr ? /** @type {[Number,Number]} */(jitter)[0] : /** @type {Number} */(jitter) || 0;
+ const jitterEnd = jitterIsArr ? /** @type {[Number,Number]} */(jitter)[1] : /** @type {Number} */(jitter) || 0;
let fromIndex = fromFirst ? 0 : isNum(from) ? from : 0;
return (target, i, t, _, tl) => {
const [ registeredTarget ] = registerTargets(target);
const total = isUnd(customTotal) ? t.length : customTotal;
const customIndex = !isUnd(useProp) ? isFnc(useProp) ? useProp(registeredTarget, i, total) : getOriginalAnimatableValue(registeredTarget, useProp) : false;
- const staggerIndex = isNum(customIndex) || isStr(customIndex) && isNum(+customIndex) ? +customIndex : i;
+ const customIdx = isNum(customIndex) || isStr(customIndex) && isNum(+customIndex) ? +customIndex : i;
+ // Fall back to the natural index when the resolved value lands outside [0, total) so values[staggerIndex] never reads undefined.
+ const staggerIndex = customIdx >= 0 && customIdx < total ? customIdx : i;
if (fromCenter) fromIndex = (total - 1) / 2;
if (fromLast) fromIndex = total - 1;
if (!values.length) {
if (autoGrid) {
let hasPositions = true;
+ let has3D = false;
let minPosX = Infinity;
let minPosY = Infinity;
+ let minPosZ = Infinity;
let maxPosX = -Infinity;
let maxPosY = -Infinity;
+ let maxPosZ = -Infinity;
const pxArr = [];
const pyArr = [];
+ const pzArr = [];
for (let index = 0; index < total; index++) {
const el = t[index];
let px = 0;
let py = 0;
+ let pz = 0;
let found = false;
if (el && isFnc(el.getBoundingClientRect)) {
const rect = el.getBoundingClientRect();
@@ -141,6 +158,10 @@ export const stagger = (val, params = {}) => {
if (obj && isNum(obj.x) && isNum(obj.y)) {
px = obj.x;
py = obj.y;
+ if (isNum(obj.z)) {
+ pz = obj.z;
+ has3D = true;
+ }
found = true;
}
}
@@ -150,42 +171,52 @@ export const stagger = (val, params = {}) => {
}
pxArr.push(px);
pyArr.push(py);
+ pzArr.push(pz);
if (px < minPosX) minPosX = px;
if (py < minPosY) minPosY = py;
+ if (pz < minPosZ) minPosZ = pz;
if (px > maxPosX) maxPosX = px;
if (py > maxPosY) maxPosY = py;
+ if (pz > maxPosZ) maxPosZ = pz;
}
if (hasPositions) {
let fX = pxArr[0];
let fY = pyArr[0];
+ let fZ = pzArr[0];
if (fromArr) {
fX = minPosX + from[0] * (maxPosX - minPosX);
fY = minPosY + from[1] * (maxPosY - minPosY);
+ fZ = has3D ? minPosZ + (from.length >= 3 ? from[2] : 0.5) * (maxPosZ - minPosZ) : 0;
} else if (fromCenter) {
fX = (minPosX + maxPosX) / 2;
fY = (minPosY + maxPosY) / 2;
+ fZ = (minPosZ + maxPosZ) / 2;
} else if (fromLast) {
fX = pxArr[total - 1];
fY = pyArr[total - 1];
+ fZ = pzArr[total - 1];
} else if (isNum(from)) {
fX = pxArr[from];
fY = pyArr[from];
+ fZ = pzArr[from];
}
for (let index = 0; index < total; index++) {
const distanceX = fX - pxArr[index];
const distanceY = fY - pyArr[index];
- let value = sqrt(distanceX * distanceX + distanceY * distanceY);
+ const distanceZ = fZ - pzArr[index];
+ let value = sqrt(distanceX * distanceX + distanceY * distanceY + (has3D ? distanceZ * distanceZ : 0));
if (axis === 'x') value = -distanceX;
if (axis === 'y') value = -distanceY;
+ if (axis === 'z') value = -distanceZ;
values.push(value);
}
let minDist = Infinity;
- for (let index = 0, l = values.length; index < l; index++) {
+ for (let index = 0; index < total; index++) {
const absVal = abs(values[index]);
if (absVal > 0 && absVal < minDist) minDist = absVal;
}
if (minDist > 0 && minDist < Infinity) {
- for (let index = 0, l = values.length; index < l; index++) {
+ for (let index = 0; index < total; index++) {
values[index] = values[index] / minDist;
}
}
@@ -199,32 +230,51 @@ export const stagger = (val, params = {}) => {
if (!grid) {
values.push(abs(fromIndex - index));
} else {
- let fromX, fromY;
+ const dims = grid.length;
+ const wh = grid[0] * grid[1];
+ let fromX, fromY, fromZ;
if (fromArr) {
fromX = from[0] * (grid[0] - 1);
fromY = from[1] * (grid[1] - 1);
+ fromZ = dims === 3 ? (from.length >= 3 ? from[2] : 0.5) * (grid[2] - 1) : 0;
} else if (fromCenter) {
fromX = (grid[0] - 1) / 2;
fromY = (grid[1] - 1) / 2;
+ fromZ = dims === 3 ? (grid[2] - 1) / 2 : 0;
} else {
fromX = fromIndex % grid[0];
- fromY = floor(fromIndex / grid[0]);
+ fromY = floor(fromIndex / grid[0]) % grid[1];
+ fromZ = dims === 3 ? floor(fromIndex / wh) : 0;
}
const toX = index % grid[0];
- const toY = floor(index / grid[0]);
+ const toY = floor(index / grid[0]) % grid[1];
+ const toZ = dims === 3 ? floor(index / wh) : 0;
const distanceX = fromX - toX;
const distanceY = fromY - toY;
- let value = sqrt(distanceX * distanceX + distanceY * distanceY);
+ const distanceZ = fromZ - toZ;
+ let value = sqrt(distanceX * distanceX + distanceY * distanceY + (dims === 3 ? distanceZ * distanceZ : 0));
if (axis === 'x') value = -distanceX;
if (axis === 'y') value = -distanceY;
+ if (axis === 'z') value = -distanceZ;
values.push(value);
}
}
}
- maxValue = max(...values);
- if (staggerEase) values = values.map(val => staggerEase(val / maxValue) * maxValue);
- if (reversed) values = values.map(val => axis ? (val < 0) ? val * -1 : -val : abs(maxValue - val));
- if (fromRandom) values = shuffle(values);
+ maxValue = values[0];
+ for (let k = 1; k < total; k++) if (values[k] > maxValue) maxValue = values[k];
+ if (staggerEase || reversed) {
+ for (let k = 0; k < total; k++) {
+ let v = values[k];
+ if (staggerEase) v = staggerEase(v / maxValue) * maxValue;
+ if (reversed) v = axis ? -v : abs(maxValue - v);
+ values[k] = v;
+ }
+ }
+ if (hasJitter) {
+ jitterSamples = new Array(total);
+ for (let k = 0; k < total; k++) jitterSamples[k] = rng(-1, 1, 4);
+ }
+ if (fromRandom) values = shuffle(values, rng);
}
const spacing = isRange ? (val2 - val1) / maxValue : val1;
if (isUnd(cachedOffset)) {
@@ -232,6 +282,11 @@ export const stagger = (val, params = {}) => {
}
/** @type {String|Number} */
let output = cachedOffset + ((spacing * round(values[staggerIndex], 2)) || 0);
+ if (hasJitter) {
+ const progress = maxValue ? values[staggerIndex] / maxValue : 0;
+ const mag = jitterStart + (jitterEnd - jitterStart) * progress;
+ output = /** @type {Number} */(output) + jitterSamples[staggerIndex] * mag;
+ }
if (params.modifier) output = params.modifier(/** @type {Number} */(output));
if (unitMatch) output = `${output}${unitMatch[2]}`;
return output;
diff --git a/src/utils/target.js b/src/utils/target.js
index c8be4e0f..13918a67 100644
--- a/src/utils/target.js
+++ b/src/utils/target.js
@@ -123,6 +123,9 @@ export function get(targetSelector, propName, unit) {
*/
export const set = (targets, parameters) => {
if (isUnd(parameters)) return;
+ if (globals.editor && globals.editor.addSet) {
+ return globals.editor.addSet(targets, parameters);
+ }
parameters.duration = minValue;
// Do not overrides currently active tweens by default
parameters.composition = setValue(parameters.composition, compositionTypes.none);
diff --git a/src/utils/time.js b/src/utils/time.js
index 1f96b92c..79be6551 100644
--- a/src/utils/time.js
+++ b/src/utils/time.js
@@ -31,13 +31,14 @@ export const sync = (callback = noop) => {
}
/**
- * @param {(...args: any[]) => Tickable | ((...args: any[]) => void) | void} constructor
- * @return {(...args: any[]) => Tickable | ((...args: any[]) => void)}
+ * @template {Tickable | ((...args: any[]) => void) | void} T
+ * @param {(...args: any[]) => T} constructor
+ * @return {(...args: any[]) => T extends void ? () => void : T}
*/
export const keepTime = constructor => {
/** @type {Tickable} */
let tracked;
- return (...args) => {
+ return /** @type {(...args: any[]) => T extends void ? () => void : T} */(/** @type {*} */((...args) => {
let currentIteration, currentIterationProgress, reversed, alternate, startTime;
if (tracked) {
currentIteration = tracked.currentIteration;
@@ -55,5 +56,5 @@ export const keepTime = constructor => {
/** @type {Tickable} */(tracked)._startTime = startTime;
}
return cleanup || noop;
- }
+ }));
}
diff --git a/tests/index.html b/tests/index.html
index 245471ae..ccd8cd94 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -5,6 +5,15 @@
<title>Anime.js tests</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
+ <script type="importmap">
+ {
+ "imports": {
+ "three": "https://unpkg.com/[email protected]/build/three.module.js",
+ "three/tsl": "https://unpkg.com/[email protected]/build/three.tsl.js",
+ "three/webgpu": "https://unpkg.com/[email protected]/build/three.webgpu.js"
+ }
+ }
+ </script>
<link rel="icon" href="./assets/favicon.png?v=5">
<style>
@font-face {
diff --git a/tests/playground/animejs-v2-logo-animation.html b/tests/playground/animejs-v2-logo-animation.html
index 9c346600..e6611322 100644
--- a/tests/playground/animejs-v2-logo-animation.html
+++ b/tests/playground/animejs-v2-logo-animation.html
@@ -190,9 +190,10 @@
import { createTimeline, utils, stagger, svg } from '../../../dist/modules/index.js';
-
utils.set(['.fill.out', '.line.out'], { opacity: 0 });
+ const fillDraggable = svg.createDrawable('.fill');
+
const logoTimeline = createTimeline({
alternate: true,
loop: 1,
@@ -220,36 +221,32 @@
],
delay: 1200
}, 0)
- .add(svg.createDrawable('.fill.in'), {
- strokeDashoffset: {
- draw: '0 1',
+ .add(fillDraggable, {
+ draw: {
+ to: '0 1',
duration: 600,
ease: 'outQuart',
},
stroke: {
to: ['#FFF', el => utils.get(el.parentNode, 'stroke')],
duration: 350,
- ease: 'inQuad',
+ ease: 'inOutQuart',
},
- delay: stagger(100, { start: 700 }),
- }, 0)
- .add(svg.createDrawable('.fill.out'), {
- strokeDashoffset: [
- {
- to: '1 1',
- duration: 800,
- delay: stagger(80),
- ease: 'inQuart'
- }
- ]
- }, 1890)
+ }, stagger(60, { start: 700 }))
+ .add(fillDraggable, {
+ draw: {
+ to: '1 1',
+ duration: 800,
+ ease: 'inQuart'
+ }
+ }, stagger(80, { start: 2000 }))
.add(svg.createDrawable('.line.out'), {
opacity: {
to: 1,
duration: 100,
},
- strokeDashoffset: {
- draw: ['0 1', '1 1'],
+ draw: {
+ to: ['0 1', '1 1'],
duration: 1200,
delay: stagger(100, { start: 500 }),
ease: 'inQuart'
@@ -268,8 +265,8 @@
delay: 4200
}, 0)
.add(svg.createDrawable('.icon-line'), {
- strokeDashoffset: {
- draw: '0 1',
+ draw: {
+ to: '0 1',
duration: 1200,
ease: 'inOutQuart',
},
diff --git a/tests/playground/benchmark/index.js b/tests/playground/benchmark/index.js
index 1cece012..9a6ad4a7 100644
--- a/tests/playground/benchmark/index.js
+++ b/tests/playground/benchmark/index.js
@@ -19,11 +19,11 @@ import {
const noop = () => {};
const url = new URL(window.location.href);
const urlParams = url.searchParams;
-const $particlesContainer = document.querySelector('#particles-container');
-const $countRange = document.querySelector('#count-range');
-const $restartButton = document.querySelector('#restart-button');
+const $particlesContainer = /** @type {HTMLElement} */ (document.querySelector('#particles-container'));
+const $countRange = /** @type {HTMLInputElement} */ (document.querySelector('#count-range'));
+const $restartButton = /** @type {HTMLButtonElement} */ (document.querySelector('#restart-button'));
const $activeTweens = document.querySelector('#active-tweens');
-const $configItems = document.querySelectorAll('.config-item');
+const $configItems = /** @type {NodeListOf<HTMLInputElement>} */ (document.querySelectorAll('.config-item'));
const startedSymbol = Symbol();
const reversedSymbol = Symbol();
const duration = 4000;
@@ -470,7 +470,7 @@ function updateUI() {
$item.checked = $item.value === config[$item.name];
}
if ($item.name === 'count') {
- $item.value = config.count;
+ $item.value = `${config.count}`;
}
if ($item.name === 'tween') {
$item.checked = config[$item.value];
@@ -536,7 +536,7 @@ function onConfigItemChange() {
}
function onRangeInput() {
- config.count = $countRange.value;
+ config.count = +$countRange.value;
updateUrl();
updateUI();
}
@@ -559,8 +559,8 @@ window.onresize = onResize;
// Calculating FPS past requestAnimationFrame limit with requestIdleCallback
// https://www.clicktorelease.com/blog/calculating-fps-with-requestIdleCallback/
-const $fps = document.getElementById('fps');
-const $avg = document.getElementById('avg');
+const $fps = /** @type {HTMLInputElement} */ (document.getElementById('fps'));
+const $avg = /** @type {HTMLInputElement} */ (document.getElementById('avg'));
let t = Date.now();
let hasrICBeenCalledForThisFrame = null;
diff --git a/tests/playground/color-trail-canvas.html b/tests/playground/color-trail-canvas.html
new file mode 100644
index 00000000..aadcb025
--- /dev/null
+++ b/tests/playground/color-trail-canvas.html
@@ -0,0 +1,207 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Color trail canvas / Anime.js</title>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+ <style>
+ html, body {
+ margin: 0;
+ padding: 0;
+ width: 100%;
+ height: 100%;
+ background: #111;
+ overflow: hidden;
+ font-family: system-ui, sans-serif;
+ }
+ canvas {
+ display: block;
+ width: 100%;
+ height: 100%;
+ }
+ .label {
+ position: absolute;
+ top: 12px;
+ left: 12px;
+ color: #888;
+ font-size: 12px;
+ pointer-events: none;
+ }
+ </style>
+</head>
+<body>
+ <canvas id="stage"></canvas>
+ <div class="label">top: overlap -=500 mid-way handoff<br>bottom: 4 simple sequential adds (no overlap)</div>
+
+ <script type="module">
+ import { animate, createTimeline, createTimer } from '../../dist/modules/index.js';
+
+ const canvas = document.getElementById('stage');
+ const ctx = canvas.getContext('2d');
+ const dpr = window.devicePixelRatio || 1;
+
+ function resize() {
+ const w = canvas.clientWidth;
+ const h = canvas.clientHeight;
+ canvas.width = w * dpr;
+ canvas.height = h * dpr;
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
+ }
+ resize();
+ window.addEventListener('resize', resize);
+
+ const colors = [
+ '#ff3b30',
+ '#ffcc00',
+ '#34c759',
+ '#0a84ff',
+ ];
+
+ const stationRadius = 22;
+ const ballRadius = 16;
+ const trailFadeAlpha = 0.00001;
+
+ function stationsLayout() {
+ const w = canvas.clientWidth;
+ const h = canvas.clientHeight;
+ const cx = w * 0.5;
+ const cy = h * 0.5;
+ const radius = Math.min(w, h) * 0.35;
+ // Start at the top (-PI/2), step clockwise.
+ const startAngle = -Math.PI * 0.5;
+ return colors.map((_, i) => {
+ const a = startAngle + (Math.PI * 2 * i) / colors.length;
+ return { x: cx + Math.cos(a) * radius, y: cy + Math.sin(a) * radius };
+ });
+ }
+
+ let stations = stationsLayout();
+ window.addEventListener('resize', () => { stations = stationsLayout(); });
+
+ // The ball traces an axis-aligned square inscribed in the circle.
+ // Its 4 corners sit on the circle, at the arc-midpoints between
+ // pairs of color stations. The colored stations sit at the cardinal
+ // points (outside the square edges), as visual markers.
+ function squareCornersLayout() {
+ const w = canvas.clientWidth;
+ const h = canvas.clientHeight;
+ const cx = w * 0.5;
+ const cy = h * 0.5;
+ const radius = Math.min(w, h) * 0.35;
+ // Corners at -3π/4, -π/4, π/4, 3π/4 — between left/top, top/right,
+ // right/bottom, bottom/left respectively.
+ const angles = [-3 * Math.PI / 4, -Math.PI / 4, Math.PI / 4, 3 * Math.PI / 4];
+ return angles.map(a => ({ x: cx + Math.cos(a) * radius, y: cy + Math.sin(a) * radius }));
+ }
+
+ let corners = squareCornersLayout();
+ window.addEventListener('resize', () => { corners = squareCornersLayout(); });
+
+ // Animated state. Plain object target. Color string animation goes through the COLOR value type. Without an adapter setter, render composes the rgba string and writes it straight to `state.color`.
+ const state = {
+ x: corners[0].x,
+ y: corners[0].y,
+ color: colors[0],
+ };
+
+ // Second ball: same circle, offset inward, walks station-to-station
+ // with 4 sequential, non-overlapping .add() calls. Exercises
+ // cross-add color sibling chaining (each tween's from-color is the
+ // previous tween's end-color, resolved via prevSibling._value).
+ const state2 = {
+ x: stations[0].x,
+ y: stations[0].y,
+ color: colors[0],
+ };
+
+ const tl = createTimeline({
+ autoplay: true,
+ loop: true,
+ defaults: { ease: 'linear', duration: 1000 },
+ });
+
+ const tl2 = createTimeline({
+ autoplay: true,
+ loop: true,
+ defaults: { ease: 'linear', duration: 800 },
+ });
+
+ // 4 simple sequential adds, one per station. Each new add only specifies the destination color, the from-color must come from the previous add via sibling chaining.
+ for (let i = 1; i <= 4; i++) {
+ const next = stations[i % stations.length];
+ tl2.add(state2, {
+ x: next.x,
+ y: next.y,
+ color: colors[i % colors.length],
+ });
+ }
+
+ // Tweens 1–3 overshoot the next corner by the same distance, so each
+ // tween's midpoint lands exactly on the corner. With -=250 overlap
+ // the next tween hands off at that midpoint and state-chains the
+ // ball off in a new straight line.
+ // Tween 4 is the *correct* distance (no overshoot): it runs to
+ // completion and lands the ball back on corner[0] to close the loop.
+ for (let i = 1; i <= 4; i++) {
+ const isLast = i === 4;
+ const fromCorner = corners[i - 1];
+ const nextCorner = corners[i % 4];
+ const targetX = isLast ? nextCorner.x : 2 * nextCorner.x - fromCorner.x;
+ const targetY = isLast ? nextCorner.y : 2 * nextCorner.y - fromCorner.y;
+ tl.add(state, {
+ x: targetX,
+ y: targetY,
+ color: colors[i % colors.length],
+ duration: isLast ? 500 : 1000,
+ }, i === 1 ? 0 : '-=500');
+ }
+
+ function drawStation(s, color) {
+ ctx.beginPath();
+ ctx.arc(s.x, s.y, stationRadius, 0, Math.PI * 2);
+ ctx.fillStyle = color;
+ ctx.fill();
+ ctx.lineWidth = 2;
+ ctx.strokeStyle = 'rgba(255, 255, 255, 0.15)';
+ ctx.stroke();
+ }
+
+ function drawBall(s) {
+ ctx.beginPath();
+ ctx.arc(s.x, s.y, ballRadius, 0, Math.PI * 2);
+ ctx.fillStyle = s.color;
+ ctx.fill();
+ }
+
+ createTimer({
+ autoplay: true,
+ onUpdate: () => {
+ // Fade prior frames to a soft trail. A small alpha overlay each
+ // frame attenuates pixels exponentially without fully clearing.
+ ctx.fillStyle = `rgba(17, 17, 17, ${trailFadeAlpha})`;
+ ctx.fillRect(0, 0, canvas.clientWidth, canvas.clientHeight);
+
+ // Track ring + stations. Both static, redraw on top of the fade so they stay sharp.
+ const w = canvas.clientWidth;
+ const h = canvas.clientHeight;
+ const cx = w * 0.5;
+ const cy = h * 0.5;
+ const ringRadius = Math.min(w, h) * 0.35;
+ ctx.beginPath();
+ ctx.arc(cx, cy, ringRadius, 0, Math.PI * 2);
+ ctx.lineWidth = 1;
+ ctx.strokeStyle = 'rgba(255, 255, 255, 0.08)';
+ ctx.stroke();
+ for (let i = 0; i < stations.length; i++) {
+ drawStation(stations[i], colors[i]);
+ }
+
+ drawBall(state);
+ drawBall(state2);
+ },
+ });
+
+
+ </script>
+</body>
+</html>
diff --git a/tests/playground/layout/clone/index.js b/tests/playground/layout/clone/index.js
index 7d3c653b..33ac1237 100644
--- a/tests/playground/layout/clone/index.js
+++ b/tests/playground/layout/clone/index.js
@@ -1,4 +1,4 @@
-import { createLayout, utils } from '../../../dist/modules/index.js';
+import { createLayout, utils } from '../../../../dist/modules/index.js';
const layout = createLayout('.container', {
properties: ['color'],
@@ -14,7 +14,7 @@ const moveCard = $card => {
}
document.addEventListener('click', e => {
- const $card = e.target.closest('.card');
+ const $card = /** @type {HTMLElement} */(e.target).closest('.card');
console.log($card);
if ($card) layout.update(() => moveCard($card));
});
diff --git a/tests/playground/layout/index.js b/tests/playground/layout/index.js
index 13021549..14057587 100644
--- a/tests/playground/layout/index.js
+++ b/tests/playground/layout/index.js
@@ -281,7 +281,7 @@ const tests = [
delay: stagger(200),
onBegin: () => {
utils.set($container, {
- background: 'var(--sky-2)',
+ background: 'var(--cyan-2)',
})
},
onComplete: () => {
diff --git a/tests/playground/scramble/index.js b/tests/playground/scramble/index.js
index 5c94ac92..244e5ddb 100644
--- a/tests/playground/scramble/index.js
+++ b/tests/playground/scramble/index.js
@@ -1,5 +1,13 @@
import { animate, createTimeline, scrambleText, stagger } from '../../../dist/modules/index.js';
+/**
+ * @import {
+ * ScrambleTextParams,
+ * AnimationParams,
+ * } from '../../../dist/modules/index.js'
+ */
+
+/** @type {Array<{ id: String, params: ScrambleTextParams|null, animParams?: AnimationParams }>} */
const demos = [
{ id: 'default', params: null },
{ id: 'from-end', params: { from: 'right' } },
diff --git a/tests/playground/threejs/adapters/api.js b/tests/playground/threejs/adapters/api.js
new file mode 100644
index 00000000..f17fe24d
--- /dev/null
+++ b/tests/playground/threejs/adapters/api.js
@@ -0,0 +1,360 @@
+import {
+ Scene, WebGLRenderer, PCFShadowMap,
+ Mesh, Group, Sprite, Points, Line,
+ PerspectiveCamera, AmbientLight, DirectionalLight, PointLight, SpotLight, HemisphereLight,
+ InstancedMesh, BatchedMesh,
+ BoxGeometry, SphereGeometry, ConeGeometry, PlaneGeometry, BufferGeometry, BufferAttribute,
+ MeshStandardMaterial, PointsMaterial, LineBasicMaterial, SpriteMaterial,
+ CanvasTexture, MathUtils,
+ DirectionalLightHelper, PointLightHelper, SpotLightHelper, HemisphereLightHelper,
+} from 'three';
+
+import { animate, createTimer, stagger, utils } from '../../../../dist/modules/index.js';
+
+// Side-effect import: registers the Object3D adapter so animate() and
+// utils.set() accept raw three.js objects with flat properties
+// (x, rotateY, scale, opacity, color, ...).
+import { getInstances, commitChanges } from '../../../../dist/modules/adapters/three/index.js';
+
+// renderer + camera
+const scene = new Scene();
+
+const camera = new PerspectiveCamera(50, innerWidth / innerHeight, 0.1, 1000);
+utils.set(camera, { x: 0, y: 6, z: 22 });
+camera.lookAt(0, 0, 0);
+
+const renderer = new WebGLRenderer({ antialias: true });
+renderer.setSize(innerWidth, innerHeight);
+renderer.setPixelRatio(devicePixelRatio);
+renderer.shadowMap.enabled = true;
+renderer.shadowMap.type = PCFShadowMap;
+document.body.appendChild(renderer.domElement);
+addEventListener('resize', () => {
+ camera.aspect = innerWidth / innerHeight;
+ camera.updateProjectionMatrix();
+ renderer.setSize(innerWidth, innerHeight);
+});
+
+// lights + helpers
+const ambient = new AmbientLight(0xffffff, 0.25);
+scene.add(ambient);
+
+const dir = new DirectionalLight(0xffffff, 1.4);
+utils.set(dir, { x: 6, y: 10, z: 6 });
+dir.castShadow = true;
+dir.shadow.mapSize.set(1024, 1024);
+dir.shadow.camera.left = -12;
+dir.shadow.camera.right = 12;
+dir.shadow.camera.top = 12;
+dir.shadow.camera.bottom = -12;
+dir.shadow.camera.near = 1;
+dir.shadow.camera.far = 40;
+scene.add(dir);
+const dirHelper = new DirectionalLightHelper(dir, 1.5, 0xffffff);
+scene.add(dirHelper);
+
+const point = new PointLight(0xff66aa, 80, 30, 1.6);
+utils.set(point, { x: 0, y: 4, z: 4 });
+scene.add(point);
+const pointHelper = new PointLightHelper(point, 0.4);
+scene.add(pointHelper);
+
+const spot = new SpotLight(0x66ddff, 60, 40, Math.PI / 6, 0.4, 1.5);
+utils.set(spot, { x: -8, y: 8, z: 4 });
+spot.target.position.set(0, 0, 0);
+scene.add(spot);
+scene.add(spot.target);
+const spotHelper = new SpotLightHelper(spot);
+scene.add(spotHelper);
+
+const hemi = new HemisphereLight(0x88aaff, 0x442200, 0.4);
+utils.set(hemi, { x: 0, y: 12, z: 0 });
+scene.add(hemi);
+const hemiHelper = new HemisphereLightHelper(hemi, 1);
+scene.add(hemiHelper);
+
+// floor (receives shadows)
+const floor = new Mesh(
+ new PlaneGeometry(40, 40),
+ new MeshStandardMaterial({ color: 0x222233, roughness: 1, metalness: 0 })
+);
+utils.set(floor, { rotateX: -90, y: -3 });
+floor.receiveShadow = true;
+scene.add(floor);
+
+// root group (everything that moves together)
+const root = new Group();
+scene.add(root);
+
+// animated cube
+const cube = new Mesh(
+ new BoxGeometry(1.2, 1.2, 1.2),
+ new MeshStandardMaterial({ color: 0xff4b4b, transparent: true })
+);
+utils.set(cube, { x: -7 });
+cube.castShadow = true;
+cube.receiveShadow = true;
+root.add(cube);
+
+// scale = 0 and opacity = 0 mid-tween exercise the visibility flip.
+animate(cube, {
+ rotateY: 360,
+ rotateX: [0, 180],
+ scale: [{ to: 1.6 }, { to: 0 }, { to: 1 }],
+ color: ['#fff', '#f0a', '#fff'],
+ opacity: [1, 0, 1],
+ duration: 3000,
+ loop: true,
+});
+
+// sprite billboard
+const spriteCanvas = (() => {
+ const c = document.createElement('canvas');
+ c.width = c.height = 128;
+ const ctx = c.getContext('2d');
+ const grad = ctx.createRadialGradient(64, 64, 4, 64, 64, 64);
+ grad.addColorStop(0, '#fff');
+ grad.addColorStop(0.4, '#fc0');
+ grad.addColorStop(1, '#f000');
+ ctx.fillStyle = grad;
+ ctx.fillRect(0, 0, 128, 128);
+ return c;
+})();
+
+const sprite = new Sprite(new SpriteMaterial({
+ map: new CanvasTexture(spriteCanvas),
+ transparent: true,
+ depthWrite: false,
+}));
+utils.set(sprite, { x: 7, y: 1, scale: 1.5 });
+root.add(sprite);
+
+animate(sprite, {
+ y: [1, 3, 1],
+ scale: [1.5, 2.5, 1.5],
+ opacity: [0.5, 1, 0.5],
+ color: ['#ffcc00', '#ff66ff', '#66ffff', '#ffcc00'],
+ duration: 3000,
+ loop: true,
+ ease: 'inOutSine',
+});
+
+// points cloud
+const POINTS_COUNT = 600;
+const pointsGeo = new BufferGeometry();
+const pointsPos = new Float32Array(POINTS_COUNT * 3);
+for (let i = 0; i < POINTS_COUNT; i++) {
+ const a = (i / POINTS_COUNT) * Math.PI * 2;
+ const r = 9 + Math.random() * 1.5;
+ pointsPos[i * 3] = Math.cos(a) * r;
+ pointsPos[i * 3 + 1] = (Math.random() - 0.5) * 0.6;
+ pointsPos[i * 3 + 2] = Math.sin(a) * r;
+}
+pointsGeo.setAttribute('position', new BufferAttribute(pointsPos, 3));
+const pointsCloud = new Points(
+ pointsGeo,
+ new PointsMaterial({ color: 0xffffff, size: 0.08, transparent: true, opacity: 0.9 })
+);
+root.add(pointsCloud);
+
+animate(pointsCloud, {
+ rotateY: 360,
+ color: ['#fff', '#ff7', '#7ff', '#fff'],
+ duration: 8000,
+ loop: true,
+ ease: 'linear',
+});
+
+// line (orbit ring)
+const RING_SEGMENTS = 128;
+const ringGeo = new BufferGeometry();
+const ringPos = new Float32Array((RING_SEGMENTS + 1) * 3);
+for (let i = 0; i <= RING_SEGMENTS; i++) {
+ const a = (i / RING_SEGMENTS) * Math.PI * 2;
+ ringPos[i * 3] = Math.cos(a) * 6;
+ ringPos[i * 3 + 1] = 0;
+ ringPos[i * 3 + 2] = Math.sin(a) * 6;
+}
+ringGeo.setAttribute('position', new BufferAttribute(ringPos, 3));
+const ring = new Line(
+ ringGeo,
+ new LineBasicMaterial({ color: 0xffffff, transparent: true, opacity: 0.6 })
+);
+utils.set(ring, { rotateX: 90 });
+root.add(ring);
+
+animate(ring, {
+ rotateZ: 360,
+ color: ['#fff', '#88f', '#fff'],
+ opacity: [0.3, 0.8, 0.3],
+ duration: 4000,
+ loop: true,
+ ease: 'inOutSine',
+});
+
+// instanced mesh grid
+const instanced = new InstancedMesh(
+ new BoxGeometry(0.3, 0.3, 0.3),
+ new MeshStandardMaterial({ color: 0x42a5ff }),
+ 4000
+);
+instanced.castShadow = true;
+utils.set(instanced, { y: 5 });
+root.add(instanced);
+
+const instancedInstances = getInstances(instanced);
+utils.set(instancedInstances, {
+ x: stagger(0.45, { grid: [80, 50], from: 'center', axis: 'x' }),
+ y: stagger(0.45, { grid: [80, 50], from: 'center', axis: 'y' }),
+});
+
+animate(instancedInstances, {
+ z: () => utils.random(-10, 10),
+ rotateX: () => utils.random(-180, 180),
+ rotateY: () => utils.random(-180, 180),
+ duration: 3000,
+ delay: stagger([0, 1000], { grid: true, from: 'center' }),
+ loop: true,
+ alternate: true,
+ ease: 'inOutSine',
+});
+
+// User onBeforeRender chains transparently with the auto-flush; commit
+// any pending instance writes happens before this runs.
+// Assigning your own onBeforeRender keeps the auto-flush chain (the
+// adapter installs an accessor that stores user handlers separately);
+// no need to capture and call any previous handler.
+instanced.onBeforeRender = function () {
+ instanced.position.y = 5 + Math.sin(performance.now() * 0.0015) * 0.6;
+};
+
+// BatchedMesh ring with three different geometries sharing one material
+// and one draw call (the whole point of BatchedMesh).
+const BATCH_COUNT = 24;
+const batchedMat = new MeshStandardMaterial({ color: 0x88ffaa });
+const batched = new BatchedMesh(BATCH_COUNT, 2000, 4000, batchedMat);
+const geoIds = [
+ batched.addGeometry(new BoxGeometry(0.7, 0.7, 0.7)),
+ batched.addGeometry(new SphereGeometry(0.45, 12, 8)),
+ batched.addGeometry(new ConeGeometry(0.45, 0.9, 6)),
+];
+for (let i = 0; i < BATCH_COUNT; i++) batched.addInstance(geoIds[i % geoIds.length]);
+batched.castShadow = true;
+utils.set(batched, { y: 2 });
+scene.add(batched);
+
+// arrange instances around a ring
+const batchedInstances = getInstances(batched);
+for (let i = 0; i < BATCH_COUNT; i++) {
+ const inst = batchedInstances[i];
+ if (!inst) continue;
+ const a = (i / BATCH_COUNT) * Math.PI * 2;
+ utils.set(inst, { x: Math.cos(a) * 6, z: Math.sin(a) * 6 });
+}
+
+// scale crosses 0 -> exercises the per-instance visibility flip path
+animate(batchedInstances, {
+ scale: [1, 0, 1],
+ rotateY: 360,
+ color: ['#88ffaa', '#ffaa88', '#88ffaa'],
+ duration: 3000,
+ delay: stagger(80),
+ loop: true,
+ ease: 'inOutSine',
+});
+
+// per-instance visibility flicker -> exercises BatchedMesh.setVisibleAt
+// (no-op on InstancedMesh, see Instance.visible).
+createTimer({
+ duration: 600,
+ loop: true,
+ onLoop: () => {
+ for (let i = 0, l = batchedInstances.length; i < l; i++) {
+ const inst = batchedInstances[i];
+ if (inst) inst.visible = Math.random() > 0.18;
+ }
+ },
+});
+
+// light animations
+animate(ambient, {
+ intensity: [0.15, 2],
+ color: ['#fff', '#ffe0b3', '#fff'],
+ duration: 5000,
+ loop: true,
+ alternate: true,
+ ease: 'inOutSine',
+});
+
+animate(dir, {
+ intensity: [0.6, 2.6],
+ color: ['#ffffff', '#ffd0b0', '#ffffff'],
+ rotateY: 360,
+ duration: 6000,
+ loop: true,
+ ease: 'linear',
+});
+
+animate(point, {
+ x: [-6, 6],
+ z: [-4, 4],
+ intensity: [40, 120],
+ color: ['#ff66aa', '#aa66ff', '#ff66aa'],
+ duration: 3500,
+ loop: true,
+ alternate: true,
+ ease: 'inOutSine',
+});
+
+animate(spot, {
+ intensity: [30, 90],
+ color: ['#66ddff', '#66ffaa', '#66ddff'],
+ duration: 2800,
+ loop: true,
+ alternate: true,
+ ease: 'inOutSine',
+});
+
+animate(hemi, {
+ intensity: [0.2, 0.8],
+ color: ['#88aaff', '#ffaa88', '#88aaff'],
+ duration: 7000,
+ loop: true,
+ ease: 'linear',
+});
+
+// camera fov breathe (fov setter on the adapter auto-calls
+// updateProjectionMatrix)
+animate(camera, {
+ fov: [50, 38],
+ duration: 6000,
+ loop: true,
+ alternate: true,
+ ease: 'inOutQuad',
+});
+
+// root rotation
+animate(root, {
+ rotateY: 360,
+ duration: 30000,
+ loop: true,
+ ease: 'linear',
+});
+
+// render + helper updates
+createTimer({
+ priority: 0,
+ onUpdate: () => {
+ // Helpers don't update themselves - call update() each frame.
+ dirHelper.update();
+ pointHelper.update();
+ spotHelper.update();
+ hemiHelper.update();
+ renderer.render(scene, camera);
+ },
+});
+
+// Touch unused imports the linter/types might flag. (MathUtils is reserved
+// for direct degree conversions outside animate(); commitChanges is
+// available if you ever read instanceMatrix between a tick and a render.)
+void MathUtils; void commitChanges;
diff --git a/tests/playground/threejs/adapters/index.html b/tests/playground/threejs/adapters/index.html
new file mode 100644
index 00000000..43d32714
--- /dev/null
+++ b/tests/playground/threejs/adapters/index.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Three.js adapter / Anime.js</title>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+ <style>
+ html, body { margin: 0; padding: 0; height: 100%; background: #111; overflow: hidden; }
+ canvas { display: block; }
+ </style>
+ <script type="importmap">
+ {
+ "imports": {
+ "three": "https://unpkg.com/[email protected]/build/three.module.js",
+ "three/tsl": "https://unpkg.com/[email protected]/build/three.tsl.js",
+ "three/webgpu": "https://unpkg.com/[email protected]/build/three.webgpu.js"
+ }
+ }
+ </script>
+</head>
+<body>
+<script type="module" src="./index.js"></script>
+</body>
+</html>
diff --git a/tests/playground/threejs/adapters/index.js b/tests/playground/threejs/adapters/index.js
new file mode 100644
index 00000000..de6dc520
--- /dev/null
+++ b/tests/playground/threejs/adapters/index.js
@@ -0,0 +1,626 @@
+import {
+ Scene, WebGLRenderer, PCFShadowMap,
+ Mesh, Group, Sprite, Points, Line,
+ PerspectiveCamera, AmbientLight, DirectionalLight, PointLight, SpotLight, HemisphereLight,
+ InstancedMesh, BatchedMesh,
+ BoxGeometry, SphereGeometry, ConeGeometry, TorusKnotGeometry, IcosahedronGeometry, PlaneGeometry, BufferGeometry, BufferAttribute,
+ MeshStandardMaterial, MeshPhysicalMaterial, ShaderMaterial, PointsMaterial, LineBasicMaterial, SpriteMaterial,
+ CanvasTexture, MathUtils, Vector2, Vector3, Color,
+ DirectionalLightHelper, PointLightHelper, SpotLightHelper, HemisphereLightHelper,
+} from 'three';
+
+import { uniform } from 'three/tsl';
+import { MeshStandardNodeMaterial } from 'three/webgpu';
+
+import { engine, animate, createTimeline, createTimer, stagger, utils } from '../../../../dist/modules/index.js';
+
+// Side-effect import: registers the Object3D adapter so animate() and
+// utils.set() accept raw three.js objects with flat properties
+// (x, rotateY, scale, opacity, color, ...).
+import { getInstances, commitChanges } from '../../../../dist/modules/adapters/three/index.js';
+
+engine.fps = 60;
+// renderer + camera
+const scene = new Scene();
+
+const camera = new PerspectiveCamera(50, innerWidth / innerHeight, 0.1, 1000);
+utils.set(camera, { x: 0, y: 6, z: 22 });
+camera.lookAt(0, 0, 0);
+
+const renderer = new WebGLRenderer({ antialias: true });
+renderer.setSize(innerWidth, innerHeight);
+renderer.setPixelRatio(1);
+renderer.shadowMap.enabled = true;
+renderer.shadowMap.type = PCFShadowMap;
+document.body.appendChild(renderer.domElement);
+addEventListener('resize', () => {
+ camera.aspect = innerWidth / innerHeight;
+ camera.updateProjectionMatrix();
+ renderer.setSize(innerWidth, innerHeight);
+});
+
+// lights + helpers
+const ambient = new AmbientLight(0xffffff, 0.25);
+scene.add(ambient);
+
+const dir = new DirectionalLight(0xffffff, 1.4);
+utils.set(dir, { x: 6, y: 10, z: 6 });
+dir.castShadow = true;
+dir.shadow.mapSize.set(1024, 1024);
+dir.shadow.camera.left = -12;
+dir.shadow.camera.right = 12;
+dir.shadow.camera.top = 12;
+dir.shadow.camera.bottom = -12;
+dir.shadow.camera.near = 1;
+dir.shadow.camera.far = 40;
+scene.add(dir);
+const dirHelper = new DirectionalLightHelper(dir, 1.5, 0xffffff);
+scene.add(dirHelper);
+
+const point = new PointLight(0xff66aa, 80, 30, 1.6);
+utils.set(point, { x: 0, y: 4, z: 4 });
+scene.add(point);
+const pointHelper = new PointLightHelper(point, 0.4);
+scene.add(pointHelper);
+
+const spot = new SpotLight(0x66ddff, 60, 40, Math.PI / 6, 0.4, 1.5);
+utils.set(spot, { x: -8, y: 8, z: 4 });
+spot.target.position.set(0, 0, 0);
+scene.add(spot);
+scene.add(spot.target);
+const spotHelper = new SpotLightHelper(spot);
+scene.add(spotHelper);
+
+const hemi = new HemisphereLight(0x88aaff, 0x442200, 0.4);
+utils.set(hemi, { x: 0, y: 12, z: 0 });
+scene.add(hemi);
+const hemiHelper = new HemisphereLightHelper(hemi, 1);
+scene.add(hemiHelper);
+
+// floor (receives shadows)
+const floor = new Mesh(
+ new PlaneGeometry(40, 40),
+ new MeshStandardMaterial({ color: 0x222233, roughness: 1, metalness: 0 })
+);
+utils.set(floor, { rotateX: -90, y: -3 });
+floor.receiveShadow = true;
+scene.add(floor);
+
+// root group (everything that moves together)
+const root = new Group();
+scene.add(root);
+
+// animated cube
+const cube = new Mesh(
+ new BoxGeometry(1.2, 1.2, 1.2),
+ new MeshStandardMaterial({ color: 0xff4b4b, transparent: true })
+);
+utils.set(cube, { x: -7 });
+cube.castShadow = true;
+cube.receiveShadow = true;
+root.add(cube);
+
+// scale = 0 and opacity = 0 mid-tween exercise the visibility flip.
+animate(cube, {
+ rotateY: 360,
+ rotateX: [0, 180],
+ scale: [{ to: 1.6 }, { to: 0 }, { to: 1 }],
+ color: ['#fff', '#f0a', '#fff'],
+ opacity: [1, 0, 1],
+ duration: 3000,
+ loop: true,
+});
+
+// sprite billboard
+const spriteCanvas = (() => {
+ const c = document.createElement('canvas');
+ c.width = c.height = 128;
+ const ctx = c.getContext('2d');
+ const grad = ctx.createRadialGradient(64, 64, 4, 64, 64, 64);
+ grad.addColorStop(0, '#fff');
+ grad.addColorStop(0.4, '#fc0');
+ grad.addColorStop(1, '#f000');
+ ctx.fillStyle = grad;
+ ctx.fillRect(0, 0, 128, 128);
+ return c;
+})();
+
+const sprite = new Sprite(new SpriteMaterial({
+ map: new CanvasTexture(spriteCanvas),
+ transparent: true,
+ depthWrite: false,
+}));
+utils.set(sprite, { x: 7, y: 1, scale: 1.5 });
+root.add(sprite);
+
+animate(sprite, {
+ y: [1, 3, 1],
+ scale: [1.5, 2.5, 1.5],
+ opacity: [0.5, 1, 0.5],
+ color: ['#ffcc00', '#ff66ff', '#66ffff', '#ffcc00'],
+ duration: 3000,
+ loop: true,
+ ease: 'inOutSine',
+});
+
+// points cloud
+const POINTS_COUNT = 600;
+const pointsGeo = new BufferGeometry();
+const pointsPos = new Float32Array(POINTS_COUNT * 3);
+for (let i = 0; i < POINTS_COUNT; i++) {
+ const a = (i / POINTS_COUNT) * Math.PI * 2;
+ const r = 9 + Math.random() * 1.5;
+ pointsPos[i * 3] = Math.cos(a) * r;
+ pointsPos[i * 3 + 1] = (Math.random() - 0.5) * 0.6;
+ pointsPos[i * 3 + 2] = Math.sin(a) * r;
+}
+pointsGeo.setAttribute('position', new BufferAttribute(pointsPos, 3));
+const pointsCloud = new Points(
+ pointsGeo,
+ new PointsMaterial({ color: 0xffffff, size: 0.08, transparent: true, opacity: 0.9 })
+);
+root.add(pointsCloud);
+
+animate(pointsCloud, {
+ rotateY: 360,
+ color: ['#fff', '#ff7', '#7ff', '#fff'],
+ duration: 8000,
+ loop: true,
+ ease: 'linear',
+});
+
+// line (orbit ring)
+const RING_SEGMENTS = 128;
+const ringGeo = new BufferGeometry();
+const ringPos = new Float32Array((RING_SEGMENTS + 1) * 3);
+for (let i = 0; i <= RING_SEGMENTS; i++) {
+ const a = (i / RING_SEGMENTS) * Math.PI * 2;
+ ringPos[i * 3] = Math.cos(a) * 6;
+ ringPos[i * 3 + 1] = 0;
+ ringPos[i * 3 + 2] = Math.sin(a) * 6;
+}
+ringGeo.setAttribute('position', new BufferAttribute(ringPos, 3));
+const ring = new Line(
+ ringGeo,
+ new LineBasicMaterial({ color: 0xffffff, transparent: true, opacity: 0.6 })
+);
+utils.set(ring, { rotateX: 90 });
+root.add(ring);
+
+animate(ring, {
+ rotateZ: 360,
+ color: ['#fff', '#88f', '#fff'],
+ opacity: [0.3, 0.8, 0.3],
+ duration: 4000,
+ loop: true,
+ ease: 'inOutSine',
+});
+
+// instanced mesh grid
+// Material is white so per-instance colors uploaded via `instanceColor` render at full intensity (the material color multiplies them).
+const instancePalette = ['#ff4b4b', '#ff8f42', '#ffc730', '#a4ff4f', '#3cffec', '#5a87ff', '#8453e3', '#fb89fb'];
+const instanced = new InstancedMesh(
+ new BoxGeometry(0.3, 0.3, 0.3),
+ new MeshStandardMaterial({ color: 0xffffff }),
+ 4000
+);
+instanced.castShadow = true;
+utils.set(instanced, { y: 5 });
+root.add(instanced);
+
+const instancedInstances = getInstances(instanced);
+utils.set(instancedInstances, {
+ x: stagger(0.45, { grid: [80, 50], from: 'center', axis: 'x' }),
+ y: stagger(0.45, { grid: [80, 50], from: 'center', axis: 'y' }),
+ color: () => utils.randomPick(instancePalette),
+});
+
+animate(instancedInstances, {
+ z: () => utils.random(-10, 10),
+ rotateX: () => utils.random(-180, 180),
+ rotateY: () => utils.random(-180, 180),
+ color: () => [utils.randomPick(instancePalette), utils.randomPick(instancePalette)],
+ duration: 3000,
+ delay: stagger([0, 1000], { grid: true, from: 'center' }),
+ loop: true,
+ alternate: true,
+ ease: 'inOutSine',
+});
+
+// Assigning your own onBeforeRender keeps the auto-flush chain (the
+// adapter installs an accessor that stores user handlers separately);
+// no need to capture and call any previous handler.
+instanced.onBeforeRender = function () {
+ instanced.position.y = 5 + Math.sin(performance.now() * 0.0015) * 0.6;
+};
+
+// BatchedMesh ring with three different geometries sharing one material
+// and one draw call (the whole point of BatchedMesh).
+const BATCH_COUNT = 24;
+const batchedMat = new MeshStandardMaterial({ color: 0x88ffaa });
+const batched = new BatchedMesh(BATCH_COUNT, 2000, 4000, batchedMat);
+const geoIds = [
+ batched.addGeometry(new BoxGeometry(0.7, 0.7, 0.7)),
+ batched.addGeometry(new SphereGeometry(0.45, 12, 8)),
+ batched.addGeometry(new ConeGeometry(0.45, 0.9, 6)),
+];
+for (let i = 0; i < BATCH_COUNT; i++) batched.addInstance(geoIds[i % geoIds.length]);
+batched.castShadow = true;
+utils.set(batched, { y: 2 });
+scene.add(batched);
+
+// arrange instances around a ring
+const batchedInstances = getInstances(batched);
+for (let i = 0; i < BATCH_COUNT; i++) {
+ const inst = batchedInstances[i];
+ if (!inst) continue;
+ const a = (i / BATCH_COUNT) * Math.PI * 2;
+ utils.set(inst, { x: Math.cos(a) * 6, z: Math.sin(a) * 6 });
+}
+
+// scale crosses 0 -> exercises the per-instance visibility flip path
+animate(batchedInstances, {
+ scale: [1, 0, 1],
+ rotateY: 360,
+ color: ['#88ffaa', '#ffaa88', '#88ffaa'],
+ duration: 3000,
+ delay: stagger(80),
+ loop: true,
+ ease: 'inOutSine',
+});
+
+// Skew + transformOrigin demos
+// Two single meshes (Object3D adapter path) and two InstancedMesh grids (Instance adapter path),
+// one of each pair animating skewX / skewY, the other animating transformOrigin around a fixed pivot.
+
+const skewMesh = new Mesh(
+ new BoxGeometry(1.2, 1.2, 1.2),
+ new MeshStandardMaterial({ color: '#ff66aa' }),
+);
+skewMesh.castShadow = true;
+utils.set(skewMesh, { x: -8, y: 1, z: 6 });
+root.add(skewMesh);
+animate(skewMesh, {
+ skewX: [-30, 30],
+ skewY: [20, -20],
+ rotateY: 360,
+ duration: 4000,
+ loop: true,
+ alternate: true,
+ ease: 'inOutSine',
+});
+
+const originMesh = new Mesh(
+ new BoxGeometry(1.2, 1.2, 1.2),
+ new MeshStandardMaterial({ color: '#66ffaa' }),
+);
+originMesh.castShadow = true;
+utils.set(originMesh, { x: -5, y: 1, z: 6 });
+root.add(originMesh);
+animate(originMesh, {
+ // Off-center pivot pulls the visible position as scale/rotation animate.
+ transformOriginY: [-1, 1],
+ scale: [1, 2.2],
+ rotateZ: 360,
+ duration: 4000,
+ loop: true,
+ alternate: true,
+ ease: 'inOutSine',
+});
+
+const skewInstanced = new InstancedMesh(
+ new BoxGeometry(0.4, 0.4, 0.4),
+ new MeshStandardMaterial({ color: '#ffaa66' }),
+ 16,
+);
+skewInstanced.castShadow = true;
+utils.set(skewInstanced, { x: 4, y: 1, z: 6 });
+root.add(skewInstanced);
+const skewInstances = getInstances(skewInstanced);
+utils.set(skewInstances, {
+ x: stagger(0.55, { from: 'center' }),
+});
+animate(skewInstances, {
+ skewX: () => utils.random(-45, 45),
+ skewY: () => utils.random(-30, 30),
+ duration: 2500,
+ delay: stagger(80),
+ loop: true,
+ alternate: true,
+ ease: 'inOutSine',
+});
+
+const originInstanced = new InstancedMesh(
+ new BoxGeometry(0.4, 0.4, 0.4),
+ new MeshStandardMaterial({ color: '#aa66ff' }),
+ 16,
+);
+originInstanced.castShadow = true;
+utils.set(originInstanced, { x: 11, y: 1, z: 6 });
+root.add(originInstanced);
+const originInstances = getInstances(originInstanced);
+utils.set(originInstances, {
+ x: stagger(0.55, { from: 'center' }),
+});
+animate(originInstances, {
+ // Per-instance pivot offsets make rotateY swing each cube around a different point.
+ transformOriginX: () => utils.random(-1, 1),
+ transformOriginY: () => utils.random(-1, 1),
+ rotateY: 360,
+ duration: 3000,
+ delay: stagger(50),
+ loop: true,
+ ease: 'linear',
+});
+
+// per-instance visibility flicker -> exercises BatchedMesh.setVisibleAt
+// (no-op on InstancedMesh, see Instance.visible).
+createTimer({
+ duration: 600,
+ loop: true,
+ onLoop: () => {
+ for (let i = 0, l = batchedInstances.length; i < l; i++) {
+ const inst = batchedInstances[i];
+ if (inst) inst.visible = Math.random() > 0.18;
+ }
+ },
+});
+
+// light animations
+animate(ambient, {
+ intensity: [0.15, 2],
+ color: ['#fff', '#ffe0b3', '#fff'],
+ duration: 5000,
+ loop: true,
+ alternate: true,
+ ease: 'inOutSine',
+});
+
+animate(dir, {
+ intensity: [0.6, 2.6],
+ color: ['#ffffff', '#ffd0b0', '#ffffff'],
+ rotateY: 360,
+ duration: 6000,
+ loop: true,
+ ease: 'linear',
+});
+
+animate(point, {
+ x: [-6, 6],
+ z: [-4, 4],
+ intensity: [40, 120],
+ color: ['#ff66aa', '#aa66ff', '#ff66aa'],
+ duration: 3500,
+ loop: true,
+ alternate: true,
+ ease: 'inOutSine',
+});
+
+animate(spot, {
+ intensity: [30, 90],
+ color: ['#66ddff', '#66ffaa', '#66ddff'],
+ duration: 2800,
+ loop: true,
+ alternate: true,
+ ease: 'inOutSine',
+});
+
+animate(hemi, {
+ intensity: [0.2, 0.8],
+ color: ['#88aaff', '#ffaa88', '#88aaff'],
+ duration: 7000,
+ loop: true,
+ ease: 'linear',
+});
+
+// camera fov breathe (fov setter on the adapter auto-calls
+// updateProjectionMatrix)
+animate(camera, {
+ fov: [50, 38],
+ duration: 6000,
+ loop: true,
+ alternate: true,
+ ease: 'inOutQuad',
+});
+
+// root rotation
+animate(root, {
+ rotateY: 360,
+ duration: 30000,
+ loop: true,
+ ease: 'linear',
+});
+
+// Procedural tangent-space normal map: a grid of round bumps. Encoded as RGB where
+// r/g = (nx/ny + 1) * 0.5, b = (nz + 1) * 0.5. CanvasTexture defaults to NoColorSpace,
+// which is what three's normal-map shader expects (no sRGB decoding).
+const normalMapCanvas = (() => {
+ const N = 256;
+ const cells = 6;
+ const strength = 4;
+ const c = document.createElement('canvas');
+ c.width = c.height = N;
+ const ctx = c.getContext('2d');
+ const img = ctx.createImageData(N, N);
+ const data = img.data;
+ const heightAt = (u, v) => {
+ const fu = u * cells, fv = v * cells;
+ const dx = (fu - Math.floor(fu)) - 0.5;
+ const dy = (fv - Math.floor(fv)) - 0.5;
+ const r = Math.sqrt(dx * dx + dy * dy);
+ return Math.max(0, 1 - r * 2.5);
+ };
+ const eps = 1 / N;
+ for (let y = 0; y < N; y++) {
+ for (let x = 0; x < N; x++) {
+ const u = x / N, v = y / N;
+ const dhdu = (heightAt(u + eps, v) - heightAt(u - eps, v)) * 0.5;
+ const dhdv = (heightAt(u, v + eps) - heightAt(u, v - eps)) * 0.5;
+ const nx = -dhdu * strength;
+ const ny = -dhdv * strength;
+ const nz = 1;
+ const len = Math.sqrt(nx * nx + ny * ny + nz * nz);
+ const i = (y * N + x) * 4;
+ data[i] = ((nx / len) + 1) * 127.5;
+ data[i + 1] = ((ny / len) + 1) * 127.5;
+ data[i + 2] = ((nz / len) + 1) * 127.5;
+ data[i + 3] = 255;
+ }
+ }
+ ctx.putImageData(img, 0, 0);
+ return c;
+})();
+const normalMapTexture = new CanvasTexture(normalMapCanvas);
+
+// MeshPhysicalMaterial: animate built-in material props through the mesh
+// (metalness / roughness / emissive / clearcoat / iridescence are auto-detected
+// on mesh.material at tween creation time). normalMap + normalScale demonstrate
+// the X / Y axis decomposition of a Vector2 material prop, with the bump strength
+// visibly growing, flattening at zero, then inverting as the values swing.
+const physicalKnot = new Mesh(
+ new TorusKnotGeometry(0.7, 0.22, 96, 12),
+ new MeshPhysicalMaterial({
+ color: 0xeeeeee,
+ metalness: 0,
+ roughness: 1,
+ clearcoat: 0,
+ clearcoatRoughness: 0.1,
+ iridescence: 0,
+ iridescenceIOR: 1.3,
+ emissive: new Color(0x000000),
+ normalMap: normalMapTexture,
+ normalScale: new Vector2(1, 1),
+ })
+);
+physicalKnot.castShadow = true;
+physicalKnot.receiveShadow = true;
+utils.set(physicalKnot, { x: -3, y: 3 });
+root.add(physicalKnot);
+
+animate(physicalKnot, {
+ metalness: [0, 1],
+ roughness: [1, 0.05],
+ clearcoat: [0, 1],
+ iridescence: [0, 1],
+ emissive: ['#000000', '#3300aa', '#000000'],
+ rotateY: 360,
+ duration: 5000,
+ loop: true,
+ alternate: true,
+ ease: 'inOutSine',
+});
+
+animate(physicalKnot, {
+ normalScaleX: [-1.5, 1.5],
+ normalScaleY: [1.5, -1.5],
+ duration: 4000,
+ loop: true,
+ alternate: true,
+ ease: 'inOutSine',
+});
+
+// ShaderMaterial: animate user-defined uniforms through the mesh.
+// uTime (scalar), uTint (Color), uIntensity (scalar) are auto-routed
+// to material.uniforms[name].value by the threeObject3D adapter.
+
+const sharderMaterial = new ShaderMaterial({
+ uniforms: {
+ uTime: { value: 0 },
+ uTint: { value: new Color('#0033ff') },
+ uIntensity: { value: 0.4 },
+ uOffset: { value: new Vector3(0, 0, 0) },
+ },
+ vertexShader: /* glsl */`
+ uniform float uTime;
+ uniform vec3 uOffset;
+ varying vec3 vNormal;
+ varying vec3 vPos;
+ void main() {
+ vNormal = normalize(normalMatrix * normal);
+ vec3 p = position + uOffset + normal * sin(uTime + position.y * 2.0) * 0.08;
+ vPos = p;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(p, 1.0);
+ }
+ `,
+ fragmentShader: /* glsl */`
+ uniform vec3 uTint;
+ uniform float uIntensity;
+ uniform float uTime;
+ varying vec3 vNormal;
+ varying vec3 vPos;
+ void main() {
+ float fresnel = pow(1.0 - max(dot(normalize(vNormal), vec3(0.0, 0.0, 1.0)), 0.0), 2.0);
+ float pulse = 0.5 + 0.5 * sin(uTime * 1.4 + vPos.y * 3.0);
+ vec3 col = uTint * (uIntensity + fresnel * 1.5) * pulse;
+ gl_FragColor = vec4(col, 1.0);
+ }
+ `,
+});
+const shaderMesh = new Mesh(new IcosahedronGeometry(0.9, 4), sharderMaterial);
+utils.set(shaderMesh, { x: 3, y: 3 });
+root.add(shaderMesh);
+
+animate(shaderMesh, {
+ uTime: [0, 60],
+ uTint: ['#0033ff', '#ff0066', '#33ff88', '#0033ff'],
+ uIntensity: [0.2, 1.4],
+ uOffsetX: [-0.25, 0.25], // uOffsetX / uOffsetY / uOffsetZ routed to uniform.uOffset.value.x / .y / .z
+ uOffsetY: [-0.3, 0.3],
+ uOffsetZ: [-0.15, 0.15],
+ duration: 12000,
+ loop: true,
+ alternate: true,
+ ease: 'inOutSine',
+});
+
+// TSL: animate UniformNode slots on a NodeMaterial and bare uniforms.
+// The playground uses WebGLRenderer so TSL is not rendered visibly here,
+// but the adapter wiring is exercised through `animate()`. Inspect the
+// uniforms in devtools to confirm `.value` ticks each frame.
+const tslMat = new MeshStandardNodeMaterial();
+tslMat.colorNode = uniform(new Color('#ff0066'));
+tslMat.metalnessNode = uniform(0);
+tslMat.opacityNode = uniform(1);
+tslMat.offsetNode = uniform(new Vector3());
+
+animate(tslMat, {
+ colorNode: ['#ff0066', '#33ff88', '#0033ff', '#ff0066'],
+ metalnessNode: [0, 1],
+ opacityNode: [1, 0.4],
+ offsetNodeX: [-0.5, 0.5],
+ offsetNodeY: [-0.3, 0.3],
+ duration: 8000,
+ loop: true,
+ alternate: true,
+ ease: 'inOutSine',
+});
+
+// Bare uniforms: scalar via `value`, color via `color`, vector via axis keys.
+const uTimeNode = uniform(0);
+const uTintNode = uniform(new Color('#000'));
+const uOffNode = uniform(new Vector3());
+
+animate(uTimeNode, { value: [0, 60], duration: 12000, loop: true, ease: 'linear' });
+animate(uTintNode, { color: ['#0033ff', '#33ff88', '#ff0066', '#0033ff'], duration: 9000, loop: true, ease: 'inOutSine' });
+animate(uOffNode, { x: [-1, 1], y: [-0.5, 0.5], z: [0, 0.25], duration: 7000, loop: true, alternate: true, ease: 'inOutQuad' });
+
+window.tslMat = tslMat;
+window.tslUniforms = { uTimeNode, uTintNode, uOffNode };
+
+// render + helper updates
+createTimer({
+ priority: 0,
+ onUpdate: () => {
+ // Helpers don't update themselves - call update() each frame.
+ dirHelper.update();
+ pointHelper.update();
+ spotHelper.update();
+ hemiHelper.update();
+ renderer.render(scene, camera);
+ },
+});
+
+// Touch unused imports the linter/types might flag. (MathUtils is reserved
+// for direct degree conversions outside animate(); commitChanges is
+// available if you ever read instanceMatrix between a tick and a render.)
+void MathUtils; void commitChanges;
diff --git a/tests/playground/threejs/adapters/three-adapters-api.js b/tests/playground/threejs/adapters/three-adapters-api.js
new file mode 100644
index 00000000..27b37557
--- /dev/null
+++ b/tests/playground/threejs/adapters/three-adapters-api.js
@@ -0,0 +1,89 @@
+/**
+ * Comparison: animating a three.js mesh with vs. without the
+ * `animejs/three` adapter.
+ *
+ * Two cubes run identical animations side by side. Read the two code
+ * blocks below for the syntactic comparison.
+ */
+
+import {
+ Scene, WebGLRenderer,
+ BoxGeometry, MeshStandardMaterial, Mesh,
+ PerspectiveCamera, AmbientLight, DirectionalLight,
+} from 'three';
+
+import { animate, createTimeline, createTimer, utils } from '../../../../dist/modules/index.js';
+
+// Side-effect import: registers the three.js adapter so animate() and
+// createTimeline() recognize raw three.js objects with flat properties.
+import '../../../../dist/modules/adapters/three/index.js';
+
+// scene setup
+
+const scene = new Scene();
+const camera = new PerspectiveCamera(50, innerWidth / innerHeight, 0.1, 1000);
+camera.position.set(0, 0, 10);
+camera.lookAt(0, 0, 0);
+
+const renderer = new WebGLRenderer({ antialias: true });
+renderer.setSize(innerWidth, innerHeight);
+renderer.setPixelRatio(devicePixelRatio);
+document.body.appendChild(renderer.domElement);
+addEventListener('resize', () => {
+ camera.aspect = innerWidth / innerHeight;
+ camera.updateProjectionMatrix();
+ renderer.setSize(innerWidth, innerHeight);
+});
+
+scene.add(new AmbientLight(0xffffff, 0.4));
+const dir = new DirectionalLight(0xffffff, 1);
+dir.position.set(3, 5, 4);
+scene.add(dir);
+
+// two cubes side by side
+
+function makeCube(x) {
+ const mesh = new Mesh(
+ new BoxGeometry(1, 1, 1),
+ new MeshStandardMaterial({ color: 0xffffff, transparent: true }),
+ );
+ mesh.position.x = x;
+ scene.add(mesh);
+ return mesh;
+}
+
+const leftCube = makeCube(-2);
+const rightCube = makeCube(2);
+
+// 1. without the adapters
+
+createTimeline({
+ defaults: {
+ duration: 350,
+ ease: 'inOutSine',
+ },
+})
+.add(leftCube.position, { y: -1 }, 0)
+.add(leftCube.rotation, { x: utils.degToRad(90), y: utils.degToRad(180) }, 0)
+.add(leftCube.scale, { x: 1.5, y: 1.5, z: 1.5 }, 0)
+.add(leftCube.material, { opacity: 0.3 }, 0)
+.add(leftCube.material.color, { r: 1, g: 0.4, b: 0.66 }, 0)
+
+// 2. with the adapters
+
+animate(rightCube, {
+ y: -1,
+ rotateX: 90,
+ rotateY: 180,
+ scaleAll: 1.5,
+ opacity: 0.3,
+ color: '#ff66aa',
+ duration: 350,
+ ease: 'inOutSine',
+});
+
+// render loop
+
+createTimer({
+ onUpdate: () => renderer.render(scene, camera),
+});
diff --git a/tests/playground/threejs/color-compare/index.html b/tests/playground/threejs/color-compare/index.html
new file mode 100644
index 00000000..0507e99a
--- /dev/null
+++ b/tests/playground/threejs/color-compare/index.html
@@ -0,0 +1,140 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>three.js color compare / Anime.js</title>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+ <style>
+ html, body { margin: 0; padding: 0; height: 100%; background: #111; overflow: hidden; font-family: system-ui, sans-serif; color: #ddd; }
+ canvas { display: block; }
+ .label {
+ position: absolute;
+ top: 12px;
+ left: 12px;
+ font-size: 12px;
+ pointer-events: none;
+ line-height: 1.4;
+ }
+ .controls {
+ position: absolute;
+ bottom: 16px;
+ left: 16px;
+ display: flex;
+ gap: 12px;
+ font-size: 12px;
+ }
+ button {
+ background: #222;
+ color: #ddd;
+ border: 1px solid #444;
+ padding: 6px 10px;
+ border-radius: 4px;
+ cursor: pointer;
+ font: inherit;
+ }
+ button.active {
+ background: #444;
+ border-color: #888;
+ }
+ </style>
+ <script type="importmap">
+ {
+ "imports": {
+ "three": "https://unpkg.com/[email protected]/build/three.module.js"
+ }
+ }
+ </script>
+</head>
+<body>
+ <div class="label">
+ Top row: <code>material.color.set(hex)</code> (native three.js)<br>
+ Bottom row: <code>utils.set(mesh, { color: hex })</code> (anime adapter)<br>
+ Each column should look identical top vs bottom.
+ </div>
+ <div class="controls">
+ <span>outputColorSpace:</span>
+ <button id="srgb" class="active">SRGBColorSpace (default)</button>
+ <button id="linear">LinearSRGBColorSpace</button>
+ </div>
+ <script type="module">
+ import {
+ Scene, WebGLRenderer, PerspectiveCamera,
+ Mesh, BoxGeometry, MeshBasicMaterial, Color,
+ SRGBColorSpace, LinearSRGBColorSpace,
+ } from 'three';
+
+ import { utils } from '../../../../dist/modules/index.js';
+ import '../../../../dist/modules/adapters/three/index.js';
+
+ const swatches = [
+ '#ff3b30', '#ff8800', '#ffcc00', '#34c759',
+ '#0a84ff', '#5e5ce6', '#bf5af2', '#ff2d55',
+ '#ffffff', '#cccccc', '#888888', '#444444', '#111111',
+ ];
+
+ const scene = new Scene();
+ scene.background = new Color(0x111111);
+
+ const camera = new PerspectiveCamera(45, innerWidth / innerHeight, 0.1, 100);
+ camera.position.z = 18;
+
+ const renderer = new WebGLRenderer({ antialias: true });
+ renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
+ renderer.setSize(innerWidth, innerHeight);
+ renderer.outputColorSpace = SRGBColorSpace;
+ document.body.appendChild(renderer.domElement);
+
+ addEventListener('resize', () => {
+ camera.aspect = innerWidth / innerHeight;
+ camera.updateProjectionMatrix();
+ renderer.setSize(innerWidth, innerHeight);
+ });
+
+ // Two rows of cubes. Top row sets material.color via three's own
+ // setStyle path; bottom row sets via the anime adapter.
+ const cubeSize = 1.4;
+ const stride = cubeSize;
+ const rowOffset = cubeSize * 0.5;
+ const xStart = -((swatches.length - 1) * stride) / 2;
+ const nativeMeshes = [];
+ const animeMeshes = [];
+ const geometry = new BoxGeometry(cubeSize, cubeSize, cubeSize);
+ for (let i = 0; i < swatches.length; i++) {
+ const native = new Mesh(geometry, new MeshBasicMaterial());
+ native.material.color.set(swatches[i]);
+ native.position.set(xStart + i * stride, rowOffset, 0);
+ scene.add(native);
+ nativeMeshes.push(native);
+
+ const anime = new Mesh(geometry, new MeshBasicMaterial());
+ anime.position.set(xStart + i * stride, -rowOffset, 0);
+ scene.add(anime);
+ utils.set(anime, { color: swatches[i] });
+ animeMeshes.push(anime);
+ }
+
+ function loop() {
+ requestAnimationFrame(loop);
+ renderer.render(scene, camera);
+ }
+ loop();
+
+ // outputColorSpace toggle. SRGBColorSpace is the default; LinearSRGBColorSpace skips gamma encoding so all swatches look darker, but native and adapter rows must still match each other.
+ const srgbBtn = document.getElementById('srgb');
+ const linearBtn = document.getElementById('linear');
+ function setSpace(space, activeBtn, inactiveBtn) {
+ renderer.outputColorSpace = space;
+ // Materials cache their compiled shaders; re-set the colors so the
+ // cached uniforms refresh against the new output space.
+ for (let i = 0; i < swatches.length; i++) {
+ nativeMeshes[i].material.color.set(swatches[i]);
+ utils.set(animeMeshes[i], { color: swatches[i] });
+ }
+ activeBtn.classList.add('active');
+ inactiveBtn.classList.remove('active');
+ }
+ srgbBtn.onclick = () => setSpace(SRGBColorSpace, srgbBtn, linearBtn);
+ linearBtn.onclick = () => setSpace(LinearSRGBColorSpace, linearBtn, srgbBtn);
+ </script>
+</body>
+</html>
diff --git a/tests/playground/threejs/color-trail/index.html b/tests/playground/threejs/color-trail/index.html
new file mode 100644
index 00000000..3a0358bd
--- /dev/null
+++ b/tests/playground/threejs/color-trail/index.html
@@ -0,0 +1,187 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Color trail three.js / Anime.js</title>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+ <style>
+ html, body { margin: 0; padding: 0; height: 100%; background: #111; overflow: hidden; font-family: system-ui, sans-serif; }
+ canvas { display: block; }
+ .label {
+ position: absolute;
+ top: 12px;
+ left: 12px;
+ color: #888;
+ font-size: 12px;
+ pointer-events: none;
+ }
+ </style>
+ <script type="importmap">
+ {
+ "imports": {
+ "three": "https://unpkg.com/[email protected]/build/three.module.js"
+ }
+ }
+ </script>
+</head>
+<body>
+ <div class="label">three.js port: outer ball overlap -=500 mid-way handoff<br>inner ball: 4 simple sequential adds (no overlap)</div>
+
+ <script type="module">
+ import {
+ Scene, WebGLRenderer, PerspectiveCamera,
+ Mesh, SphereGeometry, MeshBasicMaterial, Color, BufferGeometry,
+ LineBasicMaterial, LineLoop, BufferAttribute,
+ } from 'three';
+
+ import { animate, createTimeline, createTimer } from '../../../../dist/modules/index.js';
+ import '../../../../dist/modules/adapters/three/index.js';
+
+ const colors = [
+ '#ff3b30',
+ '#ffcc00',
+ '#34c759',
+ '#0a84ff',
+ ];
+
+ const scene = new Scene();
+ scene.background = new Color(0x111111);
+
+ const camera = new PerspectiveCamera(50, innerWidth / innerHeight, 0.1, 1000);
+ camera.position.z = 18;
+
+ const renderer = new WebGLRenderer({ antialias: true });
+ renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
+ renderer.setSize(innerWidth, innerHeight);
+ document.body.appendChild(renderer.domElement);
+
+ addEventListener('resize', () => {
+ camera.aspect = innerWidth / innerHeight;
+ camera.updateProjectionMatrix();
+ renderer.setSize(innerWidth, innerHeight);
+ });
+
+ const ringRadius = 6;
+ const stationRadius = 0.8;
+ const ballRadius = 0.55;
+
+ // Station meshes at the cardinal points; Y is negated so the layout matches the canvas demo (canvas Y goes down, three.js Y goes up).
+ const stations = [];
+ for (let i = 0; i < 4; i++) {
+ const a = -Math.PI * 0.5 + (Math.PI * 2 * i) / 4;
+ const mesh = new Mesh(
+ new SphereGeometry(stationRadius, 24, 16),
+ new MeshBasicMaterial({ color: colors[i] }),
+ );
+ mesh.position.set(Math.cos(a) * ringRadius, -Math.sin(a) * ringRadius, 0);
+ scene.add(mesh);
+ stations.push(mesh);
+ }
+
+ // Ring outline
+ {
+ const segments = 128;
+ const positions = new Float32Array(segments * 3);
+ for (let i = 0; i < segments; i++) {
+ const a = (i / segments) * Math.PI * 2;
+ positions[i * 3] = Math.cos(a) * ringRadius;
+ positions[i * 3 + 1] = Math.sin(a) * ringRadius;
+ positions[i * 3 + 2] = 0;
+ }
+ const geo = new BufferGeometry();
+ geo.setAttribute('position', new BufferAttribute(positions, 3));
+ scene.add(new LineLoop(geo, new LineBasicMaterial({ color: 0xffffff, transparent: true, opacity: 0.08 })));
+ }
+
+ // Trail ghost pool: each frame spawns a fading sphere at the ball's current position. Ghost meshes avoid the 8-bit precision artifacts of framebuffer-feedback fading.
+ const trailLifetime = 1500;
+ const trailGhostGeometry = new SphereGeometry(0.35, 12, 8);
+ const trailGhosts = [];
+
+ function spawnGhost(x, y, color, scaleMult) {
+ let ghost = trailGhosts.find(g => g.material.opacity <= 0);
+ if (!ghost) {
+ ghost = new Mesh(trailGhostGeometry, new MeshBasicMaterial({ transparent: true, depthWrite: false }));
+ scene.add(ghost);
+ trailGhosts.push(ghost);
+ }
+ ghost.position.set(x, y, 0);
+ ghost.scale.setScalar(scaleMult);
+ ghost.material.color.copy(color);
+ ghost.material.opacity = 0.85;
+ animate(ghost.material, { opacity: 0, duration: trailLifetime, ease: 'linear' });
+ }
+
+ // Square corners inscribed in the circle, between station pairs. Y negated to match the canvas layout.
+ const corners = [];
+ {
+ const angles = [-3 * Math.PI / 4, -Math.PI / 4, Math.PI / 4, 3 * Math.PI / 4];
+ for (let i = 0; i < 4; i++) {
+ const a = angles[i];
+ corners.push({ x: Math.cos(a) * ringRadius, y: -Math.sin(a) * ringRadius });
+ }
+ }
+
+ // Outer ball: traces the inscribed square with overshoot + -=500 handoffs (replace composition takes over mid-tween).
+ const outer = new Mesh(
+ new SphereGeometry(ballRadius, 24, 16),
+ new MeshBasicMaterial({ color: colors[0] }),
+ );
+ outer.position.set(corners[0].x, corners[0].y, 0);
+ scene.add(outer);
+
+ const tl = createTimeline({
+ autoplay: true,
+ loop: true,
+ defaults: { ease: 'linear', duration: 1000 },
+ });
+
+ for (let i = 1; i <= 4; i++) {
+ const isLast = i === 4;
+ const fromCorner = corners[i - 1];
+ const nextCorner = corners[i % 4];
+ const targetX = isLast ? nextCorner.x : 2 * nextCorner.x - fromCorner.x;
+ const targetY = isLast ? nextCorner.y : 2 * nextCorner.y - fromCorner.y;
+ tl.add(outer, {
+ x: targetX,
+ y: targetY,
+ color: colors[i % colors.length],
+ duration: isLast ? 500 : 1000,
+ }, i === 1 ? 0 : '-=500');
+ }
+
+ // Inner ball: 4 sequential non-overlapping adds. Exercises cross-add color sibling chaining through the three.js adapter setter.
+ const inner = new Mesh(
+ new SphereGeometry(ballRadius * 0.65, 24, 16),
+ new MeshBasicMaterial({ color: colors[0] }),
+ );
+ inner.position.set(stations[0].position.x, stations[0].position.y, 0);
+ scene.add(inner);
+
+ const tl2 = createTimeline({
+ autoplay: true,
+ loop: true,
+ defaults: { ease: 'linear', duration: 800 },
+ });
+
+ for (let i = 1; i <= 4; i++) {
+ const next = stations[i % stations.length];
+ tl2.add(inner, {
+ x: next.position.x,
+ y: next.position.y,
+ color: colors[i % colors.length],
+ });
+ }
+
+ // Render loop: spawn one ghost per frame at each ball's current position/color, then render. Ghosts fade themselves out via their own opacity animations.
+ createTimer({
+ autoplay: true,
+ onUpdate: () => {
+ spawnGhost(outer.position.x, outer.position.y, outer.material.color, 1);
+ spawnGhost(inner.position.x, inner.position.y, inner.material.color, 0.65);
+ renderer.render(scene, camera);
+ },
+ });
+ </script>
+</body>
+</html>
diff --git a/tests/playground/threejs/instanced-mesh/InstancedMeshProxy.js b/tests/playground/threejs/instanced-mesh/InstancedMeshProxy.js
deleted file mode 100644
index e69de29b..00000000
diff --git a/tests/playground/threejs/instanced-mesh/index.html b/tests/playground/threejs/instanced-mesh/index.html
deleted file mode 100644
index 335ddd77..00000000
--- a/tests/playground/threejs/instanced-mesh/index.html
+++ /dev/null
@@ -1,136 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>Benchmark | anime.js</title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
- <link href="../../assets/css/styles.css" rel="stylesheet">
- <style>
- body, html {
- background-color: black;
- }
- body {
- display: flex;
- justify-content: center;
- align-items: center;
- position: absolute;
- width: 100%;
- height: 100%;
- }
- #stats {
- position: absolute;
- z-index: 2;
- right: 0;
- top: 0;
- background-color: rgba(0, 0, 0, .5);
- font-size: 12px;
- text-transform: uppercase;
- padding: 1em;
- }
- #stats fieldset {
- display: flex;
- padding: 0;
- margin: 0;
- flex-direction: column;
- font-family: monospace;
- min-width: 13em;
- border: none;
- }
- #stats legend {
- display: flex;
- justify-content: space-between;
- align-items: center;
- width: 100%;
- border-top: 1px solid currentColor;
- border-bottom: 1px solid currentColor;
- padding: 0;
- margin: 0;
- }
- #stats label {
- display: flex;
- justify-content: space-between;
- }
- #stats input {
- font-family: inherit;
- border: none;
- padding: 0;
- margin: 0;
- background: transparent;
- color: currentColor;
- text-align: right;
- font-size: inherit;
- }
- #stats button,
- #stats select {
- font-family: inherit;
- border: none;
- padding: 0;
- background: #FFF;
- color: #000;
- height: 1em;
- font-size: inherit;
- line-height: 1em;
- }
- #stats button:not(:last-child),
- #stats select:not(:last-child),
- #stats fieldset:not(:last-child) {
- margin-bottom: 1ch;
- }
- #particles-container {
- pointer-events: none;
- display: flex;
- position: relative;
- width: 100%;
- height: 100vh;
- max-width: 1440px;
- overflow: hidden;
- }
- .particle {
- position: absolute;
- z-index: 1;
- left: 50%;
- top: 50%;
- width: .5rem;
- height: .5rem;
- margin: -.25rem 0 0 -.25rem;
- background: currentColor;
-/* border-radius: 50%;*/
- }
- .color1 { color: #FF4B4B; }
- .color2 { color: #9F3A39; }
- .color3 { color: #CF4242; }
- </style>
-</head>
-<body>
- <div id="particles-container"></div>
- <div id="stats">
- <fieldset>
- <legend>MONITOR</legend>
- <label>FPS<input type="text" id="fps" value="00.00" size=6 /></label>
- <label>AVG FPS<input type="text" id="avg" value="0" size=6 /></label>
- </fieldset>
- <fieldset>
- <legend>RENDER MODE</legend>
- <label>Anime.js<input class="config-item" type="radio" name="mode" value="css-transform"></label>
- <label>Web Animation<input class="config-item" type="radio" name="mode" value="wappi-css-transform"></label>
- <label>Anime.js & Three.js<input class="config-item" type="radio" name="mode" value="webgl-threejs"></label>
- </fieldset>
- <fieldset>
- <legend>ANIMATIONS<input class="config-item" type="text" name="count" value="0" size=6 /></label></legend>
- <label for="count-range">COUNT</label>
- <input id="count-range" class="config-item" type="range" name="count" min="0" max="4000" value="0" step="500" />
- </fieldset>
- <fieldset>
- <legend>TWEENS<span id="active-tweens"></span></legend>
- <label>x<input class="config-item" type="checkbox" name="tween" value="x"></label>
- <label>y<input class="config-item" type="checkbox" name="tween" value="y"></label>
- <label>rotation<input class="config-item" type="checkbox" name="tween" value="rotation"></label>
- <label>scale<input class="config-item" type="checkbox" name="tween" value="scale"></label>
- </fieldset>
- <fieldset>
- <button id="restart-button" class="restart-button">RESTART</button>
- </fieldset>
- </div>
-</body>
-<script type="module" src="index.js"></script>
-</html>
diff --git a/tests/playground/threejs/instanced-mesh/index.js b/tests/playground/threejs/instanced-mesh/index.js
deleted file mode 100644
index f4c6efcb..00000000
--- a/tests/playground/threejs/instanced-mesh/index.js
+++ /dev/null
@@ -1,276 +0,0 @@
-import { animate, createTimer, createTimeline, utils, engine, stagger } from '../../../../dist/modules/index.js';
-
-import {
- Object3D,
- Vector3,
- Color,
- PerspectiveCamera,
- BoxGeometry,
- SphereGeometry,
- MeshPhongMaterial, // Changed from MeshBasicMaterial for light interaction
- InstancedMesh,
- AmbientLight,
- DirectionalLight,
- Scene,
- WebGLRenderer,
- Mesh,
- PCFSoftShadowMap,
- Matrix4,
- Euler,
- Quaternion,
- MathUtils,
-} from '../../../node_modules/three/build/three.module.min.js';
-
-const { random, cos, sin, sqrt, PI } = Math;
-
-const $particlesContainer = document.querySelector('#particles-container');
-
-const count = 2500;
-const duration = 3000;
-const colors = [new Color('#FF4B4B'), new Color('#9F3A39'), new Color('#CF4242')];
-
-let containerRect = $particlesContainer.getBoundingClientRect();
-let containerW = containerRect.width;
-let containerH = containerRect.height;
-let W = 20;
-let H = 10;
-
-const target = { x: 0, y: 0, r: W * .25 };
-
-class InstancedMeshProxy {
- constructor(instancedMesh, initialIndex = 0) {
- this._mesh = instancedMesh;
- this._currentIndex = initialIndex;
- this._matrix = new Matrix4();
- this._position = new Vector3();
- this._rotation = new Euler();
- this._quaternion = new Quaternion();
- this._scale = new Vector3(1, 1, 1);
- this._dummyMatrix = new Matrix4();
- this.theta = utils.random(0, 1, 5) * PI * 2;
- this.radius = (W * .1) * sqrt(utils.random(0, 1, 5));
- }
-
- set index(value) {
- if (value < 0 || value >= this._mesh.count) {
- throw new Error(`Index ${value} is out of bounds for InstancedMesh with count ${this._mesh.count}`);
- }
- this._currentIndex = value;
- this._mesh.getMatrixAt(this._currentIndex, this._dummyMatrix);
- this._dummyMatrix.decompose(this._position, this._quaternion, this._scale);
- this._rotation.setFromQuaternion(this._quaternion);
- }
-
- get index() {
- return this._currentIndex;
- }
-
- set x(value) {
- this._position.x = value;
- this._updateMatrix();
- }
-
- set y(value) {
- this._position.y = value;
- this._updateMatrix();
- }
-
- set z(value) {
- this._position.z = value;
- this._updateMatrix();
- }
-
- get x() { return this._position.x; }
- get y() { return this._position.y; }
- get z() { return this._position.z; }
-
- set rotateX(value) {
- this._rotation.x = MathUtils.degToRad(value);
- this._updateMatrix();
- }
-
- set rotateY(value) {
- this._rotation.y = MathUtils.degToRad(value);
- this._updateMatrix();
- }
-
- set rotateZ(value) {
- this._rotation.z = MathUtils.degToRad(value);
- this._updateMatrix();
- }
-
- get rotateX() { return MathUtils.radToDeg(this._rotation.x); }
- get rotateY() { return MathUtils.radToDeg(this._rotation.y); }
- get rotateZ() { return MathUtils.radToDeg(this._rotation.z); }
-
- set scale(value) {
- this._scale.set(value, value, value);
- this._updateMatrix();
- }
-
- get scale() { return this._scale.x; }
-
- _updateMatrix() {
- this._quaternion.setFromEuler(this._rotation);
- this._matrix.compose(this._position, this._quaternion, this._scale);
- this._mesh.setMatrixAt(this._currentIndex, this._matrix);
- this._mesh.instanceMatrix.needsUpdate = true;
- }
-}
-
-const dummy = new Object3D();
-
-const camera = new PerspectiveCamera(60, containerW / containerH, 1, 400);
-camera.position.set(0, 0, -100);
-camera.lookAt(0, 0, 0);
-
-const geometry = new BoxGeometry(1, 1, 1);
-const material = new MeshPhongMaterial({
- color: 0xffffff,
- shininess: 60,
- specular: 0x004488,
-});
-
-const mesh = new InstancedMesh(geometry, material, count);
-mesh.castShadow = true;
-mesh.receiveShadow = true;
-const meshProxy = new InstancedMeshProxy(mesh);
-
-const meshes = [];
-
-for (let i = 0; i < count; i++) {
- meshes.push(new InstancedMeshProxy(mesh, i));
-}
-
-// Create ground plane to receive shadows
-const groundGeometry = new BoxGeometry(200, 200, 1);
-const groundMaterial = new MeshPhongMaterial({ color: 0x808080 });
-const ground = new Mesh(groundGeometry, groundMaterial);
-ground.rotation.x = Math.PI / 2;
-ground.position.y = -50;
-ground.receiveShadow = true;
-
-const scene = new Scene();
-scene.add(mesh);
-scene.add(ground);
-
-// Add lighting
-const ambientLight = new AmbientLight(0x404040, 0.5);
-scene.add(ambientLight);
-
-// Add main directional light with shadow
-const mainLight = new DirectionalLight(0xffffff, 1);
-mainLight.position.set(50, 50, 50);
-mainLight.castShadow = true;
-mainLight.shadow.camera.near = 1;
-mainLight.shadow.camera.far = 200;
-mainLight.shadow.camera.left = -50;
-mainLight.shadow.camera.right = 50;
-mainLight.shadow.camera.top = 50;
-mainLight.shadow.camera.bottom = -50;
-mainLight.shadow.mapSize.width = 2048;
-mainLight.shadow.mapSize.height = 2048;
-mainLight.shadow.bias = -0.001;
-scene.add(mainLight);
-
-// Add fill light
-const fillLight = new DirectionalLight(0x8080ff, 0.5);
-fillLight.position.set(-50, 20, -50);
-scene.add(fillLight);
-
-const renderer = new WebGLRenderer({
- antialias: false, // Enabled antialiasing for better quality
- powerPreference: 'high-performance',
-});
-
-// renderer.setPixelRatio(window.devicePixelRatio);
-renderer.setSize(containerW, containerH);
-renderer.shadowMap.enabled = true;
-renderer.shadowMap.type = PCFSoftShadowMap;
-
-$particlesContainer.appendChild(renderer.domElement);
-
-const renderLoop = createTimer({
- onUpdate: () => {
- renderer.render(scene, camera);
- },
- autoplay: false
-});
-
-const screenCoords = new Vector3();
-const worldCoords = new Vector3();
-
-// animate(meshes, {
-// x: () => utils.random(-100, 100),
-// y: () => utils.random(-100, 100),
-// z: () => utils.random(-100, 100),
-// rotateX: () => utils.random(-180, 180),
-// rotateY: () => utils.random(-180, 180),
-// rotateZ: () => utils.random(-180, 180),
-// scale: () => utils.random(1, 3, 2),
-// loop: true,
-// duration: 5000,
-// delay: stagger([0, count]),
-// onLoop: self => self.refresh().restart()
-// })
-
-const tl = createTimeline({
- defaults: {
- loop: true,
- ease: 'inOut(1.3)',
- onLoop: self => self.refresh(),
- },
-});
-
-tl.add(meshes, {
- x: m => target.x + (m.radius * cos(m.theta)),
- y: m => target.y + (m.radius * sin(m.theta)),
- duration: () => duration + utils.random(-100, 100),
- ease: 'inOut(1.5)',
- onLoop: self => {
- const t = self.targets[0];
- // t.theta = random() * PI * 2;
- // t.radius = target.r * sqrt(random());
- self.refresh();
- },
-}, stagger((duration / count) * 1.125))
-.add(target, {
- r: () => W * utils.random(.05, .5, 2),
- duration: 1250,
-}, 0)
-.add(target, {
- x: () => utils.random(-W * .1, W * .1),
- modifier: x => x + sin(tl.currentTime * .0007) * (W * .1),
- duration: 2800,
-}, 0)
-.add(target, {
- y: () => utils.random(-H * .1, H * .1),
- modifier: y => y + cos(tl.currentTime * .00012) * (H * .1),
- duration: 1800,
-}, 0)
-.add(target, {
- z: () => utils.random(-W * .1, W * .1),
- modifier: x => x + sin(tl.currentTime * .0007) * (W * .1),
- duration: 2800,
-}, 0)
-
-renderLoop.play();
-
-function onResize() {
- containerRect = $particlesContainer.getBoundingClientRect();
- containerW = containerRect.width;
- containerH = containerRect.height;
- camera.aspect = containerW / containerH;
- camera.updateProjectionMatrix();
- renderer.setSize(containerW, containerH);
- screenCoords.set(2, 2, .5);
- screenCoords.unproject(camera);
- screenCoords.sub(camera.position).normalize();
- worldCoords.copy(camera.position).add(screenCoords.multiplyScalar(-camera.position.z / screenCoords.z));
- W = worldCoords.x;
- H = worldCoords.y;
-}
-
-onResize();
-
-window.onresize = onResize;
\ No newline at end of file
diff --git a/tests/playground/timekeeper/index.js b/tests/playground/timekeeper/index.js
index 70a0b38e..7fbe8b5e 100644
--- a/tests/playground/timekeeper/index.js
+++ b/tests/playground/timekeeper/index.js
@@ -19,7 +19,6 @@ createScope({
alternate: true,
loop: true,
ease: 'inOutQuad',
- mediaQueries: { minM: '(min-width: 800px)' }
-}).add(self => {
- self.preserve(timekeeper);
-});
\ No newline at end of file
+ });
+ });
+});
diff --git a/tests/playground/timeline/test/index.js b/tests/playground/timeline/test/index.js
index 07a50057..f0dfbc3d 100644
--- a/tests/playground/timeline/test/index.js
+++ b/tests/playground/timeline/test/index.js
@@ -131,5 +131,5 @@ const tl = createTimeline({
// })
// }
-inspect(tl);
+// inspect(tl);
diff --git a/tests/playground/waapi/eases/index.js b/tests/playground/waapi/eases/index.js
index 61d2d8f1..d0c8e4fe 100644
--- a/tests/playground/waapi/eases/index.js
+++ b/tests/playground/waapi/eases/index.js
@@ -1,4 +1,4 @@
-import { waapi, animate, stagger, createSpring, utils } from '../../../../dist/modules/index.js';
+import { waapi, stagger, utils, spring } from '../../../../dist/modules/index.js';
const $animation = document.querySelector('.animation');
const total = 36;
@@ -6,7 +6,7 @@ const total = 36;
for (let i = 0; i < total; i++) {
const $square = document.createElement('div');
$square.classList.add('square', 'red');
- utils.set($square, { rotate: (i / total) * 360, translateY: 250 })
+ $square.style.transform = `rotate(${(i / total) * 360}deg) translateY(250px)`;
$animation.appendChild($square);
}
@@ -36,13 +36,15 @@ for (let i = 0; i < total; i++) {
// Anime.js WAAPI wrapper
waapi.animate('.square', {
- transform: (_, i) => `rotate(${(i / total) * 360}deg) translateY(200px) scaleX(.25)`,
+ transform: (_, i) => {
+ return `rotate(${(i / total) * 360}deg) translateY(200px) scaleX(.25)`;
+ },
backgroundColor: {
to: [`var(--orange-1)`, `var(--red-1)`],
ease: 'linear',
duration: 3000,
},
- ease: createSpring({ stiffness: 150 }),
+ ease: spring({ stiffness: 150 }),
loop: true,
alternate: true,
delay: stagger(95),
diff --git a/tests/run.js b/tests/run.js
index 0da912c7..a5c64c57 100644
--- a/tests/run.js
+++ b/tests/run.js
@@ -26,6 +26,7 @@ import './suites/utils.test.js';
import './suites/values.test.js';
import './suites/transforms.test.js';
import './suites/colors.test.js';
+import './suites/threejs.test.js';
import './suites/eases.test.js';
import './suites/leaks.test.js';
diff --git a/tests/setup.js b/tests/setup.js
index 5ac05ab9..4732c3f9 100644
--- a/tests/setup.js
+++ b/tests/setup.js
@@ -1,4 +1,5 @@
import '../node_modules/mocha/mocha.js';
+import { engine } from '../dist/modules/index.js';
export const testObject = {};
export const anOtherTestObject = {};
@@ -13,6 +14,8 @@ mocha.setup({
globals: ['___browserSync___'],
rootHooks: {
beforeEach(done) {
+ // Pin engine offset to 0 so timeline construction has deterministic FP precision across tests.
+ engine._startTime = engine._lastTickTime;
testObject.plainValue = 10;
testObject.valueWithUnit = '10px';
testObject.multiplePLainValues = '16 32 64 128';
diff --git a/tests/suites/build.test.js b/tests/suites/build.test.js
index 13e42737..3ebce341 100644
--- a/tests/suites/build.test.js
+++ b/tests/suites/build.test.js
@@ -2,9 +2,9 @@ import {
expect,
} from '../utils.js';
-import * as esmModules from '../../../dist/modules/index.js';
-import * as esmBundle from '../../../dist/bundles/anime.esm.js';
-import * as minifiedEsmBundle from '../../../dist/bundles/anime.esm.min.js';
+import * as esmModules from '../../dist/modules/index.js';
+import * as esmBundle from '../../dist/bundles/anime.esm.js';
+import * as minifiedEsmBundle from '../../dist/bundles/anime.esm.min.js';
const apiExports = [
'animate',
diff --git a/tests/suites/colors.test.js b/tests/suites/colors.test.js
index cc85d6b1..15d8fb6d 100644
--- a/tests/suites/colors.test.js
+++ b/tests/suites/colors.test.js
@@ -5,6 +5,7 @@ import {
import {
animate,
+ createTimeline,
utils,
} from '../../dist/modules/index.js';
@@ -131,6 +132,9 @@ function createColorConversionFromDOMTests() {
});
}
+// Mirrors the engine's gamma-correct sqrt-lerp on sRGB 0-255 channels (see src/core/render.js). Used to derive expected channel values without hard-coded magic numbers. CSS targets don't go through the sRGB->linear setter conversion, so the rounded sqrt-lerp output is what ends up in the rgba string written to style.
+const sqrtLerpChannel = (from255, to255, t) => Math.round(Math.sqrt(from255 * from255 * (1 - t) + to255 * to255 * t));
+
suite('Colors', () => {
test('boxShadow should not be parsed as color value', () => {
const [ targetEl ] = utils.$('#target-id');
@@ -147,4 +151,47 @@ suite('Colors', () => {
createColorTestsByType('rgb', 'rgba');
createColorTestsByType('rgba', 'rgb');
createColorTestsByType('rgba', 'rgba');
+
+ test('Timeline color sibling chain: each add starts from the previous add end-color', () => {
+ const [ targetEl ] = utils.$('#target-id');
+ targetEl.style.backgroundColor = 'rgb(0, 0, 0)';
+ const tl = createTimeline({ autoplay: false, defaults: { duration: 100, ease: 'linear' } })
+ .add(targetEl, { backgroundColor: '#ff0000' })
+ .add(targetEl, { backgroundColor: '#00ff00' })
+ .add(targetEl, { backgroundColor: '#0000ff' });
+ tl.seek(100);
+ expect(targetEl.style.backgroundColor).to.equal('rgb(255, 0, 0)');
+ tl.seek(150);
+ const midRG_R = sqrtLerpChannel(255, 0, 0.5);
+ const midRG_G = sqrtLerpChannel(0, 255, 0.5);
+ expect(targetEl.style.backgroundColor).to.equal(`rgb(${midRG_R}, ${midRG_G}, 0)`);
+ tl.seek(200);
+ expect(targetEl.style.backgroundColor).to.equal('rgb(0, 255, 0)');
+ tl.seek(250);
+ const midGB_G = sqrtLerpChannel(255, 0, 0.5);
+ const midGB_B = sqrtLerpChannel(0, 255, 0.5);
+ expect(targetEl.style.backgroundColor).to.equal(`rgb(0, ${midGB_G}, ${midGB_B})`);
+ tl.seek(300);
+ expect(targetEl.style.backgroundColor).to.equal('rgb(0, 0, 255)');
+ });
+
+ test('Timeline color replace composition: overlapping add overrides previous', () => {
+ const [ targetEl ] = utils.$('#target-id');
+ targetEl.style.backgroundColor = 'rgb(0, 0, 0)';
+ const tl = createTimeline({ autoplay: false, defaults: { duration: 200, ease: 'linear' } })
+ .add(targetEl, { backgroundColor: '#ff0000' })
+ .add(targetEl, { backgroundColor: '#00ff00', duration: 100 }, '-=100');
+ // First add at 25% of its 200ms updateDuration before the override kicks in.
+ tl.seek(50);
+ const earlyR = sqrtLerpChannel(0, 255, 0.25);
+ expect(targetEl.style.backgroundColor).to.equal(`rgb(${earlyR}, 0, 0)`);
+ // Override boundary at t=100 snapshots the first tween's mid-frame value (rounded by the rgba composition path) as the second tween's from-color.
+ tl.seek(150);
+ const overrideFromR = sqrtLerpChannel(0, 255, 0.5);
+ const midR = sqrtLerpChannel(overrideFromR, 0, 0.5);
+ const midG = sqrtLerpChannel(0, 255, 0.5);
+ expect(targetEl.style.backgroundColor).to.equal(`rgb(${midR}, ${midG}, 0)`);
+ tl.seek(tl.duration);
+ expect(targetEl.style.backgroundColor).to.equal('rgb(0, 255, 0)');
+ });
});
diff --git a/tests/suites/controls.test.js b/tests/suites/controls.test.js
index 5a0e67ef..76419846 100644
--- a/tests/suites/controls.test.js
+++ b/tests/suites/controls.test.js
@@ -679,6 +679,28 @@ suite('Controls', () => {
expect($target.style.width).to.equal('400px');
});
+ test('Refresh an animation from value in object form', () => {
+ const $target = /** @type {HTMLElement} */(document.querySelector('#target-id'));
+ $target.setAttribute('data-width', '200px');
+ const animation1 = animate($target, {
+ width: { from: () => $target.dataset.width, to: '400px' },
+ duration: 100,
+ ease: 'linear',
+ autoplay: false
+ });
+ animation1.seek(0);
+ expect($target.style.width).to.equal('200px');
+ animation1.seek(100);
+ expect($target.style.width).to.equal('400px');
+ $target.setAttribute('data-width', '100px');
+ animation1.refresh().restart().seek(0);
+ expect($target.style.width).to.equal('100px');
+ animation1.seek(50);
+ expect($target.style.width).to.equal('250px');
+ animation1.seek(100);
+ expect($target.style.width).to.equal('400px');
+ });
+
test('Refresh an animation from value with unit conversion', () => {
const $target = /** @type {HTMLElement} */(document.querySelector('#target-id'));
$target.setAttribute('data-width', '50vw');
@@ -854,6 +876,129 @@ suite('Controls', () => {
expect(getChildAtIndex(tl, 1).duration).to.equal(150);
});
+ test('Stretch scales keyframe delays proportionally', () => {
+ const $target = /** @type {HTMLElement} */(document.querySelector('#target-id'));
+ const animation1 = animate($target, {
+ width: [
+ { from: 0, to: 100, duration: 100 },
+ { to: 500, delay: 200, duration: 500 },
+ { to: 300, delay: 150, duration: 100 },
+ ],
+ autoplay: false,
+ });
+ expect(animation1.duration).to.equal(1050);
+ const tween0 = getChildAtIndex(animation1, 0);
+ const tween1 = getChildAtIndex(animation1, 1);
+ const tween2 = getChildAtIndex(animation1, 2);
+ expect(tween0._delay).to.equal(0);
+ expect(tween0._updateDuration).to.equal(100);
+ expect(tween0._startTime).to.equal(0);
+ expect(tween1._delay).to.equal(200);
+ expect(tween1._updateDuration).to.equal(500);
+ expect(tween1._startTime).to.equal(300);
+ expect(tween2._delay).to.equal(150);
+ expect(tween2._updateDuration).to.equal(100);
+ expect(tween2._startTime).to.equal(950);
+
+ animation1.stretch(2100);
+ expect(animation1.duration).to.equal(2100);
+ expect(tween0._delay).to.equal(0);
+ expect(tween0._updateDuration).to.equal(200);
+ expect(tween0._startTime).to.equal(0);
+ expect(tween1._delay).to.equal(400);
+ expect(tween1._updateDuration).to.equal(1000);
+ expect(tween1._startTime).to.equal(600);
+ expect(tween2._delay).to.equal(300);
+ expect(tween2._updateDuration).to.equal(200);
+ expect(tween2._startTime).to.equal(1900);
+
+ animation1.stretch(525);
+ expect(animation1.duration).to.equal(525);
+ expect(tween0._delay).to.equal(0);
+ expect(tween0._updateDuration).to.equal(50);
+ expect(tween1._delay).to.equal(100);
+ expect(tween1._updateDuration).to.equal(250);
+ expect(tween1._startTime).to.equal(150);
+ expect(tween2._delay).to.equal(75);
+ expect(tween2._updateDuration).to.equal(50);
+ expect(tween2._startTime).to.equal(475);
+ });
+
+ test('Stretch scales global delay and keyframe delays proportionally', () => {
+ const $target = /** @type {HTMLElement} */(document.querySelector('#target-id'));
+ const animation1 = animate($target, {
+ width: [
+ { from: 0, to: 100, duration: 100 },
+ { to: 200, delay: 200, duration: 300 },
+ ],
+ delay: 50,
+ autoplay: false,
+ });
+ expect(animation1.duration).to.equal(600);
+ expect(animation1._delay).to.equal(50);
+ const tween0 = getChildAtIndex(animation1, 0);
+ const tween1 = getChildAtIndex(animation1, 1);
+ expect(tween0._delay).to.equal(0);
+ expect(tween0._updateDuration).to.equal(100);
+ expect(tween1._delay).to.equal(200);
+ expect(tween1._updateDuration).to.equal(300);
+ expect(tween1._startTime).to.equal(300);
+
+ animation1.stretch(1200);
+ expect(animation1.duration).to.equal(1200);
+ expect(animation1._delay).to.equal(100);
+ expect(tween0._delay).to.equal(0);
+ expect(tween0._updateDuration).to.equal(200);
+ expect(tween1._delay).to.equal(400);
+ expect(tween1._updateDuration).to.equal(600);
+ expect(tween1._startTime).to.equal(600);
+ });
+
+ test('Stretch a timeline scales keyframe delays of animation children', () => {
+ const $target = /** @type {HTMLElement} */(document.querySelector('#target-id'));
+ const tl = createTimeline({ autoplay: false })
+ .add($target, {
+ width: [
+ { from: 0, to: 100, duration: 100 },
+ { to: 200, delay: 200, duration: 300 },
+ ],
+ })
+ .add($target, {
+ height: [
+ { from: 0, to: 100, duration: 100 },
+ { to: 200, delay: 100, duration: 200 },
+ ],
+ });
+ const child0 = getChildAtIndex(tl, 0);
+ const child1 = getChildAtIndex(tl, 1);
+ expect(child0.duration).to.equal(600);
+ expect(child1.duration).to.equal(400);
+ expect(tl.duration).to.equal(1000);
+ const c0t0 = getChildAtIndex(child0, 0);
+ const c0t1 = getChildAtIndex(child0, 1);
+ const c1t0 = getChildAtIndex(child1, 0);
+ const c1t1 = getChildAtIndex(child1, 1);
+ expect(c0t1._delay).to.equal(200);
+ expect(c0t1._updateDuration).to.equal(300);
+ expect(c1t1._delay).to.equal(100);
+ expect(c1t1._updateDuration).to.equal(200);
+
+ tl.stretch(2000);
+ expect(tl.duration).to.equal(2000);
+ expect(child0.duration).to.equal(1200);
+ expect(child1.duration).to.equal(800);
+ expect(c0t0._delay).to.equal(0);
+ expect(c0t0._updateDuration).to.equal(200);
+ expect(c0t1._delay).to.equal(400);
+ expect(c0t1._updateDuration).to.equal(600);
+ expect(c0t1._startTime).to.equal(600);
+ expect(c1t0._delay).to.equal(0);
+ expect(c1t0._updateDuration).to.equal(200);
+ expect(c1t1._delay).to.equal(200);
+ expect(c1t1._updateDuration).to.equal(400);
+ expect(c1t1._startTime).to.equal(400);
+ });
+
test('Seek an animation', resolve => {
const $target = /** @type {HTMLElement} */(document.querySelector('#target-id'));
const animation1 = animate($target, {
diff --git a/tests/suites/keyframes.test.js b/tests/suites/keyframes.test.js
index fe509cf3..dd37716f 100644
--- a/tests/suites/keyframes.test.js
+++ b/tests/suites/keyframes.test.js
@@ -4,7 +4,7 @@ import {
getTweenDelay,
} from '../utils.js';
-import { animate, utils } from '../../dist/modules/index.js';
+import { animate, createTimeline, engine, stagger, utils } from '../../dist/modules/index.js';
import {
valueTypes,
@@ -364,4 +364,233 @@ suite('Keyframes', () => {
expect($target.style.transform).to.equal('translateX(400px)');
});
+ test('Forward seek skipping a short trailing keyframe restores the last keyframe\'s to value', () => {
+ const a = { y: 0 };
+ const b = { y: 0 };
+ const tl = createTimeline({ autoplay: false })
+ .add([a, b], {
+ y: [
+ { to: 1, duration: stagger([100, 50]) },
+ { to: 2, duration: stagger([100, 50]) },
+ { to: 3, duration: 10 },
+ ],
+ ease: 'linear',
+ }, 0);
+
+ // Saturate.
+ tl.seek(250);
+ expect(a.y).to.equal(3);
+ expect(b.y).to.equal(3);
+
+ // Backward into b's second keyframe range (also a's first).
+ tl.seek(75);
+ expect(b.y).to.equal(1.5);
+
+ // Forward jumping over b's tiny last keyframe range [100, 110]. b's last keyframe must still write its to value.
+ tl.seek(115);
+ expect(b.y).to.equal(3);
+ });
+
+ test('Backward seek into the delay gap between two staggered keyframes restores the first keyframe\'s to value', () => {
+ const N = 31;
+ const targets = Array.from({ length: N }, () => ({ y: 1 }));
+ const tl = createTimeline({ autoplay: false }).add(targets, {
+ y: [
+ { to: -1, duration: 300, delay: stagger([0, 196], { from: 'center' }) },
+ { to: 2, duration: 200, delay: stagger(90, { from: 'center' }) },
+ ],
+ ease: 'linear',
+ });
+
+ const inGap = [];
+ let i = 0;
+ let tw = tl._head._head;
+ while (tw) {
+ const kf1End = tw._absoluteStartTime + tw._changeDuration;
+ tw = tw._next;
+ const kf2Start = tw._absoluteStartTime;
+ if (kf1End < 700 && kf2Start > 700) inGap.push(i);
+ tw = tw._next;
+ i++;
+ }
+
+ tl.seek(tl.duration);
+ tl.seek(700);
+ for (const j of inGap) expect(targets[j].y).to.equal(-1);
+
+ tl.seek(0);
+ tl.seek(700);
+ for (const j of inGap) expect(targets[j].y).to.equal(-1);
+ });
+
+ test('Sequential staggered keyframes stay non-overlapping under arbitrary engine offsets', () => {
+ // The global setup.js pin keeps the offset at 0 by default. Sweep several non-zero offsets to make sure the precision-matched _absoluteUpdateStartTime holds for the values a long-running browser session can hit.
+ const N = 31;
+ for (const offset of [173.27, 1000, 5234.5, 17300, 50000]) {
+ engine._startTime = engine._lastTickTime - offset;
+ const targets = Array.from({ length: N }, () => ({ y: 1 }));
+ const tl = createTimeline({ autoplay: false }).add(targets, {
+ y: [
+ { to: -1, duration: 300, delay: stagger([0, 196], { from: 'center' }) },
+ { to: 2, duration: 200, delay: stagger(90, { from: 'center' }) },
+ ],
+ });
+ let tw = tl._head._head;
+ while (tw) {
+ expect(tw._isOverlapped, `kf1 overlap at offset=${offset}`).to.equal(0);
+ tw = tw._next;
+ tw = tw._next;
+ }
+ }
+ });
+
+ test('Backward seek past the start of a keyframe sequence restores the first keyframe\'s from value', () => {
+ const target = { y: 0 };
+ const tl = createTimeline({ autoplay: false })
+ .add(target, {
+ y: [
+ { to: 1, duration: 10 },
+ { to: 0.5, duration: 200 },
+ ],
+ ease: 'linear',
+ }, 100);
+
+ // Forward past the entire sequence so both tween _currentTimes land at their ends.
+ tl.seek(400);
+ expect(target.y).to.equal(0.5);
+
+ // Jump backward into the second keyframe's range (mid kf 1).
+ tl.seek(150);
+ expect(target.y).to.equal(0.9);
+
+ // Jump backward across the first keyframe's tiny range to before its start.
+ tl.seek(50);
+ expect(target.y).to.equal(0);
+ });
+
+ test('Backward seek updates a single from-to keyframe inside a timeline with delay', () => {
+ const target = { y: 0 };
+ const tl = createTimeline({ autoplay: false })
+ .label('START')
+ .add(target, {
+ y: [-8, 0],
+ duration: 100,
+ delay: 1763,
+ ease: 'linear',
+ });
+ tl.seek(tl.duration);
+ expect(target.y).to.equal(0);
+ tl.seek(tl.duration - 50);
+ expect(target.y).to.equal(-4);
+ tl.seek(tl.duration - 100);
+ expect(target.y).to.equal(-8);
+ });
+
+ test('Backward seek across loop iterations updates a delayed keyframe', () => {
+ const target = { y: 0 };
+ const tl = createTimeline({ autoplay: false }).add(target, {
+ y: [-8, 0],
+ duration: 100,
+ delay: 100,
+ loop: 2,
+ ease: 'linear',
+ });
+ expect(tl.duration).to.equal(400);
+ tl.seek(400);
+ expect(target.y).to.equal(0);
+ tl.seek(350); expect(target.y).to.equal(-4);
+ tl.seek(300); expect(target.y).to.equal(-8);
+ tl.seek(250); expect(target.y).to.equal(-4);
+ tl.seek(200); expect(target.y).to.equal(-8);
+ tl.seek(150); expect(target.y).to.equal(-4);
+ tl.seek(100); expect(target.y).to.equal(-8);
+ });
+
+ test('Backward seek across alternate loop iterations updates a delayed keyframe', () => {
+ const target = { y: 0 };
+ const tl = createTimeline({ autoplay: false }).add(target, {
+ y: [-8, 0],
+ duration: 100,
+ delay: 100,
+ loop: 1,
+ alternate: true,
+ ease: 'linear',
+ });
+ expect(tl.duration).to.equal(300);
+ tl.seek(300);
+ expect(target.y).to.equal(-8);
+ tl.seek(250); expect(target.y).to.equal(-4);
+ tl.seek(200); expect(target.y).to.equal(0);
+ tl.seek(150); expect(target.y).to.equal(-4);
+ tl.seek(100); expect(target.y).to.equal(-8);
+ });
+
+ test('Backward seek updates a multi-keyframe property with delay', () => {
+ const target = { y: 0 };
+ const tl = createTimeline({ autoplay: false }).add(target, {
+ y: [{ to: 50, duration: 50 }, { to: 0, duration: 50 }],
+ delay: 100,
+ ease: 'linear',
+ });
+ expect(tl.duration).to.equal(200);
+ tl.seek(200);
+ expect(target.y).to.equal(0);
+ tl.seek(175); expect(target.y).to.equal(25);
+ tl.seek(150); expect(target.y).to.equal(50);
+ tl.seek(125); expect(target.y).to.equal(25);
+ tl.seek(100); expect(target.y).to.equal(0);
+ });
+
+ test('Seeking past the end and back into a delayed keyframe restores the active value', () => {
+ const target = { y: 0 };
+ const tl = createTimeline({ autoplay: false }).add(target, {
+ y: [-8, 0],
+ duration: 100,
+ delay: 100,
+ ease: 'linear',
+ });
+ expect(tl.duration).to.equal(200);
+ tl.seek(500);
+ expect(target.y).to.equal(0);
+ tl.seek(150);
+ expect(target.y).to.equal(-4);
+ tl.seek(100);
+ expect(target.y).to.equal(-8);
+ });
+
+ test('Backward seek updates a single object-form keyframe in a timeline', () => {
+ const target = { x: 0 };
+ const tl = createTimeline({ autoplay: false })
+ .add(target, { x: { to: 100 }, duration: 100, ease: 'linear' }, 100);
+ tl.seek(200);
+ expect(target.x).to.equal(100);
+ tl.seek(150);
+ expect(target.x).to.equal(50);
+ tl.seek(50);
+ expect(target.x).to.equal(0);
+ });
+
+ test('Backward seek updates a single object-form keyframe alongside a multi-keyframe property', () => {
+ const target = { x: 0, y: 0 };
+ const animation = animate(target, {
+ x: { to: 100 },
+ y: [
+ { to: 50, duration: 50 },
+ { to: 100, duration: 50 },
+ ],
+ duration: 100,
+ ease: 'linear',
+ autoplay: false,
+ });
+ animation.seek(100);
+ expect(target.x).to.equal(100);
+ expect(target.y).to.equal(100);
+ animation.seek(50);
+ expect(target.x).to.equal(50);
+ expect(target.y).to.equal(50);
+ animation.seek(0);
+ expect(target.x).to.equal(0);
+ expect(target.y).to.equal(0);
+ });
+
});
diff --git a/tests/suites/scroll.test.js b/tests/suites/scroll.test.js
index 8a228cb1..410227fd 100644
--- a/tests/suites/scroll.test.js
+++ b/tests/suites/scroll.test.js
@@ -149,6 +149,15 @@ suite('Scroll', () => {
});
});
+ test('ScrollObserver resizeTicker completing before target is resolved should not throw', () => {
+ const observer = onScroll({
+ target: '#target-id',
+ });
+ expect(observer.target).to.equal(null);
+ expect(() => observer.container.resizeTicker.complete()).to.not.throw();
+ observer.revert();
+ });
+
test('ScrollObserver onResize callback is triggered on container refresh', resolve => {
let resizeCount = 0;
const observer = onScroll({
diff --git a/tests/suites/stagger.test.js b/tests/suites/stagger.test.js
index 4ae51f88..a22fb6ef 100644
--- a/tests/suites/stagger.test.js
+++ b/tests/suites/stagger.test.js
@@ -7,7 +7,7 @@ import {
import { animate, stagger, createTimeline } from '../../dist/modules/index.js';
suite('Stagger', () => {
- test('Increase each values by a specific value for each elements', () => {
+ test('Staggers delays by a fixed step per target', () => {
const animation = animate('.target-class', {
translateX: 100,
duration: 10,
@@ -20,7 +20,7 @@ suite('Stagger', () => {
expect(getTweenDelay(getChildAtIndex(animation, 3))).to.equal(30);
});
- test('Increase each values by a specific value with unit for each elements', () => {
+ test('Staggers values with a unit string', () => {
/** @type {NodeListOf<HTMLElement>} */
const staggerEls = document.querySelectorAll('#stagger div');
const animation = animate(staggerEls, {
@@ -38,20 +38,23 @@ suite('Stagger', () => {
expect(staggerEls[4].style.transform).to.equal('translateX(4rem)');
});
- test('Starts the staggering effect from a specific value', () => {
+ test('Offsets stagger delays by the start option', () => {
const animation = animate('.target-class', {
translateX: 100,
duration: 10,
delay: stagger(10, { start: 5 }),
autoplay: false,
});
+ // start option shifts the smallest absolute start time by 5, surfaced on the animation _delay
+ expect(animation._delay).to.equal(5);
+ // Per-tween delays normalize back to 0, preserving the spacing of 10
expect(getTweenDelay(getChildAtIndex(animation, 0))).to.equal(0);
expect(getTweenDelay(getChildAtIndex(animation, 1))).to.equal(10);
expect(getTweenDelay(getChildAtIndex(animation, 2))).to.equal(20);
expect(getTweenDelay(getChildAtIndex(animation, 3))).to.equal(30);
});
- test('Distributes evenly values between two numbers', () => {
+ test('Distributes values evenly across a numeric range', () => {
/** @type {NodeListOf<HTMLElement>} */
const staggerEls = document.querySelectorAll('#stagger div');
const animation = animate(staggerEls, {
@@ -75,7 +78,7 @@ suite('Stagger', () => {
expect(staggerEls[4].style.transform).to.equal('translateX(10px)');
});
- test('Specific staggered ranged value unit', () => {
+ test('Distributes values across a unit range', () => {
/** @type {NodeListOf<HTMLElement>} */
const staggerEls = document.querySelectorAll('#stagger div');
const animation = animate(staggerEls, {
@@ -93,7 +96,7 @@ suite('Stagger', () => {
expect(staggerEls[4].style.transform).to.equal('translateX(10rem)');
});
- test('Starts the stagger effect from the center', () => {
+ test('Staggers from the center', () => {
const animation = animate('#stagger div', {
translateX: 10,
delay: stagger(10, {from: 'center'}),
@@ -106,7 +109,7 @@ suite('Stagger', () => {
expect(getTweenDelay(getChildAtIndex(animation, 4))).to.equal(20);
});
- test('Starts the stagger effect from the last element', () => {
+ test('Staggers from the last element', () => {
const animation = animate('#stagger div', {
translateX: 10,
delay: stagger(10, {from: 'last'}),
@@ -119,7 +122,7 @@ suite('Stagger', () => {
expect(getTweenDelay(getChildAtIndex(animation, 4))).to.equal(0);
});
- test('Starts the stagger effect from specific index', () => {
+ test('Staggers from a specific index', () => {
const animation = animate('#stagger div', {
translateX: 10,
delay: stagger(10, {from: 1}),
@@ -132,7 +135,7 @@ suite('Stagger', () => {
expect(getTweenDelay(getChildAtIndex(animation, 4))).to.equal(30);
});
- test('Changes the order in which the stagger operates', () => {
+ test('Reverses the stagger order', () => {
const animation = animate('#stagger div', {
translateX: 10,
delay: stagger(10, {from: 1, reversed: true}),
@@ -145,7 +148,7 @@ suite('Stagger', () => {
expect(getTweenDelay(getChildAtIndex(animation, 4))).to.equal(0);
});
- test('Stagger values using an ease function', () => {
+ test('Applies an ease function to stagger values', () => {
const animation = animate('#stagger div', {
translateX: 10,
delay: stagger(10, {ease: 'inOutQuad'}),
@@ -158,7 +161,63 @@ suite('Stagger', () => {
expect(getTweenDelay(getChildAtIndex(animation, 4))).to.equal(40);
});
- test('Stagger values on 0 duration animations', () => {
+ test('Reverses eased stagger values', () => {
+ const animation = animate('#stagger div', {
+ translateX: 10,
+ delay: stagger(10, { ease: 'inOutQuad', reversed: true }),
+ autoplay: false,
+ });
+ expect(getTweenDelay(getChildAtIndex(animation, 0))).to.equal(40);
+ expect(getTweenDelay(getChildAtIndex(animation, 1))).to.equal(35);
+ expect(getTweenDelay(getChildAtIndex(animation, 2))).to.equal(20);
+ expect(getTweenDelay(getChildAtIndex(animation, 3))).to.equal(5);
+ expect(getTweenDelay(getChildAtIndex(animation, 4))).to.equal(0);
+ });
+
+ test('Reproduces jitter delays for a given seed', () => {
+ const a = animate('#stagger div', {
+ translateX: 10,
+ delay: stagger(10, { jitter: 2, seed: 42 }),
+ autoplay: false,
+ });
+ const b = animate('#stagger div', {
+ translateX: 10,
+ delay: stagger(10, { jitter: 2, seed: 42 }),
+ autoplay: false,
+ });
+ for (let i = 0; i < 5; i++) {
+ expect(getTweenDelay(getChildAtIndex(a, i)))
+ .to.equal(getTweenDelay(getChildAtIndex(b, i)));
+ }
+ });
+
+ test('Ramps jitter magnitude across order', () => {
+ const animation = animate('#stagger div', {
+ translateX: 10,
+ delay: stagger(10, { jitter: [0, 4], seed: 0 }),
+ autoplay: false,
+ });
+ // First element progress is 0 so jitter contribution is 0
+ expect(getTweenDelay(getChildAtIndex(animation, 0))).to.equal(0);
+ // Last element progress is 1 so magnitude reaches jitterEnd
+ expect(getTweenDelay(getChildAtIndex(animation, 4))).to.be.closeTo(40, 4);
+ });
+
+ test('Handles use returning out-of-range index', () => {
+ const animation = animate('#stagger div', {
+ translateX: 10,
+ delay: stagger(10, { use: (_t, i) => i + 100 }),
+ autoplay: false,
+ });
+ // Each target advertises a distinct (but out-of-range) custom index, so the
+ // stagger should still produce distinct delays, not collapse every tween to 0
+ const delays = [];
+ for (let i = 0; i < 5; i++) delays.push(getTweenDelay(getChildAtIndex(animation, i)));
+ const unique = new Set(delays);
+ expect(unique.size).to.equal(5);
+ });
+
+ test('Applies stagger to zero-duration animations', () => {
/** @type {NodeListOf<HTMLElement>} */
const staggerEls = document.querySelectorAll('#grid div');
const animation = animate(staggerEls, {
@@ -185,7 +244,7 @@ suite('Stagger', () => {
expect(staggerEls[14].style.opacity).to.equal('0');
});
- test('Grid staggering with a 2D array', () => {
+ test('Staggers across a 2D grid', () => {
const animation = animate('#grid div', {
scale: [1, 0],
delay: stagger(10, {grid: [5, 3], from: 'center'}),
@@ -211,7 +270,7 @@ suite('Stagger', () => {
expect(getTweenDelay(getChildAtIndex(animation, 14))).to.be.closeTo(22.4, .0001);
});
- test('Grid staggering with a 2D array and axis parameters', () => {
+ test('Staggers across a 2D grid along an axis', () => {
const animation = animate('#grid div', {
translateX: stagger(10, {grid: [5, 3], from: 'center', axis: 'x'}),
translateY: stagger(10, {grid: [5, 3], from: 'center', axis: 'y'}),
@@ -255,63 +314,41 @@ suite('Stagger', () => {
expect(getChildAtIndex(animation, 29)._toNumber).to.equal(10);
});
- test('Staggered timeline time positions', () => {
- const tl = createTimeline({ defaults: { duration: 10 }, autoplay: false })
- .add('.target-class', { id: 'staggered', translateX: 50 }, stagger(100))
-
- expect(getChildAtIndex(tl, 0)._offset).to.equal(0);
- expect(getChildAtIndex(tl, 1)._offset).to.equal(100);
- expect(getChildAtIndex(tl, 2)._offset).to.equal(200);
- expect(getChildAtIndex(tl, 3)._offset).to.equal(300);
- expect(getChildAtIndex(tl, 0).id).to.equal('staggered-0');
- expect(getChildAtIndex(tl, 1).id).to.equal('staggered-1');
- expect(getChildAtIndex(tl, 2).id).to.equal('staggered-2');
- expect(getChildAtIndex(tl, 3).id).to.equal('staggered-3');
- expect(tl.duration).to.equal(310); // 300 + 10
- });
-
- test('Staggered timeline time positions with custom start value', () => {
- const tl = createTimeline({ defaults: { duration: 10 }, autoplay: false })
- .add('.target-class', { id: 'staggered', translateX: 50 }, stagger(100, { start: 100 }))
-
- expect(getChildAtIndex(tl, 0)._offset).to.equal(100);
- expect(getChildAtIndex(tl, 1)._offset).to.equal(200);
- expect(getChildAtIndex(tl, 2)._offset).to.equal(300);
- expect(getChildAtIndex(tl, 3)._offset).to.equal(400);
- expect(getChildAtIndex(tl, 0).id).to.equal('staggered-0');
- expect(getChildAtIndex(tl, 1).id).to.equal('staggered-1');
- expect(getChildAtIndex(tl, 2).id).to.equal('staggered-2');
- expect(getChildAtIndex(tl, 3).id).to.equal('staggered-3');
- expect(tl.duration).to.equal(410); // 400 + 10
- });
-
- test('Staggered timeline time positions with a label as start value', () => {
- const tl = createTimeline({ defaults: { duration: 10 }, autoplay: false })
- .label('LABEL', 100)
- .add('.target-class', { id: 'staggered', translateX: 50 }, stagger(100, { start: 'LABEL' }))
-
- expect(getChildAtIndex(tl, 0)._offset).to.equal(100);
- expect(getChildAtIndex(tl, 1)._offset).to.equal(200);
- expect(getChildAtIndex(tl, 2)._offset).to.equal(300);
- expect(getChildAtIndex(tl, 3)._offset).to.equal(400);
- expect(getChildAtIndex(tl, 0).id).to.equal('staggered-0');
- expect(getChildAtIndex(tl, 1).id).to.equal('staggered-1');
- expect(getChildAtIndex(tl, 2).id).to.equal('staggered-2');
- expect(getChildAtIndex(tl, 3).id).to.equal('staggered-3');
- expect(tl.duration).to.equal(410); // 400 + 10
+ test('Mirrors stagger order when reversed along an axis', () => {
+ const forward = animate('#stagger div', {
+ translateX: 10,
+ delay: stagger(10, { grid: [5, 1], axis: 'x' }),
+ autoplay: false,
+ });
+ const reverse = animate('#stagger div', {
+ translateX: 10,
+ delay: stagger(10, { grid: [5, 1], axis: 'x', reversed: true }),
+ autoplay: false,
+ });
+ for (let i = 0; i < 5; i++) {
+ expect(getTweenDelay(getChildAtIndex(forward, i)))
+ .to.equal(getTweenDelay(getChildAtIndex(reverse, 4 - i)));
+ }
});
- test('Staggered timeline values', () => {
- const tl = createTimeline({ defaults: { duration: 10 }, autoplay: false })
- .add('.target-class', { id: 'staggered', translateX: stagger(100, { from: 'last'}) }, stagger(100))
-
- expect(getChildAtIndex(tl, 0)._head._toNumber).to.equal(300);
- expect(getChildAtIndex(tl, 1)._head._toNumber).to.equal(200);
- expect(getChildAtIndex(tl, 2)._head._toNumber).to.equal(100);
- expect(getChildAtIndex(tl, 3)._head._toNumber).to.equal(0);
+ test('Mirrors stagger order when reversed along an axis from last', () => {
+ const forward = animate('#stagger div', {
+ translateX: 10,
+ delay: stagger(10, { grid: [5, 1], axis: 'x', from: 'last' }),
+ autoplay: false,
+ });
+ const reverse = animate('#stagger div', {
+ translateX: 10,
+ delay: stagger(10, { grid: [5, 1], axis: 'x', from: 'last', reversed: true }),
+ autoplay: false,
+ });
+ for (let i = 0; i < 5; i++) {
+ expect(getTweenDelay(getChildAtIndex(forward, i)))
+ .to.equal(getTweenDelay(getChildAtIndex(reverse, 4 - i)));
+ }
});
- test('Grid staggering with from as [x, y] array', () => {
+ test('Staggers from an [x, y] origin in a grid', () => {
const animation = animate('#grid div', {
scale: [1, 0],
delay: stagger(10, {grid: [5, 3], from: [0.5, 0.5]}),
@@ -337,7 +374,7 @@ suite('Stagger', () => {
expect(getTweenDelay(getChildAtIndex(animation, 14))).to.be.closeTo(22.4, .0001);
});
- test('Auto grid staggering with DOM elements', () => {
+ test('Computes auto grid from DOM element positions', () => {
const animation = animate('#grid div', {
scale: [1, 0],
delay: stagger(10, {grid: true, from: 'center'}),
@@ -366,7 +403,7 @@ suite('Stagger', () => {
expect(cornerDelay).to.be.greaterThan(getTweenDelay(getChildAtIndex(animation, 2)));
});
- test('Auto grid staggering with JS objects from center', () => {
+ test('Computes auto grid from JS object coordinates', () => {
const targets = [];
for (let row = 0; row < 3; row++) {
for (let col = 0; col < 5; col++) {
@@ -398,7 +435,7 @@ suite('Stagger', () => {
expect(getTweenDelay(getChildAtIndex(animation, 14))).to.be.closeTo(22.4, .0001);
});
- test('Auto grid staggering with from as [x, y] array', () => {
+ test('Computes auto grid from an [x, y] origin', () => {
const targets = [];
for (let row = 0; row < 3; row++) {
for (let col = 0; col < 5; col++) {
@@ -417,7 +454,7 @@ suite('Stagger', () => {
expect(getTweenDelay(getChildAtIndex(animation, 10))).to.equal(40);
});
- test('Auto grid staggering with axis parameter', () => {
+ test('Computes auto grid along a single axis', () => {
const targets = [];
for (let row = 0; row < 3; row++) {
for (let col = 0; col < 5; col++) {
@@ -438,7 +475,7 @@ suite('Stagger', () => {
expect(getChildAtIndex(animation, 10)._toNumber).to.equal(-20);
});
- test('Auto grid staggering fallback to 1D without spatial data', () => {
+ test('Falls back to 1D auto grid without spatial data', () => {
const targets = [{ val: 1 }, { val: 1 }, { val: 1 }, { val: 1 }];
const animation = animate(targets, {
val: 0,
@@ -450,4 +487,132 @@ suite('Stagger', () => {
expect(getTweenDelay(getChildAtIndex(animation, 2))).to.equal(20);
expect(getTweenDelay(getChildAtIndex(animation, 3))).to.equal(30);
});
+
+ test('Switches auto grid to 3D when targets expose z', () => {
+ const targets = [];
+ for (let z = 0; z < 2; z++) {
+ for (let y = 0; y < 2; y++) {
+ for (let x = 0; x < 2; x++) {
+ targets.push({ x, y, z, val: 1 });
+ }
+ }
+ }
+ const animation = animate(targets, {
+ val: 0,
+ delay: stagger(10, { grid: true, from: 'center' }),
+ autoplay: false,
+ });
+ // All 8 corner cells of a 2x2x2 cube are equidistant from the center
+ const cornerDelay = getTweenDelay(getChildAtIndex(animation, 0));
+ for (let i = 1; i < 8; i++) {
+ expect(getTweenDelay(getChildAtIndex(animation, i))).to.be.closeTo(cornerDelay, 0.01);
+ }
+ });
+
+ test('Computes auto grid along the z axis', () => {
+ const targets = [];
+ for (let z = 0; z < 3; z++) {
+ for (let y = 0; y < 2; y++) {
+ for (let x = 0; x < 2; x++) {
+ targets.push({ x, y, z, val: 0 });
+ }
+ }
+ }
+ const animation = animate(targets, {
+ val: stagger(10, { grid: true, from: 'center', axis: 'z' }),
+ autoplay: false,
+ });
+ // Cells with z=0: -10, z=1: 0, z=2: 10
+ expect(getChildAtIndex(animation, 0)._toNumber).to.equal(-10);
+ expect(getChildAtIndex(animation, 3)._toNumber).to.equal(-10);
+ expect(getChildAtIndex(animation, 4)._toNumber).to.equal(0);
+ expect(getChildAtIndex(animation, 7)._toNumber).to.equal(0);
+ expect(getChildAtIndex(animation, 8)._toNumber).to.equal(10);
+ expect(getChildAtIndex(animation, 11)._toNumber).to.equal(10);
+ });
+
+ test('Staggers across a 3D grid', () => {
+ const targets = [];
+ for (let i = 0; i < 8; i++) targets.push({ val: 1 });
+ const animation = animate(targets, {
+ val: 0,
+ delay: stagger(10, { grid: [2, 2, 2], from: 'center' }),
+ autoplay: false,
+ });
+ // 2x2x2 grid, center is the midpoint between all 8 cells, so they share the same delay
+ const d = getTweenDelay(getChildAtIndex(animation, 0));
+ for (let i = 1; i < 8; i++) {
+ expect(getTweenDelay(getChildAtIndex(animation, i))).to.be.closeTo(d, 0.01);
+ }
+ });
+
+ test('Staggers from an [x, y, z] origin in a 3D grid', () => {
+ const targets = [];
+ for (let i = 0; i < 8; i++) targets.push({ val: 1 });
+ const animation = animate(targets, {
+ val: 0,
+ delay: stagger(10, { grid: [2, 2, 2], from: [0, 0, 0] }),
+ autoplay: false,
+ });
+ // Index 0 is at the origin corner, distance 0
+ expect(getTweenDelay(getChildAtIndex(animation, 0))).to.equal(0);
+ // Index 7 is at the opposite corner (1, 1, 1), farthest
+ expect(getTweenDelay(getChildAtIndex(animation, 7))).to.be.closeTo(17.32, 0.05);
+ });
+
+ test('Staggers timeline positions', () => {
+ const tl = createTimeline({ defaults: { duration: 10 }, autoplay: false })
+ .add('.target-class', { id: 'staggered', translateX: 50 }, stagger(100))
+
+ expect(getChildAtIndex(tl, 0)._offset).to.equal(0);
+ expect(getChildAtIndex(tl, 1)._offset).to.equal(100);
+ expect(getChildAtIndex(tl, 2)._offset).to.equal(200);
+ expect(getChildAtIndex(tl, 3)._offset).to.equal(300);
+ expect(getChildAtIndex(tl, 0).id).to.equal('staggered-0');
+ expect(getChildAtIndex(tl, 1).id).to.equal('staggered-1');
+ expect(getChildAtIndex(tl, 2).id).to.equal('staggered-2');
+ expect(getChildAtIndex(tl, 3).id).to.equal('staggered-3');
+ expect(tl.duration).to.equal(310); // 300 + 10
+ });
+
+ test('Staggers timeline positions with a numeric start', () => {
+ const tl = createTimeline({ defaults: { duration: 10 }, autoplay: false })
+ .add('.target-class', { id: 'staggered', translateX: 50 }, stagger(100, { start: 100 }))
+
+ expect(getChildAtIndex(tl, 0)._offset).to.equal(100);
+ expect(getChildAtIndex(tl, 1)._offset).to.equal(200);
+ expect(getChildAtIndex(tl, 2)._offset).to.equal(300);
+ expect(getChildAtIndex(tl, 3)._offset).to.equal(400);
+ expect(getChildAtIndex(tl, 0).id).to.equal('staggered-0');
+ expect(getChildAtIndex(tl, 1).id).to.equal('staggered-1');
+ expect(getChildAtIndex(tl, 2).id).to.equal('staggered-2');
+ expect(getChildAtIndex(tl, 3).id).to.equal('staggered-3');
+ expect(tl.duration).to.equal(410); // 400 + 10
+ });
+
+ test('Staggers timeline positions starting at a label', () => {
+ const tl = createTimeline({ defaults: { duration: 10 }, autoplay: false })
+ .label('LABEL', 100)
+ .add('.target-class', { id: 'staggered', translateX: 50 }, stagger(100, { start: 'LABEL' }))
+
+ expect(getChildAtIndex(tl, 0)._offset).to.equal(100);
+ expect(getChildAtIndex(tl, 1)._offset).to.equal(200);
+ expect(getChildAtIndex(tl, 2)._offset).to.equal(300);
+ expect(getChildAtIndex(tl, 3)._offset).to.equal(400);
+ expect(getChildAtIndex(tl, 0).id).to.equal('staggered-0');
+ expect(getChildAtIndex(tl, 1).id).to.equal('staggered-1');
+ expect(getChildAtIndex(tl, 2).id).to.equal('staggered-2');
+ expect(getChildAtIndex(tl, 3).id).to.equal('staggered-3');
+ expect(tl.duration).to.equal(410); // 400 + 10
+ });
+
+ test('Staggers a tween value in a timeline', () => {
+ const tl = createTimeline({ defaults: { duration: 10 }, autoplay: false })
+ .add('.target-class', { id: 'staggered', translateX: stagger(100, { from: 'last'}) }, stagger(100))
+
+ expect(getChildAtIndex(tl, 0)._head._toNumber).to.equal(300);
+ expect(getChildAtIndex(tl, 1)._head._toNumber).to.equal(200);
+ expect(getChildAtIndex(tl, 2)._head._toNumber).to.equal(100);
+ expect(getChildAtIndex(tl, 3)._head._toNumber).to.equal(0);
+ });
});
diff --git a/tests/suites/threejs.test.js b/tests/suites/threejs.test.js
new file mode 100644
index 00000000..6157b9b3
--- /dev/null
+++ b/tests/suites/threejs.test.js
@@ -0,0 +1,1128 @@
+import {
+ Object3D,
+ Mesh,
+ Texture,
+ InstancedMesh,
+ BatchedMesh,
+ BoxGeometry,
+ MeshBasicMaterial,
+ MeshStandardMaterial,
+ AmbientLight,
+ PointLight,
+ SpotLight,
+ DirectionalLight,
+ HemisphereLight,
+ PerspectiveCamera,
+ OrthographicCamera,
+ Vector2,
+ Vector3,
+ Vector4,
+ Quaternion,
+ Matrix4,
+ Color,
+ ShaderMaterial,
+} from 'three';
+
+import { uniform } from 'three/tsl';
+import { MeshStandardNodeMaterial } from 'three/webgpu';
+
+import {
+ expect,
+} from '../utils.js';
+
+import {
+ animate,
+ createTimeline,
+ utils,
+} from '../../dist/modules/index.js';
+
+import {
+ getInstances,
+ commitChanges,
+} from '../../dist/modules/adapters/three/index.js';
+
+import { registerAdapter } from '../../dist/modules/adapters/index.js';
+import { resolveAdapterEntry } from '../../dist/modules/adapters/registry.js';
+
+const testAdapter = registerAdapter();
+
+const TAU = Math.PI * 2;
+
+// Mirrors the engine's color pipeline: render's sqrt-lerp on sRGB 0-255 channels, then the three.js adapter's setRGB(SRGBColorSpace) converting to linear-sRGB working space. Use this in assertions instead of hard-coded magic numbers.
+const sRGBToLinear = (c) => c < 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
+const expectedChannel = (from255, to255, t) => sRGBToLinear(Math.sqrt(from255 * from255 * (1 - t) + to255 * to255 * t) / 255);
+
+const createMesh = (color = '#ff0000') => {
+ return new Mesh(
+ new BoxGeometry(1, 1, 1),
+ new MeshBasicMaterial({ transparent: true, color }),
+ );
+};
+
+const createInstanced = (count) => {
+ return new InstancedMesh(
+ new BoxGeometry(1, 1, 1),
+ new MeshBasicMaterial({ transparent: true }),
+ count,
+ );
+};
+
+class Widget {
+ constructor() { this.foo = 0; this.bar = 0; this.locked = false; }
+}
+
+const widgetAdapter = testAdapter.registerTargetAdapter((t) => t instanceof Widget);
+let lastWidgetTween = null;
+let barSetterRan = false;
+widgetAdapter.registerProperty('foo',
+ (t) => t.foo,
+ (target, value, tween) => { lastWidgetTween = tween; target.foo = value; },
+);
+widgetAdapter.registerProperty('bar',
+ (t) => t.bar,
+ (target, value) => { barSetterRan = true; target.bar = value; },
+ (t) => !t.locked,
+);
+
+suite('Three.js adapter', () => {
+
+ // Adapter machinery
+
+ test('First target adapter to detect wins, later adapters cannot claim unmapped names', () => {
+ let secondCalled = false;
+ const overrideX = testAdapter.registerTargetAdapter((t) => t instanceof Object3D);
+ overrideX.registerProperty('x', () => 0, () => { secondCalled = true; });
+ const mesh = createMesh();
+ animate(mesh, { x: 10, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mesh.position.x).to.equal(10);
+ expect(secondCalled).to.equal(false);
+ const foobarAdapter = testAdapter.registerTargetAdapter((t) => t instanceof Object3D);
+ foobarAdapter.registerProperty('foobar', () => 0, () => {});
+ expect(resolveAdapterEntry(new Object3D(), 'foobar')).to.equal(null);
+ });
+
+ test('Gates conditional props per target type', () => {
+ expect(resolveAdapterEntry(new AmbientLight(), 'opacity')).to.equal(null);
+ const hemi = new HemisphereLight();
+ expect(resolveAdapterEntry(hemi, 'groundColor')).to.not.equal(null);
+ expect(resolveAdapterEntry(new PointLight(), 'groundColor')).to.equal(null);
+ const ortho = new OrthographicCamera(-1, 1, 1, -1);
+ const persp = new PerspectiveCamera();
+ expect(resolveAdapterEntry(ortho, 'left')).to.not.equal(null);
+ expect(resolveAdapterEntry(ortho, 'right')).to.not.equal(null);
+ expect(resolveAdapterEntry(ortho, 'top')).to.not.equal(null);
+ expect(resolveAdapterEntry(ortho, 'bottom')).to.not.equal(null);
+ expect(resolveAdapterEntry(persp, 'left')).to.equal(null);
+ expect(resolveAdapterEntry(persp, 'right')).to.equal(null);
+ expect(resolveAdapterEntry(persp, 'top')).to.equal(null);
+ expect(resolveAdapterEntry(persp, 'bottom')).to.equal(null);
+ const audioLike = new Object3D();
+ audioLike.setVolume = () => {};
+ audioLike.getVolume = () => 0;
+ expect(resolveAdapterEntry(audioLike, 'volume')).to.not.equal(null);
+ expect(resolveAdapterEntry(new Object3D(), 'volume')).to.equal(null);
+ const positionalLike = new Object3D();
+ positionalLike.setRefDistance = () => {};
+ positionalLike.setRolloffFactor = () => {};
+ positionalLike.setMaxDistance = () => {};
+ expect(resolveAdapterEntry(positionalLike, 'refDistance')).to.not.equal(null);
+ expect(resolveAdapterEntry(positionalLike, 'rolloffFactor')).to.not.equal(null);
+ expect(resolveAdapterEntry(positionalLike, 'maxDistance')).to.not.equal(null);
+ expect(resolveAdapterEntry(new Object3D(), 'refDistance')).to.equal(null);
+ });
+
+ test('Passes tween with target, property, _number to custom adapter setter', () => {
+ const w = new Widget();
+ animate(w, { foo: 42, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(w.foo).to.equal(42);
+ expect(lastWidgetTween.target).to.equal(w);
+ expect(lastWidgetTween.property).to.equal('foo');
+ expect(lastWidgetTween._number).to.equal(42);
+ });
+
+ test('Falls through to direct write when custom adapter appliesTo rejects target', () => {
+ const unlocked = new Widget();
+ const locked = new Widget();
+ locked.locked = true;
+ expect(resolveAdapterEntry(unlocked, 'bar')).to.not.equal(null);
+ expect(resolveAdapterEntry(locked, 'bar')).to.equal(null);
+ barSetterRan = false;
+ animate(locked, { bar: 5, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(locked.bar).to.equal(5);
+ expect(barSetterRan).to.equal(false);
+ });
+
+ test('Property resolver claims runtime-matched names', () => {
+ let calls = 0;
+ testAdapter.registerPropertyResolver((t, name) => {
+ calls++;
+ if (t && t.kind === 'probe' && name === 'dynamic') {
+ return {
+ get: (x) => x.value,
+ set: (target, value) => { target.value = value; },
+ };
+ }
+ return null;
+ });
+ const target = { kind: 'probe', value: 0 };
+ animate(target, { dynamic: 42, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(target.value).to.equal(42);
+ expect(calls).to.be.greaterThan(0);
+ });
+
+ // Object3D adapter
+
+ // Transform
+
+ test('Animates position x, y, z', () => {
+ const mesh = createMesh();
+ mesh.position.x = 25;
+ const animation = animate(mesh, { x: 75, y: 50, z: -25, duration: 100, ease: 'linear', autoplay: false });
+ animation.seek(0);
+ expect(mesh.position.x).to.equal(25);
+ expect(mesh.position.y).to.equal(0);
+ expect(mesh.position.z).to.equal(0);
+ animation.seek(50);
+ expect(mesh.position.x).to.equal(50);
+ expect(mesh.position.y).to.equal(25);
+ expect(mesh.position.z).to.equal(-12.5);
+ animation.seek(100);
+ expect(mesh.position.x).to.equal(75);
+ expect(mesh.position.y).to.equal(50);
+ expect(mesh.position.z).to.equal(-25);
+ });
+
+ test('Animates rotation in degrees, supports multiple revolutions', () => {
+ const mesh = createMesh();
+ mesh.rotation.x = Math.PI;
+ mesh.rotation.y = Math.PI / 2;
+ mesh.rotation.z = -Math.PI / 4;
+ animate(mesh, { rotateX: 360, duration: 100, ease: 'linear', autoplay: false }).seek(0);
+ expect(mesh.rotation.x).to.equal(Math.PI);
+ animate(mesh, { rotateY: 180, duration: 100, ease: 'linear', autoplay: false }).seek(0);
+ expect(mesh.rotation.y).to.equal(Math.PI / 2);
+ animate(mesh, { rotateZ: 90, duration: 100, ease: 'linear', autoplay: false }).seek(0);
+ expect(mesh.rotation.z).to.equal(-Math.PI / 4);
+ const fresh = createMesh();
+ animate(fresh, { rotateX: 90, duration: 100, ease: 'linear', autoplay: false }).seek(50);
+ expect(fresh.rotation.x).to.equal(Math.PI / 4);
+ animate(fresh, { rotateY: 90, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(fresh.rotation.y).to.equal(Math.PI / 2);
+ animate(fresh, { rotateZ: 720, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(fresh.rotation.z).to.equal(2 * TAU);
+ });
+
+ test('Auto-converts degrees to radians on rotation and angle fields', () => {
+ // 1. Object3D rotateX, rotateY, rotateZ via the static Object3D adapter mappings.
+ const mesh = createMesh();
+ animate(mesh, { rotateX: 90, rotateY: 180, rotateZ: 45, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mesh.rotation.x).to.be.closeTo(Math.PI / 2, 1e-6);
+ expect(mesh.rotation.y).to.be.closeTo(Math.PI, 1e-6);
+ expect(mesh.rotation.z).to.be.closeTo(Math.PI / 4, 1e-6);
+
+ // 2. Texture rotation as a scalar number via the angle resolver.
+ const texture = new Texture();
+ animate(texture, { rotation: 90, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(texture.rotation).to.be.closeTo(Math.PI / 2, 1e-6);
+
+ // 3. SpotLight angle as a scalar number via the angle resolver.
+ const spot = new SpotLight();
+ animate(spot, { angle: 30, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(spot.angle).to.be.closeTo(Math.PI / 6, 1e-6);
+
+ // 4. Mesh rotationX, rotationY, rotationZ via the Euler axis resolver, alternate spelling of rotateX/Y/Z.
+ const fresh = createMesh();
+ animate(fresh, { rotationX: 90, rotationY: 180, rotationZ: 45, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(fresh.rotation.x).to.be.closeTo(Math.PI / 2, 1e-6);
+ expect(fresh.rotation.y).to.be.closeTo(Math.PI, 1e-6);
+ expect(fresh.rotation.z).to.be.closeTo(Math.PI / 4, 1e-6);
+ });
+
+ test('Uniform scale writes all axes, per-axis writes stay independent', () => {
+ const mesh = createMesh();
+ const uniform = animate(mesh, { scale: 2, duration: 100, ease: 'linear', autoplay: false });
+ uniform.seek(50);
+ expect(mesh.scale.x).to.equal(1.5);
+ expect(mesh.scale.y).to.equal(1.5);
+ expect(mesh.scale.z).to.equal(1.5);
+ uniform.seek(100);
+ expect(mesh.scale.x).to.equal(2);
+ expect(mesh.scale.y).to.equal(2);
+ expect(mesh.scale.z).to.equal(2);
+ animate(mesh, { scaleX: 5, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mesh.scale.x).to.equal(5);
+ expect(mesh.scale.y).to.equal(2);
+ expect(mesh.scale.z).to.equal(2);
+ animate(mesh, { scaleY: 4, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mesh.scale.x).to.equal(5);
+ expect(mesh.scale.y).to.equal(4);
+ expect(mesh.scale.z).to.equal(2);
+ animate(mesh, { scaleZ: 3, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mesh.scale.x).to.equal(5);
+ expect(mesh.scale.y).to.equal(4);
+ expect(mesh.scale.z).to.equal(3);
+ });
+
+ test('Toggles visible based on scale being zero', () => {
+ const mesh = createMesh();
+ mesh.visible = false;
+ const animation = animate(mesh, { scale: [1, 0], duration: 100, ease: 'linear', autoplay: false });
+ animation.seek(0);
+ expect(mesh.visible).to.equal(true);
+ animation.seek(100);
+ expect(mesh.visible).to.equal(false);
+ });
+
+ test('Animates visible from truthy to falsy', () => {
+ const mesh = createMesh();
+ mesh.visible = false;
+ const animation = animate(mesh, { visible: [1, 0], duration: 100, ease: 'linear', autoplay: false });
+ animation.seek(50);
+ expect(mesh.visible).to.equal(true);
+ animation.seek(100);
+ expect(mesh.visible).to.equal(false);
+ });
+
+ // Opacity
+
+ test('Writes opacity to material and toggles visible at zero', () => {
+ const mesh = createMesh();
+ mesh.material.opacity = 0.3;
+ mesh.visible = false;
+ const animation = animate(mesh, { opacity: [1, 0], duration: 100, ease: 'linear', autoplay: false });
+ animation.seek(0);
+ expect(mesh.material.opacity).to.equal(1);
+ expect(mesh.visible).to.equal(true);
+ animation.seek(50);
+ expect(mesh.material.opacity).to.equal(0.5);
+ expect(mesh.visible).to.equal(true);
+ animation.seek(100);
+ expect(mesh.material.opacity).to.equal(0);
+ expect(mesh.visible).to.equal(false);
+ });
+
+ test('Writes opacity to every entry in material array', () => {
+ const m1 = new MeshBasicMaterial({ transparent: true });
+ const m2 = new MeshBasicMaterial({ transparent: true });
+ const multi = new Mesh(new BoxGeometry(1, 1, 1), [m1, m2]);
+ animate(multi, { opacity: 0.5, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(m1.opacity).to.equal(0.5);
+ expect(m2.opacity).to.equal(0.5);
+ });
+
+ // Color
+
+ test('Animates color and reads from-value off material', () => {
+ const mesh = createMesh('#888888');
+ const animation = animate(mesh, { color: ['#000000', '#ff0000'], duration: 100, ease: 'linear', autoplay: false });
+ animation.seek(50);
+ expect(mesh.material.color.r).to.be.closeTo(expectedChannel(0, 255, 0.5), 1e-6);
+ expect(mesh.material.color.g).to.be.closeTo(0, 1e-6);
+ expect(mesh.material.color.b).to.be.closeTo(0, 1e-6);
+ animation.seek(100);
+ expect(mesh.material.color.r).to.be.closeTo(1, 1e-6);
+ expect(mesh.material.color.g).to.be.closeTo(0, 1e-6);
+ expect(mesh.material.color.b).to.be.closeTo(0, 1e-6);
+ const fromMesh = createMesh('#ff0000');
+ const fromAnim = animate(fromMesh, { color: '#0000ff', duration: 100, ease: 'linear', autoplay: false });
+ fromAnim.seek(50);
+ expect(fromMesh.material.color.r).to.be.closeTo(expectedChannel(255, 0, 0.5), 1e-6);
+ expect(fromMesh.material.color.b).to.be.closeTo(expectedChannel(0, 255, 0.5), 1e-6);
+ fromAnim.seek(100);
+ expect(fromMesh.material.color.r).to.be.closeTo(0, 1e-6);
+ expect(fromMesh.material.color.b).to.be.closeTo(1, 1e-6);
+ });
+
+ test('Animates color across all channels between explicit from-to endpoints', () => {
+ const mesh = createMesh('#888888');
+ const animation = animate(mesh, { color: ['#000000', '#ffffff'], duration: 100, ease: 'linear', autoplay: false });
+ animation.seek(0);
+ expect(mesh.material.color.r).to.be.closeTo(0, 1e-6);
+ expect(mesh.material.color.g).to.be.closeTo(0, 1e-6);
+ expect(mesh.material.color.b).to.be.closeTo(0, 1e-6);
+ animation.seek(50);
+ const mid = expectedChannel(0, 255, 0.5);
+ expect(mesh.material.color.r).to.be.closeTo(mid, 1e-6);
+ expect(mesh.material.color.g).to.be.closeTo(mid, 1e-6);
+ expect(mesh.material.color.b).to.be.closeTo(mid, 1e-6);
+ animation.seek(100);
+ expect(mesh.material.color.r).to.be.closeTo(1, 1e-6);
+ expect(mesh.material.color.g).to.be.closeTo(1, 1e-6);
+ expect(mesh.material.color.b).to.be.closeTo(1, 1e-6);
+ });
+
+ test('Chains color through multi-keyframe steps', () => {
+ const mesh = createMesh('#888888');
+ const animation = animate(mesh, {
+ color: ['#ff0000', '#00ff00', '#0000ff'],
+ duration: 200,
+ ease: 'linear',
+ autoplay: false,
+ });
+ animation.seek(0);
+ expect(mesh.material.color.r).to.be.closeTo(1, 1e-6);
+ expect(mesh.material.color.g).to.be.closeTo(0, 1e-6);
+ expect(mesh.material.color.b).to.be.closeTo(0, 1e-6);
+ animation.seek(100);
+ expect(mesh.material.color.r).to.be.closeTo(0, 1e-6);
+ expect(mesh.material.color.g).to.be.closeTo(1, 1e-6);
+ expect(mesh.material.color.b).to.be.closeTo(0, 1e-6);
+ animation.seek(200);
+ expect(mesh.material.color.r).to.be.closeTo(0, 1e-6);
+ expect(mesh.material.color.g).to.be.closeTo(0, 1e-6);
+ expect(mesh.material.color.b).to.be.closeTo(1, 1e-6);
+ });
+
+ test('Writes color to light.color, leaves HemisphereLight groundColor alone', () => {
+ const point = new PointLight(0x000000);
+ animate(point, { color: '#00ff00', duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(point.color.r).to.be.closeTo(0, 1e-6);
+ expect(point.color.g).to.be.closeTo(1, 1e-6);
+ expect(point.color.b).to.be.closeTo(0, 1e-6);
+ const hemi = new HemisphereLight(0x000000, 0xffffff);
+ const groundR0 = hemi.groundColor.r;
+ animate(hemi, { color: '#ff0000', duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(hemi.color.r).to.be.closeTo(1, 1e-6);
+ expect(hemi.color.g).to.be.closeTo(0, 1e-6);
+ expect(hemi.color.b).to.be.closeTo(0, 1e-6);
+ expect(hemi.groundColor.r).to.be.closeTo(groundR0, 1e-6);
+ });
+
+ test('Writes color to every entry in material array', () => {
+ const ma = new MeshBasicMaterial({ color: '#000000' });
+ const mb = new MeshBasicMaterial({ color: '#000000' });
+ const multi = new Mesh(new BoxGeometry(1, 1, 1), [ma, mb]);
+ animate(multi, { color: '#ff0000', duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(ma.color.r).to.be.closeTo(1, 1e-6);
+ expect(mb.color.r).to.be.closeTo(1, 1e-6);
+ });
+
+ test('Animates HemisphereLight groundColor as a color tween', () => {
+ const hemi = new HemisphereLight(0xffffff, 0x000000);
+ const animation = animate(hemi, { groundColor: '#00ff00', duration: 100, ease: 'linear', autoplay: false });
+ animation.seek(0);
+ expect(hemi.groundColor.r).to.be.closeTo(0, 1e-6);
+ expect(hemi.groundColor.g).to.be.closeTo(0, 1e-6);
+ expect(hemi.groundColor.b).to.be.closeTo(0, 1e-6);
+ animation.seek(100);
+ expect(hemi.groundColor.r).to.be.closeTo(0, 1e-6);
+ expect(hemi.groundColor.g).to.be.closeTo(1, 1e-6);
+ expect(hemi.groundColor.b).to.be.closeTo(0, 1e-6);
+ });
+
+ // Audio (method-bridged)
+
+ test('Bridges volume, refDistance, rolloffFactor, maxDistance via setX and getX', () => {
+ const audio = new Object3D();
+ let v = 0.5;
+ let getterCalls = 0;
+ audio.setVolume = (val) => { v = val; };
+ audio.getVolume = () => { getterCalls++; return v; };
+ animate(audio, { volume: 1, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(v).to.equal(1);
+ expect(getterCalls).to.be.greaterThan(0);
+ const positional = new Object3D();
+ let rd = 1, rf = 1, md = 1000;
+ positional.setRefDistance = (val) => { rd = val; };
+ positional.setRolloffFactor = (val) => { rf = val; };
+ positional.setMaxDistance = (val) => { md = val; };
+ positional.getRefDistance = () => rd;
+ positional.getRolloffFactor = () => rf;
+ positional.getMaxDistance = () => md;
+ animate(positional, { refDistance: 10, rolloffFactor: 2, maxDistance: 500, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(rd).to.equal(10);
+ expect(rf).to.equal(2);
+ expect(md).to.equal(500);
+ });
+
+ // Camera
+
+ test('Updates projection matrix on Perspective and Orthographic camera writes', () => {
+ const persp = new PerspectiveCamera(50, 1, 0.1, 1000);
+ let perspCount = 0;
+ const perspOrig = persp.updateProjectionMatrix.bind(persp);
+ persp.updateProjectionMatrix = () => { perspCount++; perspOrig(); };
+ animate(persp, { fov: 80, aspect: 2, near: 5, far: 500, zoom: 2, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(persp.fov).to.equal(80);
+ expect(persp.aspect).to.equal(2);
+ expect(persp.near).to.equal(5);
+ expect(persp.far).to.equal(500);
+ expect(persp.zoom).to.equal(2);
+ expect(perspCount).to.be.greaterThan(0);
+ const focal = new PerspectiveCamera(50, 1, 0.1, 1000);
+ let focalCount = 0;
+ const focalOrig = focal.updateProjectionMatrix.bind(focal);
+ focal.updateProjectionMatrix = () => { focalCount++; focalOrig(); };
+ animate(focal, { focalLength: 35, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(focal.getFocalLength()).to.be.closeTo(35, 1e-3);
+ expect(focalCount).to.be.greaterThan(0);
+ const ortho = new OrthographicCamera(-1, 1, 1, -1, 0.1, 1000);
+ let orthoCount = 0;
+ const orthoOrig = ortho.updateProjectionMatrix.bind(ortho);
+ ortho.updateProjectionMatrix = () => { orthoCount++; orthoOrig(); };
+ animate(ortho, { left: -2, right: 2, top: 2, bottom: -2, near: 4, far: 400, zoom: 3, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(ortho.left).to.equal(-2);
+ expect(ortho.right).to.equal(2);
+ expect(ortho.top).to.equal(2);
+ expect(ortho.bottom).to.equal(-2);
+ expect(ortho.near).to.equal(4);
+ expect(ortho.far).to.equal(400);
+ expect(ortho.zoom).to.equal(3);
+ expect(orthoCount).to.be.greaterThan(0);
+ });
+
+ // Direct property fall-through (unmapped names)
+
+ test('Animates intensity on Point, Spot, Directional, Hemisphere lights', () => {
+ const lights = [
+ new PointLight(0xffffff, 0.5),
+ new SpotLight(0xffffff, 0.5),
+ new DirectionalLight(0xffffff, 0.5),
+ new HemisphereLight(0xffffff, 0xffffff, 0.5),
+ ];
+ for (let i = 0, l = lights.length; i < l; i++) {
+ const light = lights[i];
+ const animation = animate(light, { intensity: 2, duration: 100, ease: 'linear', autoplay: false });
+ animation.seek(0);
+ expect(light.intensity).to.equal(0.5);
+ animation.seek(100);
+ expect(light.intensity).to.equal(2);
+ }
+ });
+
+ // utils.set / revert / edge
+
+ test('Routes utils.set through three adapter', () => {
+ const mesh = createMesh();
+ utils.set(mesh, { x: 100, opacity: 0.4 });
+ expect(mesh.position.x).to.equal(100);
+ expect(mesh.material.opacity).to.equal(0.4);
+ });
+
+ test('Reverts numeric adapter props to pre-animation value', () => {
+ const mesh = createMesh();
+ mesh.position.x = 5;
+ mesh.rotation.y = 0.5;
+ mesh.scale.set(1.5, 1.5, 1.5);
+ mesh.material.opacity = 0.7;
+ const meshAnim = animate(mesh, { x: 100, rotateY: 90, scale: 3, opacity: 0.1, duration: 100, autoplay: false });
+ meshAnim.seek(meshAnim.duration);
+ meshAnim.revert();
+ expect(mesh.position.x).to.equal(5);
+ expect(mesh.rotation.y).to.be.closeTo(0.5, 1e-9);
+ expect(mesh.scale.x).to.equal(1.5);
+ expect(mesh.scale.y).to.equal(1.5);
+ expect(mesh.scale.z).to.equal(1.5);
+ expect(mesh.material.opacity).to.equal(0.7);
+ const camera = new PerspectiveCamera(45, 1, 0.1, 1000);
+ const camAnim = animate(camera, { fov: 80, duration: 100, autoplay: false });
+ camAnim.seek(camAnim.duration);
+ camAnim.revert();
+ expect(camera.fov).to.equal(45);
+ });
+
+ test('Reverts material color to pre-animation value', () => {
+ const mesh = createMesh('#ff8800');
+ const r0 = mesh.material.color.r;
+ const g0 = mesh.material.color.g;
+ const b0 = mesh.material.color.b;
+ const colorAnim = animate(mesh, { color: '#0000ff', duration: 100, autoplay: false });
+ colorAnim.seek(colorAnim.duration);
+ expect(mesh.material.color.b).to.be.closeTo(1, 1e-6);
+ colorAnim.revert();
+ expect(mesh.material.color.r).to.be.closeTo(r0, 1e-6);
+ expect(mesh.material.color.g).to.be.closeTo(g0, 1e-6);
+ expect(mesh.material.color.b).to.be.closeTo(b0, 1e-6);
+ });
+
+ test('Animates opacity and color on bare Object3D without throwing', () => {
+ const opacityObj = new Object3D();
+ expect(() => animate(opacityObj, { opacity: 0, duration: 100, ease: 'linear', autoplay: false }).seek(100)).to.not.throw();
+ expect(opacityObj.visible).to.equal(false);
+ const colorObj = new Object3D();
+ expect(() => animate(colorObj, { color: '#ff0000', duration: 100, ease: 'linear', autoplay: false }).seek(100)).to.not.throw();
+ });
+
+ // Material adapter
+
+ // Direct material props
+
+ test('Decomposes material emissive via Material adapter', () => {
+ const mat = new MeshStandardMaterial({ emissive: '#888888' });
+ animate(mat, { emissive: '#ff0000', duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mat.emissive.r).to.be.closeTo(1, 1e-6);
+ expect(mat.emissive.g).to.be.closeTo(0, 1e-6);
+ expect(mat.emissive.b).to.be.closeTo(0, 1e-6);
+ });
+
+ test('Animates numeric prop directly on material', () => {
+ const mat = new MeshStandardMaterial();
+ animate(mat, { metalness: 0.8, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mat.metalness).to.equal(0.8);
+ });
+
+ test('Routes material color and scalar props on mesh via property resolver', () => {
+ const mesh = new Mesh(
+ new BoxGeometry(1, 1, 1),
+ new MeshStandardMaterial({ emissive: '#888888', metalness: 0, roughness: 1 }),
+ );
+ animate(mesh, {
+ emissive: '#00ff00',
+ metalness: 0.7,
+ roughness: 0.3,
+ duration: 100,
+ ease: 'linear',
+ autoplay: false,
+ }).seek(100);
+ expect(mesh.material.emissive.r).to.be.closeTo(0, 1e-6);
+ expect(mesh.material.emissive.g).to.be.closeTo(1, 1e-6);
+ expect(mesh.material.emissive.b).to.be.closeTo(0, 1e-6);
+ expect(mesh.material.metalness).to.equal(0.7);
+ expect(mesh.material.roughness).to.equal(0.3);
+ });
+
+ test('Routes utils.set bool write to material prop', () => {
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), new MeshStandardMaterial({ wireframe: false }));
+ expect(resolveAdapterEntry(mesh, 'wireframe')).to.not.equal(null);
+ utils.set(mesh, { wireframe: true });
+ expect(mesh.material.wireframe).to.equal(1);
+ utils.set(mesh, { wireframe: false });
+ expect(mesh.material.wireframe).to.equal(0);
+ });
+
+ test('Writes mesh material props to every entry in array', () => {
+ const m1 = new MeshStandardMaterial({ emissive: '#000000', metalness: 0 });
+ const m2 = new MeshStandardMaterial({ emissive: '#000000', metalness: 0 });
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), [m1, m2]);
+ animate(mesh, { emissive: '#ff0000', metalness: 0.5, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(m1.emissive.r).to.be.closeTo(1, 1e-6);
+ expect(m2.emissive.r).to.be.closeTo(1, 1e-6);
+ expect(m1.metalness).to.equal(0.5);
+ expect(m2.metalness).to.equal(0.5);
+ });
+
+ test('Mesh-owned prop wins over material prop on name collision', () => {
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), new MeshStandardMaterial({ metalness: 0.1 }));
+ /** @type {any} */(mesh).metalness = 5;
+ animate(mesh, { metalness: 10, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(/** @type {any} */(mesh).metalness).to.equal(10);
+ expect(mesh.material.metalness).to.equal(0.1);
+ });
+
+ // ShaderMaterial uniforms
+
+ const makeShaderMaterial = () => new ShaderMaterial({
+ uniforms: {
+ uTime: { value: 0 },
+ uIntensity: { value: 1 },
+ uTint: { value: new Color('#000000') },
+ uOffset: { value: new Vector3(0, 0, 0) },
+ },
+ vertexShader: 'void main() { gl_Position = vec4(0.0); }',
+ fragmentShader: 'void main() { gl_FragColor = vec4(0.0); }',
+ });
+
+ test('Routes scalar uniform via uniforms value on material', () => {
+ const mat = makeShaderMaterial();
+ animate(mat, { uTime: 5, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mat.uniforms.uTime.value).to.equal(5);
+ });
+
+ test('Interpolates scalar uniform linearly', () => {
+ const mat = makeShaderMaterial();
+ animate(mat, { uIntensity: [0, 10], duration: 100, ease: 'linear', autoplay: false }).seek(50);
+ expect(mat.uniforms.uIntensity.value).to.equal(5);
+ });
+
+ test('Routes color uniform from hex input via uniforms value', () => {
+ const mat = makeShaderMaterial();
+ animate(mat, { uTint: '#ff0000', duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mat.uniforms.uTint.value.r).to.be.closeTo(1, 1e-6);
+ expect(mat.uniforms.uTint.value.g).to.be.closeTo(0, 1e-6);
+ expect(mat.uniforms.uTint.value.b).to.be.closeTo(0, 1e-6);
+ });
+
+ test('Auto-detects scalar uniform on mesh material', () => {
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), makeShaderMaterial());
+ animate(mesh, { uTime: [0, 10], duration: 100, ease: 'linear', autoplay: false }).seek(50);
+ expect(mesh.material.uniforms.uTime.value).to.equal(5);
+ });
+
+ test('Auto-detects color uniform on mesh material', () => {
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), makeShaderMaterial());
+ animate(mesh, { uTint: '#00ff00', duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mesh.material.uniforms.uTint.value.r).to.be.closeTo(0, 1e-6);
+ expect(mesh.material.uniforms.uTint.value.g).to.be.closeTo(1, 1e-6);
+ expect(mesh.material.uniforms.uTint.value.b).to.be.closeTo(0, 1e-6);
+ });
+
+ test('Animates vector uniform via OBJECT path on uniforms value', () => {
+ const mat = makeShaderMaterial();
+ animate(mat.uniforms.uOffset.value, { x: 5, y: -2, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mat.uniforms.uOffset.value.x).to.equal(5);
+ expect(mat.uniforms.uOffset.value.y).to.equal(-2);
+ expect(mat.uniforms.uOffset.value.z).to.equal(0);
+ });
+
+ test('Writes scalar uniform to every entry in material array', () => {
+ const m1 = makeShaderMaterial();
+ const m2 = makeShaderMaterial();
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), [m1, m2]);
+ animate(mesh, { uIntensity: [1, 0], duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(m1.uniforms.uIntensity.value).to.equal(0);
+ expect(m2.uniforms.uIntensity.value).to.equal(0);
+ });
+
+ test('Writes color uniform to every entry in material array', () => {
+ const m1 = makeShaderMaterial();
+ const m2 = makeShaderMaterial();
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), [m1, m2]);
+ animate(mesh, { uTint: '#ff0000', duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(m1.uniforms.uTint.value.r).to.be.closeTo(1, 1e-6);
+ expect(m2.uniforms.uTint.value.r).to.be.closeTo(1, 1e-6);
+ });
+
+ test('Direct material prop wins over uniform with same name', () => {
+ const mat = makeShaderMaterial();
+ /** @type {any} */(mat).uTime = 99;
+ animate(mat, { uTime: [0, 10], duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(/** @type {any} */(mat).uTime).to.equal(10);
+ expect(mat.uniforms.uTime.value).to.equal(0);
+ });
+
+ test('Direct material prop wins over uniform with same name via mesh', () => {
+ const mat = makeShaderMaterial();
+ /** @type {any} */(mat).uTime = 99;
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), mat);
+ animate(mesh, { uTime: [0, 10], duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(/** @type {any} */(mat).uTime).to.equal(10);
+ expect(mat.uniforms.uTime.value).to.equal(0);
+ });
+
+ // Vector axis decomposition (X / Y / Z / W suffix)
+
+ const makeVectorShaderMaterial = () => new ShaderMaterial({
+ uniforms: {
+ uOffset: { value: new Vector3(0, 0, 0) },
+ uPair: { value: new Vector2(0, 0) },
+ uVec4: { value: new Vector4(0, 0, 0, 0) },
+ },
+ vertexShader: 'void main() { gl_Position = vec4(0.0); }',
+ fragmentShader: 'void main() { gl_FragColor = vec4(0.0); }',
+ });
+
+ test('Decomposes Vector2 material prop normalScale to X, Y axes', () => {
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), new MeshStandardMaterial({ normalScale: new Vector2(1, 1) }));
+ const ref = mesh.material.normalScale;
+ animate(mesh, { normalScaleX: 0.5, normalScaleY: -0.5, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mesh.material.normalScale.x).to.equal(0.5);
+ expect(mesh.material.normalScale.y).to.equal(-0.5);
+ expect(mesh.material.normalScale).to.equal(ref);
+ });
+
+ test('Decomposes Vector3 uniform to X, Y, Z axes via material', () => {
+ const mat = makeVectorShaderMaterial();
+ const ref = mat.uniforms.uOffset.value;
+ animate(mat, { uOffsetX: 5, uOffsetY: -2, uOffsetZ: 7, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mat.uniforms.uOffset.value.x).to.equal(5);
+ expect(mat.uniforms.uOffset.value.y).to.equal(-2);
+ expect(mat.uniforms.uOffset.value.z).to.equal(7);
+ expect(mat.uniforms.uOffset.value).to.equal(ref);
+ });
+
+ test('Decomposes Vector3 uniform via mesh and lerps linearly', () => {
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), makeVectorShaderMaterial());
+ animate(mesh, { uOffsetX: [0, 10], duration: 100, ease: 'linear', autoplay: false }).seek(50);
+ expect(mesh.material.uniforms.uOffset.value.x).to.equal(5);
+ });
+
+ test('Writes Vector4 uniform W axis to w', () => {
+ const mat = makeVectorShaderMaterial();
+ animate(mat, { uVec4W: 9, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mat.uniforms.uVec4.value.w).to.equal(9);
+ });
+
+ test('Falls through OBJECT path on out-of-dim axis suffix', () => {
+ const mat = makeVectorShaderMaterial();
+ animate(mat, { uPairZ: 99, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mat.uniforms.uPair.value.x).to.equal(0);
+ expect(mat.uniforms.uPair.value.y).to.equal(0);
+ expect(/** @type {any} */(mat).uPairZ).to.equal(99);
+ });
+
+ test('Skips Quaternion decomposition to preserve unit-length invariant', () => {
+ const mat = new MeshStandardMaterial();
+ /** @type {any} */(mat).qrot = new Quaternion(0, 0, 0, 1);
+ animate(mat, { qrotW: 0.5, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(/** @type {any} */(mat).qrot.w).to.equal(1);
+ expect(/** @type {any} */(mat).qrotW).to.equal(0.5);
+ });
+
+ test('Writes vector axis direct prop to every entry in material array', () => {
+ const m1 = new MeshStandardMaterial({ normalScale: new Vector2(1, 1) });
+ const m2 = new MeshStandardMaterial({ normalScale: new Vector2(1, 1) });
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), [m1, m2]);
+ animate(mesh, { normalScaleX: 0.25, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(m1.normalScale.x).to.equal(0.25);
+ expect(m2.normalScale.x).to.equal(0.25);
+ });
+
+ test('Writes vector axis uniform to every entry in material array', () => {
+ const m1 = makeVectorShaderMaterial();
+ const m2 = makeVectorShaderMaterial();
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), [m1, m2]);
+ animate(mesh, { uOffsetX: 3, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(m1.uniforms.uOffset.value.x).to.equal(3);
+ expect(m2.uniforms.uOffset.value.x).to.equal(3);
+ });
+
+ // TSL
+
+ // Bare UniformNode
+
+ test('Animates scalar UniformNode via value', () => {
+ const u = uniform(0);
+ animate(u, { value: [0, 10], duration: 100, ease: 'linear', autoplay: false }).seek(50);
+ expect(u.value).to.equal(5);
+ });
+
+ test('Routes utils.set bool UniformNode via OBJECT fallthrough', () => {
+ const u = uniform(false);
+ utils.set(u, { value: true });
+ expect(u.value).to.equal(1);
+ utils.set(u, { value: false });
+ expect(u.value).to.equal(0);
+ });
+
+ test('Animates color UniformNode via color', () => {
+ const u = uniform(new Color('#000000'));
+ animate(u, { color: '#ff0000', duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(u.value.r).to.be.closeTo(1, 1e-6);
+ expect(u.value.g).to.be.closeTo(0, 1e-6);
+ expect(u.value.b).to.be.closeTo(0, 1e-6);
+ });
+
+ test('Animates Vector3 UniformNode via x, y, z axes', () => {
+ const u = uniform(new Vector3());
+ animate(u, { x: 5, y: -2, z: 1, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(u.value.x).to.equal(5);
+ expect(u.value.y).to.equal(-2);
+ expect(u.value.z).to.equal(1);
+ });
+
+ test('Writes Vector4 UniformNode w axis to w', () => {
+ const u = uniform(new Vector4());
+ animate(u, { w: 7, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(u.value.w).to.equal(7);
+ });
+
+ // NodeMaterial slots
+
+ const makeNodeMaterial = () => {
+ const mat = new MeshStandardNodeMaterial();
+ mat.colorNode = uniform(new Color('#000000'));
+ mat.metalnessNode = uniform(0);
+ mat.opacityNode = uniform(1);
+ mat.offsetNode = uniform(new Vector3(0, 0, 0));
+ mat.flagNode = uniform(false);
+ return mat;
+ };
+
+ test('Animates NodeMaterial scalar slot via metalnessNode value', () => {
+ const mat = makeNodeMaterial();
+ animate(mat, { metalnessNode: [0, 1], duration: 100, ease: 'linear', autoplay: false }).seek(50);
+ expect(mat.metalnessNode.value).to.equal(0.5);
+ });
+
+ test('Routes utils.set bool write to NodeMaterial slot value', () => {
+ const mat = makeNodeMaterial();
+ expect(resolveAdapterEntry(mat, 'flagNode')).to.not.equal(null);
+ utils.set(mat, { flagNode: true });
+ expect(mat.flagNode.value).to.equal(1);
+ utils.set(mat, { flagNode: false });
+ expect(mat.flagNode.value).to.equal(0);
+ });
+
+ test('Animates NodeMaterial color slot from hex via colorNode value', () => {
+ const mat = makeNodeMaterial();
+ animate(mat, { colorNode: '#ff0000', duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mat.colorNode.value.r).to.be.closeTo(1, 1e-6);
+ expect(mat.colorNode.value.g).to.be.closeTo(0, 1e-6);
+ expect(mat.colorNode.value.b).to.be.closeTo(0, 1e-6);
+ });
+
+ test('Decomposes NodeMaterial vector slot to X, Y, Z axes', () => {
+ const mat = makeNodeMaterial();
+ animate(mat, { offsetNodeX: 3, offsetNodeY: -1, offsetNodeZ: 2, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mat.offsetNode.value.x).to.equal(3);
+ expect(mat.offsetNode.value.y).to.equal(-1);
+ expect(mat.offsetNode.value.z).to.equal(2);
+ });
+
+ test('Auto-detects NodeMaterial scalar slot via mesh', () => {
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), makeNodeMaterial());
+ animate(mesh, { metalnessNode: [0, 1], duration: 100, ease: 'linear', autoplay: false }).seek(50);
+ expect(mesh.material.metalnessNode.value).to.equal(0.5);
+ });
+
+ test('Auto-detects NodeMaterial color slot via mesh', () => {
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), makeNodeMaterial());
+ animate(mesh, { colorNode: '#00ff00', duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mesh.material.colorNode.value.r).to.be.closeTo(0, 1e-6);
+ expect(mesh.material.colorNode.value.g).to.be.closeTo(1, 1e-6);
+ expect(mesh.material.colorNode.value.b).to.be.closeTo(0, 1e-6);
+ });
+
+ test('Auto-detects NodeMaterial vector slot axis via mesh', () => {
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), makeNodeMaterial());
+ animate(mesh, { offsetNodeY: 4, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mesh.material.offsetNode.value.y).to.equal(4);
+ });
+
+ test('Writes NodeMaterial scalar slot to every entry in material array', () => {
+ const m1 = makeNodeMaterial();
+ const m2 = makeNodeMaterial();
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), [m1, m2]);
+ animate(mesh, { metalnessNode: [0, 1], duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(m1.metalnessNode.value).to.equal(1);
+ expect(m2.metalnessNode.value).to.equal(1);
+ });
+
+ test('Writes NodeMaterial vector slot axis to every entry in material array', () => {
+ const m1 = makeNodeMaterial();
+ const m2 = makeNodeMaterial();
+ const mesh = new Mesh(new BoxGeometry(1, 1, 1), [m1, m2]);
+ animate(mesh, { offsetNodeY: 5, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(m1.offsetNode.value.y).to.equal(5);
+ expect(m2.offsetNode.value.y).to.equal(5);
+ });
+
+ // Instance adapter
+
+ test('Enumerates instances with stable ids, grows and shrinks in place, skips deleted BatchedMesh slots', () => {
+ const m1 = createInstanced(3);
+ const a = getInstances(m1);
+ expect(a.length).to.equal(3);
+ expect(a[0].id).to.equal(0);
+ expect(a[1].id).to.equal(1);
+ expect(a[2].id).to.equal(2);
+ expect(getInstances(m1)).to.equal(a);
+ const m2 = new InstancedMesh(new BoxGeometry(1, 1, 1), new MeshBasicMaterial(), 10);
+ m2.count = 2;
+ const grown = getInstances(m2);
+ expect(grown.length).to.equal(2);
+ m2.count = 4;
+ const after = getInstances(m2);
+ expect(after).to.equal(grown);
+ expect(after.length).to.equal(4);
+ expect(after[3]).to.not.equal(null);
+ m2.count = 1;
+ expect(getInstances(m2).length).to.equal(1);
+ const bm = new BatchedMesh(4, 100, 100, new MeshBasicMaterial());
+ const geomId = bm.addGeometry(new BoxGeometry(1, 1, 1));
+ const bid1 = bm.addInstance(geomId);
+ const bid2 = bm.addInstance(geomId);
+ bm.deleteInstance(bid1);
+ const bins = getInstances(bm);
+ expect(bins[bid1]).to.equal(null);
+ expect(bins[bid2]).to.not.equal(null);
+ expect(bins[bid2].id).to.equal(bid2);
+ });
+
+ test('Writes instance matrix and decomposes seeded matrix, dirty flag coalesces', () => {
+ const mesh = createInstanced(2);
+ const seeded = new Matrix4().compose(new Vector3(5, 10, 15), new Quaternion(), new Vector3(2, 2, 2));
+ mesh.setMatrixAt(0, seeded);
+ const instances = getInstances(mesh);
+ expect(instances[0].x).to.equal(5);
+ expect(instances[0].y).to.equal(10);
+ expect(instances[0].z).to.equal(15);
+ expect(instances[0].scale).to.equal(2);
+ animate(instances[1], { x: 5, y: 6, z: 7, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ commitChanges(mesh);
+ const m = new Matrix4();
+ mesh.getMatrixAt(1, m);
+ expect(m.elements[12]).to.equal(5);
+ expect(m.elements[13]).to.equal(6);
+ expect(m.elements[14]).to.equal(7);
+ instances[1]._dirty = 0;
+ instances[1].x = 1;
+ instances[1].y = 2;
+ instances[1].z = 3;
+ expect(instances[1]._dirty).to.equal(1);
+ instances[1].rotateY = 30;
+ expect(instances[1]._dirty).to.equal(1 | 2);
+ instances[1].scaleX = 2;
+ expect(instances[1]._dirty).to.equal(1 | 2 | 4);
+ animate(instances[0], { scale: 0, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ commitChanges(mesh);
+ const zero = new Matrix4();
+ mesh.getMatrixAt(0, zero);
+ expect(zero.elements[0]).to.equal(0);
+ expect(zero.elements[5]).to.equal(0);
+ expect(zero.elements[10]).to.equal(0);
+ });
+
+ test('Flushes instance writes via commitChanges and onBeforeRender, chains user handler', () => {
+ const mesh = createInstanced(1);
+ const instances = getInstances(mesh);
+ const v0 = mesh.instanceMatrix.version;
+ instances[0].x = 7;
+ expect(mesh.instanceMatrix.version).to.equal(v0);
+ commitChanges(mesh);
+ expect(mesh.instanceMatrix.version).to.be.greaterThan(v0);
+ const m = new Matrix4();
+ mesh.getMatrixAt(0, m);
+ expect(m.elements[12]).to.equal(7);
+ const v1 = mesh.instanceMatrix.version;
+ instances[0].x = 11;
+ let userCalled = false;
+ mesh.onBeforeRender = () => { userCalled = true; };
+ mesh.onBeforeRender(null, null, null, null, null, null);
+ expect(mesh.instanceMatrix.version).to.be.greaterThan(v1);
+ expect(userCalled).to.equal(true);
+ const m2 = new Matrix4();
+ mesh.getMatrixAt(0, m2);
+ expect(m2.elements[12]).to.equal(11);
+ const fn = () => {};
+ mesh.onBeforeRender = fn;
+ expect(mesh.onBeforeRender).to.not.equal(fn);
+ });
+
+ test('Composes rotated matrix from instance rotation', () => {
+ const mesh = createInstanced(1);
+ const instances = getInstances(mesh);
+ animate(instances[0], { rotateY: 90, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ commitChanges(mesh);
+ const m = new Matrix4();
+ mesh.getMatrixAt(0, m);
+ // 90 deg Y rotation matrix: m00 = cos = 0, m02 = sin = 1, m20 = -sin = -1, m22 = cos = 0.
+ expect(m.elements[0]).to.be.closeTo(0, 1e-6);
+ expect(m.elements[2]).to.be.closeTo(-1, 1e-6);
+ expect(m.elements[8]).to.be.closeTo(1, 1e-6);
+ expect(m.elements[10]).to.be.closeTo(0, 1e-6);
+ });
+
+ test('Writes instance opacity to parent shared material', () => {
+ const mesh = createInstanced(2);
+ const instances = getInstances(mesh);
+ animate(instances[0], { opacity: 0.25, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mesh.material.opacity).to.equal(0.25);
+ });
+
+ test('Writes instance color to InstancedMesh instanceColor', () => {
+ const mesh = createInstanced(2);
+ const instances = getInstances(mesh);
+ animate(instances[0], { color: '#ff0000', duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ expect(mesh.instanceColor).to.not.equal(null);
+ expect(mesh.instanceColor.version).to.be.greaterThan(0);
+ const c = new Color();
+ mesh.getColorAt(0, c);
+ expect(c.r).to.be.closeTo(1, 1e-6);
+ expect(c.g).to.be.closeTo(0, 1e-6);
+ expect(c.b).to.be.closeTo(0, 1e-6);
+ });
+
+ test('Writes BatchedMesh instance visible via setVisibleAt and getVisibleAt', () => {
+ const bm = new BatchedMesh(2, 100, 100, new MeshBasicMaterial());
+ const geomId = bm.addGeometry(new BoxGeometry(1, 1, 1));
+ const bid = bm.addInstance(geomId);
+ const bins = getInstances(bm);
+ bins[bid].visible = false;
+ expect(bm.getVisibleAt(bid)).to.equal(false);
+ bins[bid].visible = true;
+ expect(bm.getVisibleAt(bid)).to.equal(true);
+ });
+
+ test('Writes slot matrix from BatchedMesh instance position', () => {
+ const bm = new BatchedMesh(2, 100, 100, new MeshBasicMaterial());
+ const geomId = bm.addGeometry(new BoxGeometry(1, 1, 1));
+ const bid = bm.addInstance(geomId);
+ const bins = getInstances(bm);
+ animate(bins[bid], { x: 9, y: -3, z: 4, duration: 100, ease: 'linear', autoplay: false }).seek(100);
+ commitChanges(bm);
+ const m = new Matrix4();
+ bm.getMatrixAt(bid, m);
+ expect(m.elements[12]).to.equal(9);
+ expect(m.elements[13]).to.equal(-3);
+ expect(m.elements[14]).to.equal(4);
+ });
+
+ test('Applies stagger offsets per instance', () => {
+ const mesh = createInstanced(3);
+ const instances = getInstances(mesh);
+ const animation = animate(instances, {
+ x: 10,
+ delay: utils.stagger(100),
+ duration: 100,
+ ease: 'linear',
+ autoplay: false,
+ });
+ animation.seek(100);
+ expect(instances[0].x).to.equal(10);
+ expect(instances[1].x).to.equal(0);
+ expect(instances[2].x).to.equal(0);
+ animation.seek(200);
+ expect(instances[1].x).to.equal(10);
+ expect(instances[2].x).to.equal(0);
+ animation.seek(300);
+ expect(instances[2].x).to.equal(10);
+ });
+
+ // Timeline composition
+
+ test('Chains color across sibling timeline adds from previous end-color', () => {
+ const mesh = createMesh('#000000');
+ const tl = createTimeline({ autoplay: false, defaults: { duration: 100, ease: 'linear' } })
+ .add(mesh, { color: '#ff0000' })
+ .add(mesh, { color: '#00ff00' })
+ .add(mesh, { color: '#0000ff' });
+ tl.seek(100);
+ expect(mesh.material.color.r).to.be.closeTo(1, 1e-6);
+ expect(mesh.material.color.g).to.be.closeTo(0, 1e-6);
+ tl.seek(150);
+ expect(mesh.material.color.r).to.be.closeTo(expectedChannel(255, 0, 0.5), 1e-6);
+ expect(mesh.material.color.g).to.be.closeTo(expectedChannel(0, 255, 0.5), 1e-6);
+ tl.seek(200);
+ expect(mesh.material.color.r).to.be.closeTo(0, 1e-6);
+ expect(mesh.material.color.g).to.be.closeTo(1, 1e-6);
+ tl.seek(250);
+ expect(mesh.material.color.g).to.be.closeTo(expectedChannel(255, 0, 0.5), 1e-6);
+ expect(mesh.material.color.b).to.be.closeTo(expectedChannel(0, 255, 0.5), 1e-6);
+ tl.seek(300);
+ expect(mesh.material.color.b).to.be.closeTo(1, 1e-6);
+ });
+
+ test('Overlapping color add overrides previous in timeline', () => {
+ const mesh = createMesh('#000000');
+ const tl = createTimeline({ autoplay: false, defaults: { duration: 200, ease: 'linear' } })
+ .add(mesh, { color: '#ff0000' })
+ .add(mesh, { color: '#00ff00', duration: 100 }, '-=100');
+ // First add at 25% of its 200ms updateDuration before the override kicks in.
+ tl.seek(50);
+ expect(mesh.material.color.r).to.be.closeTo(expectedChannel(0, 255, 0.25), 1e-6);
+ expect(mesh.material.color.g).to.be.closeTo(0, 1e-6);
+ // Override boundary at t=100 snapshots the first tween's mid-frame value as the second tween's from-color. The render path composes the snapshot through `rgba(${round(...,0)},...)`, so the channel is rounded to an integer before chaining.
+ tl.seek(150);
+ const overrideFromR = Math.round(Math.sqrt(255 * 255 * 0.5));
+ expect(mesh.material.color.r).to.be.closeTo(expectedChannel(overrideFromR, 0, 0.5), 1e-6);
+ expect(mesh.material.color.g).to.be.closeTo(expectedChannel(0, 255, 0.5), 1e-6);
+ tl.seek(tl.duration);
+ expect(mesh.material.color.r).to.be.closeTo(0, 1e-6);
+ expect(mesh.material.color.g).to.be.closeTo(1, 1e-6);
+ });
+
+ test('transformOrigin animates under any composition mode', () => {
+ const readOrigin = (t) => resolveAdapterEntry(t, 'transformOrigin').get(t).split(' ').map(Number);
+ // Control: default composition replace interpolates the origin triplet.
+ const meshReplace = createMesh();
+ animate(meshReplace, { transformOrigin: ['0 0 0', '10 20 30'], duration: 100, ease: 'linear', autoplay: false }).seek(50);
+ expect(readOrigin(meshReplace)).to.deep.equal([5, 10, 15]);
+ // composition none must interpolate identically. The setter reads tween _numbers, which
+ // composeComplexValue only refreshes when composition is not none, so the origin freezes at its from triplet.
+ const meshNone = createMesh();
+ animate(meshNone, { transformOrigin: ['0 0 0', '10 20 30'], duration: 100, ease: 'linear', autoplay: false, composition: 'none' }).seek(50);
+ expect(readOrigin(meshNone)).to.deep.equal([5, 10, 15]);
+ });
+
+});
diff --git a/tests/suites/timelines.test.js b/tests/suites/timelines.test.js
index 18509ca7..7974df61 100644
--- a/tests/suites/timelines.test.js
+++ b/tests/suites/timelines.test.js
@@ -760,6 +760,81 @@ suite('Timelines', () => {
});
+ test('Seek does not re-fire .call() when not crossing its position', () => {
+ let timer1Log = 0;
+ let timer2Log = 0;
+ let timer3Log = 0;
+ const tl = createTimeline({ autoplay: false })
+ .call(() => { timer1Log += 1; }, 0)
+ .call(() => { timer2Log += 1; }, 500)
+ .call(() => { timer3Log += 1; }, 1000);
+
+ tl.seek(600);
+ expect(timer1Log).to.equal(1);
+ expect(timer2Log).to.equal(1);
+ expect(timer3Log).to.equal(0);
+
+ tl.seek(550);
+ expect(timer2Log).to.equal(1);
+
+ tl.seek(540);
+ expect(timer2Log).to.equal(1);
+
+ tl.seek(501);
+ expect(timer2Log).to.equal(1);
+
+ tl.seek(800);
+ expect(timer2Log).to.equal(1);
+ expect(timer3Log).to.equal(0);
+
+ tl.seek(600);
+ expect(timer2Log).to.equal(1);
+ expect(timer3Log).to.equal(0);
+ });
+
+ test('Repeated seek to the same position does not re-fire .call()', () => {
+ let timer1Log = 0;
+ let timer2Log = 0;
+ const tl = createTimeline({ autoplay: false })
+ .call(() => { timer1Log += 1; }, 0)
+ .call(() => { timer2Log += 1; }, 500);
+
+ tl.seek(600);
+ expect(timer1Log).to.equal(1);
+ expect(timer2Log).to.equal(1);
+
+ tl.seek(600);
+ expect(timer1Log).to.equal(1);
+ expect(timer2Log).to.equal(1);
+
+ tl.seek(600);
+ expect(timer1Log).to.equal(1);
+ expect(timer2Log).to.equal(1);
+ });
+
+ test('Seek direction reversal past a .call() in the middle of a timeline does not re-fire it', () => {
+ const $target = /** @type {HTMLElement} */(document.querySelector('#target-id'));
+ let timer2Log = 0;
+ const tl = createTimeline({ autoplay: false })
+ .add($target, { x: 100, duration: 1000 }, 0)
+ .call(() => { timer2Log += 1; }, 500);
+
+ tl.seek(600);
+ expect(timer2Log).to.equal(1);
+
+ tl.seek(550);
+ expect(timer2Log).to.equal(1);
+
+ tl.seek(580);
+ expect(timer2Log).to.equal(1);
+
+ tl.seek(560);
+ expect(timer2Log).to.equal(1);
+
+ tl.seek(700);
+ expect(timer2Log).to.equal(1);
+ });
+
test('Call callbaks with alternate loops', () => {
let timer1Log = 0;
let timer2Log = 0;
@@ -986,5 +1061,132 @@ suite('Timelines', () => {
expect(call1Count).to.equal(2);
});
+ test('Backward seek through a sibling-chain timeline writes the active child value, not the stale to-value of an earlier past-end sibling', () => {
+ const target = { x: 0 };
+ const tl = createTimeline({ autoplay: false, loop: true, defaults: { duration: 1000, ease: 'linear' } })
+ .add(target, { x: 10 })
+ .add(target, { x: 20 })
+ .add(target, { x: 30 });
+ // Forward seek to mid of the last segment so siblings 0/1 become past-end.
+ tl.seek(3000.01);
+ expect(target.x).to.equal(0.0001);
+ // Backward seek (still inside last segment's range, but iteration order is now reversed). Without the fix, past-end siblings render at progress=1 in backward iteration order and segment 0 writes its to-value (10) last, masking the active segment's correct value.
+ tl.seek(3000);
+ expect(target.x).to.equal(0);
+ // Continue backward into the dead-zone of segment 0 (still past the end of segments 0 / 1 in a hypothetical longer chain, but here we just verify segment 0 wins legitimately).
+ tl.seek(2999.99);
+ expect(target.x).to.equal(29.9999);
+ });
+
+ test('Seek into the gap between a truncated child and a delayed child writes the hold value', () => {
+ const target = { x: 0 };
+ const tl = createTimeline({ autoplay: false })
+ .add(target, { x: { from: 0, to: 100, duration: 1000 }, ease: 'linear' }, 0)
+ .add(target, { x: { to: 200, duration: 500, delay: 300 }, ease: 'linear' }, 500);
+ tl.seek(400);
+ expect(target.x).to.equal(40);
+ // First forward entry into the gap left by the truncated first child
+ tl.seek(600);
+ expect(target.x).to.equal(50);
+ tl.seek(900);
+ expect(target.x).to.equal(80);
+ tl.seek(600);
+ expect(target.x).to.equal(50);
+ tl.seek(1300);
+ expect(target.x).to.equal(200);
+ tl.seek(650);
+ expect(target.x).to.equal(50);
+ tl.seek(400);
+ expect(target.x).to.equal(40);
+ tl.seek(0);
+ tl.seek(700);
+ expect(target.x).to.equal(50);
+ });
+
+ test('Backward seek before a negative delay sibling start restores the previous child end value', () => {
+ const targets = [{ y: 0 }, { y: 0 }, { y: 0 }];
+ const tl = createTimeline({ autoplay: false })
+ .add(targets, { y: { to: 1, duration: 100 }, ease: 'linear' }, 0)
+ .add(targets, { y: { to: 2, duration: 100, delay: (t, i) => [-50, 0, 300][i] }, ease: 'linear' }, 200);
+ expect(tl.duration).to.equal(600);
+ tl.seek(600);
+ expect(targets[0].y).to.equal(2);
+ expect(targets[1].y).to.equal(2);
+ expect(targets[2].y).to.equal(2);
+ // The last target tween spans 500 to 600, seeking back before its start must restore the first child end value
+ tl.seek(400);
+ expect(targets[0].y).to.equal(2);
+ expect(targets[1].y).to.equal(2);
+ expect(targets[2].y).to.equal(1);
+ tl.seek(175);
+ expect(targets[0].y).to.equal(1.25);
+ expect(targets[1].y).to.equal(1);
+ expect(targets[2].y).to.equal(1);
+ tl.seek(50);
+ expect(targets[0].y).to.equal(0.5);
+ expect(targets[1].y).to.equal(0.5);
+ expect(targets[2].y).to.equal(0.5);
+ tl.seek(550);
+ expect(targets[0].y).to.equal(2);
+ expect(targets[1].y).to.equal(2);
+ expect(targets[2].y).to.equal(1.5);
+ });
+
+ test('Backward seek re-entering an earlier child range keeps the active child value', () => {
+ const target = { v: 0 };
+ const tl = createTimeline({ autoplay: false })
+ .add(target, { v: [{ to: 1, duration: 100 }, { to: 2, duration: 100 }, { to: 3, duration: 200 }], ease: 'linear' }, 0)
+ .add(target, { v: { to: 4.5, duration: 300 }, ease: 'linear' }, 300);
+ expect(tl.duration).to.equal(600);
+ tl.seek(600);
+ expect(target.v).to.equal(4.5);
+ // The first child re-renders on backward re-entry, its keyframes must yield to the second child write
+ tl.seek(360);
+ expect(target.v).to.be.closeTo(2.9, 1e-12);
+ tl.seek(250);
+ expect(target.v).to.equal(2.25);
+ tl.seek(150);
+ expect(target.v).to.equal(1.5);
+ });
+
+ test('A past-end child whose delay exceeds its duration must not overwrite a later sibling on a forward seek', () => {
+ // The dot pop child animates to 14.5 by 1250, then holds it until the outro at 1600, so y is 14.5 across [1250,1600].
+ // The expand child has delay 300 greater than its 200 duration, so once past its end its iteration time equals its
+ // duration, which is below its delay. That used to re-trigger a render of the finished tween on a forward seek and
+ // overwrite dot pop's held value with expand's 0.75. A fresh seek was always correct, only a sequential seek broke.
+ const target = { y: 0 };
+ const tl = createTimeline({ autoplay: false })
+ .add(target, { y: [{ to: -2.5, duration: 150 }, { to: -2.53, duration: 150 }], ease: 'linear' }, 500)
+ .add(target, { y: { to: 0.75, duration: 200, delay: 300 }, ease: 'linear' }, 550)
+ .add(target, { y: { to: 14.5, duration: 150 }, ease: 'linear' }, 1100)
+ .add(target, { y: 5.5, duration: 200, ease: 'linear' }, 1600);
+ // Seek forward into the hold so the previous time is set, then step forward again across it.
+ tl.seek(1250);
+ expect(target.y).to.equal(14.5);
+ tl.seek(1300);
+ expect(target.y).to.equal(14.5);
+ tl.seek(1450);
+ expect(target.y).to.equal(14.5);
+ });
+
+ test('An implicit from chains from the latest live sibling, skipping an overridden mid-chain keyframe', () => {
+ // The dot pop child leaves y at 14.5 before the outro, so the outro's bare to value must start from 14.5.
+ // expand squeeze-overrides recover's last keyframe in place, so that keyframe sits overridden mid-chain before dot pop.
+ // The from walk must skip the overridden keyframe and reach dot pop, not stop at it and chain from the stale -2.5.
+ const target = { y: 0 };
+ const tl = createTimeline({ autoplay: false })
+ .add(target, { y: [{ to: -2.5, duration: 200 }, { to: -2.53, duration: 200 }], ease: 'linear' }, 1000)
+ .add(target, { y: { to: 0.75, duration: 2000, delay: 700 }, ease: 'linear' }, 1100)
+ .add(target, { y: { to: 14.5, duration: 200 }, ease: 'linear' }, 5000)
+ .add(target, { y: 5.5, duration: 200, ease: 'linear' }, 8000)
+ .init();
+ tl.seek(5200);
+ expect(target.y).to.equal(14.5); // dot pop landed, the live value before the outro
+ tl.seek(8000);
+ expect(target.y).to.equal(14.5); // outro starts continuous, the bug chained from the stale -2.5
+ tl.seek(8100);
+ expect(target.y).to.equal(10); // midpoint of 14.5 down to 5.5, the bug gives 1.5 from the snapped start
+ });
+
});
diff --git a/tests/suites/tweens.test.js b/tests/suites/tweens.test.js
index 8a5f6994..e830b88b 100644
--- a/tests/suites/tweens.test.js
+++ b/tests/suites/tweens.test.js
@@ -18,6 +18,8 @@ import {
valueTypes,
} from '../../dist/modules/core/consts.js';
+/** @import { Tween, JSAnimation } from '../../dist/modules/index.js' */
+
suite('Tweens', () => {
test('Single tween timings', () => {
const delay = 200;
@@ -476,8 +478,8 @@ suite('Tweens', () => {
delay: stagger(100),
}, '-=' + duration)
- const animA = /** @type {$Animation} */(tl._head._next._next._next._next._next._next);
- const animB = /** @type {$Animation} */(animA._next._next._next._next);
+ const animA = /** @type {JSAnimation} */(tl._head._next._next._next._next._next._next);
+ const animB = /** @type {JSAnimation} */(animA._next._next._next._next);
expect(animA._head._fromNumber).to.equal(75);
expect(animB._head._fromNumber).to.equal(50);
diff --git a/tests/suites/types.test.js b/tests/suites/types.test.js
index f4d32c2a..c7b5dfc1 100644
--- a/tests/suites/types.test.js
+++ b/tests/suites/types.test.js
@@ -1,4 +1,4 @@
-import { animate, createTimer, createTimeline, utils } from '../../dist/modules/index.js';
+import { animate, createTimer, createTimeline, utils, Timer, Timeline, JSAnimation } from '../../dist/modules/index.js';
animate('.anime-css', {
keyframes: {
@@ -35,7 +35,8 @@ const animation = animate('#target-id', {
b: 'string',
c0: (el) => el.dataset.index, // el should be of type target
c1: (el, i) => el.dataset.index + i,
- c2: (el, i, targets) => { targets.length - (el.dataset.index + i) }, // Should throw because not returing a valid value
+ // @ts-expect-error - returns void, not a valid tween value
+ c2: (el, i, targets) => { targets.length - (el.dataset.index + i) },
d: {
to: 100,
duration: 10,
@@ -89,11 +90,12 @@ const tl = createTimeline({
duration: 100
}
})
-.add('label', 10000)
+.label('label', 10000)
.add('#target-id', {
a: 100,
b: 'string',
- c: (el, i, targets) => { targets.length - (el.dataset.index + i) }, // Should throw
+ // @ts-expect-error - returns void, not a valid tween value
+ c: (el, i, targets) => { targets.length - (el.dataset.index + i) },
d: {
to: 100,
duration: 10,
@@ -135,15 +137,15 @@ const tl = createTimeline({
onLoop: self => console.log(self.currentTime),
onComplete: self => console.log(self.currentTime),
}, 10000)
-.add(self => {
+.call(self => {
console.log(self.currentTime)
}, 10000)
-/** @param {String} v */
+/** @param {JSAnimation} v */
animation.onComplete = (v) => v;
-/** @param {Animation} v */
+/** @param {Timer} v */
timer.onComplete = (v) => v;
/** @param {Timeline} v */
diff --git a/tests/suites/values.test.js b/tests/suites/values.test.js
index e6594a42..cca0c6e1 100644
--- a/tests/suites/values.test.js
+++ b/tests/suites/values.test.js
@@ -390,7 +390,9 @@ suite('Values', () => {
translateX: 100,
translateY: 100,
scale: 10,
- duration: 10
+ duration: 100,
+ autoplay: false,
+ ease: 'linear',
});
expect(utils.get($target, 'translateX')).to.equal('10px');
@@ -404,7 +406,9 @@ suite('Values', () => {
const $target = document.querySelector('#target-id');
const animation = animate($target, {
backgroundSize: ['auto 100%', 'auto 200%'],
- duration: 10
+ duration: 100,
+ autoplay: false,
+ ease: 'linear',
});
expect(getChildAtIndex(animation, 0)._valueType).to.equal(valueTypes.COMPLEX);
@@ -430,7 +434,9 @@ suite('Values', () => {
filter: 'blur(10px) contrast(200)',
translateX: 'calc(calc(15px * 2) - 42rem)',
zIndex: {to: 10, modifier: utils.round(1)},
- duration: 10
+ duration: 100,
+ autoplay: false,
+ ease: 'linear',
});
expect($target.style.zIndex).to.equal('0');
@@ -449,7 +455,9 @@ suite('Values', () => {
expect(getComputedStyle($target).getPropertyValue('--width')).to.equal('100px');
const animation = animate($target, {
'--width': 200,
- duration: 10
+ duration: 100,
+ autoplay: false,
+ ease: 'linear',
});
expect(getComputedStyle($target).getPropertyValue('--width')).to.equal('100px'); // Anime.js removes the first white space to get a simpler (number + unit) animation type instead of commplex type (string + number + string)
@@ -484,7 +492,9 @@ suite('Values', () => {
'--x': x2,
'--rx': rx2,
'--s': s2,
- duration: 10
+ duration: 100,
+ autoplay: false,
+ ease: 'linear',
});
animation.pause().seek(animation.duration);
@@ -504,7 +514,9 @@ suite('Values', () => {
$target.style.transform = 'translateX(100px)';
const animation = animate($target, {
translateX: {from: 50},
- duration: 10,
+ duration: 100,
+ autoplay: false,
+ ease: 'linear',
});
expect($target.style.transform).to.equal('translateX(50px)');
@@ -518,7 +530,9 @@ suite('Values', () => {
$target.style.transform = 'translateX(100px)';
const animation = animate($target, {
translateX: {from: 50, to: 150},
- duration: 10,
+ duration: 100,
+ autoplay: false,
+ ease: 'linear',
});
expect($target.style.transform).to.equal('translateX(50px)');
@@ -532,7 +546,9 @@ suite('Values', () => {
$target.style.transform = 'translateX(100px)';
const animation = animate($target, {
translateX: {from: 50, to: 0},
- duration: 10,
+ duration: 100,
+ autoplay: false,
+ ease: 'linear',
});
expect($target.style.transform).to.equal('translateX(50px)');
@@ -547,7 +563,9 @@ suite('Values', () => {
$target.style.transform = 'translateX(100px)';
const animation = animate($target, {
translateX: [50, 150],
- duration: 10,
+ duration: 100,
+ autoplay: false,
+ ease: 'linear',
});
expect($target.style.transform).to.equal('translateX(50px)');
@@ -564,7 +582,9 @@ suite('Values', () => {
translateX: '*=2.5', // 100px * 2.5 = '250px',
width: '-=20px', // 28 - 20 = '8px',
rotate: '+=2turn', // 0 + 2 = '2turn',
- duration: 10
+ duration: 100,
+ autoplay: false,
+ ease: 'linear',
});
expect(relativeEl.style.transform).to.equal('translateX(100px) rotate(0turn)');
@@ -585,7 +605,9 @@ suite('Values', () => {
translateX: { from: '*=2.5' },
width: { from: '-=20px' },
rotate: { from: '+=2turn' },
- duration: 10
+ duration: 100,
+ autoplay: false,
+ ease: 'linear',
});
expect(relativeEl.style.transform).to.equal('translateX(250px) rotate(4turn)');
@@ -606,7 +628,9 @@ suite('Values', () => {
translateX: ['*=2.5', 10], // Relative from value
width: [100, '-=20px'], // Relative to value
rotate: ['+=2turn', '-=1turn'], // Relative from and to values
- duration: 10
+ duration: 100,
+ autoplay: false,
+ ease: 'linear',
});
expect(relativeEl.style.transform).to.equal('translateX(250px) rotate(4turn)');
@@ -625,7 +649,8 @@ suite('Values', () => {
const animation = animate(relativeEl, {
translateX: [{to: '+=10'}, {to: '-=10'}],
rotate: [{from: '+=2turn', to: '-=1turn'}, {from: '+=5turn', to: '-=2turn'}],
- duration: 10,
+ duration: 100,
+ autoplay: false,
ease: 'linear',
});
@@ -638,4 +663,29 @@ suite('Values', () => {
expect(relativeEl.style.transform).to.equal('translateX(100px) rotate(6turn)');
});
+ test('Renders next keyframe at exact boundary when animation _offset has float rounding drift', () => {
+ /** @type {HTMLElement} */
+ const relativeEl = document.querySelector('#target-id');
+ relativeEl.style.transform = 'rotate(2turn)';
+ const animation = animate(relativeEl, {
+ rotate: [{from: '+=2turn', to: '-=1turn'}, {from: '+=5turn', to: '-=2turn'}],
+ duration: 100,
+ autoplay: false,
+ ease: 'linear',
+ });
+ // Reproduce the floating point drift that occurs in real runs when engine timing produces an _offset
+ // whose round-to-12-decimal value is strictly greater than the float itself. animation.js
+ // rounds _absoluteStartTime, render.js does not round absoluteTime, so the boundary check
+ // absoluteTime >= prev._absoluteStartTime + prev._changeDuration flips at the exact tween end.
+ const drifted = 0.49999999999999;
+ animation._offset = drifted;
+ let tween = animation._head;
+ while (tween) {
+ tween._absoluteStartTime = Math.round((drifted + tween._startTime) * 1e12) / 1e12;
+ tween = tween._next;
+ }
+ animation.seek(animation.duration * .5);
+ expect(relativeEl.style.transform).to.equal('rotate(8turn)');
+ });
+
});
diff --git a/tests/tsconfig.json b/tests/tsconfig.json
index 6137d41e..c0b6c765 100644
--- a/tests/tsconfig.json
+++ b/tests/tsconfig.json
@@ -6,5 +6,6 @@
"animejs": ["dist/modules/index.js"],
}
},
- "include": ["**/*.js"]
+ "include": ["**/*.js"],
+ "exclude": ["run.js", "suites/node.test.js", "suites/build.test.js", "playground/assets/**"]
}
\ No newline at end of file
diff --git a/tests/utils.js b/tests/utils.js
index 529d10e4..d46c8429 100644
--- a/tests/utils.js
+++ b/tests/utils.js
@@ -6,7 +6,7 @@ import {
forEachChildren,
} from '../dist/modules/core/helpers.js';
-export const { expect } = chai;
+export const { expect } = /** @type {any} */(globalThis).chai;
export const getChildAtIndex = (parent, index) => {
let next = parent._head;
diff --git a/tsconfig.json b/tsconfig.json
index 2b1dccf3..2fafb8a8 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,9 +1,9 @@
{
"compilerOptions": {
"lib": ["ESNext", "DOM"],
- "module": "ESNext",
+ "module": "esnext",
"target": "ESNext",
- "moduleResolution": "nodenext",
+ "moduleResolution": "bundler",
"allowJs": true,
"checkJs": true,
"noEmit": true