@developermafia/simple-alert-react
Version:
```bash npm i @developermafia/simple-alert-react ```
1,555 lines • 170 kB
JavaScript
import { jsx as M, jsxs as Pe, Fragment as vo } from "react/jsx-runtime";
import xo from "react-dom";
import * as Ie from "react";
import { createContext as xt, useContext as L, useId as je, useEffect as Ne, useCallback as _e, Component as To, useLayoutEffect as Po, useRef as Z, useInsertionEffect as $s, useMemo as lt, forwardRef as So, Fragment as Ks, createElement as bo, Children as wo, isValidElement as Ao, useState as bn } from "react";
var wt = {}, St = xo;
if (process.env.NODE_ENV === "production")
wt.createRoot = St.createRoot, wt.hydrateRoot = St.hydrateRoot;
else {
var It = St.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
wt.createRoot = function(t, e) {
It.usingClientEntryPoint = !0;
try {
return St.createRoot(t, e);
} finally {
It.usingClientEntryPoint = !1;
}
}, wt.hydrateRoot = function(t, e, n) {
It.usingClientEntryPoint = !0;
try {
return St.hydrateRoot(t, e, n);
} finally {
It.usingClientEntryPoint = !1;
}
};
}
const wn = /* @__PURE__ */ new Set();
function Jt(t, e, n) {
t || wn.has(e) || (console.warn(e), wn.add(e));
}
function Vo(t) {
if (typeof Proxy > "u")
return t;
const e = /* @__PURE__ */ new Map(), n = (...s) => (process.env.NODE_ENV !== "production" && Jt(!1, "motion() is deprecated. Use motion.create() instead."), t(...s));
return new Proxy(n, {
/**
* Called when `motion` is referenced with a prop: `motion.div`, `motion.input` etc.
* The prop name is passed through as `key` and we can use that to generate a `motion`
* DOM component with that name.
*/
get: (s, i) => i === "create" ? t : (e.has(i) || e.set(i, t(i)), e.get(i))
});
}
function Qt(t) {
return t !== null && typeof t == "object" && typeof t.start == "function";
}
const Se = (t) => Array.isArray(t);
function Ws(t, e) {
if (!Array.isArray(e))
return !1;
const n = e.length;
if (n !== t.length)
return !1;
for (let s = 0; s < n; s++)
if (e[s] !== t[s])
return !1;
return !0;
}
function Rt(t) {
return typeof t == "string" || Array.isArray(t);
}
function An(t) {
const e = [{}, {}];
return t == null || t.values.forEach((n, s) => {
e[0][s] = n.get(), e[1][s] = n.getVelocity();
}), e;
}
function Ue(t, e, n, s) {
if (typeof e == "function") {
const [i, r] = An(s);
e = e(n !== void 0 ? n : t.custom, i, r);
}
if (typeof e == "string" && (e = t.variants && t.variants[e]), typeof e == "function") {
const [i, r] = An(s);
e = e(n !== void 0 ? n : t.custom, i, r);
}
return e;
}
function te(t, e, n) {
const s = t.getProps();
return Ue(s, e, n !== void 0 ? n : s.custom, t);
}
const $e = [
"animate",
"whileInView",
"whileFocus",
"whileHover",
"whileTap",
"whileDrag",
"exit"
], Ke = ["initial", ...$e], kt = [
"transformPerspective",
"x",
"y",
"z",
"translateX",
"translateY",
"translateZ",
"scale",
"scaleX",
"scaleY",
"rotate",
"rotateX",
"rotateY",
"rotateZ",
"skew",
"skewX",
"skewY"
], ct = new Set(kt), U = (t) => t * 1e3, z = (t) => t / 1e3, Co = {
type: "spring",
stiffness: 500,
damping: 25,
restSpeed: 10
}, Do = (t) => ({
type: "spring",
stiffness: 550,
damping: t === 0 ? 2 * Math.sqrt(550) : 30,
restSpeed: 10
}), Mo = {
type: "keyframes",
duration: 0.8
}, Ro = {
type: "keyframes",
ease: [0.25, 0.1, 0.35, 1],
duration: 0.3
}, Eo = (t, { keyframes: e }) => e.length > 2 ? Mo : ct.has(t) ? t.startsWith("scale") ? Do(e[1]) : Co : Ro;
function We(t, e) {
return t ? t[e] || t.default || t : void 0;
}
const Lo = {
skipAnimations: !1,
useManualTiming: !1
}, Bo = (t) => t !== null;
function ee(t, { repeat: e, repeatType: n = "loop" }, s) {
const i = t.filter(Bo), r = e && n !== "loop" && e % 2 === 1 ? 0 : i.length - 1;
return !r || s === void 0 ? i[r] : s;
}
const R = (t) => t;
function ko(t) {
let e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), s = !1, i = !1;
const r = /* @__PURE__ */ new WeakSet();
let o = {
delta: 0,
timestamp: 0,
isProcessing: !1
};
function a(c) {
r.has(c) && (l.schedule(c), t()), c(o);
}
const l = {
/**
* Schedule a process to run on the next frame.
*/
schedule: (c, u = !1, h = !1) => {
const f = h && s ? e : n;
return u && r.add(c), f.has(c) || f.add(c), c;
},
/**
* Cancel the provided callback from running on the next frame.
*/
cancel: (c) => {
n.delete(c), r.delete(c);
},
/**
* Execute all schedule callbacks.
*/
process: (c) => {
if (o = c, s) {
i = !0;
return;
}
s = !0, [e, n] = [n, e], n.clear(), e.forEach(a), s = !1, i && (i = !1, l.process(c));
}
};
return l;
}
const jt = [
"read",
// Read
"resolveKeyframes",
// Write/Read/Write/Read
"update",
// Compute
"preRender",
// Compute
"render",
// Write
"postRender"
// Compute
], Fo = 40;
function Gs(t, e) {
let n = !1, s = !0;
const i = {
delta: 0,
timestamp: 0,
isProcessing: !1
}, r = () => n = !0, o = jt.reduce((y, v) => (y[v] = ko(r), y), {}), { read: a, resolveKeyframes: l, update: c, preRender: u, render: h, postRender: d } = o, f = () => {
const y = performance.now();
n = !1, i.delta = s ? 1e3 / 60 : Math.max(Math.min(y - i.timestamp, Fo), 1), i.timestamp = y, i.isProcessing = !0, a.process(i), l.process(i), c.process(i), u.process(i), h.process(i), d.process(i), i.isProcessing = !1, n && e && (s = !1, t(f));
}, p = () => {
n = !0, s = !0, i.isProcessing || t(f);
};
return { schedule: jt.reduce((y, v) => {
const m = o[v];
return y[v] = (P, S = !1, V = !1) => (n || p(), m.schedule(P, S, V)), y;
}, {}), cancel: (y) => {
for (let v = 0; v < jt.length; v++)
o[jt[v]].cancel(y);
}, state: i, steps: o };
}
const { schedule: w, cancel: J, state: D, steps: le } = Gs(typeof requestAnimationFrame < "u" ? requestAnimationFrame : R, !0), zs = (t, e, n) => (((1 - 3 * n + 3 * e) * t + (3 * n - 6 * e)) * t + 3 * e) * t, Oo = 1e-7, Io = 12;
function jo(t, e, n, s, i) {
let r, o, a = 0;
do
o = e + (n - e) / 2, r = zs(o, s, i) - t, r > 0 ? n = o : e = o;
while (Math.abs(r) > Oo && ++a < Io);
return o;
}
function Ft(t, e, n, s) {
if (t === e && n === s)
return R;
const i = (r) => jo(r, 0, 1, t, n);
return (r) => r === 0 || r === 1 ? r : zs(i(r), e, s);
}
const Hs = (t) => (e) => e <= 0.5 ? t(2 * e) / 2 : (2 - t(2 * (1 - e))) / 2, Ys = (t) => (e) => 1 - t(1 - e), qs = /* @__PURE__ */ Ft(0.33, 1.53, 0.69, 0.99), Ge = /* @__PURE__ */ Ys(qs), Xs = /* @__PURE__ */ Hs(Ge), Zs = (t) => (t *= 2) < 1 ? 0.5 * Ge(t) : 0.5 * (2 - Math.pow(2, -10 * (t - 1))), ze = (t) => 1 - Math.sin(Math.acos(t)), Js = Ys(ze), Qs = Hs(ze), ti = (t) => /^0[^.\s]+$/u.test(t);
function No(t) {
return typeof t == "number" ? t === 0 : t !== null ? t === "none" || t === "0" || ti(t) : !0;
}
let Tt = R, q = R;
process.env.NODE_ENV !== "production" && (Tt = (t, e) => {
!t && typeof console < "u" && console.warn(e);
}, q = (t, e) => {
if (!t)
throw new Error(e);
});
const ei = (t) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t), ni = (t) => (e) => typeof e == "string" && e.startsWith(t), si = /* @__PURE__ */ ni("--"), _o = /* @__PURE__ */ ni("var(--"), He = (t) => _o(t) ? Uo.test(t.split("/*")[0].trim()) : !1, Uo = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu, $o = (
// 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 Ko(t) {
const e = $o.exec(t);
if (!e)
return [,];
const [, n, s, i] = e;
return [`--${n ?? s}`, i];
}
const Wo = 4;
function ii(t, e, n = 1) {
q(n <= Wo, `Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`);
const [s, i] = Ko(t);
if (!s)
return;
const r = window.getComputedStyle(e).getPropertyValue(s);
if (r) {
const o = r.trim();
return ei(o) ? parseFloat(o) : o;
}
return He(i) ? ii(i, e, n + 1) : i;
}
const Q = (t, e, n) => n > e ? e : n < t ? t : n, Pt = {
test: (t) => typeof t == "number",
parse: parseFloat,
transform: (t) => t
}, Et = {
...Pt,
transform: (t) => Q(0, 1, t)
}, Nt = {
...Pt,
default: 1
}, Ot = (t) => ({
test: (e) => typeof e == "string" && e.endsWith(t) && e.split(" ").length === 1,
parse: parseFloat,
transform: (e) => `${e}${t}`
}), X = /* @__PURE__ */ Ot("deg"), $ = /* @__PURE__ */ Ot("%"), T = /* @__PURE__ */ Ot("px"), Go = /* @__PURE__ */ Ot("vh"), zo = /* @__PURE__ */ Ot("vw"), Vn = {
...$,
parse: (t) => $.parse(t) / 100,
transform: (t) => $.transform(t * 100)
}, Ho = /* @__PURE__ */ new Set([
"width",
"height",
"top",
"left",
"right",
"bottom",
"x",
"y",
"translateX",
"translateY"
]), Cn = (t) => t === Pt || t === T, Dn = (t, e) => parseFloat(t.split(", ")[e]), Mn = (t, e) => (n, { transform: s }) => {
if (s === "none" || !s)
return 0;
const i = s.match(/^matrix3d\((.+)\)$/u);
if (i)
return Dn(i[1], e);
{
const r = s.match(/^matrix\((.+)\)$/u);
return r ? Dn(r[1], t) : 0;
}
}, Yo = /* @__PURE__ */ new Set(["x", "y", "z"]), qo = kt.filter((t) => !Yo.has(t));
function Xo(t) {
const e = [];
return qo.forEach((n) => {
const s = t.getValue(n);
s !== void 0 && (e.push([n, s.get()]), s.set(n.startsWith("scale") ? 1 : 0));
}), e;
}
const gt = {
// 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: Mn(4, 13),
y: Mn(5, 14)
};
gt.translateX = gt.x;
gt.translateY = gt.y;
const oi = (t) => (e) => e.test(t), Zo = {
test: (t) => t === "auto",
parse: (t) => t
}, ri = [Pt, T, $, X, zo, Go, Zo], Rn = (t) => ri.find(oi(t)), at = /* @__PURE__ */ new Set();
let be = !1, we = !1;
function ai() {
if (we) {
const t = Array.from(at).filter((s) => s.needsMeasurement), e = new Set(t.map((s) => s.element)), n = /* @__PURE__ */ new Map();
e.forEach((s) => {
const i = Xo(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);
});
}
we = !1, be = !1, at.forEach((t) => t.complete()), at.clear();
}
function li() {
at.forEach((t) => {
t.readKeyframes(), t.needsMeasurement && (we = !0);
});
}
function Jo() {
li(), ai();
}
class Ye {
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 ? (at.add(this), be || (be = !0, w.read(li), w.resolveKeyframes(ai))) : (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), at.delete(this);
}
cancel() {
this.isComplete || (this.isScheduled = !1, at.delete(this));
}
resume() {
this.isComplete || this.scheduleResolve();
}
}
const Ct = (t) => Math.round(t * 1e5) / 1e5, qe = /-?(?:\d+(?:\.\d+)?|\.\d+)/gu;
function Qo(t) {
return t == null;
}
const tr = /^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu, Xe = (t, e) => (n) => !!(typeof n == "string" && tr.test(n) && n.startsWith(t) || e && !Qo(n) && Object.prototype.hasOwnProperty.call(n, e)), ci = (t, e, n) => (s) => {
if (typeof s != "string")
return s;
const [i, r, o, a] = s.match(qe);
return {
[t]: parseFloat(i),
[e]: parseFloat(r),
[n]: parseFloat(o),
alpha: a !== void 0 ? parseFloat(a) : 1
};
}, er = (t) => Q(0, 255, t), ce = {
...Pt,
transform: (t) => Math.round(er(t))
}, rt = {
test: /* @__PURE__ */ Xe("rgb", "red"),
parse: /* @__PURE__ */ ci("red", "green", "blue"),
transform: ({ red: t, green: e, blue: n, alpha: s = 1 }) => "rgba(" + ce.transform(t) + ", " + ce.transform(e) + ", " + ce.transform(n) + ", " + Ct(Et.transform(s)) + ")"
};
function nr(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 Ae = {
test: /* @__PURE__ */ Xe("#"),
parse: nr,
transform: rt.transform
}, ht = {
test: /* @__PURE__ */ Xe("hsl", "hue"),
parse: /* @__PURE__ */ ci("hue", "saturation", "lightness"),
transform: ({ hue: t, saturation: e, lightness: n, alpha: s = 1 }) => "hsla(" + Math.round(t) + ", " + $.transform(Ct(e)) + ", " + $.transform(Ct(n)) + ", " + Ct(Et.transform(s)) + ")"
}, E = {
test: (t) => rt.test(t) || Ae.test(t) || ht.test(t),
parse: (t) => rt.test(t) ? rt.parse(t) : ht.test(t) ? ht.parse(t) : Ae.parse(t),
transform: (t) => typeof t == "string" ? t : t.hasOwnProperty("red") ? rt.transform(t) : ht.transform(t)
}, sr = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
function ir(t) {
var e, n;
return isNaN(t) && typeof t == "string" && (((e = t.match(qe)) === null || e === void 0 ? void 0 : e.length) || 0) + (((n = t.match(sr)) === null || n === void 0 ? void 0 : n.length) || 0) > 0;
}
const ui = "number", hi = "color", or = "var", rr = "var(", En = "${}", ar = /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 Lt(t) {
const e = t.toString(), n = [], s = {
color: [],
number: [],
var: []
}, i = [];
let r = 0;
const a = e.replace(ar, (l) => (E.test(l) ? (s.color.push(r), i.push(hi), n.push(E.parse(l))) : l.startsWith(rr) ? (s.var.push(r), i.push(or), n.push(l)) : (s.number.push(r), i.push(ui), n.push(parseFloat(l))), ++r, En)).split(En);
return { values: n, split: a, indexes: s, types: i };
}
function di(t) {
return Lt(t).values;
}
function fi(t) {
const { split: e, types: n } = Lt(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 === ui ? r += Ct(i[o]) : a === hi ? r += E.transform(i[o]) : r += i[o];
}
return r;
};
}
const lr = (t) => typeof t == "number" ? 0 : t;
function cr(t) {
const e = di(t);
return fi(t)(e.map(lr));
}
const tt = {
test: ir,
parse: di,
createTransformer: fi,
getAnimatableNone: cr
}, ur = /* @__PURE__ */ new Set(["brightness", "contrast", "saturate", "opacity"]);
function hr(t) {
const [e, n] = t.slice(0, -1).split("(");
if (e === "drop-shadow")
return t;
const [s] = n.match(qe) || [];
if (!s)
return t;
const i = n.replace(s, "");
let r = ur.has(e) ? 1 : 0;
return s !== n && (r *= 100), e + "(" + r + i + ")";
}
const dr = /\b([a-z-]*)\(.*?\)/gu, Ve = {
...tt,
getAnimatableNone: (t) => {
const e = t.match(dr);
return e ? e.map(hr).join(" ") : t;
}
}, fr = {
// Border props
borderWidth: T,
borderTopWidth: T,
borderRightWidth: T,
borderBottomWidth: T,
borderLeftWidth: T,
borderRadius: T,
radius: T,
borderTopLeftRadius: T,
borderTopRightRadius: T,
borderBottomRightRadius: T,
borderBottomLeftRadius: T,
// Positioning props
width: T,
maxWidth: T,
height: T,
maxHeight: T,
top: T,
right: T,
bottom: T,
left: T,
// Spacing props
padding: T,
paddingTop: T,
paddingRight: T,
paddingBottom: T,
paddingLeft: T,
margin: T,
marginTop: T,
marginRight: T,
marginBottom: T,
marginLeft: T,
// Misc
backgroundPositionX: T,
backgroundPositionY: T
}, pr = {
rotate: X,
rotateX: X,
rotateY: X,
rotateZ: X,
scale: Nt,
scaleX: Nt,
scaleY: Nt,
scaleZ: Nt,
skew: X,
skewX: X,
skewY: X,
distance: T,
translateX: T,
translateY: T,
translateZ: T,
x: T,
y: T,
z: T,
perspective: T,
transformPerspective: T,
opacity: Et,
originX: Vn,
originY: Vn,
originZ: T
}, Ln = {
...Pt,
transform: Math.round
}, Ze = {
...fr,
...pr,
zIndex: Ln,
size: T,
// SVG
fillOpacity: Et,
strokeOpacity: Et,
numOctaves: Ln
}, mr = {
...Ze,
// Color props
color: E,
backgroundColor: E,
outlineColor: E,
fill: E,
stroke: E,
// Border props
borderColor: E,
borderTopColor: E,
borderRightColor: E,
borderBottomColor: E,
borderLeftColor: E,
filter: Ve,
WebkitFilter: Ve
}, Je = (t) => mr[t];
function pi(t, e) {
let n = Je(t);
return n !== Ve && (n = tt), n.getAnimatableNone ? n.getAnimatableNone(e) : void 0;
}
const gr = /* @__PURE__ */ new Set(["auto", "none", "0"]);
function yr(t, e, n) {
let s = 0, i;
for (; s < t.length && !i; ) {
const r = t[s];
typeof r == "string" && !gr.has(r) && Lt(r).values.length && (i = t[s]), s++;
}
if (i && n)
for (const r of e)
t[r] = pi(n, i);
}
class mi extends Ye {
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 c = e[l];
if (typeof c == "string" && (c = c.trim(), He(c))) {
const u = ii(c, n.current);
u !== void 0 && (e[l] = u), l === e.length - 1 && (this.finalKeyframe = c);
}
}
if (this.resolveNoneKeyframes(), !Ho.has(s) || e.length !== 2)
return;
const [i, r] = e, o = Rn(i), a = Rn(r);
if (o !== a)
if (Cn(o) && Cn(a))
for (let l = 0; l < e.length; l++) {
const c = e[l];
typeof c == "string" && (e[l] = parseFloat(c));
}
else
this.needsMeasurement = !0;
}
resolveNoneKeyframes() {
const { unresolvedKeyframes: e, name: n } = this, s = [];
for (let i = 0; i < e.length; i++)
No(e[i]) && s.push(i);
s.length && yr(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 = gt[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] = gt[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, c]) => {
n.getValue(l).set(c);
}), this.resolveNoneKeyframes();
}
}
function Qe(t) {
return typeof t == "function";
}
let $t;
function vr() {
$t = void 0;
}
const K = {
now: () => ($t === void 0 && K.set(D.isProcessing || Lo.useManualTiming ? D.timestamp : performance.now()), $t),
set: (t) => {
$t = t, queueMicrotask(vr);
}
}, Bn = (t, e) => e === "zIndex" ? !1 : !!(typeof t == "number" || Array.isArray(t) || typeof t == "string" && // It's animatable if we have a string
(tt.test(t) || t === "0") && // And it contains numbers and/or colors
!t.startsWith("url("));
function xr(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 Tr(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 = Bn(i, e), a = Bn(r, e);
return Tt(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 : xr(t) || (n === "spring" || Qe(n)) && s;
}
const Pr = 40;
class gi {
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 > Pr ? 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 && Jo(), 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: c } = this.options;
if (!c && !Tr(e, s, i, r))
if (o)
this.options.duration = 0;
else {
l == null || l(ee(e, this.options, n)), a == null || a(), this.resolveFinishedPromise();
return;
}
const u = this.initPlayback(e, n);
u !== !1 && (this._resolved = {
keyframes: e,
finalKeyframe: n,
...u
}, 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.type = "keyframes", this.options.ease = "linear";
}
updateFinishedPromise() {
this.currentFinishedPromise = new Promise((e) => {
this.resolveFinishedPromise = e;
});
}
}
function yi(t, e) {
return e ? t * (1e3 / e) : 0;
}
const Sr = 5;
function vi(t, e, n) {
const s = Math.max(e - Sr, 0);
return yi(n - t(s), e - s);
}
const ue = 1e-3, br = 0.01, kn = 10, wr = 0.05, Ar = 1;
function Vr({ duration: t = 800, bounce: e = 0.25, velocity: n = 0, mass: s = 1 }) {
let i, r;
Tt(t <= U(kn), "Spring duration must be 10 seconds or less");
let o = 1 - e;
o = Q(wr, Ar, o), t = Q(br, kn, z(t)), o < 1 ? (i = (c) => {
const u = c * o, h = u * t, d = u - n, f = Ce(c, o), p = Math.exp(-h);
return ue - d / f * p;
}, r = (c) => {
const h = c * o * t, d = h * n + n, f = Math.pow(o, 2) * Math.pow(c, 2) * t, p = Math.exp(-h), g = Ce(Math.pow(c, 2), o);
return (-i(c) + ue > 0 ? -1 : 1) * ((d - f) * p) / g;
}) : (i = (c) => {
const u = Math.exp(-c * t), h = (c - n) * t + 1;
return -ue + u * h;
}, r = (c) => {
const u = Math.exp(-c * t), h = (n - c) * (t * t);
return u * h;
});
const a = 5 / t, l = Dr(i, r, a);
if (t = U(t), isNaN(l))
return {
stiffness: 100,
damping: 10,
duration: t
};
{
const c = Math.pow(l, 2) * s;
return {
stiffness: c,
damping: o * 2 * Math.sqrt(s * c),
duration: t
};
}
}
const Cr = 12;
function Dr(t, e, n) {
let s = n;
for (let i = 1; i < Cr; i++)
s = s - t(s) / e(s);
return s;
}
function Ce(t, e) {
return t * Math.sqrt(1 - e * e);
}
const Mr = ["duration", "bounce"], Rr = ["stiffness", "damping", "mass"];
function Fn(t, e) {
return e.some((n) => t[n] !== void 0);
}
function Er(t) {
let e = {
velocity: 0,
stiffness: 100,
damping: 10,
mass: 1,
isResolvedFromDuration: !1,
...t
};
if (!Fn(t, Rr) && Fn(t, Mr)) {
const n = Vr(t);
e = {
...e,
...n,
mass: 1
}, e.isResolvedFromDuration = !0;
}
return e;
}
function xi({ keyframes: t, restDelta: e, restSpeed: n, ...s }) {
const i = t[0], r = t[t.length - 1], o = { done: !1, value: i }, { stiffness: a, damping: l, mass: c, duration: u, velocity: h, isResolvedFromDuration: d } = Er({
...s,
velocity: -z(s.velocity || 0)
}), f = h || 0, p = l / (2 * Math.sqrt(a * c)), g = r - i, x = z(Math.sqrt(a / c)), y = Math.abs(g) < 5;
n || (n = y ? 0.01 : 2), e || (e = y ? 5e-3 : 0.5);
let v;
if (p < 1) {
const m = Ce(x, p);
v = (P) => {
const S = Math.exp(-p * x * P);
return r - S * ((f + p * x * g) / m * Math.sin(m * P) + g * Math.cos(m * P));
};
} else if (p === 1)
v = (m) => r - Math.exp(-x * m) * (g + (f + x * g) * m);
else {
const m = x * Math.sqrt(p * p - 1);
v = (P) => {
const S = Math.exp(-p * x * P), V = Math.min(m * P, 300);
return r - S * ((f + p * x * g) * Math.sinh(V) + m * g * Math.cosh(V)) / m;
};
}
return {
calculatedDuration: d && u || null,
next: (m) => {
const P = v(m);
if (d)
o.done = m >= u;
else {
let S = 0;
p < 1 && (S = m === 0 ? U(f) : vi(v, m, P));
const V = Math.abs(S) <= n, O = Math.abs(r - P) <= e;
o.done = V && O;
}
return o.value = o.done ? r : P, o;
}
};
}
function On({ 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: c = 0.5, restSpeed: u }) {
const h = t[0], d = {
done: !1,
value: h
}, f = (b) => a !== void 0 && b < a || l !== void 0 && b > l, p = (b) => a === void 0 ? l : l === void 0 || Math.abs(a - b) < Math.abs(l - b) ? a : l;
let g = n * e;
const x = h + g, y = o === void 0 ? x : o(x);
y !== x && (g = y - h);
const v = (b) => -g * Math.exp(-b / s), m = (b) => y + v(b), P = (b) => {
const I = v(b), j = m(b);
d.done = Math.abs(I) <= c, d.value = d.done ? y : j;
};
let S, V;
const O = (b) => {
f(d.value) && (S = b, V = xi({
keyframes: [d.value, p(d.value)],
velocity: vi(m, b, d.value),
// TODO: This should be passing * 1000
damping: i,
stiffness: r,
restDelta: c,
restSpeed: u
}));
};
return O(0), {
calculatedDuration: null,
next: (b) => {
let I = !1;
return !V && S === void 0 && (I = !0, P(b), O(b)), S !== void 0 && b >= S ? V.next(b - S) : (!I && P(b), d);
}
};
}
const Lr = /* @__PURE__ */ Ft(0.42, 0, 1, 1), Br = /* @__PURE__ */ Ft(0, 0, 0.58, 1), Ti = /* @__PURE__ */ Ft(0.42, 0, 0.58, 1), kr = (t) => Array.isArray(t) && typeof t[0] != "number", tn = (t) => Array.isArray(t) && typeof t[0] == "number", In = {
linear: R,
easeIn: Lr,
easeInOut: Ti,
easeOut: Br,
circIn: ze,
circInOut: Qs,
circOut: Js,
backIn: Ge,
backInOut: Xs,
backOut: qs,
anticipate: Zs
}, jn = (t) => {
if (tn(t)) {
q(t.length === 4, "Cubic bezier arrays must contain four numerical values.");
const [e, n, s, i] = t;
return Ft(e, n, s, i);
} else if (typeof t == "string")
return q(In[t] !== void 0, `Invalid easing type '${t}'`), In[t];
return t;
}, Fr = (t, e) => (n) => e(t(n)), H = (...t) => t.reduce(Fr), yt = (t, e, n) => {
const s = e - t;
return s === 0 ? 1 : (n - t) / s;
}, A = (t, e, n) => t + (e - t) * n;
function he(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 Or({ 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 = he(l, a, t + 1 / 3), r = he(l, a, t), o = he(l, a, t - 1 / 3);
}
return {
red: Math.round(i * 255),
green: Math.round(r * 255),
blue: Math.round(o * 255),
alpha: s
};
}
function Gt(t, e) {
return (n) => n > 0 ? e : t;
}
const de = (t, e, n) => {
const s = t * t, i = n * (e * e - s) + s;
return i < 0 ? 0 : Math.sqrt(i);
}, Ir = [Ae, rt, ht], jr = (t) => Ir.find((e) => e.test(t));
function Nn(t) {
const e = jr(t);
if (Tt(!!e, `'${t}' is not an animatable color. Use the equivalent color code instead.`), !e)
return !1;
let n = e.parse(t);
return e === ht && (n = Or(n)), n;
}
const _n = (t, e) => {
const n = Nn(t), s = Nn(e);
if (!n || !s)
return Gt(t, e);
const i = { ...n };
return (r) => (i.red = de(n.red, s.red, r), i.green = de(n.green, s.green, r), i.blue = de(n.blue, s.blue, r), i.alpha = A(n.alpha, s.alpha, r), rt.transform(i));
}, De = /* @__PURE__ */ new Set(["none", "hidden"]);
function Nr(t, e) {
return De.has(t) ? (n) => n <= 0 ? t : e : (n) => n >= 1 ? e : t;
}
function _r(t, e) {
return (n) => A(t, e, n);
}
function en(t) {
return typeof t == "number" ? _r : typeof t == "string" ? He(t) ? Gt : E.test(t) ? _n : Kr : Array.isArray(t) ? Pi : typeof t == "object" ? E.test(t) ? _n : Ur : Gt;
}
function Pi(t, e) {
const n = [...t], s = n.length, i = t.map((r, o) => en(r)(r, e[o]));
return (r) => {
for (let o = 0; o < s; o++)
n[o] = i[o](r);
return n;
};
}
function Ur(t, e) {
const n = { ...t, ...e }, s = {};
for (const i in n)
t[i] !== void 0 && e[i] !== void 0 && (s[i] = en(t[i])(t[i], e[i]));
return (i) => {
for (const r in s)
n[r] = s[r](i);
return n;
};
}
function $r(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 Kr = (t, e) => {
const n = tt.createTransformer(e), s = Lt(t), i = Lt(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 ? Nr(t, e) : H(Pi($r(s, i), i.values), n) : (Tt(!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.`), Gt(t, e));
};
function Si(t, e, n) {
return typeof t == "number" && typeof e == "number" && typeof n == "number" ? A(t, e, n) : en(t)(t, e);
}
function Wr(t, e, n) {
const s = [], i = n || Si, 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] || R : e;
a = H(l, a);
}
s.push(a);
}
return s;
}
function Gr(t, e, { clamp: n = !0, ease: s, mixer: i } = {}) {
const r = t.length;
if (q(r === e.length, "Both input and output ranges must be the same length"), r === 1)
return () => e[0];
if (r === 2 && t[0] === t[1])
return () => e[1];
t[0] > t[r - 1] && (t = [...t].reverse(), e = [...e].reverse());
const o = Wr(e, s, i), a = o.length, l = (c) => {
let u = 0;
if (a > 1)
for (; u < t.length - 2 && !(c < t[u + 1]); u++)
;
const h = yt(t[u], t[u + 1], c);
return o[u](h);
};
return n ? (c) => l(Q(t[0], t[r - 1], c)) : l;
}
function zr(t, e) {
const n = t[t.length - 1];
for (let s = 1; s <= e; s++) {
const i = yt(0, e, s);
t.push(A(n, 1, i));
}
}
function Hr(t) {
const e = [0];
return zr(e, t.length - 1), e;
}
function Yr(t, e) {
return t.map((n) => n * e);
}
function qr(t, e) {
return t.map(() => e || Ti).splice(0, t.length - 1);
}
function zt({ duration: t = 300, keyframes: e, times: n, ease: s = "easeInOut" }) {
const i = kr(s) ? s.map(jn) : jn(s), r = {
done: !1,
value: e[0]
}, o = Yr(
// 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 : Hr(e),
t
), a = Gr(o, e, {
ease: Array.isArray(i) ? i : qr(e, i)
});
return {
calculatedDuration: t,
next: (l) => (r.value = a(l), r.done = l >= t, r)
};
}
const Un = 2e4;
function Xr(t) {
let e = 0;
const n = 50;
let s = t.next(e);
for (; !s.done && e < Un; )
e += n, s = t.next(e);
return e >= Un ? 1 / 0 : e;
}
const Zr = (t) => {
const e = ({ timestamp: n }) => t(n);
return {
start: () => w.update(e, !0),
stop: () => J(e),
/**
* If we're processing this frame we can use the
* framelocked timestamp to keep things in sync.
*/
now: () => D.isProcessing ? D.timestamp : K.now()
};
}, Jr = {
decay: On,
inertia: On,
tween: zt,
keyframes: zt,
spring: xi
}, Qr = (t) => t / 100;
class nn extends gi {
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) || Ye, a = (l, c) => this.onKeyframesResolved(l, c);
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 = Qe(n) ? n : Jr[n] || zt;
let l, c;
a !== zt && typeof e[0] != "number" && (process.env.NODE_ENV !== "production" && q(e.length === 2, `Only two keyframes currently supported with spring and inertia animations. Trying to animate ${e}`), l = H(Qr, Si(e[0], e[1])), e = [0, 100]);
const u = a({ ...this.options, keyframes: e });
r === "mirror" && (c = a({
...this.options,
keyframes: [...e].reverse(),
velocity: -o
})), u.calculatedDuration === null && (u.calculatedDuration = Xr(u));
const { calculatedDuration: h } = u, d = h + i, f = d * (s + 1) - i;
return {
generator: u,
mirroredGenerator: c,
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: b } = this.options;
return { done: !0, value: b[b.length - 1] };
}
const { finalKeyframe: i, generator: r, mirroredGenerator: o, mapPercentToKeyframes: a, keyframes: l, calculatedDuration: c, totalDuration: u, resolvedDuration: h } = s;
if (this.startTime === null)
return r.next(0);
const { delay: d, repeat: f, repeatType: p, repeatDelay: g, onUpdate: x } = this.options;
this.speed > 0 ? this.startTime = Math.min(this.startTime, e) : this.speed < 0 && (this.startTime = Math.min(e - u / 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 y = this.currentTime - d * (this.speed >= 0 ? 1 : -1), v = this.speed >= 0 ? y < 0 : y > u;
this.currentTime = Math.max(y, 0), this.state === "finished" && this.holdTime === null && (this.currentTime = u);
let m = this.currentTime, P = r;
if (f) {
const b = Math.min(this.currentTime, u) / h;
let I = Math.floor(b), j = b % 1;
!j && b >= 1 && (j = 1), j === 1 && I--, I = Math.min(I, f + 1), !!(I % 2) && (p === "reverse" ? (j = 1 - j, g && (j -= g / h)) : p === "mirror" && (P = o)), m = Q(0, 1, j) * h;
}
const S = v ? { done: !1, value: l[0] } : P.next(m);
a && (S.value = a(S.value));
let { done: V } = S;
!v && c !== null && (V = this.speed >= 0 ? this.currentTime >= u : this.currentTime <= 0);
const O = this.holdTime === null && (this.state === "finished" || this.state === "running" && V);
return O && i !== void 0 && (S.value = ee(l, this.options, i)), x && x(S.value), O && this.finish(), S;
}
get duration() {
const { resolved: e } = this;
return e ? z(e.calculatedDuration) : 0;
}
get time() {
return z(this.currentTime);
}
set time(e) {
e = U(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 = z(this.currentTime));
}
play() {
if (this.resolver.isScheduled || this.resolver.resume(), !this._resolved) {
this.pendingPlayState = "running";
return;
}
if (this.isStopped)
return;
const { driver: e = Zr, 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 ta = /* @__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"
]), ea = 10, na = (t, e) => {
let n = "";
const s = Math.max(Math.round(e / ea), 2);
for (let i = 0; i < s; i++)
n += t(yt(0, s - 1, i)) + ", ";
return `linear(${n.substring(0, n.length - 2)})`;
};
function sn(t) {
let e;
return () => (e === void 0 && (e = t()), e);
}
const sa = {
linearEasing: void 0
};
function ia(t, e) {
const n = sn(t);
return () => {
var s;
return (s = sa[e]) !== null && s !== void 0 ? s : n();
};
}
const Ht = /* @__PURE__ */ ia(() => {
try {
document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" });
} catch {
return !1;
}
return !0;
}, "linearEasing");
function bi(t) {
return !!(typeof t == "function" && Ht() || !t || typeof t == "string" && (t in Me || Ht()) || tn(t) || Array.isArray(t) && t.every(bi));
}
const At = ([t, e, n, s]) => `cubic-bezier(${t}, ${e}, ${n}, ${s})`, Me = {
linear: "linear",
ease: "ease",
easeIn: "ease-in",
easeOut: "ease-out",
easeInOut: "ease-in-out",
circIn: /* @__PURE__ */ At([0, 0.65, 0.55, 1]),
circOut: /* @__PURE__ */ At([0.55, 0, 1, 0.45]),
backIn: /* @__PURE__ */ At([0.31, 0.01, 0.66, -0.59]),
backOut: /* @__PURE__ */ At([0.33, 1.53, 0.69, 0.99])
};
function wi(t, e) {
if (t)
return typeof t == "function" && Ht() ? na(t, e) : tn(t) ? At(t) : Array.isArray(t) ? t.map((n) => wi(n, e) || Me.easeOut) : Me[t];
}
function oa(t, e, n, { delay: s = 0, duration: i = 300, repeat: r = 0, repeatType: o = "loop", ease: a = "easeInOut", times: l } = {}) {
const c = { [e]: n };
l && (c.offset = l);
const u = wi(a, i);
return Array.isArray(u) && (c.easing = u), t.animate(c, {
delay: s,
duration: i,
easing: Array.isArray(u) ? "linear" : u,
fill: "both",
iterations: r + 1,
direction: o === "reverse" ? "alternate" : "normal"
});
}
function $n(t, e) {
t.timeline = e, t.onfinish = null;
}
const ra = /* @__PURE__ */ sn(() => Object.hasOwnProperty.call(Element.prototype, "animate")), Yt = 10, aa = 2e4;
function la(t) {
return Qe(t.type) || t.type === "spring" || !bi(t.ease);
}
function ca(t, e) {
const n = new nn({
...e,
keyframes: t,
repeat: 0,
delay: 0,
isGenerator: !0
});
let s = { done: !1, value: t[0] };
const i = [];
let r = 0;
for (; !s.done && r < aa; )
s = n.sample(r), i.push(s.value), r += Yt;
return {
times: void 0,
keyframes: i,
duration: r - Yt,
ease: "linear"
};
}
const Ai = {
anticipate: Zs,
backInOut: Xs,
circInOut: Qs
};
function ua(t) {
return t in Ai;
}
class Kn extends gi {
constructor(e) {
super(e);
const { name: n, motionValue: s, element: i, keyframes: r } = this.options;
this.resolver = new mi(r, (o, a) => this.onKeyframesResolved(o, a), n, s, i), this.resolver.scheduleResolve();
}
initPlayback(e, n) {
var s;
let { duration: i = 300, times: r, ease: o, type: a, motionValue: l, name: c, startTime: u } = this.options;
if (!(!((s = l.owner) === null || s === void 0) && s.current))
return !1;
if (typeof o == "string" && Ht() && ua(o) && (o = Ai[o]), la(this.options)) {
const { onComplete: d, onUpdate: f, motionValue: p, element: g, ...x } = this.options, y = ca(e, x);
e = y.keyframes, e.length === 1 && (e[1] = e[0]), i = y.duration, r = y.times, o = y.ease, a = "keyframes";
}
const h = oa(l.owner.current, c, e, { ...this.options, duration: i, times: r, ease: o });
return h.startTime = u ?? this.calcStartTime(), this.pendingTimeline ? ($n(h, this.pendingTimeline), this.pendingTimeline = void 0) : h.onfinish = () => {
const { onComplete: d } = this.options;
l.set(ee(e, this.options, n)), d && d(), this.cancel(), this.resolveFinishedPromise();
}, {
animation: h,
duration: i,
times: r,
type: a,
ease: o,
keyframes: e
};
}
get duration() {
const { resolved: e } = this;
if (!e)
return 0;
const { duration: n } = e;
return z(n);
}
get time() {
const { resolved: e } = this;
if (!e)
return 0;
const { animation: n } = e;
return z(n.currentTime || 0);
}
set time(e) {
const { resolved: n } = this;
if (!n)
return;
const { animation: s } = n;
s.currentTime = U(e);
}
get speed() {
const { resolved: e } = this;
if (!e)
return 1;
const { animation: n } = e;
return n.playbackRate;
}
set speed(e) {
const { resolved: n } = this;
if (!n)
return;
const { animation: s } = n;
s.playbackRate = e;
}
get state() {
const { resolved: e } = this;
if (!e)
return "idle";
const { animation: n } = e;
return n.playState;
}
get startTime() {
const { resolved: e } = this;
if (!e)
return null;
const { animation: n } = e;
return n.startTime;
}
/**
* Replace the default DocumentTimeline with another AnimationTimeline.
* Currently used for scroll animations.
*/
attachTimeline(e) {
if (!this._resolved)
this.pendingTimeline = e;
else {
const { resolved: n } = this;
if (!n)
return R;
const { animation: s } = n;
$n(s, e);
}
return R;
}
play() {
if (this.isStopped)
return;
const { resolved: e } = this;
if (!e)
return;
const { animation: n } = e;
n.playState === "finished" && this.updateFinishedPromise(), n.play();
}
pause() {
const { resolved: e } = this;
if (!e)
return;
const { animation: n } = e;
n.pause();
}
stop() {
if (this.resolver.cancel(), this.isStopped = !0, this.state === "idle")
return;
this.resolveFinishedPromise(), this.updateFinishedPromise();
const { resolved: e } = this;
if (!e)
return;
const { animation: n, keyframes: s, duration: i, type: r, ease: o, times: a } = e;
if (n.playState === "idle" || n.playState === "finished")
return;
if (this.time) {
const { motionValue: c, onUpdate: u, onComplete: h, element: d, ...f } = this.options, p = new nn({
...f,
keyframes: s,
duration: i,
type: r,
ease: o,
times: a,
isGenerator: !0
}), g = U(this.time);
c.setWithVelocity(p.sample(g - Yt).value, p.sample(g).value, Yt);
}
const { onStop: l } = this.options;
l && l(), this.cancel();
}
complete() {
const { resolved: e } = this;
e && e.animation.finish();
}
cancel() {
const { resolved: e } = this;
e && e.animation.cancel();
}
static supports(e) {
const { motionValue: n, name: s, repeatDelay: i, repeatType: r, damping: o, type: a } = e;
return ra() && s && ta.has(s) && n && n.owner && n.owner.current instanceof HTMLElement && /**
* If we're outputting values to onUpdate then we can't use WAAPI as there's
* no way to read the value from WAAPI every frame.
*/
!n.owner.getProps().onUpdate && !i && r !== "mirror" && o !== 0 && a !== "inertia";
}
}
const ha = sn(() => window.ScrollTimeline !== void 0);
class da {
constructor(e) {
this.stop = () => this.runAll("stop"), this.animations = e.filter(Boolean);
}
then(e, n) {
return Promise.all(this.animations).then(e).catch(n);
}
/**
* 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) => ha() && i.attachTimeline ? i.attachTimeline(e) : 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");
}
}
function fa({ when: t, delay: e, delayChildren: n, staggerChildren: s, staggerDirection: i, repeat: r, repeatType: o, repeatDelay: a, from: l, elapsed: c, ...u }) {
return !!Object.keys(u).length;
}
const on = (t, e, n, s = {}, i, r) => (o) => {
const a = We(s, t) || {}, l = a.delay || s.delay || 0;
let { elapsed: c = 0 } = s;
c = c - U(l);
let u = {
keyf