import { styleValue } from "../../../d3-selection/src/selection/style.js";
import { interpolateTransformCss } from "../../../d3-interpolate/src/transform/index.js";
import { set } from "./schedule.js";
import { tweenValue } from "./tween.js";
import interpolate_default from "./interpolate.js";
function styleNull(t, n) {
	var r, i, a;
	return function() {
		var o = styleValue(this, t), s = (this.style.removeProperty(t), styleValue(this, t));
		return o === s ? null : o === r && s === i ? a : a = n(r = o, i = s);
	};
}
function styleRemove(e) {
	return function() {
		this.style.removeProperty(e);
	};
}
function styleConstant(t, n, r) {
	var i, a = r + "", o;
	return function() {
		var s = styleValue(this, t);
		return s === a ? null : s === i ? o : o = n(i = s, r);
	};
}
function styleFunction(t, n, r) {
	var i, a, o;
	return function() {
		var s = styleValue(this, t), c = r(this), l = c + "";
		return c ?? (l = c = (this.style.removeProperty(t), styleValue(this, t))), s === l ? null : s === i && l === a ? o : (a = l, o = n(i = s, c));
	};
}
function styleMaybeRemove(e, t) {
	var r, i, a, s = "style." + t, c = "end." + s, l;
	return function() {
		var u = set(this, e), d = u.on, f = u.value[s] == null ? l ||= styleRemove(t) : void 0;
		(d !== r || a !== f) && (i = (r = d).copy()).on(c, a = f), u.on = i;
	};
}
function style_default(e, n, u) {
	var d = (e += "") == "transform" ? interpolateTransformCss : interpolate_default;
	return n == null ? this.styleTween(e, styleNull(e, d)).on("end.style." + e, styleRemove(e)) : typeof n == "function" ? this.styleTween(e, styleFunction(e, d, tweenValue(this, "style." + e, n))).each(styleMaybeRemove(this._id, e)) : this.styleTween(e, styleConstant(e, d, n), u).on("end.style." + e, null);
}
export { style_default as default };
