import { linear as h } from "./index.es.js";
const a = (e, n) => 1 - 3 * n + 3 * e, d = (e, n) => 3 * n - 6 * e, w = (e) => 3 * e, p = (e, n, r) => ((a(n, r) * e + d(n, r)) * e + w(n)) * e, v = (e, n, r) => 3 * a(n, r) * e * e + 2 * d(n, r) * e + w(n), F = 1e-7, I = 10;
function M(e, n, r, c, o) {
  let i, t, s = 0;
  do
    t = n + (r - n) / 2, i = p(t, c, o) - e, i > 0 ? r = t : n = t;
  while (Math.abs(i) > F && ++s < I);
  return t;
}
const k = 8, x = 1e-3;
function y(e, n, r, c) {
  for (let o = 0; o < k; ++o) {
    const i = v(n, r, c);
    if (i === 0)
      return n;
    const t = p(n, r, c) - e;
    n -= t / i;
  }
  return n;
}
const f = 11, u = 1 / (f - 1);
function P(e, n, r, c) {
  if (e === n && r === c)
    return h;
  const o = new Float32Array(f);
  for (let t = 0; t < f; ++t)
    o[t] = p(t * u, e, r);
  function i(t) {
    let s = 0, l = 1;
    const z = f - 1;
    for (; l !== z && o[l] <= t; ++l)
      s += u;
    --l;
    const g = (t - o[l]) / (o[l + 1] - o[l]), S = s + g * u, b = v(S, e, r);
    return b >= x ? y(t, S, e, r) : b === 0 ? S : M(t, s, s + u, e, r);
  }
  return (t) => t === 0 || t === 1 ? t : p(i(t), n, c);
}
export {
  P as cubicBezier
};
//# sourceMappingURL=cubic-bezier.es.js.map
