import { raf as d } from "./index-react-spring_rafz.modern.js";
import { useEffect as O, useLayoutEffect as X, useState as J, useRef as j } from "react";
var K = Object.defineProperty, Y = (e, r) => {
  for (var t in r)
    K(e, t, { get: r[t], enumerable: !0 });
}, M = {};
Y(M, {
  assign: () => ne,
  colors: () => g,
  createStringInterpolator: () => P,
  skipAnimation: () => G,
  to: () => D,
  willAdvance: () => C
});
function ee() {
}
var Pe = (e, r, t) => Object.defineProperty(e, r, { value: t, writable: !0, configurable: !0 }), c = {
  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 Ce(e, r) {
  if (c.arr(e)) {
    if (!c.arr(r) || e.length !== r.length) return !1;
    for (let t = 0; t < e.length; t++)
      if (e[t] !== r[t]) return !1;
    return !0;
  }
  return e === r;
}
var re = (e, r) => e.forEach(r);
function ze(e, r, t) {
  if (c.arr(e)) {
    for (let n = 0; n < e.length; n++)
      r.call(t, e[n], `${n}`);
    return;
  }
  for (const n in e)
    e.hasOwnProperty(n) && r.call(t, e[n], n);
}
var Ve = (e) => c.und(e) ? [] : c.arr(e) ? e : [e];
function te(e, r) {
  if (e.size) {
    const t = Array.from(e);
    e.clear(), re(t, r);
  }
}
var Ue = (e, ...r) => te(e, (t) => t(...r)), q = () => typeof window > "u" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent), P, D, g = null, G = !1, C = ee, ne = (e) => {
  e.to && (D = e.to), e.now && (d.now = e.now), e.colors !== void 0 && (g = e.colors), e.skipAnimation != null && (G = e.skipAnimation), e.createStringInterpolator && (P = e.createStringInterpolator), e.requestAnimationFrame && d.use(e.requestAnimationFrame), e.batchedUpdates && (d.batchedUpdates = e.batchedUpdates), e.willAdvance && (C = e.willAdvance), e.frameLoop && (d.frameLoop = e.frameLoop);
}, h = /* @__PURE__ */ new Set(), s = [], E = [], x = 0, ae = {
  get idle() {
    return !h.size && !s.length;
  },
  /** Advance the given animation on every frame until idle. */
  start(e) {
    x > e.priority ? (h.add(e), d.onStart(ie)) : (N(e), d($));
  },
  /** Advance all animations by the given time. */
  advance: $,
  /** Call this when an animation's priority changes. */
  sort(e) {
    if (x)
      d.onFrame(() => ae.sort(e));
    else {
      const r = s.indexOf(e);
      ~r && (s.splice(r, 1), B(e));
    }
  },
  /**
   * Clear all animations. For testing purposes.
   *
   * ☠️ Never call this from within the frameloop.
   */
  clear() {
    s = [], h.clear();
  }
};
function ie() {
  h.forEach(N), h.clear(), d($);
}
function N(e) {
  s.includes(e) || B(e);
}
function B(e) {
  s.splice(
    oe(s, (r) => r.priority > e.priority),
    0,
    e
  );
}
function $(e) {
  const r = E;
  for (let t = 0; t < s.length; t++) {
    const n = s[t];
    x = n.priority, n.idle || (C(n), n.advance(e), n.idle || r.push(n));
  }
  return x = 0, E = s, E.length = 0, s = r, s.length > 0;
}
function oe(e, r) {
  const t = e.findIndex(r);
  return t < 0 ? e.length : t;
}
var _e = {
  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
}, f = "[-+]?\\d*\\.?\\d+", A = f + "%";
function F(...e) {
  return "\\(\\s*(" + e.join(")\\s*,\\s*(") + ")\\s*\\)";
}
var se = new RegExp("rgb" + F(f, f, f)), le = new RegExp("rgba" + F(f, f, f, f)), ue = new RegExp("hsl" + F(f, A, A)), fe = new RegExp(
  "hsla" + F(f, A, A, f)
), ce = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, de = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, ge = /^#([0-9a-fA-F]{6})$/, pe = /^#([0-9a-fA-F]{8})$/;
function ve(e) {
  let r;
  return typeof e == "number" ? e >>> 0 === e && e >= 0 && e <= 4294967295 ? e : null : (r = ge.exec(e)) ? parseInt(r[1] + "ff", 16) >>> 0 : g && g[e] !== void 0 ? g[e] : (r = se.exec(e)) ? (v(r[1]) << 24 | // r
  v(r[2]) << 16 | // g
  v(r[3]) << 8 | // b
  255) >>> // a
  0 : (r = le.exec(e)) ? (v(r[1]) << 24 | // r
  v(r[2]) << 16 | // g
  v(r[3]) << 8 | // b
  _(r[4])) >>> // a
  0 : (r = ce.exec(e)) ? parseInt(
    r[1] + r[1] + // r
    r[2] + r[2] + // g
    r[3] + r[3] + // b
    "ff",
    // a
    16
  ) >>> 0 : (r = pe.exec(e)) ? parseInt(r[1], 16) >>> 0 : (r = de.exec(e)) ? parseInt(
    r[1] + r[1] + // r
    r[2] + r[2] + // g
    r[3] + r[3] + // b
    r[4] + r[4],
    // a
    16
  ) >>> 0 : (r = ue.exec(e)) ? (V(
    U(r[1]),
    // h
    w(r[2]),
    // s
    w(r[3])
    // l
  ) | 255) >>> // a
  0 : (r = fe.exec(e)) ? (V(
    U(r[1]),
    // h
    w(r[2]),
    // s
    w(r[3])
    // l
  ) | _(r[4])) >>> // a
  0 : null;
}
function I(e, r, t) {
  return t < 0 && (t += 1), t > 1 && (t -= 1), t < 1 / 6 ? e + (r - e) * 6 * t : t < 1 / 2 ? r : t < 2 / 3 ? e + (r - e) * (2 / 3 - t) * 6 : e;
}
function V(e, r, t) {
  const n = t < 0.5 ? t * (1 + r) : t + r - t * r, i = 2 * t - n, o = I(i, n, e + 1 / 3), l = I(i, n, e), u = I(i, n, e - 1 / 3);
  return Math.round(o * 255) << 24 | Math.round(l * 255) << 16 | Math.round(u * 255) << 8;
}
function v(e) {
  const r = parseInt(e, 10);
  return r < 0 ? 0 : r > 255 ? 255 : r;
}
function U(e) {
  return (parseFloat(e) % 360 + 360) % 360 / 360;
}
function _(e) {
  const r = parseFloat(e);
  return r < 0 ? 0 : r > 1 ? 255 : Math.round(r * 255);
}
function w(e) {
  const r = parseFloat(e);
  return r < 0 ? 0 : r > 100 ? 1 : r / 100;
}
function L(e) {
  let r = ve(e);
  if (r === null) return e;
  r = r || 0;
  const t = (r & 4278190080) >>> 24, n = (r & 16711680) >>> 16, i = (r & 65280) >>> 8, o = (r & 255) / 255;
  return `rgba(${t}, ${n}, ${i}, ${o})`;
}
var H = (e, r, t) => {
  if (c.fun(e))
    return e;
  if (c.arr(e))
    return H({
      range: e,
      output: r,
      extrapolate: t
    });
  if (c.str(e.output[0]))
    return P(e);
  const n = e, i = n.output, o = n.range || [0, 1], l = n.extrapolateLeft || n.extrapolate || "extend", u = n.extrapolateRight || n.extrapolate || "extend", p = n.easing || ((a) => a);
  return (a) => {
    const b = he(a, o);
    return me(
      a,
      o[b],
      o[b + 1],
      i[b],
      i[b + 1],
      p,
      l,
      u,
      n.map
    );
  };
};
function me(e, r, t, n, i, o, l, u, p) {
  let a = p ? p(e) : e;
  if (a < r) {
    if (l === "identity") return a;
    l === "clamp" && (a = r);
  }
  if (a > t) {
    if (u === "identity") return a;
    u === "clamp" && (a = t);
  }
  return n === i ? n : r === t ? e <= r ? n : i : (r === -1 / 0 ? a = -a : t === 1 / 0 ? a = a - r : a = (a - r) / (t - r), a = o(a), n === -1 / 0 ? a = -a : i === 1 / 0 ? a = a + n : a = a * (i - n) + n, a);
}
function he(e, r) {
  for (var t = 1; t < r.length - 1 && !(r[t] >= e); ++t)
    ;
  return t - 1;
}
var Le = {
  linear: (e) => e
}, y = Symbol.for("FluidValue.get"), m = Symbol.for("FluidValue.observers"), Te = (e) => !!(e && e[y]), ye = (e) => e && e[y] ? e[y]() : e, je = (e) => e[m] || null;
function be(e, r) {
  e.eventObserved ? e.eventObserved(r) : e(r);
}
function De(e, r) {
  const t = e[m];
  t && t.forEach((n) => {
    be(n, r);
  });
}
var Ge = class {
  constructor(e) {
    if (!e && !(e = this.get))
      throw Error("Unknown getter");
    we(this, e);
  }
}, we = (e, r) => Q(e, y, r);
function Ne(e, r) {
  if (e[y]) {
    let t = e[m];
    t || Q(e, m, t = /* @__PURE__ */ new Set()), t.has(r) || (t.add(r), e.observerAdded && e.observerAdded(t.size, r));
  }
  return r;
}
function Be(e, r) {
  const t = e[m];
  if (t && t.has(r)) {
    const n = t.size - 1;
    n ? t.delete(r) : e[m] = null, e.observerRemoved && e.observerRemoved(n, r);
  }
}
var Q = (e, r, t) => Object.defineProperty(e, r, {
  value: t,
  writable: !0,
  configurable: !0
}), k = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ke = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi, T = new RegExp(`(${k.source})(%|[a-z]+)`, "i"), xe = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi, R = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/, Z = (e) => {
  const [r, t] = Ae(e);
  if (!r || q())
    return e;
  const n = window.getComputedStyle(document.documentElement).getPropertyValue(r);
  if (n)
    return n.trim();
  if (t && t.startsWith("--")) {
    const i = window.getComputedStyle(document.documentElement).getPropertyValue(t);
    return i || e;
  } else {
    if (t && R.test(t))
      return Z(t);
    if (t)
      return t;
  }
  return e;
}, Ae = (e) => {
  const r = R.exec(e);
  if (!r) return [,];
  const [, t, n] = r;
  return [t, n];
}, S, Fe = (e, r, t, n, i) => `rgba(${Math.round(r)}, ${Math.round(t)}, ${Math.round(n)}, ${i})`, He = (e) => {
  S || (S = g ? (
    // match color names, ignore partial matches
    new RegExp(`(${Object.keys(g).join("|")})(?!\\w)`, "g")
  ) : (
    // never match
    /^\b$/
  ));
  const r = e.output.map((o) => ye(o).replace(R, Z).replace(ke, L).replace(S, L)), t = r.map((o) => o.match(k).map(Number)), i = t[0].map(
    (o, l) => t.map((u) => {
      if (!(l in u))
        throw Error('The arity of each "output" value must be equal');
      return u[l];
    })
  ).map(
    (o) => H({ ...e, output: o })
  );
  return (o) => {
    var p;
    const l = !T.test(r[0]) && ((p = r.find((a) => T.test(a))) == null ? void 0 : p.replace(k, ""));
    let u = 0;
    return r[0].replace(
      k,
      () => `${i[u++](o)}${l || ""}`
    ).replace(xe, Fe);
  };
}, z = "react-spring: ", W = (e) => {
  const r = e;
  let t = !1;
  if (typeof r != "function")
    throw new TypeError(`${z}once requires a function parameter`);
  return (...n) => {
    t || (r(...n), t = !0);
  };
}, Re = W(console.warn);
function Qe() {
  Re(
    `${z}The "interpolate" function is deprecated in v9 (use "to" instead)`
  );
}
var Ee = W(console.warn);
function Ze() {
  Ee(
    `${z}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 We(e) {
  return c.str(e) && (e[0] == "#" || /\d/.test(e) || // Do not identify a CSS variable as an AnimatedString if its SSR
  !q() && R.test(e) || e in (g || {}));
}
var Ie = q() ? O : X, Se = () => {
  const e = j(!1);
  return Ie(() => (e.current = !0, () => {
    e.current = !1;
  }), []), e;
};
function Xe() {
  const e = J()[1], r = Se();
  return () => {
    r.current && e(Math.random());
  };
}
var Je = (e) => O(e, $e), $e = [];
function Ke(e) {
  const r = j(void 0);
  return O(() => {
    r.current = e;
  }), r.current;
}
export {
  Ge as FluidValue,
  M as Globals,
  Ne as addFluidObserver,
  be as callFluidObserver,
  De as callFluidObservers,
  L as colorToRgba,
  _e as colors,
  H as createInterpolator,
  He as createStringInterpolator,
  Pe as defineHidden,
  Ze as deprecateDirectCall,
  Qe as deprecateInterpolate,
  re as each,
  ze as eachProp,
  Le as easings,
  te as flush,
  Ue as flushCalls,
  ae as frameLoop,
  je as getFluidObservers,
  ye as getFluidValue,
  Te as hasFluidValue,
  ce as hex3,
  de as hex4,
  ge as hex6,
  pe as hex8,
  ue as hsl,
  fe as hsla,
  c as is,
  We as isAnimatedString,
  Ce as isEqual,
  q as isSSR,
  ee as noop,
  W as once,
  z as prefix,
  d as raf,
  Be as removeFluidObserver,
  se as rgb,
  le as rgba,
  we as setFluidGetter,
  Ve as toArray,
  Xe as useForceUpdate,
  Ie as useIsomorphicLayoutEffect,
  Je as useOnce,
  Ke as usePrev
};
