var pi = Math.PI, tau = 2 * pi, epsilon = 1e-6, tauEpsilon = tau - epsilon;
function Path() {
	this._x0 = this._y0 = this._x1 = this._y1 = null, this._ = "";
}
function path() {
	return new Path();
}
Path.prototype = path.prototype = {
	constructor: Path,
	moveTo: function(e, t) {
		this._ += "M" + (this._x0 = this._x1 = +e) + "," + (this._y0 = this._y1 = +t);
	},
	closePath: function() {
		this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._ += "Z");
	},
	lineTo: function(e, t) {
		this._ += "L" + (this._x1 = +e) + "," + (this._y1 = +t);
	},
	quadraticCurveTo: function(e, t, n, r) {
		this._ += "Q" + +e + "," + +t + "," + (this._x1 = +n) + "," + (this._y1 = +r);
	},
	bezierCurveTo: function(e, t, n, r, i, a) {
		this._ += "C" + +e + "," + +t + "," + +n + "," + +r + "," + (this._x1 = +i) + "," + (this._y1 = +a);
	},
	arcTo: function(t, r, i, a, o) {
		t = +t, r = +r, i = +i, a = +a, o = +o;
		var s = this._x1, c = this._y1, l = i - t, u = a - r, d = s - t, f = c - r, p = d * d + f * f;
		if (o < 0) throw Error("negative radius: " + o);
		if (this._x1 === null) this._ += "M" + (this._x1 = t) + "," + (this._y1 = r);
		else if (p > epsilon) if (!(Math.abs(f * l - u * d) > epsilon) || !o) this._ += "L" + (this._x1 = t) + "," + (this._y1 = r);
		else {
			var m = i - s, h = a - c, g = l * l + u * u, _ = m * m + h * h, v = Math.sqrt(g), y = Math.sqrt(p), b = o * Math.tan((pi - Math.acos((g + p - _) / (2 * v * y))) / 2), x = b / y, S = b / v;
			Math.abs(x - 1) > epsilon && (this._ += "L" + (t + x * d) + "," + (r + x * f)), this._ += "A" + o + "," + o + ",0,0," + +(f * m > d * h) + "," + (this._x1 = t + S * l) + "," + (this._y1 = r + S * u);
		}
	},
	arc: function(i, a, o, s, c, l) {
		i = +i, a = +a, o = +o, l = !!l;
		var u = o * Math.cos(s), d = o * Math.sin(s), f = i + u, p = a + d, m = 1 ^ l, h = l ? s - c : c - s;
		if (o < 0) throw Error("negative radius: " + o);
		this._x1 === null ? this._ += "M" + f + "," + p : (Math.abs(this._x1 - f) > epsilon || Math.abs(this._y1 - p) > epsilon) && (this._ += "L" + f + "," + p), o && (h < 0 && (h = h % tau + tau), h > tauEpsilon ? this._ += "A" + o + "," + o + ",0,1," + m + "," + (i - u) + "," + (a - d) + "A" + o + "," + o + ",0,1," + m + "," + (this._x1 = f) + "," + (this._y1 = p) : h > epsilon && (this._ += "A" + o + "," + o + ",0," + +(h >= pi) + "," + m + "," + (this._x1 = i + o * Math.cos(c)) + "," + (this._y1 = a + o * Math.sin(c))));
	},
	rect: function(e, t, n, r) {
		this._ += "M" + (this._x0 = this._x1 = +e) + "," + (this._y0 = this._y1 = +t) + "h" + +n + "v" + +r + "h" + -n + "Z";
	},
	toString: function() {
		return this._;
	}
};
var path_default = path;
export { path_default as default };
