import e from "./constant.js";
import { tau as t } from "./math.js";
import n from "./array.js";
import r from "./descending.js";
import i from "./identity.js";
//#region ../../node_modules/d3-shape/src/pie.js
function a() {
	var a = i, o = r, s = null, c = e(0), l = e(t), u = e(0);
	function d(e) {
		var r, i = (e = n(e)).length, d, f, p = 0, m = Array(i), h = Array(i), g = +c.apply(this, arguments), _ = Math.min(t, Math.max(-t, l.apply(this, arguments) - g)), v, y = Math.min(Math.abs(_) / i, u.apply(this, arguments)), b = y * (_ < 0 ? -1 : 1), x;
		for (r = 0; r < i; ++r) (x = h[m[r] = r] = +a(e[r], r, e)) > 0 && (p += x);
		for (o == null ? s != null && m.sort(function(t, n) {
			return s(e[t], e[n]);
		}) : m.sort(function(e, t) {
			return o(h[e], h[t]);
		}), r = 0, f = p ? (_ - i * b) / p : 0; r < i; ++r, g = v) d = m[r], x = h[d], v = g + (x > 0 ? x * f : 0) + b, h[d] = {
			data: e[d],
			index: r,
			value: x,
			startAngle: g,
			endAngle: v,
			padAngle: y
		};
		return h;
	}
	return d.value = function(t) {
		return arguments.length ? (a = typeof t == "function" ? t : e(+t), d) : a;
	}, d.sortValues = function(e) {
		return arguments.length ? (o = e, s = null, d) : o;
	}, d.sort = function(e) {
		return arguments.length ? (s = e, o = null, d) : s;
	}, d.startAngle = function(t) {
		return arguments.length ? (c = typeof t == "function" ? t : e(+t), d) : c;
	}, d.endAngle = function(t) {
		return arguments.length ? (l = typeof t == "function" ? t : e(+t), d) : l;
	}, d.padAngle = function(t) {
		return arguments.length ? (u = typeof t == "function" ? t : e(+t), d) : u;
	}, d;
}
//#endregion
export { a as default };
