UNPKG

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 84.1 kB
import { f as ne, w as Ke, a as D, r as Pt, t as Ct, b as Fn, i as O, o as Dn, n as X, c as Ne, d as Ft, e as G, p as be, g as En, h as Dt, j as Be, k as Z, l as In, v as On, m as Rn, q as ae, s as Te, u as le, x as Et, y as It, z as Ot, A as Ze, B as Rt, C as Kn, D as Nn, E as Bn, F as Je, G as kn, H as Ln, I as _n, J as Un, K as Gn, L as $n, M as jn, N as qn, O as zn, P as Hn, Q as Wn, R as Yn } from "./index-XavjEuVz.js"; import { Fragment as Xn } from "react"; function Zn(t, e) { t.indexOf(e) === -1 && t.push(e); } function Jn(t, e) { const n = t.indexOf(e); n > -1 && t.splice(n, 1); } const Qn = { 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 Kt { constructor() { this.subscriptions = []; } add(e) { return Zn(this.subscriptions, e), () => Jn(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, R = /* @__NO_SIDE_EFFECTS__ */ (t) => t / 1e3; function Nt(t, e) { return e ? t * (1e3 / e) : 0; } const es = /* @__PURE__ */ ke(() => window.ScrollTimeline !== void 0); class ts { 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 (es() && 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 ns extends ts { then(e, n) { return Promise.all(this.animations).then(e).catch(n); } } function Bt(t, e) { return t ? t[e] || t.default || t : void 0; } const Ve = 2e4; function kt(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 Ue = (t) => Array.isArray(t) && typeof t[0] == "number", ss = { linearEasing: void 0 }; function is(t, e) { const n = /* @__PURE__ */ ke(t); return () => { var s; return (s = ss[e]) !== null && s !== void 0 ? s : n(); }; } const se = /* @__PURE__ */ is(() => { try { document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" }); } catch { return !1; } return !0; }, "linearEasing"), Lt = (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 _t(t) { return !!(typeof t == "function" && se() || !t || typeof t == "string" && (t in Ae || se()) || Ue(t) || Array.isArray(t) && t.every(_t)); } 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 Ut(t, e) { if (t) return typeof t == "function" && se() ? Lt(t, e) : Ue(t) ? z(t) : Array.isArray(t) ? t.map((n) => Ut(n, e) || Ae.easeOut) : Ae[t]; } let te; function rs() { te = void 0; } const K = { now: () => (te === void 0 && K.set(ne.isProcessing || Qn.useManualTiming ? ne.timestamp : performance.now()), te), set: (t) => { te = t, queueMicrotask(rs); } }, os = { y: !1 }; function as() { return os.y; } function ls(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 = ls(t), s = new AbortController(), i = { passive: !0, ...e, signal: s.signal }; return [n, i, () => s.abort()]; } function et(t) { return !(t.pointerType === "touch" || as()); } function us(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; } function tt(t, e) { const n = `${e}PointerCapture`; if (t.target instanceof Element && n in t.target && t.pointerId !== void 0) try { t.target[n](t.pointerId); } catch { } } const $t = (t, e) => e ? t === e ? !0 : $t(t, e.parentElement) : !1, cs = (t) => t.pointerType === "mouse" ? typeof t.button != "number" || t.button <= 0 : t.isPrimary !== !1, hs = /* @__PURE__ */ new Set([ "BUTTON", "INPUT", "SELECT", "TEXTAREA", "A" ]); function ds(t) { return hs.has(t.tagName) || t.tabIndex !== -1; } const H = /* @__PURE__ */ new WeakSet(); function nt(t) { return (e) => { e.key === "Enter" && t(e); }; } function pe(t, e) { t.dispatchEvent(new PointerEvent("pointer" + e, { isPrimary: !0, bubbles: !0 })); } const fs = (t, e) => { const n = t.currentTarget; if (!n) return; const s = nt(() => { if (H.has(n)) return; pe(n, "down"); const i = nt(() => { 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 st(t) { return cs(t) && !0; } function ps(t, e, n = {}) { const [s, i, r] = Gt(t, n), o = (a) => { const l = a.currentTarget; if (!l || !st(a) || H.has(l)) return; H.add(l), tt(a, "set"); const u = e(l, a), c = (f, b) => { l.removeEventListener("pointerup", h), l.removeEventListener("pointercancel", d), tt(f, "release"), !(!st(f) || !H.has(l)) && (H.delete(l), typeof u == "function" && u(f, { success: b })); }, h = (f) => { (f.isTrusted ? ms(f, l instanceof Element ? l.getBoundingClientRect() : { left: 0, top: 0, right: window.innerWidth, bottom: window.innerHeight }) : !1) ? c(f, !1) : c(f, !(l instanceof Element) || $t(l, f.target)); }, d = (f) => { c(f, !1); }; l.addEventListener("pointerup", h, i), l.addEventListener("pointercancel", d, i), l.addEventListener("lostpointercapture", d, i); }; return s.forEach((a) => { a = n.useGlobalTarget ? window : a; let l = !1; a instanceof HTMLElement && (l = !0, !ds(a) && a.getAttribute("tabindex") === null && (a.tabIndex = 0)), a.addEventListener("pointerdown", o, i), l && a.addEventListener("focus", (u) => fs(u, i), i); }), r; } function ms(t, e) { return t.clientX < e.left || t.clientX > e.right || t.clientY < e.top || t.clientY > e.bottom; } const it = 30, gs = (t) => !isNaN(parseFloat(t)); class ys { /** * @param init - The initiating value * @param config - Optional configuration options * * - `transformer`: A function to transform incoming values with. */ constructor(e, n = {}) { this.version = "12.5.0", 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 = gs(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 Kt()); 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 > it) return 0; const n = Math.min(this.updatedAt - this.prevUpdatedAt, it); return Nt(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 ys(t, e); } function J(t, e, n) { const s = t.getProps(); return Pt(s, e, n !== void 0 ? n : s.custom, t); } const jt = /* @__PURE__ */ new Set([ "width", "height", "top", "left", "right", "bottom", ...Ct ]); function vs(t, e, n) { t.hasValue(e) ? t.getValue(e).set(n) : t.addValue(e, ie(n)); } function bs(t, e) { const n = J(t, e); let { transitionEnd: s = {}, transition: i = {}, ...r } = n || {}; r = { ...r, ...s }; for (const o in r) { const a = Fn(r[o]); vs(t, o, a); } } function Ts(t) { return !!(O(t) && t.add); } function Vs(t, e) { const n = t.getValue("willChange"); if (Ts(n)) return n.add(e); } function As(t) { return t.props[Dn]; } const qt = (t, e, n) => (((1 - 3 * n + 3 * e) * t + (3 * n - 6 * e)) * t + 3 * e) * t, Ss = 1e-7, ws = 12; function xs(t, e, n, s, i) { let r, o, a = 0; do o = e + (n - e) / 2, r = qt(o, s, i) - t, r > 0 ? n = o : e = o; while (Math.abs(r) > Ss && ++a < ws); return o; } function ee(t, e, n, s) { if (t === e && n === s) return X; const i = (r) => xs(r, 0, 1, t, n); return (r) => r === 0 || r === 1 ? r : qt(i(r), e, s); } const zt = (t) => (e) => e <= 0.5 ? t(2 * e) / 2 : (2 - t(2 * (1 - e))) / 2, Ht = (t) => (e) => 1 - t(1 - e), Wt = /* @__PURE__ */ ee(0.33, 1.53, 0.69, 0.99), Ge = /* @__PURE__ */ Ht(Wt), Yt = /* @__PURE__ */ zt(Ge), Xt = (t) => (t *= 2) < 1 ? 0.5 * Ge(t) : 0.5 * (2 - Math.pow(2, -10 * (t - 1))), $e = (t) => 1 - Math.sin(Math.acos(t)), Ms = Ht($e), Zt = zt($e), Jt = (t) => /^0[^.\s]+$/u.test(t); function Ps(t) { return typeof t == "number" ? t === 0 : t !== null ? t === "none" || t === "0" || Jt(t) : !0; } const W = (t) => Math.round(t * 1e5) / 1e5, je = /-?(?:\d+(?:\.\d+)?|\.\d+)/gu; function Cs(t) { return t == null; } const Fs = /^(?:#[\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" && Fs.test(n) && n.startsWith(t) || e && !Cs(n) && Object.prototype.hasOwnProperty.call(n, e)), Qt = (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 }; }, Ds = (t) => G(0, 255, t), me = { ...Ne, transform: (t) => Math.round(Ds(t)) }, B = { test: /* @__PURE__ */ qe("rgb", "red"), parse: /* @__PURE__ */ Qt("red", "green", "blue"), transform: ({ red: t, green: e, blue: n, alpha: s = 1 }) => "rgba(" + me.transform(t) + ", " + me.transform(e) + ", " + me.transform(n) + ", " + W(Ft.transform(s)) + ")" }; function Es(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: Es, transform: B.transform }, U = { test: /* @__PURE__ */ qe("hsl", "hue"), parse: /* @__PURE__ */ Qt("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(Ft.transform(s)) + ")" }, x = { test: (t) => B.test(t) || Se.test(t) || U.test(t), parse: (t) => B.test(t) ? B.parse(t) : U.test(t) ? U.parse(t) : Se.parse(t), transform: (t) => typeof t == "string" ? t : t.hasOwnProperty("red") ? B.transform(t) : U.transform(t) }, Is = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu; function Os(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(Is)) === null || n === void 0 ? void 0 : n.length) || 0) > 0; } const en = "number", tn = "color", Rs = "var", Ks = "var(", rt = "${}", Ns = /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(Ns, (l) => (x.test(l) ? (s.color.push(r), i.push(tn), n.push(x.parse(l))) : l.startsWith(Ks) ? (s.var.push(r), i.push(Rs), n.push(l)) : (s.number.push(r), i.push(en), n.push(parseFloat(l))), ++r, rt)).split(rt); return { values: n, split: a, indexes: s, types: i }; } function nn(t) { return Q(t).values; } function sn(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 === en ? r += W(i[o]) : a === tn ? r += x.transform(i[o]) : r += i[o]; } return r; }; } const Bs = (t) => typeof t == "number" ? 0 : t; function ks(t) { const e = nn(t); return sn(t)(e.map(Bs)); } const j = { test: Os, parse: nn, createTransformer: sn, getAnimatableNone: ks }, Ls = /* @__PURE__ */ new Set(["brightness", "contrast", "saturate", "opacity"]); function _s(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 = Ls.has(e) ? 1 : 0; return s !== n && (r *= 100), e + "(" + r + i + ")"; } const Us = /\b([a-z-]*)\(.*?\)/gu, we = { ...j, getAnimatableNone: (t) => { const e = t.match(Us); return e ? e.map(_s).join(" ") : t; } }, Gs = { ...En, // 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 }, rn = (t) => Gs[t]; function on(t, e) { let n = rn(t); return n !== we && (n = j), n.getAnimatableNone ? n.getAnimatableNone(e) : void 0; } const $s = /* @__PURE__ */ new Set(["auto", "none", "0"]); function js(t, e, n) { let s = 0, i; for (; s < t.length && !i; ) { const r = t[s]; typeof r == "string" && !$s.has(r) && Q(r).values.length && (i = t[s]), s++; } if (i && n) for (const r of e) t[r] = on(n, i); } const k = (t) => t * 180 / Math.PI, xe = (t) => { const e = k(Math.atan2(t[1], t[0])); return Me(e); }, qs = { 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), ot = xe, at = (t) => Math.sqrt(t[0] * t[0] + t[1] * t[1]), lt = (t) => Math.sqrt(t[4] * t[4] + t[5] * t[5]), zs = { x: 12, y: 13, z: 14, translateX: 12, translateY: 13, translateZ: 14, scaleX: at, scaleY: lt, scale: (t) => (at(t) + lt(t)) / 2, rotateX: (t) => Me(k(Math.atan2(t[6], t[5]))), rotateY: (t) => Me(k(Math.atan2(-t[2], t[0]))), rotateZ: ot, rotate: ot, 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 ut(t) { return t.includes("scale") ? 1 : 0; } function Pe(t, e) { if (!t || t === "none") return ut(e); const n = t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u); let s, i; if (n) s = zs, i = n; else { const a = t.match(/^matrix\(([-\d.e\s,]+)\)$/u); s = qs, i = a; } if (!i) return ut(e); const r = s[e], o = i[1].split(",").map(Ws); return typeof r == "function" ? r(o) : o[r]; } const Hs = (t, e) => { const { transform: n = "none" } = getComputedStyle(t); return Pe(n, e); }; function Ws(t) { return parseFloat(t.trim()); } const ct = (t) => t === Ne || t === Dt, Ys = /* @__PURE__ */ new Set(["x", "y", "z"]), Xs = Ct.filter((t) => !Ys.has(t)); function Zs(t) { const e = []; return Xs.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 an() { 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 = Zs(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 ln() { L.forEach((t) => { t.readKeyframes(), t.needsMeasurement && (Fe = !0); }); } function Js() { ln(), an(); } 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(ln), D.resolveKeyframes(an))) : (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 un = (t) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t), Qs = ( // 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 ei(t) { const e = Qs.exec(t); if (!e) return [,]; const [, n, s, i] = e; return [`--${n ?? s}`, i]; } const ti = 4; function cn(t, e, n = 1) { Z(n <= ti, `Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`); const [s, i] = ei(t); if (!s) return; const r = window.getComputedStyle(e).getPropertyValue(s); if (r) { const o = r.trim(); return un(o) ? parseFloat(o) : o; } return Be(i) ? cn(i, e, n + 1) : i; } const hn = (t) => (e) => e.test(t), ni = { test: (t) => t === "auto", parse: (t) => t }, dn = [Ne, Dt, be, In, On, Rn, ni], ht = (t) => dn.find(hn(t)); class fn 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 = cn(u, n.current); c !== void 0 && (e[l] = c), l === e.length - 1 && (this.finalKeyframe = u); } } if (this.resolveNoneKeyframes(), !jt.has(s) || e.length !== 2) return; const [i, r] = e, o = ht(i), a = ht(r); if (o !== a) if (ct(o) && ct(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++) Ps(e[i]) && s.push(i); s.length && js(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 dt = (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 si(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 ii(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 = dt(i, e), a = dt(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 : si(t) || (n === "spring" || _e(n)) && s; } const ri = (t) => t !== null; function ue(t, { repeat: e, repeatType: n = "loop" }, s) { const i = t.filter(ri), r = e && n !== "loop" && e % 2 === 1 ? 0 : i.length - 1; return !r || s === void 0 ? i[r] : s; } const oi = 40; class pn { 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 > oi ? 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 && Js(), 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 && !ii(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 ai({ 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); }, li = [Se, B, U], ui = (t) => li.find((e) => e.test(t)); function ft(t) { const e = ui(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 === U && (n = ai(n)), n; } const pt = (t, e) => { const n = ft(t), s = ft(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)); }, ci = (t, e) => (n) => e(t(n)), he = (...t) => t.reduce(ci), De = /* @__PURE__ */ new Set(["none", "hidden"]); function hi(t, e) { return De.has(t) ? (n) => n <= 0 ? t : e : (n) => n >= 1 ? e : t; } function di(t, e) { return (n) => ce(t, e, n); } function He(t) { return typeof t == "number" ? di : typeof t == "string" ? Be(t) ? re : x.test(t) ? pt : mi : Array.isArray(t) ? mn : typeof t == "object" ? x.test(t) ? pt : fi : re; } function mn(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 fi(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 pi(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 mi = (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 ? hi(t, e) : he(mn(pi(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 gn(t, e, n) { return typeof t == "number" && typeof e == "number" && typeof n == "number" ? ce(t, e, n) : He(t)(t, e); } const gi = 5; function yn(t, e, n) { const s = Math.max(e - gi, 0); return Nt(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 }, mt = 1e-3; function yi({ 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 = G(S.minDamping, S.maxDamping, o), t = G(S.minDuration, S.maxDuration, /* @__PURE__ */ R(t)), o < 1 ? (i = (u) => { const c = u * o, h = c * t, d = c - n, f = Ee(u, o), b = Math.exp(-h); return mt - 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) + mt > 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 = bi(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 vi = 12; function bi(t, e, n) { let s = n; for (let i = 1; i < vi; i++) s = s - t(s) / e(s); return s; } function Ee(t, e) { return t * Math.sqrt(1 - e * e); } const Ti = ["duration", "bounce"], Vi = ["stiffness", "damping", "mass"]; function gt(t, e) { return e.some((n) => t[n] !== void 0); } function Ai(t) { let e = { velocity: S.velocity, stiffness: S.stiffness, damping: S.damping, mass: S.mass, isResolvedFromDuration: !1, ...t }; if (!gt(t, Vi) && gt(t, Ti)) if (t.visualDuration) { const n = t.visualDuration, s = 2 * Math.PI / (n * 1.2), i = s * s, r = 2 * G(0.05, 1, 1 - (t.bounce || 0)) * Math.sqrt(i); e = { ...e, mass: S.mass, stiffness: i, damping: r }; } else { const n = yi(t); e = { ...e, ...n, mass: S.mass }, e.isResolvedFromDuration = !0; } return e; } function vn(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 } = Ai({ ...n, velocity: -/* @__PURE__ */ R(n.velocity || 0) }), b = d || 0, v = u / (2 * Math.sqrt(l * c)), y = o - r, p = /* @__PURE__ */ R(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) : yn(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(kt(C), Ve), A = Lt((w) => C.next(g * w).value, g, 30); return g + "ms " + A; } }; return C; } function yt({ 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 = vn({ keyframes: [d.value, b(d.value)], velocity: yn(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 Si = /* @__PURE__ */ ee(0.42, 0, 1, 1), wi = /* @__PURE__ */ ee(0, 0, 0.58, 1), bn = /* @__PURE__ */ ee(0.42, 0, 0.58, 1), xi = (t) => Array.isArray(t) && typeof t[0] != "number", vt = { linear: X, easeIn: Si, easeInOut: bn, easeOut: wi, circIn: $e, circInOut: Zt, circOut: Ms, backIn: Ge, backInOut: Yt, backOut: Wt, anticipate: Xt }, bt = (t) => { if (Ue(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(vt[t] !== void 0, `Invalid easing type '${t}'`), vt[t]; return t; }; function Mi(t, e, n) { const s = [], i = n || gn, 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 Pi(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 = Mi(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(G(t[0], t[r - 1], c)) : u; } function Ci(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 Fi(t) { const e = [0]; return Ci(e, t.length - 1), e; } function Di(t, e) { return t.map((n) => n * e); } function Ei(t, e) { return t.map(() => e || bn).splice(0, t.length - 1); } function Y({ duration: t = 300, keyframes: e, times: n, ease: s = "easeInOut" }) { const i = xi(s) ? s.map(bt) : bt(s), r = { done: !1, value: e[0] }, o = Di( // 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 : Fi(e), t ), a = Pi(o, e, { ease: Array.isArray(i) ? i : Ei(e, i) }); return { calculatedDuration: t, next: (l) => (r.value = a(l), r.done = l >= t, r) }; } const Ii = (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() }; }, Oi = { decay: yt, inertia: yt, tween: Y, keyframes: Y, spring: vn }, Ri = (t) => t / 100; class We extends pn { 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 : Oi[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(Ri, gn(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 = kt(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 = G(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__ */ R(e.calculatedDuration) : 0; } get time() { return /* @__PURE__ */ R(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__ */ R(this.currentTime)); } play() { if (this.resolver.isScheduled || this.resolver.resume(), !this._resolved) { this.pendingPlayState = "running"; return; } if (this.isStopped) return; const { driver: e = Ii, 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() { t