import { stringToRawPath as O, rawPathToString as R, transformRawPath as k } from "./utils/paths.es.js";
/*!
 * CustomEase 3.13.0
 * https://gsap.com
 *
 * @license Copyright 2008-2025, GreenSock. All rights reserved.
 * Subject to the terms at https://gsap.com/standard-license
 * @author: Jack Doyle, jack@greensock.com
*/
var d, j, I = function() {
  return d || typeof window != "undefined" && (d = window.gsap) && d.registerPlugin && d;
}, z = function() {
  d = I(), d ? (d.registerEase("_CE", C.create), j = 1) : console.warn("Please gsap.registerPlugin(CustomEase)");
}, q = 1e20, S = function(r) {
  return ~~(r * 1e3 + (r < 0 ? -0.5 : 0.5)) / 1e3;
}, H = /[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/gi, L = /[cLlsSaAhHvVtTqQ]/g, N = function(r) {
  var l = r.length, e = q, n;
  for (n = 1; n < l; n += 6)
    +r[n] < e && (e = +r[n]);
  return e;
}, Q = function(r, l, e) {
  !e && e !== 0 && (e = Math.max(+r[r.length - 1], +r[1]));
  var n = +r[0] * -1, h = -e, c = r.length, i = 1 / (+r[c - 2] + n), s = -l || (Math.abs(+r[c - 1] - +r[1]) < 0.01 * (+r[c - 2] - +r[0]) ? N(r) + h : +r[c - 1] + h), y;
  for (s ? s = 1 / s : s = -i, y = 0; y < c; y += 2)
    r[y] = (+r[y] + n) * i, r[y + 1] = (+r[y + 1] + h) * s;
}, X = function g(r, l, e, n, h, c, i, s, y, x, f) {
  var u = (r + e) / 2, _ = (l + n) / 2, t = (e + h) / 2, P = (n + c) / 2, m = (h + i) / 2, a = (c + s) / 2, o = (u + t) / 2, p = (_ + P) / 2, M = (t + m) / 2, w = (P + a) / 2, D = (o + M) / 2, G = (p + w) / 2, E = i - r, b = s - l, V = Math.abs((e - i) * b - (n - s) * E), A = Math.abs((h - i) * b - (c - s) * E), T;
  return x || (x = [{
    x: r,
    y: l
  }, {
    x: i,
    y: s
  }], f = 1), x.splice(f || x.length - 1, 0, {
    x: D,
    y: G
  }), (V + A) * (V + A) > y * (E * E + b * b) && (T = x.length, g(r, l, u, _, o, p, D, G, y, x, f), g(D, G, M, w, m, a, i, s, y, x, f + 1 + (x.length - T))), x;
}, C = /* @__PURE__ */ (function() {
  function g(l, e, n) {
    j || z(), this.id = l, this.setData(e, n);
  }
  var r = g.prototype;
  return r.setData = function(e, n) {
    n = n || {}, e = e || "0,0,1,1";
    var h = e.match(H), c = 1, i = [], s = [], y = n.precision || 1, x = y <= 1, f, u, _, t, P, m, a, o, p;
    if (this.data = e, (L.test(e) || ~e.indexOf("M") && e.indexOf("C") < 0) && (h = O(e)[0]), f = h.length, f === 4)
      h.unshift(0, 0), h.push(1, 1), f = 8;
    else if ((f - 2) % 6)
      throw "Invalid CustomEase";
    for ((+h[0] != 0 || +h[f - 2] != 1) && Q(h, n.height, n.originY), this.segment = h, t = 2; t < f; t += 6)
      u = {
        x: +h[t - 2],
        y: +h[t - 1]
      }, _ = {
        x: +h[t + 4],
        y: +h[t + 5]
      }, i.push(u, _), X(u.x, u.y, +h[t], +h[t + 1], +h[t + 2], +h[t + 3], _.x, _.y, 1 / (y * 2e5), i, i.length - 1);
    for (f = i.length, t = 0; t < f; t++)
      a = i[t], o = i[t - 1] || a, (a.x > o.x || o.y !== a.y && o.x === a.x || a === o) && a.x <= 1 ? (o.cx = a.x - o.x, o.cy = a.y - o.y, o.n = a, o.nx = a.x, x && t > 1 && Math.abs(o.cy / o.cx - i[t - 2].cy / i[t - 2].cx) > 2 && (x = 0), o.cx < c && (o.cx ? c = o.cx : (o.cx = 1e-3, t === f - 1 && (o.x -= 1e-3, c = Math.min(c, 1e-3), x = 0)))) : (i.splice(t--, 1), f--);
    if (f = 1 / c + 1 | 0, P = 1 / f, m = 0, a = i[0], x) {
      for (t = 0; t < f; t++)
        p = t * P, a.nx < p && (a = i[++m]), u = a.y + (p - a.x) / a.cx * a.cy, s[t] = {
          x: p,
          cx: P,
          y: u,
          cy: 0,
          nx: 9
        }, t && (s[t - 1].cy = u - s[t - 1].y);
      m = i[i.length - 1], s[f - 1].cy = m.y - u, s[f - 1].cx = m.x - s[s.length - 1].x;
    } else {
      for (t = 0; t < f; t++)
        a.nx < t * P && (a = i[++m]), s[t] = a;
      m < i.length - 1 && (s[t - 1] = i[i.length - 2]);
    }
    return this.ease = function(M) {
      var w = s[M * f | 0] || s[f - 1];
      return w.nx < M && (w = w.n), w.y + (M - w.x) / w.cx * w.cy;
    }, this.ease.custom = this, this.id && d && d.registerEase(this.id, this.ease), this;
  }, r.getSVGData = function(e) {
    return g.getSVGData(this, e);
  }, g.create = function(e, n, h) {
    return new g(e, n, h).ease;
  }, g.register = function(e) {
    d = e, z();
  }, g.get = function(e) {
    return d.parseEase(e);
  }, g.getSVGData = function(e, n) {
    n = n || {};
    var h = n.width || 100, c = n.height || 100, i = n.x || 0, s = (n.y || 0) + c, y = d.utils.toArray(n.path)[0], x, f, u, _, t, P, m, a, o, p;
    if (n.invert && (c = -c, s = 0), typeof e == "string" && (e = d.parseEase(e)), e.custom && (e = e.custom), e instanceof g)
      x = R(k([e.segment], h, 0, 0, -c, i, s));
    else {
      for (x = [i, s], m = Math.max(5, (n.precision || 1) * 200), _ = 1 / m, m += 2, a = 5 / m, o = S(i + _ * h), p = S(s + e(_) * -c), f = (p - s) / (o - i), u = 2; u < m; u++)
        t = S(i + u * _ * h), P = S(s + e(u * _) * -c), (Math.abs((P - p) / (t - o) - f) > a || u === m - 1) && (x.push(o, p), f = (P - p) / (t - o)), o = t, p = P;
      x = "M" + x.join(",");
    }
    return y && y.setAttribute("d", x), x;
  }, g;
})();
C.version = "3.13.0";
C.headless = !0;
I() && d.registerPlugin(C);
export {
  C as CustomEase,
  C as default
};
