"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const array = require("./src-array.cjs");
const constant = require("./src-constant.cjs");
const linear = require("./src-curve-linear.cjs");
const path = require("./src-path.cjs");
const point = require("./src-point.cjs");
function line(x, y) {
  var defined = constant.default(true), context = null, curve = linear.default, output = null, path$1 = path.withPath(line2);
  x = typeof x === "function" ? x : x === void 0 ? point.x : constant.default(x);
  y = typeof y === "function" ? y : y === void 0 ? point.y : constant.default(y);
  function line2(data) {
    var i, n = (data = array.default(data)).length, d, defined0 = false, buffer;
    if (context == null) output = curve(buffer = path$1());
    for (i = 0; i <= n; ++i) {
      if (!(i < n && defined(d = data[i], i, data)) === defined0) {
        if (defined0 = !defined0) output.lineStart();
        else output.lineEnd();
      }
      if (defined0) output.point(+x(d, i, data), +y(d, i, data));
    }
    if (buffer) return output = null, buffer + "" || null;
  }
  line2.x = function(_) {
    return arguments.length ? (x = typeof _ === "function" ? _ : constant.default(+_), line2) : x;
  };
  line2.y = function(_) {
    return arguments.length ? (y = typeof _ === "function" ? _ : constant.default(+_), line2) : y;
  };
  line2.defined = function(_) {
    return arguments.length ? (defined = typeof _ === "function" ? _ : constant.default(!!_), line2) : defined;
  };
  line2.curve = function(_) {
    return arguments.length ? (curve = _, context != null && (output = curve(context)), line2) : curve;
  };
  line2.context = function(_) {
    return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line2) : context;
  };
  return line2;
}
exports.default = line;
//# sourceMappingURL=src-line.cjs.map
