"use client";
var b = 1e-4, S = (e, r) => [0, 3 * e, 3 * r - 6 * e, 3 * e - 3 * r + 1], x = (e, r) => e.map((a, t) => a * r ** t).reduce((a, t) => a + t), B = (e, r) => (a) => {
  var t = S(e, r);
  return x(t, a);
}, F = (e, r) => (a) => {
  var t = S(e, r), i = [...t.map((u, n) => u * n).slice(1), 0];
  return x(i, a);
}, C = function() {
  for (var r, a, t, i, u = arguments.length, n = new Array(u), s = 0; s < u; s++)
    n[s] = arguments[s];
  if (n.length === 1)
    switch (n[0]) {
      case "linear":
        [r, t, a, i] = [0, 0, 1, 1];
        break;
      case "ease":
        [r, t, a, i] = [0.25, 0.1, 0.25, 1];
        break;
      case "ease-in":
        [r, t, a, i] = [0.42, 0, 1, 1];
        break;
      case "ease-out":
        [r, t, a, i] = [0.42, 0, 0.58, 1];
        break;
      case "ease-in-out":
        [r, t, a, i] = [0, 0, 0.58, 1];
        break;
      default: {
        var c = n[0].split("(");
        c[0] === "cubic-bezier" && c[1].split(")")[0].split(",").length === 4 && ([r, t, a, i] = c[1].split(")")[0].split(",").map((v) => parseFloat(v)));
      }
    }
  else n.length === 4 && ([r, t, a, i] = n);
  var m = B(r, a), p = B(t, i), o = F(r, a), l = (v) => v > 1 ? 1 : v < 0 ? 0 : v, h = (v) => {
    for (var g = v > 1 ? 1 : v, f = g, z = 0; z < 8; ++z) {
      var d = m(f) - g, w = o(f);
      if (Math.abs(d - g) < b || w < b)
        return p(f);
      f = l(f - d / w);
    }
    return p(f);
  };
  return h.isStepper = !1, h;
}, y = function() {
  var r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
    stiff: a = 100,
    damping: t = 8,
    dt: i = 17
  } = r, u = (n, s, c) => {
    var m = -(n - s) * a, p = c * t, o = c + (m - p) * i / 1e3, l = c * i / 1e3 + n;
    return Math.abs(l - s) < b && Math.abs(o) < b ? [s, 0] : [l, o];
  };
  return u.isStepper = !0, u.dt = i, u;
}, A = (e) => {
  if (typeof e == "string")
    switch (e) {
      case "ease":
      case "ease-in-out":
      case "ease-out":
      case "ease-in":
      case "linear":
        return C(e);
      case "spring":
        return y();
      default:
        if (e.split("(")[0] === "cubic-bezier")
          return C(e);
    }
  return typeof e == "function" ? e : null;
};
export {
  b as ACCURACY,
  C as configBezier,
  A as configEasing,
  y as configSpring
};
