import { CardinalOpen } from "./cardinalOpen.js";
import { point } from "./catmullRom.js";
function CatmullRomOpen(e, t) {
	this._context = e, this._alpha = t;
}
CatmullRomOpen.prototype = {
	areaStart: function() {
		this._line = 0;
	},
	areaEnd: function() {
		this._line = NaN;
	},
	lineStart: function() {
		this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
	},
	lineEnd: function() {
		(this._line || this._line !== 0 && this._point === 3) && this._context.closePath(), this._line = 1 - this._line;
	},
	point: function(e, n) {
		if (e = +e, n = +n, this._point) {
			var r = this._x2 - e, i = this._y2 - n;
			this._l23_a = Math.sqrt(this._l23_2a = (r * r + i * i) ** +this._alpha);
		}
		switch (this._point) {
			case 0:
				this._point = 1;
				break;
			case 1:
				this._point = 2;
				break;
			case 2:
				this._point = 3, this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
				break;
			case 3: this._point = 4;
			default:
				point(this, e, n);
				break;
		}
		this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = n;
	}
};
var catmullRomOpen_default = (function t(r) {
	function i(t) {
		return r ? new CatmullRomOpen(t, r) : new CardinalOpen(t, 0);
	}
	return i.alpha = function(e) {
		return t(+e);
	}, i;
})(.5);
export { catmullRomOpen_default as default };
