"use client";
import x from "./array.js";
import i from "./constant.js";
import z from "./curve/linear.js";
import L from "./line.js";
import { withPath as X } from "./path.js";
import { x as Y, y as b } from "./point.js";
function C(u, f, o) {
  var c = null, g = i(!0), l = null, p = z, r = null, S = X(e);
  u = typeof u == "function" ? u : u === void 0 ? Y : i(+u), f = typeof f == "function" ? f : f === void 0 ? i(0) : i(+f), o = typeof o == "function" ? o : o === void 0 ? b : i(+o);
  function e(n) {
    var t, E, a, s = (n = x(n)).length, m, h = !1, v, w = new Array(s), A = new Array(s);
    for (l == null && (r = p(v = S())), t = 0; t <= s; ++t) {
      if (!(t < s && g(m = n[t], t, n)) === h)
        if (h = !h)
          E = t, r.areaStart(), r.lineStart();
        else {
          for (r.lineEnd(), r.lineStart(), a = t - 1; a >= E; --a)
            r.point(w[a], A[a]);
          r.lineEnd(), r.areaEnd();
        }
      h && (w[t] = +u(m, t, n), A[t] = +f(m, t, n), r.point(c ? +c(m, t, n) : w[t], o ? +o(m, t, n) : A[t]));
    }
    if (v) return r = null, v + "" || null;
  }
  function d() {
    return L().defined(g).curve(p).context(l);
  }
  return e.x = function(n) {
    return arguments.length ? (u = typeof n == "function" ? n : i(+n), c = null, e) : u;
  }, e.x0 = function(n) {
    return arguments.length ? (u = typeof n == "function" ? n : i(+n), e) : u;
  }, e.x1 = function(n) {
    return arguments.length ? (c = n == null ? null : typeof n == "function" ? n : i(+n), e) : c;
  }, e.y = function(n) {
    return arguments.length ? (f = typeof n == "function" ? n : i(+n), o = null, e) : f;
  }, e.y0 = function(n) {
    return arguments.length ? (f = typeof n == "function" ? n : i(+n), e) : f;
  }, e.y1 = function(n) {
    return arguments.length ? (o = n == null ? null : typeof n == "function" ? n : i(+n), e) : o;
  }, e.lineX0 = e.lineY0 = function() {
    return d().x(u).y(f);
  }, e.lineY1 = function() {
    return d().x(u).y(o);
  }, e.lineX1 = function() {
    return d().x(c).y(f);
  }, e.defined = function(n) {
    return arguments.length ? (g = typeof n == "function" ? n : i(!!n), e) : g;
  }, e.curve = function(n) {
    return arguments.length ? (p = n, l != null && (r = p(l)), e) : p;
  }, e.context = function(n) {
    return arguments.length ? (n == null ? l = r = null : r = p(l = n), e) : l;
  }, e;
}
export {
  C as default
};
