class M {
  interpolate(e) {
    const { xs: c, ys: u, c1s: g, c2s: h, c3s: n } = this;
    let s = c.length - 1;
    if (e === c[s])
      return u[s];
    let p = 0, o = n.length - 1, l;
    for (; p <= o; ) {
      l = Math.floor(0.5 * (p + o));
      const t = c[l];
      if (t < e)
        p = l + 1;
      else if (t > e)
        o = l - 1;
      else
        return u[l];
    }
    s = Math.max(0, o);
    const i = e - c[s], r = i * i;
    return u[s] + g[s] * i + h[s] * r + n[s] * i * r;
  }
  constructor(e, c) {
    const { length: u } = e, g = [];
    for (let t = 0; t < u; t++)
      g.push(t);
    g.sort(
      (t, f) => e[t] < e[f] ? -1 : 1
    );
    const h = [], n = [];
    let s, p;
    for (let t = 0; t < u - 1; t++)
      s = e[t + 1] - e[t], p = c[t + 1] - c[t], h.push(s), n.push(p / s);
    const o = [
      n[0]
    ];
    for (let t = 0; t < h.length - 1; t++) {
      const f = n[t], m = n[t + 1];
      if (f * m <= 0)
        o.push(0);
      else {
        s = h[t];
        const d = h[t + 1], a = s + d;
        o.push(3 * a / ((a + d) / f + (a + s) / m));
      }
    }
    o.push(n[n.length - 1]);
    const l = [], i = [];
    let r;
    for (let t = 0; t < o.length - 1; t++) {
      r = n[t];
      const f = o[t], m = 1 / h[t], d = f + o[t + 1] - r - r;
      l.push((r - f - d) * m), i.push(d * m * m);
    }
    this.xs = e, this.ys = c, this.c1s = o, this.c2s = l, this.c3s = i;
  }
}
export {
  M as MonotonicInterpolant
};
//# sourceMappingURL=MonotonicInterpolant.es.js.map
