react-ts-tab-lib
Version:
A React Typescript library rendering a Table compenent receiving in props for rows an array of a generic type T (precised when using the component) and for columns an array of objects of type Column<T> precising the displayName, the key of the T type and
1,522 lines • 83.5 kB
JavaScript
import { f as ne, w as Ke, a as D, r as Mt, t as Pt, b as Cn, i as R, o as Fn, n as X, c as Ne, d as Ct, e as U, p as be, g as Dn, h as Ft, j as Be, k as Z, l as En, v as In, m as Rn, q as ae, s as Te, u as le, x as Dt, y as Et, z as It, A as Ze, B as Rt, C as On, D as Kn, E as Nn, F as Je, G as Bn, H as kn, I as Ln, J as _n, K as Gn, L as Un, M as $n, N as jn, O as qn, P as zn, Q as Hn, R as Wn } from "./index-BV6rn10c.js";
import { Fragment as Yn } from "react";
function Xn(t, e) {
t.indexOf(e) === -1 && t.push(e);
}
function Zn(t, e) {
const n = t.indexOf(e);
n > -1 && t.splice(n, 1);
}
const Jn = {
useManualTiming: !1
};
// @__NO_SIDE_EFFECTS__
function ke(t) {
let e;
return () => (e === void 0 && (e = t()), e);
}
const Le = /* @__NO_SIDE_EFFECTS__ */ (t, e, n) => {
const s = e - t;
return s === 0 ? 1 : (n - t) / s;
};
class Ot {
constructor() {
this.subscriptions = [];
}
add(e) {
return Xn(this.subscriptions, e), () => Zn(this.subscriptions, e);
}
notify(e, n, s) {
const i = this.subscriptions.length;
if (i)
if (i === 1)
this.subscriptions[0](e, n, s);
else
for (let r = 0; r < i; r++) {
const o = this.subscriptions[r];
o && o(e, n, s);
}
}
getSize() {
return this.subscriptions.length;
}
clear() {
this.subscriptions.length = 0;
}
}
const I = /* @__NO_SIDE_EFFECTS__ */ (t) => t * 1e3, O = /* @__NO_SIDE_EFFECTS__ */ (t) => t / 1e3;
function Kt(t, e) {
return e ? t * (1e3 / e) : 0;
}
const Qn = /* @__PURE__ */ ke(() => window.ScrollTimeline !== void 0);
class es {
constructor(e) {
this.stop = () => this.runAll("stop"), this.animations = e.filter(Boolean);
}
get finished() {
return Promise.all(this.animations.map((e) => "finished" in e ? e.finished : e));
}
/**
* TODO: Filter out cancelled or stopped animations before returning
*/
getAll(e) {
return this.animations[0][e];
}
setAll(e, n) {
for (let s = 0; s < this.animations.length; s++)
this.animations[s][e] = n;
}
attachTimeline(e, n) {
const s = this.animations.map((i) => {
if (Qn() && i.attachTimeline)
return i.attachTimeline(e);
if (typeof n == "function")
return n(i);
});
return () => {
s.forEach((i, r) => {
i && i(), this.animations[r].stop();
});
};
}
get time() {
return this.getAll("time");
}
set time(e) {
this.setAll("time", e);
}
get speed() {
return this.getAll("speed");
}
set speed(e) {
this.setAll("speed", e);
}
get startTime() {
return this.getAll("startTime");
}
get duration() {
let e = 0;
for (let n = 0; n < this.animations.length; n++)
e = Math.max(e, this.animations[n].duration);
return e;
}
runAll(e) {
this.animations.forEach((n) => n[e]());
}
flatten() {
this.runAll("flatten");
}
play() {
this.runAll("play");
}
pause() {
this.runAll("pause");
}
cancel() {
this.runAll("cancel");
}
complete() {
this.runAll("complete");
}
}
class ts extends es {
then(e, n) {
return Promise.all(this.animations).then(e).catch(n);
}
}
function Nt(t, e) {
return t ? t[e] || t.default || t : void 0;
}
const Ve = 2e4;
function Bt(t) {
let e = 0;
const n = 50;
let s = t.next(e);
for (; !s.done && e < Ve; )
e += n, s = t.next(e);
return e >= Ve ? 1 / 0 : e;
}
function _e(t) {
return typeof t == "function";
}
function Qe(t, e) {
t.timeline = e, t.onfinish = null;
}
const Ge = (t) => Array.isArray(t) && typeof t[0] == "number", ns = {
linearEasing: void 0
};
function ss(t, e) {
const n = /* @__PURE__ */ ke(t);
return () => {
var s;
return (s = ns[e]) !== null && s !== void 0 ? s : n();
};
}
const se = /* @__PURE__ */ ss(() => {
try {
document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" });
} catch {
return !1;
}
return !0;
}, "linearEasing"), kt = (t, e, n = 10) => {
let s = "";
const i = Math.max(Math.round(e / n), 2);
for (let r = 0; r < i; r++)
s += t(/* @__PURE__ */ Le(0, i - 1, r)) + ", ";
return `linear(${s.substring(0, s.length - 2)})`;
};
function Lt(t) {
return !!(typeof t == "function" && se() || !t || typeof t == "string" && (t in Ae || se()) || Ge(t) || Array.isArray(t) && t.every(Lt));
}
const z = ([t, e, n, s]) => `cubic-bezier(${t}, ${e}, ${n}, ${s})`, Ae = {
linear: "linear",
ease: "ease",
easeIn: "ease-in",
easeOut: "ease-out",
easeInOut: "ease-in-out",
circIn: /* @__PURE__ */ z([0, 0.65, 0.55, 1]),
circOut: /* @__PURE__ */ z([0.55, 0, 1, 0.45]),
backIn: /* @__PURE__ */ z([0.31, 0.01, 0.66, -0.59]),
backOut: /* @__PURE__ */ z([0.33, 1.53, 0.69, 0.99])
};
function _t(t, e) {
if (t)
return typeof t == "function" && se() ? kt(t, e) : Ge(t) ? z(t) : Array.isArray(t) ? t.map((n) => _t(n, e) || Ae.easeOut) : Ae[t];
}
let te;
function is() {
te = void 0;
}
const K = {
now: () => (te === void 0 && K.set(ne.isProcessing || Jn.useManualTiming ? ne.timestamp : performance.now()), te),
set: (t) => {
te = t, queueMicrotask(is);
}
}, rs = {
y: !1
};
function os() {
return rs.y;
}
function as(t, e, n) {
var s;
if (t instanceof EventTarget)
return [t];
if (typeof t == "string") {
let i = document;
const r = (s = void 0) !== null && s !== void 0 ? s : i.querySelectorAll(t);
return r ? Array.from(r) : [];
}
return Array.from(t);
}
function Gt(t, e) {
const n = as(t), s = new AbortController(), i = {
passive: !0,
...e,
signal: s.signal
};
return [n, i, () => s.abort()];
}
function et(t) {
return !(t.pointerType === "touch" || os());
}
function ls(t, e, n = {}) {
const [s, i, r] = Gt(t, n), o = (a) => {
if (!et(a))
return;
const { target: l } = a, u = e(l, a);
if (typeof u != "function" || !l)
return;
const c = (h) => {
et(h) && (u(h), l.removeEventListener("pointerleave", c));
};
l.addEventListener("pointerleave", c, i);
};
return s.forEach((a) => {
a.addEventListener("pointerenter", o, i);
}), r;
}
const Ut = (t, e) => e ? t === e ? !0 : Ut(t, e.parentElement) : !1, us = (t) => t.pointerType === "mouse" ? typeof t.button != "number" || t.button <= 0 : t.isPrimary !== !1, cs = /* @__PURE__ */ new Set([
"BUTTON",
"INPUT",
"SELECT",
"TEXTAREA",
"A"
]);
function hs(t) {
return cs.has(t.tagName) || t.tabIndex !== -1;
}
const H = /* @__PURE__ */ new WeakSet();
function tt(t) {
return (e) => {
e.key === "Enter" && t(e);
};
}
function pe(t, e) {
t.dispatchEvent(new PointerEvent("pointer" + e, { isPrimary: !0, bubbles: !0 }));
}
const ds = (t, e) => {
const n = t.currentTarget;
if (!n)
return;
const s = tt(() => {
if (H.has(n))
return;
pe(n, "down");
const i = tt(() => {
pe(n, "up");
}), r = () => pe(n, "cancel");
n.addEventListener("keyup", i, e), n.addEventListener("blur", r, e);
});
n.addEventListener("keydown", s, e), n.addEventListener("blur", () => n.removeEventListener("keydown", s), e);
};
function nt(t) {
return us(t) && !0;
}
function fs(t, e, n = {}) {
const [s, i, r] = Gt(t, n), o = (a) => {
const l = a.currentTarget;
if (!nt(a) || H.has(l))
return;
H.add(l);
const u = e(l, a), c = (f, b) => {
window.removeEventListener("pointerup", h), window.removeEventListener("pointercancel", d), !(!nt(f) || !H.has(l)) && (H.delete(l), typeof u == "function" && u(f, { success: b }));
}, h = (f) => {
c(f, l === window || l === document || n.useGlobalTarget || Ut(l, f.target));
}, d = (f) => {
c(f, !1);
};
window.addEventListener("pointerup", h, i), window.addEventListener("pointercancel", d, i);
};
return s.forEach((a) => {
(n.useGlobalTarget ? window : a).addEventListener("pointerdown", o, i), a instanceof HTMLElement && (a.addEventListener("focus", (u) => ds(u, i)), !hs(a) && a.tabIndex === null && (a.tabIndex = 0));
}), r;
}
const st = 30, ps = (t) => !isNaN(parseFloat(t));
class ms {
/**
* @param init - The initiating value
* @param config - Optional configuration options
*
* - `transformer`: A function to transform incoming values with.
*/
constructor(e, n = {}) {
this.version = "12.6.1", this.canTrackVelocity = null, this.events = {}, this.updateAndNotify = (s, i = !0) => {
const r = K.now();
this.updatedAt !== r && this.setPrevFrameValue(), this.prev = this.current, this.setCurrent(s), this.current !== this.prev && this.events.change && this.events.change.notify(this.current), i && this.events.renderRequest && this.events.renderRequest.notify(this.current);
}, this.hasAnimated = !1, this.setCurrent(e), this.owner = n.owner;
}
setCurrent(e) {
this.current = e, this.updatedAt = K.now(), this.canTrackVelocity === null && e !== void 0 && (this.canTrackVelocity = ps(this.current));
}
setPrevFrameValue(e = this.current) {
this.prevFrameValue = e, this.prevUpdatedAt = this.updatedAt;
}
/**
* Adds a function that will be notified when the `MotionValue` is updated.
*
* It returns a function that, when called, will cancel the subscription.
*
* When calling `onChange` inside a React component, it should be wrapped with the
* `useEffect` hook. As it returns an unsubscribe function, this should be returned
* from the `useEffect` function to ensure you don't add duplicate subscribers..
*
* ```jsx
* export const MyComponent = () => {
* const x = useMotionValue(0)
* const y = useMotionValue(0)
* const opacity = useMotionValue(1)
*
* useEffect(() => {
* function updateOpacity() {
* const maxXY = Math.max(x.get(), y.get())
* const newOpacity = transform(maxXY, [0, 100], [1, 0])
* opacity.set(newOpacity)
* }
*
* const unsubscribeX = x.on("change", updateOpacity)
* const unsubscribeY = y.on("change", updateOpacity)
*
* return () => {
* unsubscribeX()
* unsubscribeY()
* }
* }, [])
*
* return <motion.div style={{ x }} />
* }
* ```
*
* @param subscriber - A function that receives the latest value.
* @returns A function that, when called, will cancel this subscription.
*
* @deprecated
*/
onChange(e) {
return process.env.NODE_ENV !== "production" && Ke(!1, 'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'), this.on("change", e);
}
on(e, n) {
this.events[e] || (this.events[e] = new Ot());
const s = this.events[e].add(n);
return e === "change" ? () => {
s(), D.read(() => {
this.events.change.getSize() || this.stop();
});
} : s;
}
clearListeners() {
for (const e in this.events)
this.events[e].clear();
}
/**
* Attaches a passive effect to the `MotionValue`.
*/
attach(e, n) {
this.passiveEffect = e, this.stopPassiveEffect = n;
}
/**
* Sets the state of the `MotionValue`.
*
* @remarks
*
* ```jsx
* const x = useMotionValue(0)
* x.set(10)
* ```
*
* @param latest - Latest value to set.
* @param render - Whether to notify render subscribers. Defaults to `true`
*
* @public
*/
set(e, n = !0) {
!n || !this.passiveEffect ? this.updateAndNotify(e, n) : this.passiveEffect(e, this.updateAndNotify);
}
setWithVelocity(e, n, s) {
this.set(n), this.prev = void 0, this.prevFrameValue = e, this.prevUpdatedAt = this.updatedAt - s;
}
/**
* Set the state of the `MotionValue`, stopping any active animations,
* effects, and resets velocity to `0`.
*/
jump(e, n = !0) {
this.updateAndNotify(e), this.prev = e, this.prevUpdatedAt = this.prevFrameValue = void 0, n && this.stop(), this.stopPassiveEffect && this.stopPassiveEffect();
}
/**
* Returns the latest state of `MotionValue`
*
* @returns - The latest state of `MotionValue`
*
* @public
*/
get() {
return this.current;
}
/**
* @public
*/
getPrevious() {
return this.prev;
}
/**
* Returns the latest velocity of `MotionValue`
*
* @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
*
* @public
*/
getVelocity() {
const e = K.now();
if (!this.canTrackVelocity || this.prevFrameValue === void 0 || e - this.updatedAt > st)
return 0;
const n = Math.min(this.updatedAt - this.prevUpdatedAt, st);
return Kt(parseFloat(this.current) - parseFloat(this.prevFrameValue), n);
}
/**
* Registers a new animation to control this `MotionValue`. Only one
* animation can drive a `MotionValue` at one time.
*
* ```jsx
* value.start()
* ```
*
* @param animation - A function that starts the provided animation
*/
start(e) {
return this.stop(), new Promise((n) => {
this.hasAnimated = !0, this.animation = e(n), this.events.animationStart && this.events.animationStart.notify();
}).then(() => {
this.events.animationComplete && this.events.animationComplete.notify(), this.clearAnimation();
});
}
/**
* Stop the currently active animation.
*
* @public
*/
stop() {
this.animation && (this.animation.stop(), this.events.animationCancel && this.events.animationCancel.notify()), this.clearAnimation();
}
/**
* Returns `true` if this value is currently animating.
*
* @public
*/
isAnimating() {
return !!this.animation;
}
clearAnimation() {
delete this.animation;
}
/**
* Destroy and clean up subscribers to this `MotionValue`.
*
* The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
* handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
* created a `MotionValue` via the `motionValue` function.
*
* @public
*/
destroy() {
this.clearListeners(), this.stop(), this.stopPassiveEffect && this.stopPassiveEffect();
}
}
function ie(t, e) {
return new ms(t, e);
}
function J(t, e, n) {
const s = t.getProps();
return Mt(s, e, n !== void 0 ? n : s.custom, t);
}
const $t = /* @__PURE__ */ new Set([
"width",
"height",
"top",
"left",
"right",
"bottom",
...Pt
]);
function gs(t, e, n) {
t.hasValue(e) ? t.getValue(e).set(n) : t.addValue(e, ie(n));
}
function ys(t, e) {
const n = J(t, e);
let { transitionEnd: s = {}, transition: i = {}, ...r } = n || {};
r = { ...r, ...s };
for (const o in r) {
const a = Cn(r[o]);
gs(t, o, a);
}
}
function vs(t) {
return !!(R(t) && t.add);
}
function bs(t, e) {
const n = t.getValue("willChange");
if (vs(n))
return n.add(e);
}
function Ts(t) {
return t.props[Fn];
}
const jt = (t, e, n) => (((1 - 3 * n + 3 * e) * t + (3 * n - 6 * e)) * t + 3 * e) * t, Vs = 1e-7, As = 12;
function Ss(t, e, n, s, i) {
let r, o, a = 0;
do
o = e + (n - e) / 2, r = jt(o, s, i) - t, r > 0 ? n = o : e = o;
while (Math.abs(r) > Vs && ++a < As);
return o;
}
function ee(t, e, n, s) {
if (t === e && n === s)
return X;
const i = (r) => Ss(r, 0, 1, t, n);
return (r) => r === 0 || r === 1 ? r : jt(i(r), e, s);
}
const qt = (t) => (e) => e <= 0.5 ? t(2 * e) / 2 : (2 - t(2 * (1 - e))) / 2, zt = (t) => (e) => 1 - t(1 - e), Ht = /* @__PURE__ */ ee(0.33, 1.53, 0.69, 0.99), Ue = /* @__PURE__ */ zt(Ht), Wt = /* @__PURE__ */ qt(Ue), Yt = (t) => (t *= 2) < 1 ? 0.5 * Ue(t) : 0.5 * (2 - Math.pow(2, -10 * (t - 1))), $e = (t) => 1 - Math.sin(Math.acos(t)), ws = zt($e), Xt = qt($e), Zt = (t) => /^0[^.\s]+$/u.test(t);
function xs(t) {
return typeof t == "number" ? t === 0 : t !== null ? t === "none" || t === "0" || Zt(t) : !0;
}
const W = (t) => Math.round(t * 1e5) / 1e5, je = /-?(?:\d+(?:\.\d+)?|\.\d+)/gu;
function Ms(t) {
return t == null;
}
const Ps = /^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu, qe = (t, e) => (n) => !!(typeof n == "string" && Ps.test(n) && n.startsWith(t) || e && !Ms(n) && Object.prototype.hasOwnProperty.call(n, e)), Jt = (t, e, n) => (s) => {
if (typeof s != "string")
return s;
const [i, r, o, a] = s.match(je);
return {
[t]: parseFloat(i),
[e]: parseFloat(r),
[n]: parseFloat(o),
alpha: a !== void 0 ? parseFloat(a) : 1
};
}, Cs = (t) => U(0, 255, t), me = {
...Ne,
transform: (t) => Math.round(Cs(t))
}, B = {
test: /* @__PURE__ */ qe("rgb", "red"),
parse: /* @__PURE__ */ Jt("red", "green", "blue"),
transform: ({ red: t, green: e, blue: n, alpha: s = 1 }) => "rgba(" + me.transform(t) + ", " + me.transform(e) + ", " + me.transform(n) + ", " + W(Ct.transform(s)) + ")"
};
function Fs(t) {
let e = "", n = "", s = "", i = "";
return t.length > 5 ? (e = t.substring(1, 3), n = t.substring(3, 5), s = t.substring(5, 7), i = t.substring(7, 9)) : (e = t.substring(1, 2), n = t.substring(2, 3), s = t.substring(3, 4), i = t.substring(4, 5), e += e, n += n, s += s, i += i), {
red: parseInt(e, 16),
green: parseInt(n, 16),
blue: parseInt(s, 16),
alpha: i ? parseInt(i, 16) / 255 : 1
};
}
const Se = {
test: /* @__PURE__ */ qe("#"),
parse: Fs,
transform: B.transform
}, G = {
test: /* @__PURE__ */ qe("hsl", "hue"),
parse: /* @__PURE__ */ Jt("hue", "saturation", "lightness"),
transform: ({ hue: t, saturation: e, lightness: n, alpha: s = 1 }) => "hsla(" + Math.round(t) + ", " + be.transform(W(e)) + ", " + be.transform(W(n)) + ", " + W(Ct.transform(s)) + ")"
}, x = {
test: (t) => B.test(t) || Se.test(t) || G.test(t),
parse: (t) => B.test(t) ? B.parse(t) : G.test(t) ? G.parse(t) : Se.parse(t),
transform: (t) => typeof t == "string" ? t : t.hasOwnProperty("red") ? B.transform(t) : G.transform(t)
}, Ds = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
function Es(t) {
var e, n;
return isNaN(t) && typeof t == "string" && (((e = t.match(je)) === null || e === void 0 ? void 0 : e.length) || 0) + (((n = t.match(Ds)) === null || n === void 0 ? void 0 : n.length) || 0) > 0;
}
const Qt = "number", en = "color", Is = "var", Rs = "var(", it = "${}", Os = /var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;
function Q(t) {
const e = t.toString(), n = [], s = {
color: [],
number: [],
var: []
}, i = [];
let r = 0;
const a = e.replace(Os, (l) => (x.test(l) ? (s.color.push(r), i.push(en), n.push(x.parse(l))) : l.startsWith(Rs) ? (s.var.push(r), i.push(Is), n.push(l)) : (s.number.push(r), i.push(Qt), n.push(parseFloat(l))), ++r, it)).split(it);
return { values: n, split: a, indexes: s, types: i };
}
function tn(t) {
return Q(t).values;
}
function nn(t) {
const { split: e, types: n } = Q(t), s = e.length;
return (i) => {
let r = "";
for (let o = 0; o < s; o++)
if (r += e[o], i[o] !== void 0) {
const a = n[o];
a === Qt ? r += W(i[o]) : a === en ? r += x.transform(i[o]) : r += i[o];
}
return r;
};
}
const Ks = (t) => typeof t == "number" ? 0 : t;
function Ns(t) {
const e = tn(t);
return nn(t)(e.map(Ks));
}
const j = {
test: Es,
parse: tn,
createTransformer: nn,
getAnimatableNone: Ns
}, Bs = /* @__PURE__ */ new Set(["brightness", "contrast", "saturate", "opacity"]);
function ks(t) {
const [e, n] = t.slice(0, -1).split("(");
if (e === "drop-shadow")
return t;
const [s] = n.match(je) || [];
if (!s)
return t;
const i = n.replace(s, "");
let r = Bs.has(e) ? 1 : 0;
return s !== n && (r *= 100), e + "(" + r + i + ")";
}
const Ls = /\b([a-z-]*)\(.*?\)/gu, we = {
...j,
getAnimatableNone: (t) => {
const e = t.match(Ls);
return e ? e.map(ks).join(" ") : t;
}
}, _s = {
...Dn,
// Color props
color: x,
backgroundColor: x,
outlineColor: x,
fill: x,
stroke: x,
// Border props
borderColor: x,
borderTopColor: x,
borderRightColor: x,
borderBottomColor: x,
borderLeftColor: x,
filter: we,
WebkitFilter: we
}, sn = (t) => _s[t];
function rn(t, e) {
let n = sn(t);
return n !== we && (n = j), n.getAnimatableNone ? n.getAnimatableNone(e) : void 0;
}
const Gs = /* @__PURE__ */ new Set(["auto", "none", "0"]);
function Us(t, e, n) {
let s = 0, i;
for (; s < t.length && !i; ) {
const r = t[s];
typeof r == "string" && !Gs.has(r) && Q(r).values.length && (i = t[s]), s++;
}
if (i && n)
for (const r of e)
t[r] = rn(n, i);
}
const k = (t) => t * 180 / Math.PI, xe = (t) => {
const e = k(Math.atan2(t[1], t[0]));
return Me(e);
}, $s = {
x: 4,
y: 5,
translateX: 4,
translateY: 5,
scaleX: 0,
scaleY: 3,
scale: (t) => (Math.abs(t[0]) + Math.abs(t[3])) / 2,
rotate: xe,
rotateZ: xe,
skewX: (t) => k(Math.atan(t[1])),
skewY: (t) => k(Math.atan(t[2])),
skew: (t) => (Math.abs(t[1]) + Math.abs(t[2])) / 2
}, Me = (t) => (t = t % 360, t < 0 && (t += 360), t), rt = xe, ot = (t) => Math.sqrt(t[0] * t[0] + t[1] * t[1]), at = (t) => Math.sqrt(t[4] * t[4] + t[5] * t[5]), js = {
x: 12,
y: 13,
z: 14,
translateX: 12,
translateY: 13,
translateZ: 14,
scaleX: ot,
scaleY: at,
scale: (t) => (ot(t) + at(t)) / 2,
rotateX: (t) => Me(k(Math.atan2(t[6], t[5]))),
rotateY: (t) => Me(k(Math.atan2(-t[2], t[0]))),
rotateZ: rt,
rotate: rt,
skewX: (t) => k(Math.atan(t[4])),
skewY: (t) => k(Math.atan(t[1])),
skew: (t) => (Math.abs(t[1]) + Math.abs(t[4])) / 2
};
function lt(t) {
return t.includes("scale") ? 1 : 0;
}
function Pe(t, e) {
if (!t || t === "none")
return lt(e);
const n = t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);
let s, i;
if (n)
s = js, i = n;
else {
const a = t.match(/^matrix\(([-\d.e\s,]+)\)$/u);
s = $s, i = a;
}
if (!i)
return lt(e);
const r = s[e], o = i[1].split(",").map(zs);
return typeof r == "function" ? r(o) : o[r];
}
const qs = (t, e) => {
const { transform: n = "none" } = getComputedStyle(t);
return Pe(n, e);
};
function zs(t) {
return parseFloat(t.trim());
}
const ut = (t) => t === Ne || t === Ft, Hs = /* @__PURE__ */ new Set(["x", "y", "z"]), Ws = Pt.filter((t) => !Hs.has(t));
function Ys(t) {
const e = [];
return Ws.forEach((n) => {
const s = t.getValue(n);
s !== void 0 && (e.push([n, s.get()]), s.set(n.startsWith("scale") ? 1 : 0));
}), e;
}
const $ = {
// Dimensions
width: ({ x: t }, { paddingLeft: e = "0", paddingRight: n = "0" }) => t.max - t.min - parseFloat(e) - parseFloat(n),
height: ({ y: t }, { paddingTop: e = "0", paddingBottom: n = "0" }) => t.max - t.min - parseFloat(e) - parseFloat(n),
top: (t, { top: e }) => parseFloat(e),
left: (t, { left: e }) => parseFloat(e),
bottom: ({ y: t }, { top: e }) => parseFloat(e) + (t.max - t.min),
right: ({ x: t }, { left: e }) => parseFloat(e) + (t.max - t.min),
// Transform
x: (t, { transform: e }) => Pe(e, "x"),
y: (t, { transform: e }) => Pe(e, "y")
};
$.translateX = $.x;
$.translateY = $.y;
const L = /* @__PURE__ */ new Set();
let Ce = !1, Fe = !1;
function on() {
if (Fe) {
const t = Array.from(L).filter((s) => s.needsMeasurement), e = new Set(t.map((s) => s.element)), n = /* @__PURE__ */ new Map();
e.forEach((s) => {
const i = Ys(s);
i.length && (n.set(s, i), s.render());
}), t.forEach((s) => s.measureInitialState()), e.forEach((s) => {
s.render();
const i = n.get(s);
i && i.forEach(([r, o]) => {
var a;
(a = s.getValue(r)) === null || a === void 0 || a.set(o);
});
}), t.forEach((s) => s.measureEndState()), t.forEach((s) => {
s.suspendedScrollY !== void 0 && window.scrollTo(0, s.suspendedScrollY);
});
}
Fe = !1, Ce = !1, L.forEach((t) => t.complete()), L.clear();
}
function an() {
L.forEach((t) => {
t.readKeyframes(), t.needsMeasurement && (Fe = !0);
});
}
function Xs() {
an(), on();
}
class ze {
constructor(e, n, s, i, r, o = !1) {
this.isComplete = !1, this.isAsync = !1, this.needsMeasurement = !1, this.isScheduled = !1, this.unresolvedKeyframes = [...e], this.onComplete = n, this.name = s, this.motionValue = i, this.element = r, this.isAsync = o;
}
scheduleResolve() {
this.isScheduled = !0, this.isAsync ? (L.add(this), Ce || (Ce = !0, D.read(an), D.resolveKeyframes(on))) : (this.readKeyframes(), this.complete());
}
readKeyframes() {
const { unresolvedKeyframes: e, name: n, element: s, motionValue: i } = this;
for (let r = 0; r < e.length; r++)
if (e[r] === null)
if (r === 0) {
const o = i == null ? void 0 : i.get(), a = e[e.length - 1];
if (o !== void 0)
e[0] = o;
else if (s && n) {
const l = s.readValue(n, a);
l != null && (e[0] = l);
}
e[0] === void 0 && (e[0] = a), i && o === void 0 && i.set(e[0]);
} else
e[r] = e[r - 1];
}
setFinalKeyframe() {
}
measureInitialState() {
}
renderEndStyles() {
}
measureEndState() {
}
complete() {
this.isComplete = !0, this.onComplete(this.unresolvedKeyframes, this.finalKeyframe), L.delete(this);
}
cancel() {
this.isComplete || (this.isScheduled = !1, L.delete(this));
}
resume() {
this.isComplete || this.scheduleResolve();
}
}
const ln = (t) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t), Zs = (
// eslint-disable-next-line redos-detector/no-unsafe-regex -- false positive, as it can match a lot of words
/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u
);
function Js(t) {
const e = Zs.exec(t);
if (!e)
return [,];
const [, n, s, i] = e;
return [`--${n ?? s}`, i];
}
const Qs = 4;
function un(t, e, n = 1) {
Z(n <= Qs, `Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`);
const [s, i] = Js(t);
if (!s)
return;
const r = window.getComputedStyle(e).getPropertyValue(s);
if (r) {
const o = r.trim();
return ln(o) ? parseFloat(o) : o;
}
return Be(i) ? un(i, e, n + 1) : i;
}
const cn = (t) => (e) => e.test(t), ei = {
test: (t) => t === "auto",
parse: (t) => t
}, hn = [Ne, Ft, be, En, In, Rn, ei], ct = (t) => hn.find(cn(t));
class dn extends ze {
constructor(e, n, s, i, r) {
super(e, n, s, i, r, !0);
}
readKeyframes() {
const { unresolvedKeyframes: e, element: n, name: s } = this;
if (!n || !n.current)
return;
super.readKeyframes();
for (let l = 0; l < e.length; l++) {
let u = e[l];
if (typeof u == "string" && (u = u.trim(), Be(u))) {
const c = un(u, n.current);
c !== void 0 && (e[l] = c), l === e.length - 1 && (this.finalKeyframe = u);
}
}
if (this.resolveNoneKeyframes(), !$t.has(s) || e.length !== 2)
return;
const [i, r] = e, o = ct(i), a = ct(r);
if (o !== a)
if (ut(o) && ut(a))
for (let l = 0; l < e.length; l++) {
const u = e[l];
typeof u == "string" && (e[l] = parseFloat(u));
}
else
this.needsMeasurement = !0;
}
resolveNoneKeyframes() {
const { unresolvedKeyframes: e, name: n } = this, s = [];
for (let i = 0; i < e.length; i++)
xs(e[i]) && s.push(i);
s.length && Us(e, s, n);
}
measureInitialState() {
const { element: e, unresolvedKeyframes: n, name: s } = this;
if (!e || !e.current)
return;
s === "height" && (this.suspendedScrollY = window.pageYOffset), this.measuredOrigin = $[s](e.measureViewportBox(), window.getComputedStyle(e.current)), n[0] = this.measuredOrigin;
const i = n[n.length - 1];
i !== void 0 && e.getValue(s, i).jump(i, !1);
}
measureEndState() {
var e;
const { element: n, name: s, unresolvedKeyframes: i } = this;
if (!n || !n.current)
return;
const r = n.getValue(s);
r && r.jump(this.measuredOrigin, !1);
const o = i.length - 1, a = i[o];
i[o] = $[s](n.measureViewportBox(), window.getComputedStyle(n.current)), a !== null && this.finalKeyframe === void 0 && (this.finalKeyframe = a), !((e = this.removedTransforms) === null || e === void 0) && e.length && this.removedTransforms.forEach(([l, u]) => {
n.getValue(l).set(u);
}), this.resolveNoneKeyframes();
}
}
const ht = (t, e) => e === "zIndex" ? !1 : !!(typeof t == "number" || Array.isArray(t) || typeof t == "string" && // It's animatable if we have a string
(j.test(t) || t === "0") && // And it contains numbers and/or colors
!t.startsWith("url("));
function ti(t) {
const e = t[0];
if (t.length === 1)
return !0;
for (let n = 0; n < t.length; n++)
if (t[n] !== e)
return !0;
}
function ni(t, e, n, s) {
const i = t[0];
if (i === null)
return !1;
if (e === "display" || e === "visibility")
return !0;
const r = t[t.length - 1], o = ht(i, e), a = ht(r, e);
return ae(o === a, `You are trying to animate ${e} from "${i}" to "${r}". ${i} is not an animatable value - to enable this animation set ${i} to a value animatable to ${r} via the \`style\` property.`), !o || !a ? !1 : ti(t) || (n === "spring" || _e(n)) && s;
}
const si = (t) => t !== null;
function ue(t, { repeat: e, repeatType: n = "loop" }, s) {
const i = t.filter(si), r = e && n !== "loop" && e % 2 === 1 ? 0 : i.length - 1;
return !r || s === void 0 ? i[r] : s;
}
const ii = 40;
class fn {
constructor({ autoplay: e = !0, delay: n = 0, type: s = "keyframes", repeat: i = 0, repeatDelay: r = 0, repeatType: o = "loop", ...a }) {
this.isStopped = !1, this.hasAttemptedResolve = !1, this.createdAt = K.now(), this.options = {
autoplay: e,
delay: n,
type: s,
repeat: i,
repeatDelay: r,
repeatType: o,
...a
}, this.updateFinishedPromise();
}
/**
* This method uses the createdAt and resolvedAt to calculate the
* animation startTime. *Ideally*, we would use the createdAt time as t=0
* as the following frame would then be the first frame of the animation in
* progress, which would feel snappier.
*
* However, if there's a delay (main thread work) between the creation of
* the animation and the first commited frame, we prefer to use resolvedAt
* to avoid a sudden jump into the animation.
*/
calcStartTime() {
return this.resolvedAt ? this.resolvedAt - this.createdAt > ii ? this.resolvedAt : this.createdAt : this.createdAt;
}
/**
* A getter for resolved data. If keyframes are not yet resolved, accessing
* this.resolved will synchronously flush all pending keyframe resolvers.
* This is a deoptimisation, but at its worst still batches read/writes.
*/
get resolved() {
return !this._resolved && !this.hasAttemptedResolve && Xs(), this._resolved;
}
/**
* A method to be called when the keyframes resolver completes. This method
* will check if its possible to run the animation and, if not, skip it.
* Otherwise, it will call initPlayback on the implementing class.
*/
onKeyframesResolved(e, n) {
this.resolvedAt = K.now(), this.hasAttemptedResolve = !0;
const { name: s, type: i, velocity: r, delay: o, onComplete: a, onUpdate: l, isGenerator: u } = this.options;
if (!u && !ni(e, s, i, r))
if (o)
this.options.duration = 0;
else {
l && l(ue(e, this.options, n)), a && a(), this.resolveFinishedPromise();
return;
}
const c = this.initPlayback(e, n);
c !== !1 && (this._resolved = {
keyframes: e,
finalKeyframe: n,
...c
}, this.onPostResolved());
}
onPostResolved() {
}
/**
* Allows the returned animation to be awaited or promise-chained. Currently
* resolves when the animation finishes at all but in a future update could/should
* reject if its cancels.
*/
then(e, n) {
return this.currentFinishedPromise.then(e, n);
}
flatten() {
this.options.allowFlatten && (this.options.type = "keyframes", this.options.ease = "linear");
}
updateFinishedPromise() {
this.currentFinishedPromise = new Promise((e) => {
this.resolveFinishedPromise = e;
});
}
}
const ce = (t, e, n) => t + (e - t) * n;
function ge(t, e, n) {
return n < 0 && (n += 1), n > 1 && (n -= 1), n < 1 / 6 ? t + (e - t) * 6 * n : n < 1 / 2 ? e : n < 2 / 3 ? t + (e - t) * (2 / 3 - n) * 6 : t;
}
function ri({ hue: t, saturation: e, lightness: n, alpha: s }) {
t /= 360, e /= 100, n /= 100;
let i = 0, r = 0, o = 0;
if (!e)
i = r = o = n;
else {
const a = n < 0.5 ? n * (1 + e) : n + e - n * e, l = 2 * n - a;
i = ge(l, a, t + 1 / 3), r = ge(l, a, t), o = ge(l, a, t - 1 / 3);
}
return {
red: Math.round(i * 255),
green: Math.round(r * 255),
blue: Math.round(o * 255),
alpha: s
};
}
function re(t, e) {
return (n) => n > 0 ? e : t;
}
const ye = (t, e, n) => {
const s = t * t, i = n * (e * e - s) + s;
return i < 0 ? 0 : Math.sqrt(i);
}, oi = [Se, B, G], ai = (t) => oi.find((e) => e.test(t));
function dt(t) {
const e = ai(t);
if (ae(!!e, `'${t}' is not an animatable color. Use the equivalent color code instead.`), !e)
return !1;
let n = e.parse(t);
return e === G && (n = ri(n)), n;
}
const ft = (t, e) => {
const n = dt(t), s = dt(e);
if (!n || !s)
return re(t, e);
const i = { ...n };
return (r) => (i.red = ye(n.red, s.red, r), i.green = ye(n.green, s.green, r), i.blue = ye(n.blue, s.blue, r), i.alpha = ce(n.alpha, s.alpha, r), B.transform(i));
}, li = (t, e) => (n) => e(t(n)), he = (...t) => t.reduce(li), De = /* @__PURE__ */ new Set(["none", "hidden"]);
function ui(t, e) {
return De.has(t) ? (n) => n <= 0 ? t : e : (n) => n >= 1 ? e : t;
}
function ci(t, e) {
return (n) => ce(t, e, n);
}
function He(t) {
return typeof t == "number" ? ci : typeof t == "string" ? Be(t) ? re : x.test(t) ? ft : fi : Array.isArray(t) ? pn : typeof t == "object" ? x.test(t) ? ft : hi : re;
}
function pn(t, e) {
const n = [...t], s = n.length, i = t.map((r, o) => He(r)(r, e[o]));
return (r) => {
for (let o = 0; o < s; o++)
n[o] = i[o](r);
return n;
};
}
function hi(t, e) {
const n = { ...t, ...e }, s = {};
for (const i in n)
t[i] !== void 0 && e[i] !== void 0 && (s[i] = He(t[i])(t[i], e[i]));
return (i) => {
for (const r in s)
n[r] = s[r](i);
return n;
};
}
function di(t, e) {
var n;
const s = [], i = { color: 0, var: 0, number: 0 };
for (let r = 0; r < e.values.length; r++) {
const o = e.types[r], a = t.indexes[o][i[o]], l = (n = t.values[a]) !== null && n !== void 0 ? n : 0;
s[r] = l, i[o]++;
}
return s;
}
const fi = (t, e) => {
const n = j.createTransformer(e), s = Q(t), i = Q(e);
return s.indexes.var.length === i.indexes.var.length && s.indexes.color.length === i.indexes.color.length && s.indexes.number.length >= i.indexes.number.length ? De.has(t) && !i.values.length || De.has(e) && !s.values.length ? ui(t, e) : he(pn(di(s, i), i.values), n) : (ae(!0, `Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`), re(t, e));
};
function mn(t, e, n) {
return typeof t == "number" && typeof e == "number" && typeof n == "number" ? ce(t, e, n) : He(t)(t, e);
}
const pi = 5;
function gn(t, e, n) {
const s = Math.max(e - pi, 0);
return Kt(n - t(s), e - s);
}
const S = {
// Default spring physics
stiffness: 100,
damping: 10,
mass: 1,
velocity: 0,
// Default duration/bounce-based options
duration: 800,
// in ms
bounce: 0.3,
visualDuration: 0.3,
// in seconds
// Rest thresholds
restSpeed: {
granular: 0.01,
default: 2
},
restDelta: {
granular: 5e-3,
default: 0.5
},
// Limits
minDuration: 0.01,
// in seconds
maxDuration: 10,
// in seconds
minDamping: 0.05,
maxDamping: 1
}, pt = 1e-3;
function mi({ duration: t = S.duration, bounce: e = S.bounce, velocity: n = S.velocity, mass: s = S.mass }) {
let i, r;
ae(t <= /* @__PURE__ */ I(S.maxDuration), "Spring duration must be 10 seconds or less");
let o = 1 - e;
o = U(S.minDamping, S.maxDamping, o), t = U(S.minDuration, S.maxDuration, /* @__PURE__ */ O(t)), o < 1 ? (i = (u) => {
const c = u * o, h = c * t, d = c - n, f = Ee(u, o), b = Math.exp(-h);
return pt - d / f * b;
}, r = (u) => {
const h = u * o * t, d = h * n + n, f = Math.pow(o, 2) * Math.pow(u, 2) * t, b = Math.exp(-h), v = Ee(Math.pow(u, 2), o);
return (-i(u) + pt > 0 ? -1 : 1) * ((d - f) * b) / v;
}) : (i = (u) => {
const c = Math.exp(-u * t), h = (u - n) * t + 1;
return -1e-3 + c * h;
}, r = (u) => {
const c = Math.exp(-u * t), h = (n - u) * (t * t);
return c * h;
});
const a = 5 / t, l = yi(i, r, a);
if (t = /* @__PURE__ */ I(t), isNaN(l))
return {
stiffness: S.stiffness,
damping: S.damping,
duration: t
};
{
const u = Math.pow(l, 2) * s;
return {
stiffness: u,
damping: o * 2 * Math.sqrt(s * u),
duration: t
};
}
}
const gi = 12;
function yi(t, e, n) {
let s = n;
for (let i = 1; i < gi; i++)
s = s - t(s) / e(s);
return s;
}
function Ee(t, e) {
return t * Math.sqrt(1 - e * e);
}
const vi = ["duration", "bounce"], bi = ["stiffness", "damping", "mass"];
function mt(t, e) {
return e.some((n) => t[n] !== void 0);
}
function Ti(t) {
let e = {
velocity: S.velocity,
stiffness: S.stiffness,
damping: S.damping,
mass: S.mass,
isResolvedFromDuration: !1,
...t
};
if (!mt(t, bi) && mt(t, vi))
if (t.visualDuration) {
const n = t.visualDuration, s = 2 * Math.PI / (n * 1.2), i = s * s, r = 2 * U(0.05, 1, 1 - (t.bounce || 0)) * Math.sqrt(i);
e = {
...e,
mass: S.mass,
stiffness: i,
damping: r
};
} else {
const n = mi(t);
e = {
...e,
...n,
mass: S.mass
}, e.isResolvedFromDuration = !0;
}
return e;
}
function yn(t = S.visualDuration, e = S.bounce) {
const n = typeof t != "object" ? {
visualDuration: t,
keyframes: [0, 1],
bounce: e
} : t;
let { restSpeed: s, restDelta: i } = n;
const r = n.keyframes[0], o = n.keyframes[n.keyframes.length - 1], a = { done: !1, value: r }, { stiffness: l, damping: u, mass: c, duration: h, velocity: d, isResolvedFromDuration: f } = Ti({
...n,
velocity: -/* @__PURE__ */ O(n.velocity || 0)
}), b = d || 0, v = u / (2 * Math.sqrt(l * c)), y = o - r, p = /* @__PURE__ */ O(Math.sqrt(l / c)), T = Math.abs(y) < 5;
s || (s = T ? S.restSpeed.granular : S.restSpeed.default), i || (i = T ? S.restDelta.granular : S.restDelta.default);
let V;
if (v < 1) {
const g = Ee(p, v);
V = (A) => {
const w = Math.exp(-v * p * A);
return o - w * ((b + v * p * y) / g * Math.sin(g * A) + y * Math.cos(g * A));
};
} else if (v === 1)
V = (g) => o - Math.exp(-p * g) * (y + (b + p * y) * g);
else {
const g = p * Math.sqrt(v * v - 1);
V = (A) => {
const w = Math.exp(-v * p * A), m = Math.min(g * A, 300);
return o - w * ((b + v * p * y) * Math.sinh(m) + g * y * Math.cosh(m)) / g;
};
}
const C = {
calculatedDuration: f && h || null,
next: (g) => {
const A = V(g);
if (f)
a.done = g >= h;
else {
let w = 0;
v < 1 && (w = g === 0 ? /* @__PURE__ */ I(b) : gn(V, g, A));
const m = Math.abs(w) <= s, P = Math.abs(o - A) <= i;
a.done = m && P;
}
return a.value = a.done ? o : A, a;
},
toString: () => {
const g = Math.min(Bt(C), Ve), A = kt((w) => C.next(g * w).value, g, 30);
return g + "ms " + A;
}
};
return C;
}
function gt({ keyframes: t, velocity: e = 0, power: n = 0.8, timeConstant: s = 325, bounceDamping: i = 10, bounceStiffness: r = 500, modifyTarget: o, min: a, max: l, restDelta: u = 0.5, restSpeed: c }) {
const h = t[0], d = {
done: !1,
value: h
}, f = (m) => a !== void 0 && m < a || l !== void 0 && m > l, b = (m) => a === void 0 ? l : l === void 0 || Math.abs(a - m) < Math.abs(l - m) ? a : l;
let v = n * e;
const y = h + v, p = o === void 0 ? y : o(y);
p !== y && (v = p - h);
const T = (m) => -v * Math.exp(-m / s), V = (m) => p + T(m), C = (m) => {
const P = T(m), F = V(m);
d.done = Math.abs(P) <= u, d.value = d.done ? p : F;
};
let g, A;
const w = (m) => {
f(d.value) && (g = m, A = yn({
keyframes: [d.value, b(d.value)],
velocity: gn(V, m, d.value),
// TODO: This should be passing * 1000
damping: i,
stiffness: r,
restDelta: u,
restSpeed: c
}));
};
return w(0), {
calculatedDuration: null,
next: (m) => {
let P = !1;
return !A && g === void 0 && (P = !0, C(m), w(m)), g !== void 0 && m >= g ? A.next(m - g) : (!P && C(m), d);
}
};
}
const Vi = /* @__PURE__ */ ee(0.42, 0, 1, 1), Ai = /* @__PURE__ */ ee(0, 0, 0.58, 1), vn = /* @__PURE__ */ ee(0.42, 0, 0.58, 1), Si = (t) => Array.isArray(t) && typeof t[0] != "number", yt = {
linear: X,
easeIn: Vi,
easeInOut: vn,
easeOut: Ai,
circIn: $e,
circInOut: Xt,
circOut: ws,
backIn: Ue,
backInOut: Wt,
backOut: Ht,
anticipate: Yt
}, vt = (t) => {
if (Ge(t)) {
Z(t.length === 4, "Cubic bezier arrays must contain four numerical values.");
const [e, n, s, i] = t;
return ee(e, n, s, i);
} else if (typeof t == "string")
return Z(yt[t] !== void 0, `Invalid easing type '${t}'`), yt[t];
return t;
};
function wi(t, e, n) {
const s = [], i = n || mn, r = t.length - 1;
for (let o = 0; o < r; o++) {
let a = i(t[o], t[o + 1]);
if (e) {
const l = Array.isArray(e) ? e[o] || X : e;
a = he(l, a);
}
s.push(a);
}
return s;
}
function xi(t, e, { clamp: n = !0, ease: s, mixer: i } = {}) {
const r = t.length;
if (Z(r === e.length, "Both input and output ranges must be the same length"), r === 1)
return () => e[0];
if (r === 2 && e[0] === e[1])
return () => e[1];
const o = t[0] === t[1];
t[0] > t[r - 1] && (t = [...t].reverse(), e = [...e].reverse());
const a = wi(e, s, i), l = a.length, u = (c) => {
if (o && c < t[0])
return e[0];
let h = 0;
if (l > 1)
for (; h < t.length - 2 && !(c < t[h + 1]); h++)
;
const d = /* @__PURE__ */ Le(t[h], t[h + 1], c);
return a[h](d);
};
return n ? (c) => u(U(t[0], t[r - 1], c)) : u;
}
function Mi(t, e) {
const n = t[t.length - 1];
for (let s = 1; s <= e; s++) {
const i = /* @__PURE__ */ Le(0, e, s);
t.push(ce(n, 1, i));
}
}
function Pi(t) {
const e = [0];
return Mi(e, t.length - 1), e;
}
function Ci(t, e) {
return t.map((n) => n * e);
}
function Fi(t, e) {
return t.map(() => e || vn).splice(0, t.length - 1);
}
function Y({ duration: t = 300, keyframes: e, times: n, ease: s = "easeInOut" }) {
const i = Si(s) ? s.map(vt) : vt(s), r = {
done: !1,
value: e[0]
}, o = Ci(
// Only use the provided offsets if they're the correct length
// TODO Maybe we should warn here if there's a length mismatch
n && n.length === e.length ? n : Pi(e),
t
), a = xi(o, e, {
ease: Array.isArray(i) ? i : Fi(e, i)
});
return {
calculatedDuration: t,
next: (l) => (r.value = a(l), r.done = l >= t, r)
};
}
const Di = (t) => {
const e = ({ timestamp: n }) => t(n);
return {
start: () => D.update(e, !0),
stop: () => Te(e),
/**
* If we're processing this frame we can use the
* framelocked timestamp to keep things in sync.
*/
now: () => ne.isProcessing ? ne.timestamp : K.now()
};
}, Ei = {
decay: gt,
inertia: gt,
tween: Y,
keyframes: Y,
spring: yn
}, Ii = (t) => t / 100;
class We extends fn {
constructor(e) {
super(e), this.holdTime = null, this.cancelTime = null, this.currentTime = 0, this.playbackSpeed = 1, this.pendingPlayState = "running", this.startTime = null, this.state = "idle", this.stop = () => {
if (this.resolver.cancel(), this.isStopped = !0, this.state === "idle")
return;
this.teardown();
const { onStop: l } = this.options;
l && l();
};
const { name: n, motionValue: s, element: i, keyframes: r } = this.options, o = (i == null ? void 0 : i.KeyframeResolver) || ze, a = (l, u) => this.onKeyframesResolved(l, u);
this.resolver = new o(r, a, n, s, i), this.resolver.scheduleResolve();
}
flatten() {
super.flatten(), this._resolved && Object.assign(this._resolved, this.initPlayback(this._resolved.keyframes));
}
initPlayback(e) {
const { type: n = "keyframes", repeat: s = 0, repeatDelay: i = 0, repeatType: r, velocity: o = 0 } = this.options, a = _e(n) ? n : Ei[n] || Y;
let l, u;
process.env.NODE_ENV !== "production" && a !== Y && Z(e.length <= 2, `Only two keyframes currently supported with spring and inertia animations. Trying to animate ${e}`), a !== Y && typeof e[0] != "number" && (l = he(Ii, mn(e[0], e[1])), e = [0, 100]);
const c = a({ ...this.options, keyframes: e });
r === "mirror" && (u = a({
...this.options,
keyframes: [...e].reverse(),
velocity: -o
})), c.calculatedDuration === null && (c.calculatedDuration = Bt(c));
const { calculatedDuration: h } = c, d = h + i, f = d * (s + 1) - i;
return {
generator: c,
mirroredGenerator: u,
mapPercentToKeyframes: l,
calculatedDuration: h,
resolvedDuration: d,
totalDuration: f
};
}
onPostResolved() {
const { autoplay: e = !0 } = this.options;
this.play(), this.pendingPlayState === "paused" || !e ? this.pause() : this.state = this.pendingPlayState;
}
tick(e, n = !1) {
const { resolved: s } = this;
if (!s) {
const { keyframes: m } = this.options;
return { done: !0, value: m[m.length - 1] };
}
const { finalKeyframe: i, generator: r, mirroredGenerator: o, mapPercentToKeyframes: a, keyframes: l, calculatedDuration: u, totalDuration: c, resolvedDuration: h } = s;
if (this.startTime === null)
return r.next(0);
const { delay: d, repeat: f, repeatType: b, repeatDelay: v, onUpdate: y } = this.options;
this.speed > 0 ? this.startTime = Math.min(this.startTime, e) : this.speed < 0 && (this.startTime = Math.min(e - c / this.speed, this.startTime)), n ? this.currentTime = e : this.holdTime !== null ? this.currentTime = this.holdTime : this.currentTime = Math.round(e - this.startTime) * this.speed;
const p = this.currentTime - d * (this.speed >= 0 ? 1 : -1), T = this.speed >= 0 ? p < 0 : p > c;
this.currentTime = Math.max(p, 0), this.state === "finished" && this.holdTime === null && (this.currentTime = c);
let V = this.currentTime, C = r;
if (f) {
const m = Math.min(this.currentTime, c) / h;
let P = Math.floor(m), F = m % 1;
!F && m >= 1 && (F = 1), F === 1 && P--, P = Math.min(P, f + 1), !!(P % 2) && (b === "reverse" ? (F = 1 - F, v && (F -= v / h)) : b === "mirror" && (C = o)), V = U(0, 1, F) * h;
}
const g = T ? { done: !1, value: l[0] } : C.next(V);
a && (g.value = a(g.value));
let { done: A } = g;
!T && u !== null && (A = this.speed >= 0 ? this.currentTime >= c : this.currentTime <= 0);
const w = this.holdTime === null && (this.state === "finished" || this.state === "running" && A);
return w && i !== void 0 && (g.value = ue(l, this.options, i)), y && y(g.value), w && this.finish(), g;
}
get duration() {
const { resolved: e } = this;
return e ? /* @__PURE__ */ O(e.calculatedDuration) : 0;
}
get time() {
return /* @__PURE__ */ O(this.currentTime);
}
set time(e) {
e = /* @__PURE__ */ I(e), this.currentTime = e, this.holdTime !== null || this.speed === 0 ? this.holdTime = e : this.driver && (this.startTime = this.driver.now() - e / this.speed);
}
get speed() {
return this.playbackSpeed;
}
set speed(e) {
const n = this.playbackSpeed !== e;
this.playbackSpeed = e, n && (this.time = /* @__PURE__ */ O(this.currentTime));
}
play() {
if (this.resolver.isScheduled || this.resolver.resume(), !this._resolved) {
this.pendingPlayState = "running";
return;
}
if (this.isStopped)
return;
const { driver: e = Di, onPlay: n, startTime: s } = this.options;
this.driver || (this.driver = e((r) => this.tick(r))), n && n();
const i = this.driver.now();
this.holdTime !== null ? this.startTime = i - this.holdTime : this.startTime ? this.state === "finished" && (this.startTime = i) : this.startTime = s ?? this.calcStartTime(), this.state === "finished" && this.updateFinishedPromise(), this.cancelTime = this.startTime, this.holdTime = null, this.state = "running", this.driver.start();
}
pause() {
var e;
if (!this._resolved) {
this.pendingPlayState = "paused";
return;
}
this.state = "paused", this.holdTime = (e = this.currentTime) !== null && e !== void 0 ? e : 0;
}
complete() {
this.state !== "running" && this.play(), this.pendingPlayState = this.state = "finished", this.holdTime = null;
}
finish() {
this.teardown(), this.state = "finished";
const { onComplete: e } = this.options;
e && e();
}
cancel() {
this.cancelTime !== null && this.tick(this.cancelTime), this.teardown(), this.updateFinishedPromise();
}
teardown() {
this.state = "idle", this.stopDriver(), this.resolveFinishedPromise(), this.updateFinishedPromise(), this.startTime = this.cancelTime = null, this.resolver.cancel();
}
stopDriver() {
this.driver && (this.driver.stop(), this.driver = void 0);
}
sample(e) {
return this.startTime = 0, this.tick(e, !0);
}
}
const Ri = /* @__PURE__ */ new Set([
"opacity",
"clipPath",
"filter",
"transform"
// TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved
// or until we implement support for linear() easing.
// "background-color"
]);
fun