import { raf as d } from "../../rafz/dist/react-spring-rafz.esm.mjs";
import { useState as Z, useRef as Q, useEffect as E, useLayoutEffect as ne } from "react";
function re() {
}
const Ve = (e, f, t) => Object.defineProperty(e, f, {
  value: t,
  writable: !0,
  configurable: !0
}), l = {
  arr: Array.isArray,
  obj: (e) => !!e && e.constructor.name === "Object",
  fun: (e) => typeof e == "function",
  str: (e) => typeof e == "string",
  num: (e) => typeof e == "number",
  und: (e) => e === void 0
};
function je(e, f) {
  if (l.arr(e)) {
    if (!l.arr(f) || e.length !== f.length)
      return !1;
    for (let t = 0; t < e.length; t++)
      if (e[t] !== f[t])
        return !1;
    return !0;
  }
  return e === f;
}
const ae = (e, f) => e.forEach(f);
function Ue(e, f, t) {
  if (l.arr(e)) {
    for (let n = 0; n < e.length; n++)
      f.call(t, e[n], `${n}`);
    return;
  }
  for (const n in e)
    e.hasOwnProperty(n) && f.call(t, e[n], n);
}
const Le = (e) => l.und(e) ? [] : l.arr(e) ? e : [e];
function oe(e, f) {
  if (e.size) {
    const t = Array.from(e);
    e.clear(), ae(t, f);
  }
}
const Te = (e, ...f) => oe(e, (t) => t(...f)), z = () => typeof window == "undefined" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
let _, W, h = null, X = !1, B = re;
const ie = (e) => {
  e.to && (W = e.to), e.now && (d.now = e.now), e.colors !== void 0 && (h = e.colors), e.skipAnimation != null && (X = e.skipAnimation), e.createStringInterpolator && (_ = e.createStringInterpolator), e.requestAnimationFrame && d.use(e.requestAnimationFrame), e.batchedUpdates && (d.batchedUpdates = e.batchedUpdates), e.willAdvance && (B = e.willAdvance), e.frameLoop && (d.frameLoop = e.frameLoop);
};
var De = /* @__PURE__ */ Object.freeze({
  __proto__: null,
  get createStringInterpolator() {
    return _;
  },
  get to() {
    return W;
  },
  get colors() {
    return h;
  },
  get skipAnimation() {
    return X;
  },
  get willAdvance() {
    return B;
  },
  assign: ie
});
const m = /* @__PURE__ */ new Set();
let s = [], $ = [], O = 0;
const se = {
  get idle() {
    return !m.size && !s.length;
  },
  start(e) {
    O > e.priority ? (m.add(e), d.onStart(ce)) : (J(e), d(q));
  },
  advance: q,
  sort(e) {
    if (O)
      d.onFrame(() => se.sort(e));
    else {
      const f = s.indexOf(e);
      ~f && (s.splice(f, 1), K(e));
    }
  },
  clear() {
    s = [], m.clear();
  }
};
function ce() {
  m.forEach(J), m.clear(), d(q);
}
function J(e) {
  s.includes(e) || K(e);
}
function K(e) {
  s.splice(ue(s, (f) => f.priority > e.priority), 0, e);
}
function q(e) {
  const f = $;
  for (let t = 0; t < s.length; t++) {
    const n = s[t];
    O = n.priority, n.idle || (B(n), n.advance(e), n.idle || f.push(n));
  }
  return O = 0, $ = s, $.length = 0, s = f, s.length > 0;
}
function ue(e, f) {
  const t = e.findIndex(f);
  return t < 0 ? e.length : t;
}
const le = (e, f, t) => Math.min(Math.max(t, e), f), Ge = {
  transparent: 0,
  aliceblue: 4042850303,
  antiquewhite: 4209760255,
  aqua: 16777215,
  aquamarine: 2147472639,
  azure: 4043309055,
  beige: 4126530815,
  bisque: 4293182719,
  black: 255,
  blanchedalmond: 4293643775,
  blue: 65535,
  blueviolet: 2318131967,
  brown: 2771004159,
  burlywood: 3736635391,
  burntsienna: 3934150143,
  cadetblue: 1604231423,
  chartreuse: 2147418367,
  chocolate: 3530104575,
  coral: 4286533887,
  cornflowerblue: 1687547391,
  cornsilk: 4294499583,
  crimson: 3692313855,
  cyan: 16777215,
  darkblue: 35839,
  darkcyan: 9145343,
  darkgoldenrod: 3095792639,
  darkgray: 2846468607,
  darkgreen: 6553855,
  darkgrey: 2846468607,
  darkkhaki: 3182914559,
  darkmagenta: 2332068863,
  darkolivegreen: 1433087999,
  darkorange: 4287365375,
  darkorchid: 2570243327,
  darkred: 2332033279,
  darksalmon: 3918953215,
  darkseagreen: 2411499519,
  darkslateblue: 1211993087,
  darkslategray: 793726975,
  darkslategrey: 793726975,
  darkturquoise: 13554175,
  darkviolet: 2483082239,
  deeppink: 4279538687,
  deepskyblue: 12582911,
  dimgray: 1768516095,
  dimgrey: 1768516095,
  dodgerblue: 512819199,
  firebrick: 2988581631,
  floralwhite: 4294635775,
  forestgreen: 579543807,
  fuchsia: 4278255615,
  gainsboro: 3705462015,
  ghostwhite: 4177068031,
  gold: 4292280575,
  goldenrod: 3668254975,
  gray: 2155905279,
  green: 8388863,
  greenyellow: 2919182335,
  grey: 2155905279,
  honeydew: 4043305215,
  hotpink: 4285117695,
  indianred: 3445382399,
  indigo: 1258324735,
  ivory: 4294963455,
  khaki: 4041641215,
  lavender: 3873897215,
  lavenderblush: 4293981695,
  lawngreen: 2096890111,
  lemonchiffon: 4294626815,
  lightblue: 2916673279,
  lightcoral: 4034953471,
  lightcyan: 3774873599,
  lightgoldenrodyellow: 4210742015,
  lightgray: 3553874943,
  lightgreen: 2431553791,
  lightgrey: 3553874943,
  lightpink: 4290167295,
  lightsalmon: 4288707327,
  lightseagreen: 548580095,
  lightskyblue: 2278488831,
  lightslategray: 2005441023,
  lightslategrey: 2005441023,
  lightsteelblue: 2965692159,
  lightyellow: 4294959359,
  lime: 16711935,
  limegreen: 852308735,
  linen: 4210091775,
  magenta: 4278255615,
  maroon: 2147483903,
  mediumaquamarine: 1724754687,
  mediumblue: 52735,
  mediumorchid: 3126187007,
  mediumpurple: 2473647103,
  mediumseagreen: 1018393087,
  mediumslateblue: 2070474495,
  mediumspringgreen: 16423679,
  mediumturquoise: 1221709055,
  mediumvioletred: 3340076543,
  midnightblue: 421097727,
  mintcream: 4127193855,
  mistyrose: 4293190143,
  moccasin: 4293178879,
  navajowhite: 4292783615,
  navy: 33023,
  oldlace: 4260751103,
  olive: 2155872511,
  olivedrab: 1804477439,
  orange: 4289003775,
  orangered: 4282712319,
  orchid: 3664828159,
  palegoldenrod: 4008225535,
  palegreen: 2566625535,
  paleturquoise: 2951671551,
  palevioletred: 3681588223,
  papayawhip: 4293907967,
  peachpuff: 4292524543,
  peru: 3448061951,
  pink: 4290825215,
  plum: 3718307327,
  powderblue: 2967529215,
  purple: 2147516671,
  rebeccapurple: 1714657791,
  red: 4278190335,
  rosybrown: 3163525119,
  royalblue: 1097458175,
  saddlebrown: 2336560127,
  salmon: 4202722047,
  sandybrown: 4104413439,
  seagreen: 780883967,
  seashell: 4294307583,
  sienna: 2689740287,
  silver: 3233857791,
  skyblue: 2278484991,
  slateblue: 1784335871,
  slategray: 1887473919,
  slategrey: 1887473919,
  snow: 4294638335,
  springgreen: 16744447,
  steelblue: 1182971135,
  tan: 3535047935,
  teal: 8421631,
  thistle: 3636451583,
  tomato: 4284696575,
  turquoise: 1088475391,
  violet: 4001558271,
  wheat: 4125012991,
  white: 4294967295,
  whitesmoke: 4126537215,
  yellow: 4294902015,
  yellowgreen: 2597139199
}, u = "[-+]?\\d*\\.?\\d+", M = u + "%";
function F(...e) {
  return "\\(\\s*(" + e.join(")\\s*,\\s*(") + ")\\s*\\)";
}
const de = new RegExp("rgb" + F(u, u, u)), he = new RegExp("rgba" + F(u, u, u, u)), pe = new RegExp("hsl" + F(u, M, M)), xe = new RegExp("hsla" + F(u, M, M, u)), ge = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, be = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, me = /^#([0-9a-fA-F]{6})$/, we = /^#([0-9a-fA-F]{8})$/;
function ye(e) {
  let f;
  return typeof e == "number" ? e >>> 0 === e && e >= 0 && e <= 4294967295 ? e : null : (f = me.exec(e)) ? parseInt(f[1] + "ff", 16) >>> 0 : h && h[e] !== void 0 ? h[e] : (f = de.exec(e)) ? (g(f[1]) << 24 | g(f[2]) << 16 | g(f[3]) << 8 | 255) >>> 0 : (f = he.exec(e)) ? (g(f[1]) << 24 | g(f[2]) << 16 | g(f[3]) << 8 | L(f[4])) >>> 0 : (f = ge.exec(e)) ? parseInt(f[1] + f[1] + f[2] + f[2] + f[3] + f[3] + "ff", 16) >>> 0 : (f = we.exec(e)) ? parseInt(f[1], 16) >>> 0 : (f = be.exec(e)) ? parseInt(f[1] + f[1] + f[2] + f[2] + f[3] + f[3] + f[4] + f[4], 16) >>> 0 : (f = pe.exec(e)) ? (j(U(f[1]), y(f[2]), y(f[3])) | 255) >>> 0 : (f = xe.exec(e)) ? (j(U(f[1]), y(f[2]), y(f[3])) | L(f[4])) >>> 0 : null;
}
function S(e, f, t) {
  return t < 0 && (t += 1), t > 1 && (t -= 1), t < 1 / 6 ? e + (f - e) * 6 * t : t < 1 / 2 ? f : t < 2 / 3 ? e + (f - e) * (2 / 3 - t) * 6 : e;
}
function j(e, f, t) {
  const n = t < 0.5 ? t * (1 + f) : t + f - t * f, o = 2 * t - n, a = S(o, n, e + 1 / 3), i = S(o, n, e), c = S(o, n, e - 1 / 3);
  return Math.round(a * 255) << 24 | Math.round(i * 255) << 16 | Math.round(c * 255) << 8;
}
function g(e) {
  const f = parseInt(e, 10);
  return f < 0 ? 0 : f > 255 ? 255 : f;
}
function U(e) {
  return (parseFloat(e) % 360 + 360) % 360 / 360;
}
function L(e) {
  const f = parseFloat(e);
  return f < 0 ? 0 : f > 1 ? 255 : Math.round(f * 255);
}
function y(e) {
  const f = parseFloat(e);
  return f < 0 ? 0 : f > 100 ? 1 : f / 100;
}
function T(e) {
  let f = ye(e);
  if (f === null)
    return e;
  f = f || 0;
  let t = (f & 4278190080) >>> 24, n = (f & 16711680) >>> 16, o = (f & 65280) >>> 8, a = (f & 255) / 255;
  return `rgba(${t}, ${n}, ${o}, ${a})`;
}
const Y = (e, f, t) => {
  if (l.fun(e))
    return e;
  if (l.arr(e))
    return Y({
      range: e,
      output: f,
      extrapolate: t
    });
  if (l.str(e.output[0]))
    return _(e);
  const n = e, o = n.output, a = n.range || [0, 1], i = n.extrapolateLeft || n.extrapolate || "extend", c = n.extrapolateRight || n.extrapolate || "extend", x = n.easing || ((r) => r);
  return (r) => {
    const w = ke(r, a);
    return ve(r, a[w], a[w + 1], o[w], o[w + 1], x, i, c, n.map);
  };
};
function ve(e, f, t, n, o, a, i, c, x) {
  let r = x ? x(e) : e;
  if (r < f) {
    if (i === "identity")
      return r;
    i === "clamp" && (r = f);
  }
  if (r > t) {
    if (c === "identity")
      return r;
    c === "clamp" && (r = t);
  }
  return n === o ? n : f === t ? e <= f ? n : o : (f === -1 / 0 ? r = -r : t === 1 / 0 ? r = r - f : r = (r - f) / (t - f), r = a(r), n === -1 / 0 ? r = -r : o === 1 / 0 ? r = r + n : r = r * (o - n) + n, r);
}
function ke(e, f) {
  for (var t = 1; t < f.length - 1 && !(f[t] >= e); ++t)
    ;
  return t - 1;
}
const Ie = (e, f = "end") => (t) => {
  t = f === "end" ? Math.min(t, 0.999) : Math.max(t, 1e-3);
  const n = t * e, o = f === "end" ? Math.floor(n) : Math.ceil(n);
  return le(0, 1, o / e);
}, A = 1.70158, v = A * 1.525, D = A + 1, G = 2 * Math.PI / 3, N = 2 * Math.PI / 4.5, k = (e) => e < 1 / 2.75 ? 7.5625 * e * e : e < 2 / 2.75 ? 7.5625 * (e -= 1.5 / 2.75) * e + 0.75 : e < 2.5 / 2.75 ? 7.5625 * (e -= 2.25 / 2.75) * e + 0.9375 : 7.5625 * (e -= 2.625 / 2.75) * e + 0.984375, Ne = {
  linear: (e) => e,
  easeInQuad: (e) => e * e,
  easeOutQuad: (e) => 1 - (1 - e) * (1 - e),
  easeInOutQuad: (e) => e < 0.5 ? 2 * e * e : 1 - Math.pow(-2 * e + 2, 2) / 2,
  easeInCubic: (e) => e * e * e,
  easeOutCubic: (e) => 1 - Math.pow(1 - e, 3),
  easeInOutCubic: (e) => e < 0.5 ? 4 * e * e * e : 1 - Math.pow(-2 * e + 2, 3) / 2,
  easeInQuart: (e) => e * e * e * e,
  easeOutQuart: (e) => 1 - Math.pow(1 - e, 4),
  easeInOutQuart: (e) => e < 0.5 ? 8 * e * e * e * e : 1 - Math.pow(-2 * e + 2, 4) / 2,
  easeInQuint: (e) => e * e * e * e * e,
  easeOutQuint: (e) => 1 - Math.pow(1 - e, 5),
  easeInOutQuint: (e) => e < 0.5 ? 16 * e * e * e * e * e : 1 - Math.pow(-2 * e + 2, 5) / 2,
  easeInSine: (e) => 1 - Math.cos(e * Math.PI / 2),
  easeOutSine: (e) => Math.sin(e * Math.PI / 2),
  easeInOutSine: (e) => -(Math.cos(Math.PI * e) - 1) / 2,
  easeInExpo: (e) => e === 0 ? 0 : Math.pow(2, 10 * e - 10),
  easeOutExpo: (e) => e === 1 ? 1 : 1 - Math.pow(2, -10 * e),
  easeInOutExpo: (e) => e === 0 ? 0 : e === 1 ? 1 : e < 0.5 ? Math.pow(2, 20 * e - 10) / 2 : (2 - Math.pow(2, -20 * e + 10)) / 2,
  easeInCirc: (e) => 1 - Math.sqrt(1 - Math.pow(e, 2)),
  easeOutCirc: (e) => Math.sqrt(1 - Math.pow(e - 1, 2)),
  easeInOutCirc: (e) => e < 0.5 ? (1 - Math.sqrt(1 - Math.pow(2 * e, 2))) / 2 : (Math.sqrt(1 - Math.pow(-2 * e + 2, 2)) + 1) / 2,
  easeInBack: (e) => D * e * e * e - A * e * e,
  easeOutBack: (e) => 1 + D * Math.pow(e - 1, 3) + A * Math.pow(e - 1, 2),
  easeInOutBack: (e) => e < 0.5 ? Math.pow(2 * e, 2) * ((v + 1) * 2 * e - v) / 2 : (Math.pow(2 * e - 2, 2) * ((v + 1) * (e * 2 - 2) + v) + 2) / 2,
  easeInElastic: (e) => e === 0 ? 0 : e === 1 ? 1 : -Math.pow(2, 10 * e - 10) * Math.sin((e * 10 - 10.75) * G),
  easeOutElastic: (e) => e === 0 ? 0 : e === 1 ? 1 : Math.pow(2, -10 * e) * Math.sin((e * 10 - 0.75) * G) + 1,
  easeInOutElastic: (e) => e === 0 ? 0 : e === 1 ? 1 : e < 0.5 ? -(Math.pow(2, 20 * e - 10) * Math.sin((20 * e - 11.125) * N)) / 2 : Math.pow(2, -20 * e + 10) * Math.sin((20 * e - 11.125) * N) / 2 + 1,
  easeInBounce: (e) => 1 - k(1 - e),
  easeOutBounce: k,
  easeInOutBounce: (e) => e < 0.5 ? (1 - k(1 - 2 * e)) / 2 : (1 + k(2 * e - 1)) / 2,
  steps: Ie
};
function P() {
  return P = Object.assign ? Object.assign.bind() : function(e) {
    for (var f = 1; f < arguments.length; f++) {
      var t = arguments[f];
      for (var n in t)
        Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
    }
    return e;
  }, P.apply(this, arguments);
}
const b = Symbol.for("FluidValue.get"), p = Symbol.for("FluidValue.observers"), He = (e) => !!(e && e[b]), Oe = (e) => e && e[b] ? e[b]() : e, Ze = (e) => e[p] || null;
function Me(e, f) {
  e.eventObserved ? e.eventObserved(f) : e(f);
}
function We(e, f) {
  let t = e[p];
  t && t.forEach((n) => {
    Me(n, f);
  });
}
class Xe {
  constructor(f) {
    if (this[b] = void 0, this[p] = void 0, !f && !(f = this.get))
      throw Error("Unknown getter");
    Ae(this, f);
  }
}
const Ae = (e, f) => ee(e, b, f);
function Je(e, f) {
  if (e[b]) {
    let t = e[p];
    t || ee(e, p, t = /* @__PURE__ */ new Set()), t.has(f) || (t.add(f), e.observerAdded && e.observerAdded(t.size, f));
  }
  return f;
}
function Ke(e, f) {
  let t = e[p];
  if (t && t.has(f)) {
    const n = t.size - 1;
    n ? t.delete(f) : e[p] = null, e.observerRemoved && e.observerRemoved(n, f);
  }
}
const ee = (e, f, t) => Object.defineProperty(e, f, {
  value: t,
  writable: !0,
  configurable: !0
}), I = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, Ee = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi, H = new RegExp(`(${I.source})(%|[a-z]+)`, "i"), Fe = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi, R = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/, fe = (e) => {
  const [f, t] = Re(e);
  if (!f || z())
    return e;
  const n = window.getComputedStyle(document.documentElement).getPropertyValue(f);
  if (n)
    return n.trim();
  if (t && t.startsWith("--")) {
    const o = window.getComputedStyle(document.documentElement).getPropertyValue(t);
    return o || e;
  } else {
    if (t && R.test(t))
      return fe(t);
    if (t)
      return t;
  }
  return e;
}, Re = (e) => {
  const f = R.exec(e);
  if (!f)
    return [,];
  const [, t, n] = f;
  return [t, n];
};
let C;
const $e = (e, f, t, n, o) => `rgba(${Math.round(f)}, ${Math.round(t)}, ${Math.round(n)}, ${o})`, Ye = (e) => {
  C || (C = h ? new RegExp(`(${Object.keys(h).join("|")})(?!\\w)`, "g") : /^\b$/);
  const f = e.output.map((a) => Oe(a).replace(R, fe).replace(Ee, T).replace(C, T)), t = f.map((a) => a.match(I).map(Number)), o = t[0].map((a, i) => t.map((c) => {
    if (!(i in c))
      throw Error('The arity of each "output" value must be equal');
    return c[i];
  })).map((a) => Y(P({}, e, {
    output: a
  })));
  return (a) => {
    var i;
    const c = !H.test(f[0]) && ((i = f.find((r) => H.test(r))) == null ? void 0 : i.replace(I, ""));
    let x = 0;
    return f[0].replace(I, () => `${o[x++](a)}${c || ""}`).replace(Fe, $e);
  };
}, V = "react-spring: ", te = (e) => {
  const f = e;
  let t = !1;
  if (typeof f != "function")
    throw new TypeError(`${V}once requires a function parameter`);
  return (...n) => {
    t || (f(...n), t = !0);
  };
}, Se = te(console.warn);
function ef() {
  Se(`${V}The "interpolate" function is deprecated in v9 (use "to" instead)`);
}
const Ce = te(console.warn);
function ff() {
  Ce(`${V}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`);
}
function tf(e) {
  return l.str(e) && (e[0] == "#" || /\d/.test(e) || !z() && R.test(e) || e in (h || {}));
}
const qe = z() ? E : ne, Pe = () => {
  const e = Q(!1);
  return qe(() => (e.current = !0, () => {
    e.current = !1;
  }), []), e;
};
function nf() {
  const e = Z()[1], f = Pe();
  return () => {
    f.current && e(Math.random());
  };
}
function rf(e, f) {
  const [t] = Z(() => ({
    inputs: f,
    result: e()
  })), n = Q(), o = n.current;
  let a = o;
  return a ? f && a.inputs && Qe(f, a.inputs) || (a = {
    inputs: f,
    result: e()
  }) : a = t, E(() => {
    n.current = a, o == t && (t.inputs = t.result = void 0);
  }, [a]), a.result;
}
function Qe(e, f) {
  if (e.length !== f.length)
    return !1;
  for (let t = 0; t < e.length; t++)
    if (e[t] !== f[t])
      return !1;
  return !0;
}
const af = (e) => E(e, ze), ze = [];
function of(e) {
  const f = Q();
  return E(() => {
    f.current = e;
  }), f.current;
}
export {
  Xe as FluidValue,
  De as Globals,
  Je as addFluidObserver,
  Me as callFluidObserver,
  We as callFluidObservers,
  le as clamp,
  T as colorToRgba,
  Ge as colors,
  Y as createInterpolator,
  Ye as createStringInterpolator,
  Ve as defineHidden,
  ff as deprecateDirectCall,
  ef as deprecateInterpolate,
  ae as each,
  Ue as eachProp,
  Ne as easings,
  oe as flush,
  Te as flushCalls,
  se as frameLoop,
  Ze as getFluidObservers,
  Oe as getFluidValue,
  He as hasFluidValue,
  ge as hex3,
  be as hex4,
  me as hex6,
  we as hex8,
  pe as hsl,
  xe as hsla,
  l as is,
  tf as isAnimatedString,
  je as isEqual,
  z as isSSR,
  re as noop,
  te as once,
  V as prefix,
  d as raf,
  Ke as removeFluidObserver,
  de as rgb,
  he as rgba,
  Ae as setFluidGetter,
  Le as toArray,
  nf as useForceUpdate,
  qe as useIsomorphicLayoutEffect,
  rf as useMemoOne,
  af as useOnce,
  of as usePrev
};
